From 29bbf451a22916d39017ec1a3f53f4e0f0e65ee0 Mon Sep 17 00:00:00 2001 From: abranson Date: Mon, 1 Aug 2011 13:57:20 +0200 Subject: Java7 compatibility and some code refresh --- source/com/c2kernel/gui/tabs/ExecutionPane.java | 19 +++++++++---------- .../c2kernel/gui/tabs/JTabbedPaneWithCloseIcons.java | 3 ++- .../com/c2kernel/gui/tabs/execution/ActivityItem.java | 10 ++++++++-- .../gui/tabs/outcome/form/field/ComboField.java | 9 +++++---- .../gui/tabs/outcome/form/field/ListOfValues.java | 2 +- .../c2kernel/lifecycle/chooser/LDAPEntryChooser.java | 3 +-- source/com/c2kernel/utils/CastorXMLUtility.java | 2 +- source/com/c2kernel/utils/SoftCache.java | 2 +- 8 files changed, 28 insertions(+), 22 deletions(-) mode change 100755 => 100644 source/com/c2kernel/gui/tabs/ExecutionPane.java mode change 100755 => 100644 source/com/c2kernel/gui/tabs/JTabbedPaneWithCloseIcons.java mode change 100755 => 100644 source/com/c2kernel/gui/tabs/execution/ActivityItem.java mode change 100755 => 100644 source/com/c2kernel/gui/tabs/outcome/form/field/ComboField.java mode change 100755 => 100644 source/com/c2kernel/gui/tabs/outcome/form/field/ListOfValues.java mode change 100755 => 100644 source/com/c2kernel/lifecycle/chooser/LDAPEntryChooser.java mode change 100755 => 100644 source/com/c2kernel/utils/CastorXMLUtility.java mode change 100755 => 100644 source/com/c2kernel/utils/SoftCache.java (limited to 'source/com/c2kernel') diff --git a/source/com/c2kernel/gui/tabs/ExecutionPane.java b/source/com/c2kernel/gui/tabs/ExecutionPane.java old mode 100755 new mode 100644 index de07319..0685fa9 --- 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 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 activitySelector = new JComboBox(); Box activityBox = Box.createHorizontalBox(); String selAct = null; - ArrayList activities; + ArrayList 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(); 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 old mode 100755 new mode 100644 index 338e0c3..1629672 --- 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 old mode 100755 new mode 100644 index 1a73dc2..051f1dc --- 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 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 old mode 100755 new mode 100644 index 2a0b34a..303a870 --- 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 comboField; ListOfValues vals; - DefaultComboBoxModel comboModel; + DefaultComboBoxModel comboModel; AnyNode listNode; public ComboField(SimpleType type, AnyNode listNode) { super(); - comboField = new JComboBox(); + comboField = new JComboBox(); 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(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 old mode 100755 new mode 100644 index 2557cbe..3204766 --- 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 defaultKey = null; diff --git a/source/com/c2kernel/lifecycle/chooser/LDAPEntryChooser.java b/source/com/c2kernel/lifecycle/chooser/LDAPEntryChooser.java old mode 100755 new mode 100644 index c2cdb0c..6e91469 --- 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 allItems = new ArrayList(); + ArrayList 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 old mode 100755 new mode 100644 index 3f23d53..07e8e3f --- 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 old mode 100755 new mode 100644 index ce2b390..f13c87d --- 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 $ -- cgit v1.2.3