diff options
| author | abranson <andrew.branson@cern.ch> | 2011-08-01 13:57:20 +0200 |
|---|---|---|
| committer | abranson <andrew.branson@cern.ch> | 2011-08-01 13:57:20 +0200 |
| commit | 29bbf451a22916d39017ec1a3f53f4e0f0e65ee0 (patch) | |
| tree | b6e5d3a4c79e6afb4369c70a4d178156cbf43eeb /source/com | |
| parent | 5b0919b3601340e7f71eee2b4cda8bf0a98090ee (diff) | |
Java7 compatibility and some code refresh
Diffstat (limited to 'source/com')
| -rw-r--r--[-rwxr-xr-x] | source/com/c2kernel/gui/tabs/ExecutionPane.java | 19 | ||||
| -rw-r--r--[-rwxr-xr-x] | source/com/c2kernel/gui/tabs/JTabbedPaneWithCloseIcons.java | 3 | ||||
| -rw-r--r--[-rwxr-xr-x] | source/com/c2kernel/gui/tabs/execution/ActivityItem.java | 10 | ||||
| -rw-r--r--[-rwxr-xr-x] | source/com/c2kernel/gui/tabs/outcome/form/field/ComboField.java | 9 | ||||
| -rw-r--r--[-rwxr-xr-x] | source/com/c2kernel/gui/tabs/outcome/form/field/ListOfValues.java | 2 | ||||
| -rw-r--r--[-rwxr-xr-x] | source/com/c2kernel/lifecycle/chooser/LDAPEntryChooser.java | 3 | ||||
| -rw-r--r--[-rwxr-xr-x] | source/com/c2kernel/utils/CastorXMLUtility.java | 2 | ||||
| -rw-r--r--[-rwxr-xr-x] | source/com/c2kernel/utils/SoftCache.java | 2 |
8 files changed, 28 insertions, 22 deletions
diff --git a/source/com/c2kernel/gui/tabs/ExecutionPane.java b/source/com/c2kernel/gui/tabs/ExecutionPane.java index de07319..0685fa9 100755..100644 --- a/source/com/c2kernel/gui/tabs/ExecutionPane.java +++ b/source/com/c2kernel/gui/tabs/ExecutionPane.java @@ -24,16 +24,16 @@ import com.c2kernel.utils.Logger; public class ExecutionPane extends EntityTabPane implements EntityProxyObserver {
- ArrayList jobList = null;
+ ArrayList<Job> jobList = null;
Object jobLock = new Object();
- String[] emptyAct = { "--" };
+ ActivityItem emptyAct = new ActivityItem();
JLabel noActs = new JLabel(Language.translate("There are currently no activities that you can execute in this item."));
JPanel view = new JPanel(new GridLayout(1, 1));
ActivityViewer currentActView;
- JComboBox activitySelector = new JComboBox(emptyAct);
+ JComboBox<ActivityItem> activitySelector = new JComboBox<ActivityItem>();
Box activityBox = Box.createHorizontalBox();
String selAct = null;
- ArrayList activities;
+ ArrayList<ActivityItem> activities;
String autoRun = null;
boolean init = false;
boolean formIsActive = false;
@@ -76,24 +76,23 @@ public class ExecutionPane extends EntityTabPane implements EntityProxyObserver synchronized (jobLock) {
activitySelector.removeAllItems();
view.removeAll();
- activities = new ArrayList();
+ activities = new ArrayList<ActivityItem>();
try {
jobList = ((ItemProxy)sourceEntity.getEntity()).getJobList(MainFrame.userAgent);
- activitySelector.addItem("--");
+ activitySelector.addItem(emptyAct);
for (Iterator e = jobList.iterator(); e.hasNext();) {
Job thisJob = (Job)e.next();
Logger.msg(7, "ExecutionPane - loadJobList " + thisJob.isOutcomeUsed() + "|" + thisJob.getSchemaType() + "|" + thisJob.getSchemaVersion() + "|");
ActivityItem newAct = new ActivityItem(thisJob);
if (activities.contains(newAct)) {
int actIndex = activities.indexOf(newAct);
- ((ActivityItem)activities.get(actIndex)).addJob(thisJob);
+ activities.get(actIndex).addJob(thisJob);
} else {
Logger.msg(2, "ExecutionPane - Adding activity " + thisJob.getStepPath());
addActivity(newAct);
}
}
} catch (Exception e) {
- activitySelector.addItem("Error fetching JobList");
Logger.debug("Error fetching joblist");
Logger.error(e);
}
@@ -103,7 +102,7 @@ public class ExecutionPane extends EntityTabPane implements EntityProxyObserver view.add(noActs);
break;
case 1 :
- currentActView = new ActivityViewer((ActivityItem)activities.get(0), (ItemProxy)sourceEntity.getEntity(), this);
+ currentActView = new ActivityViewer(activities.get(0), (ItemProxy)sourceEntity.getEntity(), this);
c.fill = GridBagConstraints.BOTH;
gridbag.setConstraints(view, c);
view.add(currentActView);
@@ -135,7 +134,7 @@ public class ExecutionPane extends EntityTabPane implements EntityProxyObserver }
}
private void selectActivity(Object selObj) {
- if (!(selObj instanceof ActivityItem))
+ if (selObj.equals(emptyAct))
return;
view.removeAll();
c.fill = GridBagConstraints.BOTH;
diff --git a/source/com/c2kernel/gui/tabs/JTabbedPaneWithCloseIcons.java b/source/com/c2kernel/gui/tabs/JTabbedPaneWithCloseIcons.java index 338e0c3..1629672 100755..100644 --- a/source/com/c2kernel/gui/tabs/JTabbedPaneWithCloseIcons.java +++ b/source/com/c2kernel/gui/tabs/JTabbedPaneWithCloseIcons.java @@ -1,6 +1,7 @@ package com.c2kernel.gui.tabs;
import java.awt.Component;
import java.awt.Rectangle;
+import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
@@ -44,7 +45,7 @@ public class JTabbedPaneWithCloseIcons extends JTabbedPane implements MouseListe if (tabNumber < 0)
return;
Rectangle rect = ((CloseTabIcon) getIconAt(tabNumber)).getBounds();
- if (rect.contains(e.getX(), e.getY())||(e.getModifiers()& MouseEvent.CTRL_MASK) != 0)
+ if (rect.contains(e.getX(), e.getY())||(e.getModifiers()& InputEvent.CTRL_MASK) != 0)
{ //the tab is being closed
cp = this.getComponent(tabNumber);
//if (getComponentCount() != 1)
diff --git a/source/com/c2kernel/gui/tabs/execution/ActivityItem.java b/source/com/c2kernel/gui/tabs/execution/ActivityItem.java index 1a73dc2..051f1dc 100755..100644 --- a/source/com/c2kernel/gui/tabs/execution/ActivityItem.java +++ b/source/com/c2kernel/gui/tabs/execution/ActivityItem.java @@ -8,7 +8,13 @@ public class ActivityItem { public String stepPath;
public int state;
public String name;
- ArrayList jobs = new ArrayList();
+ ArrayList<Job> jobs = new ArrayList<>();
+
+ public ActivityItem() {
+ stepPath = "";
+ state = -1;
+ name = "--";
+ }
public ActivityItem(Job thisJob) {
stepPath = thisJob.getStepPath();
@@ -30,7 +36,7 @@ public class ActivityItem { }
public String toString() {
- return name+" ("+States.getStateName(state)+")";
+ return name+(state>-1?" ("+States.getStateName(state)+")":"");
}
public boolean equals(Object other) {
diff --git a/source/com/c2kernel/gui/tabs/outcome/form/field/ComboField.java b/source/com/c2kernel/gui/tabs/outcome/form/field/ComboField.java index 2a0b34a..303a870 100755..100644 --- a/source/com/c2kernel/gui/tabs/outcome/form/field/ComboField.java +++ b/source/com/c2kernel/gui/tabs/outcome/form/field/ComboField.java @@ -28,14 +28,14 @@ import com.c2kernel.utils.Logger; public class ComboField extends StringEditField {
- JComboBox comboField;
+ JComboBox<String> comboField;
ListOfValues vals;
- DefaultComboBoxModel comboModel;
+ DefaultComboBoxModel<String> comboModel;
AnyNode listNode;
public ComboField(SimpleType type, AnyNode listNode) {
super();
- comboField = new JComboBox();
+ comboField = new JComboBox<String>();
content = type;
this.listNode = listNode;
createLOV();
@@ -88,7 +88,8 @@ public class ComboField extends StringEditField { }
}
- comboModel = new DefaultComboBoxModel(vals.keySet().toArray());
+ String[] keyArray = new String[vals.keySet().size()];
+ comboModel = new DefaultComboBoxModel<String>(vals.keySet().toArray(keyArray));
comboModel.setSelectedItem(vals.getDefaultKey());
comboField.setModel(comboModel);
}
diff --git a/source/com/c2kernel/gui/tabs/outcome/form/field/ListOfValues.java b/source/com/c2kernel/gui/tabs/outcome/form/field/ListOfValues.java index 2557cbe..3204766 100755..100644 --- a/source/com/c2kernel/gui/tabs/outcome/form/field/ListOfValues.java +++ b/source/com/c2kernel/gui/tabs/outcome/form/field/ListOfValues.java @@ -11,7 +11,7 @@ import java.util.HashMap; * All rights reserved.
**************************************************************************/
-public class ListOfValues extends HashMap {
+public class ListOfValues extends HashMap<String, Object> {
String defaultKey = null;
diff --git a/source/com/c2kernel/lifecycle/chooser/LDAPEntryChooser.java b/source/com/c2kernel/lifecycle/chooser/LDAPEntryChooser.java index c2cdb0c..6e91469 100755..100644 --- a/source/com/c2kernel/lifecycle/chooser/LDAPEntryChooser.java +++ b/source/com/c2kernel/lifecycle/chooser/LDAPEntryChooser.java @@ -8,7 +8,6 @@ import java.awt.Dimension; import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
-import java.util.Iterator;
import javax.swing.JComboBox;
@@ -20,7 +19,7 @@ public class LDAPEntryChooser extends JComboBox {
DomainPath mDomainPath = null;
- ArrayList<String> allItems = new ArrayList<String>();
+ ArrayList<String> allItems = new ArrayList<>();
public LDAPEntryChooser(DomainPath domPath, boolean editable)
{
diff --git a/source/com/c2kernel/utils/CastorXMLUtility.java b/source/com/c2kernel/utils/CastorXMLUtility.java index 3f23d53..07e8e3f 100755..100644 --- a/source/com/c2kernel/utils/CastorXMLUtility.java +++ b/source/com/c2kernel/utils/CastorXMLUtility.java @@ -41,7 +41,7 @@ public class CastorXMLUtility Logger.msg(3, "Loading maps from "+mapURL);
String index;
try {
- index = FileStringUtility.url2String( new URL(mapURL, "index.xml") );
+ index = FileStringUtility.url2String( new URL(mapURL, "index") );
} catch (Exception e) {
Logger.warning("Could not load map index from "+mapURL.toString());
return;
diff --git a/source/com/c2kernel/utils/SoftCache.java b/source/com/c2kernel/utils/SoftCache.java index ce2b390..f13c87d 100755..100644 --- a/source/com/c2kernel/utils/SoftCache.java +++ b/source/com/c2kernel/utils/SoftCache.java @@ -5,7 +5,7 @@ import java.lang.ref.SoftReference; import java.util.*;
/*******************************************************************************
- * SoftReferences are reaped if not strong references are left and the vm is
+ * SoftReferences are reaped if no strong references are left and the vm is
* running out of memory. Most caches in the kernel use this.
*
* $Revision: 1.5 $ $Date: 2004/10/29 13:29:09 $
|
