Author: tfmorris
Date: 2007-09-17 16:18:25-0700
New Revision: 13566
Modified:
trunk/src_new/org/argouml/ui/DisplayTextTree.java
trunk/src_new/org/argouml/ui/explorer/ExplorerPerspective.java
trunk/src_new/org/argouml/ui/explorer/ExplorerTreeNode.java
trunk/src_new/org/argouml/ui/explorer/PerspectiveConfigurator.java
trunk/src_new/org/argouml/ui/explorer/PerspectiveManager.java
trunk/src_new/org/argouml/uml/diagram/ui/TabDiagram.java
Log:
Add Java 5 generics, loops, and annotations.
Modified: trunk/src_new/org/argouml/ui/DisplayTextTree.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/ui/DisplayTextTree.java?view=diff&rev=13566&p1=trunk/src_new/org/argouml/ui/DisplayTextTree.java&p2=trunk/src_new/org/argouml/ui/DisplayTextTree.java&r1=13565&r2=13566
==============================================================================
--- trunk/src_new/org/argouml/ui/DisplayTextTree.java (original)
+++ trunk/src_new/org/argouml/ui/DisplayTextTree.java 2007-09-17 16:18:25-0700
@@ -25,11 +25,13 @@
package org.argouml.ui;
import java.text.MessageFormat;
+import java.util.ArrayList;
import java.util.Collection;
-import java.util.Enumeration;
+
import java.util.Hashtable;
import java.util.Iterator;
-import java.util.Vector;
+import java.util.List;
+
import javax.swing.JTree;
import javax.swing.tree.TreeModel;
@@ -64,10 +66,10 @@
*
* <pre>
* keys are the current TreeModel of this Tree
- * values are Vector of currently expanded paths.
+ * values are Lists of currently expanded paths.
* </pre>
*/
- private Hashtable expandedPathsInModel;
+ private Hashtable<TreeModel, List<TreePath>> expandedPathsInModel;
private boolean reexpanding;
@@ -99,7 +101,7 @@
/* The default (16) puts the icons too close together: */
setRowHeight(18);
- expandedPathsInModel = new Hashtable();
+ expandedPathsInModel = new Hashtable<TreeModel, List<TreePath>>();
reexpanding = false;
Project p = ProjectManager.getManager().getCurrentProject();
@@ -282,8 +284,12 @@
i = dataValues.iterator();
}
String theValue = "";
- if (i.hasNext()) theValue = i.next().toString();
- if (i.hasNext()) theValue += " , ...";
+ if (i.hasNext()) {
+ theValue = i.next().toString();
+ }
+ if (i.hasNext()) {
+ theValue += " , ...";
+ }
name = (tagName + " = " + theValue);
return name;
}
@@ -359,15 +365,12 @@
super.fireTreeExpanded(path);
LOG.debug("fireTreeExpanded");
- if (reexpanding) {
- return;
- }
- if (path == null || expandedPathsInModel == null) {
+ if (reexpanding || path == null) {
return;
}
- Vector expanded = getExpandedPaths();
- expanded.removeElement(path);
- expanded.addElement(path);
+ List<TreePath> expanded = getExpandedPaths();
+ expanded.remove(path);
+ expanded.add(path);
}
/*
@@ -381,8 +384,8 @@
if (path == null || expandedPathsInModel == null) {
return;
}
- Vector expanded = getExpandedPaths();
- expanded.removeElement(path);
+ List<TreePath> expanded = getExpandedPaths();
+ expanded.remove(path);
}
/*
@@ -405,13 +408,13 @@
*
* @return a Vector containing all expanded paths
*/
- protected Vector getExpandedPaths() {
+ protected List<TreePath> getExpandedPaths() {
LOG.debug("getExpandedPaths");
TreeModel tm = getModel();
- Vector res = (Vector) expandedPathsInModel.get(tm);
+ List<TreePath> res = expandedPathsInModel.get(tm);
if (res == null) {
- res = new Vector();
+ res = new ArrayList<TreePath>();
expandedPathsInModel.put(tm, res);
}
return res;
@@ -432,9 +435,7 @@
reexpanding = true;
- Enumeration pathsEnum = getExpandedPaths().elements();
- while (pathsEnum.hasMoreElements()) {
- TreePath path = (TreePath) pathsEnum.nextElement();
+ for (TreePath path : getExpandedPaths()) {
expandPath(path);
}
reexpanding = false;
Modified: trunk/src_new/org/argouml/ui/explorer/ExplorerPerspective.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/ui/explorer/ExplorerPerspective.java?view=diff&rev=13566&p1=trunk/src_new/org/argouml/ui/explorer/ExplorerPerspective.java&p2=trunk/src_new/org/argouml/ui/explorer/ExplorerPerspective.java&r1=13565&r2=13566
==============================================================================
--- trunk/src_new/org/argouml/ui/explorer/ExplorerPerspective.java (original)
+++ trunk/src_new/org/argouml/ui/explorer/ExplorerPerspective.java 2007-09-17 16:18:25-0700
@@ -45,7 +45,7 @@
*/
public class ExplorerPerspective {
- private List rules;
+ private List<PerspectiveRule> rules;
private String name;
/**
@@ -55,7 +55,7 @@
*/
public ExplorerPerspective(String newName) {
name = Translator.localize(newName);
- rules = new ArrayList();
+ rules = new ArrayList<PerspectiveRule>();
}
/**
@@ -82,13 +82,12 @@
/**
* @return the List with all the rules
*/
- public List getList() {
+ public List<PerspectiveRule> getList() {
return rules;
}
- /*
- * @see java.lang.Object#toString()
- */
+
+ @Override
public String toString() {
return name;
}
@@ -103,6 +102,7 @@
ep.rules.addAll(rules);
return ep;
}
+
/**
* @param theNewName the new name for the ExplorerPerspective
*/
Modified: trunk/src_new/org/argouml/ui/explorer/ExplorerTreeNode.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/ui/explorer/ExplorerTreeNode.java?view=diff&rev=13566&p1=trunk/src_new/org/argouml/ui/explorer/ExplorerTreeNode.java&p2=trunk/src_new/org/argouml/ui/explorer/ExplorerTreeNode.java&r1=13565&r2=13566
==============================================================================
--- trunk/src_new/org/argouml/ui/explorer/ExplorerTreeNode.java (original)
+++ trunk/src_new/org/argouml/ui/explorer/ExplorerTreeNode.java 2007-09-17 16:18:25-0700
@@ -36,9 +36,10 @@
import org.tigris.gef.base.Diagram;
/**
- * Ensures that explorer tree nodes have a default ordering.
- *
- * @author alexb
+ * TreeNode implementation for Explorer. Ensures that explorer tree nodes have a
+ * default ordering.
+ *
+ * @author alexb
* @since 0.15.2, Created on 27 September 2003, 17:40
*/
public class ExplorerTreeNode extends DefaultMutableTreeNode implements
@@ -66,6 +67,7 @@
/*
* @see javax.swing.tree.TreeNode#isLeaf()
*/
+ @Override
public boolean isLeaf() {
if (!expanded) {
model.updateChildren(new TreePath(model.getPathToRoot(this)));
@@ -96,10 +98,12 @@
* @param node the modified node in the tree
*/
public void nodeModified(Object node) {
- if (modifySet.contains(node))
+ if (modifySet.contains(node)) {
model.getNodeUpdater().schedule(this);
- if (node == getUserObject())
+ }
+ if (node == getUserObject()) {
model.nodeChanged(this);
+ }
}
/**
Modified: trunk/src_new/org/argouml/ui/explorer/PerspectiveConfigurator.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/ui/explorer/PerspectiveConfigurator.java?view=diff&rev=13566&p1=trunk/src_new/org/argouml/ui/explorer/PerspectiveConfigurator.java&p2=trunk/src_new/org/argouml/ui/explorer/PerspectiveConfigurator.java&r1=13565&r2=13566
==============================================================================
--- trunk/src_new/org/argouml/ui/explorer/PerspectiveConfigurator.java (original)
+++ trunk/src_new/org/argouml/ui/explorer/PerspectiveConfigurator.java 2007-09-17 16:18:25-0700
@@ -389,12 +389,10 @@
* the user may pick from.
*/
private void loadLibrary() {
- List rulesLib = new ArrayList();
- // get them
+ List<PerspectiveRule> rulesLib = new ArrayList<PerspectiveRule>();
rulesLib.addAll(PerspectiveManager.getInstance().getRules());
- // sort them
- Collections.sort(rulesLib, new Comparator() {
- public int compare(Object o1, Object o2) {
+ Collections.sort(rulesLib, new Comparator<PerspectiveRule>() {
+ public int compare(PerspectiveRule o1, PerspectiveRule o2) {
return o1.toString().compareTo(o2.toString());
}
});
@@ -427,21 +425,19 @@
* Load the perspectives from the perspective manager for presentation.
*/
private void loadPerspectives() {
- List perspectives = new ArrayList();
- perspectives.addAll(PerspectiveManager.getInstance().getPerspectives());
+ List<ExplorerPerspective> perspectives =
+ PerspectiveManager.getInstance().getPerspectives();
// must add an editable list of new ExplorerPerspective's
- // to the list model so that the orginal ones are not changed
+ // to the list model so that the original ones are not changed
// in the case of a cancel action by the user.
- for (int i = 0; i < perspectives.size(); i++) {
- ExplorerPerspective perspective =
- (ExplorerPerspective) perspectives.get(i);
- Object[] ruleArray = perspective.getRulesArray();
+ for (ExplorerPerspective perspective : perspectives) {
+ List<PerspectiveRule> rules = perspective.getList();
ExplorerPerspective editablePerspective =
new ExplorerPerspective(perspective.toString());
- for (int r = 0; r < ruleArray.length; r++) {
- editablePerspective.addRule((PerspectiveRule) ruleArray[r]);
+ for (PerspectiveRule rule : rules) {
+ editablePerspective.addRule(rule);
}
perspectiveListModel.addElement(editablePerspective);
@@ -508,9 +504,10 @@
PerspectiveManager.getInstance().removeAllPerspectives();
- for (int i = 0; i < perspectiveListModel.getSize(); i++) {
- Object elem = perspectiveListModel.getElementAt(i);
- PerspectiveManager.getInstance().addPerspective(elem);
+ for (int i = 0; i < perspectiveListModel.size(); i++) {
+ ExplorerPerspective perspective =
+ (ExplorerPerspective) perspectiveListModel.get(i);
+ PerspectiveManager.getInstance().addPerspective(perspective);
}
PerspectiveManager.getInstance().saveUserPerspectives();
@@ -520,7 +517,7 @@
/**
* Handles pressing the Reset-To-Default button. <p>
*
- * Resets all prerspectives to the build-in defaults.
+ * Resets all perspectives to the build-in defaults.
*/
class ResetListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
Modified: trunk/src_new/org/argouml/ui/explorer/PerspectiveManager.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/ui/explorer/PerspectiveManager.java?view=diff&rev=13566&p1=trunk/src_new/org/argouml/ui/explorer/PerspectiveManager.java&p2=trunk/src_new/org/argouml/ui/explorer/PerspectiveManager.java&r1=13565&r2=13566
==============================================================================
--- trunk/src_new/org/argouml/ui/explorer/PerspectiveManager.java (original)
+++ trunk/src_new/org/argouml/ui/explorer/PerspectiveManager.java 2007-09-17 16:18:25-0700
@@ -129,11 +129,11 @@
private static PerspectiveManager instance;
- private List perspectiveListeners;
+ private List<PerspectiveManagerListener> perspectiveListeners;
- private List perspectives;
+ private List<ExplorerPerspective> perspectives;
- private List rules;
+ private List<PerspectiveRule> rules;
/**
* @return the instance (singleton)
@@ -150,9 +150,9 @@
*/
private PerspectiveManager() {
- perspectiveListeners = new ArrayList();
- perspectives = new ArrayList();
- rules = new ArrayList();
+ perspectiveListeners = new ArrayList<PerspectiveManagerListener>();
+ perspectives = new ArrayList<ExplorerPerspective>();
+ rules = new ArrayList<PerspectiveRule>();
loadRules();
}
@@ -176,7 +176,7 @@
* @param perspective
* the perspective to be added
*/
- public void addPerspective(Object perspective) {
+ public void addPerspective(ExplorerPerspective perspective) {
perspectives.add(perspective);
Iterator listenerIt = perspectiveListeners.iterator();
while (listenerIt.hasNext()) {
@@ -192,12 +192,9 @@
* @param newPerspectives
* the collection of perspectives to be added
*/
- public void addAllPerspectives(Collection newPerspectives) {
-
- Iterator newPerspectivesIt = newPerspectives.iterator();
- while (newPerspectivesIt.hasNext()) {
-
- Object newPerspective = newPerspectivesIt.next();
+ public void addAllPerspectives(
+ Collection<ExplorerPerspective> newPerspectives) {
+ for (ExplorerPerspective newPerspective : newPerspectives) {
addPerspective(newPerspective);
}
}
@@ -206,15 +203,9 @@
* @param perspective
* the perspective to be removed
*/
- public void removePerspective(Object perspective) {
-
+ public void removePerspective(ExplorerPerspective perspective) {
perspectives.remove(perspective);
- Iterator listenerIt = perspectiveListeners.iterator();
- while (listenerIt.hasNext()) {
-
- PerspectiveManagerListener listener =
- (PerspectiveManagerListener) listenerIt.next();
-
+ for (PerspectiveManagerListener listener : perspectiveListeners) {
listener.removePerspective(perspective);
}
}
@@ -224,17 +215,18 @@
*/
public void removeAllPerspectives() {
- List pers = new ArrayList();
+ List<ExplorerPerspective> pers = new ArrayList<ExplorerPerspective>();
+
pers.addAll(getPerspectives());
- for (int i = 0; i < pers.size(); i++) {
- removePerspective(pers.get(i));
+ for (ExplorerPerspective perspective : pers) {
+ removePerspective(perspective);
}
}
/**
- * @return the list of all persppectives
+ * @return the list of all perspectives
*/
- public List getPerspectives() {
+ public List<ExplorerPerspective> getPerspectives() {
return perspectives;
}
@@ -327,7 +319,7 @@
* Loads a pre-defined default set of perspectives.
*/
public void loadDefaultPerspectives() {
- Collection c = getDefaultPerspectives();
+ Collection<ExplorerPerspective> c = getDefaultPerspectives();
addAllPerspectives(c);
}
@@ -335,7 +327,7 @@
/**
* @return a collection of default perspectives (i.e. the predefined ones)
*/
- public Collection getDefaultPerspectives() {
+ public Collection<ExplorerPerspective> getDefaultPerspectives() {
ExplorerPerspective classPerspective =
new ExplorerPerspective(
"combobox.item.class-centric");
@@ -459,7 +451,7 @@
compositionPerspective.addRule(new GoModelElementToContents());
compositionPerspective.addRule(new GoModelElementToContainedDiagrams());
- Collection c = new ArrayList();
+ Collection<ExplorerPerspective> c = new ArrayList<ExplorerPerspective>();
c.add(packagePerspective);
c.add(classPerspective);
c.add(diagramPerspective);
@@ -561,7 +553,7 @@
/**
* @return the collection of rules
*/
- public Collection getRules() {
+ public Collection<PerspectiveRule> getRules() {
return rules;
}
@@ -578,6 +570,7 @@
* saved in the user properties.
* @see java.lang.Object#toString()
*/
+ @Override
public String toString() {
String p = "";
Modified: trunk/src_new/org/argouml/uml/diagram/ui/TabDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/diagram/ui/TabDiagram.java?view=diff&rev=13566&p1=trunk/src_new/org/argouml/uml/diagram/ui/TabDiagram.java&p2=trunk/src_new/org/argouml/uml/diagram/ui/TabDiagram.java&r1=13565&r2=13566
==============================================================================
--- trunk/src_new/org/argouml/uml/diagram/ui/TabDiagram.java (original)
+++ trunk/src_new/org/argouml/uml/diagram/ui/TabDiagram.java 2007-09-17 16:18:25-0700
@@ -34,7 +34,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
import java.util.Vector;
@@ -252,13 +251,14 @@
public void selectionChanged(GraphSelectionEvent gse) {
if (!updatingSelection) {
updatingSelection = true;
- Vector sels = gse.getSelections(); // the new selection
- ActionCut.getInstance().setEnabled(sels != null && !sels.isEmpty());
+ List<Fig> selections = gse.getSelections();
+ ActionCut.getInstance().setEnabled(
+ selections != null && !selections.isEmpty());
// TODO: If ActionCopy is no longer a singleton, how shall
// this work?
ActionCopy.getInstance()
- .setEnabled(sels != null && !sels.isEmpty());
+ .setEnabled(selections != null && !selections.isEmpty());
/*
* ActionPaste.getInstance().setEnabled( Globals.clipBoard
* != null && !Globals.clipBoard.isEmpty());
@@ -268,21 +268,16 @@
TargetManager.getInstance().getTargets();
List removedTargets = new ArrayList(currentSelection);
- Iterator i = sels.iterator();
- while (i.hasNext()) {
- Object o = i.next();
- o = TargetManager.getInstance().getOwner(o);
- if (currentSelection.contains(o)) {
- removedTargets.remove(o); // remains selected
+ for (Object selection : selections) {
+ Object owner = TargetManager.getInstance().getOwner(selection);
+ if (currentSelection.contains(owner)) {
+ removedTargets.remove(owner); // remains selected
} else {
// add to selection
- TargetManager.getInstance().addTarget(o);
+ TargetManager.getInstance().addTarget(owner);
}
}
- i = removedTargets.iterator();
- while (i.hasNext()) {
- Object o = i.next();
- // remove from selection
+ for (Object o : removedTargets) {
TargetManager.getInstance().removeTarget(o);
}
updatingSelection = false;
@@ -367,14 +362,14 @@
private void select(Object[] targets) {
LayerManager manager = graph.getEditor().getLayerManager();
- Vector figList = new Vector();
+ List<Fig> figList = new ArrayList<Fig>();
for (int i = 0; i < targets.length; i++) {
if (targets[i] != null) {
- Object theTarget = null;
+ Fig theTarget = null;
if (targets[i] instanceof Fig
&& manager.getActiveLayer().getContents().contains(
targets[i])) {
- theTarget = targets[i];
+ theTarget = (Fig) targets[i];
} else {
theTarget = manager.presentationFor(targets[i]);
}
@@ -387,7 +382,7 @@
if (!figList.equals(graph.selectedFigs())) {
graph.deselectAll();
- graph.select(figList);
+ graph.select(new Vector<Fig>(figList));
}
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.