Author: tfmorris
Date: 2007-06-14 11:44:38-0700
New Revision: 12831
Modified:
trunk/src_new/org/argouml/i18n/button.properties
trunk/src_new/org/argouml/i18n/label.properties
trunk/src_new/org/argouml/uml/ui/UMLRadioButtonPanel.java
trunk/src_new/org/argouml/uml/ui/foundation/core/ActionSetParameterDirectionKind.java
trunk/src_new/org/argouml/uml/ui/foundation/core/UMLParameterDirectionKindRadioButtonPanel.java
Log:
Issue 4784 - Allow no buttons to be selected in panel so that it properly reflects the model. Enhance so the order of buttons is fixed (not alphabetical per locale). I18N.
Modified: trunk/src_new/org/argouml/i18n/button.properties
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/i18n/button.properties?view=diff&rev=12831&p1=trunk/src_new/org/argouml/i18n/button.properties&p2=trunk/src_new/org/argouml/i18n/button.properties&r1=12830&r2=12831
==============================================================================
--- trunk/src_new/org/argouml/i18n/button.properties (original)
+++ trunk/src_new/org/argouml/i18n/button.properties 2007-06-14 11:44:38-0700
@@ -68,6 +68,8 @@
button.go-up-previous-down = Go to previous
button.help = Help
button.help.mnemonic = H
+button.in = In
+button.inout = In/Out
button.move-down = Move Down
button.move-down.mnemonic = M
button.move-down.tooltip = Move the selected item Down
@@ -170,6 +172,7 @@
button.ok = OK
button.ok.mnemonic = O
button.open = Open
+button.out = Out
button.reason-given-below = Reason given below
button.reason-given-below.mnemonic = R
button.remove = Remove
@@ -183,6 +186,7 @@
button.restore-defaults.mnemonic = R
button.restore-defaults.tooltip = Restore all perspectives to pre-defined \
defaults
+button.return = Return
button.run-gc = Run Garbage Collector
button.run-gc.mnemonic = R
button.select = Select
Modified: trunk/src_new/org/argouml/i18n/label.properties
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/i18n/label.properties?view=diff&rev=12831&p1=trunk/src_new/org/argouml/i18n/label.properties&p2=trunk/src_new/org/argouml/i18n/label.properties&r1=12830&r2=12831
==============================================================================
--- trunk/src_new/org/argouml/i18n/label.properties (original)
+++ trunk/src_new/org/argouml/i18n/label.properties 2007-06-14 11:44:38-0700
@@ -229,7 +229,7 @@
label.owning-use-case = Owning Use Case:
label.package = Package
label.parameter.default-value = Default Value:
-label.parameter.kind = Kind:
+label.parameter.kind = Direction Kind:
label.parameters = Parameters:
label.parent = Parent:
label.perspectives = Perspectives
Modified: trunk/src_new/org/argouml/uml/ui/UMLRadioButtonPanel.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/ui/UMLRadioButtonPanel.java?view=diff&rev=12831&p1=trunk/src_new/org/argouml/uml/ui/UMLRadioButtonPanel.java&p2=trunk/src_new/org/argouml/uml/ui/UMLRadioButtonPanel.java&r1=12830&r2=12831
==============================================================================
--- trunk/src_new/org/argouml/uml/ui/UMLRadioButtonPanel.java (original)
+++ trunk/src_new/org/argouml/uml/ui/UMLRadioButtonPanel.java 2007-06-14 11:44:38-0700
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 1996-2006 The Regents of the University of California. All
+// Copyright (c) 1996-2007 The Regents of the University of California. All
// Rights Reserved. Permission to use, copy, modify, and distribute this
// software and its documentation without fee, and without a written
// agreement is hereby granted, provided that the above copyright notice
@@ -28,14 +28,14 @@
import java.awt.GridLayout;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
import java.util.Enumeration;
-import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import javax.swing.AbstractButton;
import javax.swing.Action;
import javax.swing.ButtonGroup;
-import javax.swing.ButtonModel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.border.TitledBorder;
@@ -68,7 +68,7 @@
private Object panelTarget;
/**
- * The name of the MEvent that is fired when the target object has changed
+ * The name of the event that is fired when the target object has changed
* the attribute that is shown here.
*/
private String propertySetName;
@@ -77,28 +77,34 @@
* The group of buttons
*/
private ButtonGroup buttonGroup = new ButtonGroup();
-
+
/**
* Constructs a new UMLRadioButtonPanel.
- * @param isDoubleBuffered @see JPanel
- * @param title The title of the titledborder around the buttons. If the
- * title is null, there is no border shown.
- * @param labeltextsActioncommands A map of keys containing the texts for
- * the buttons and values containing the actioncommand that permits the
- * setAction to logically recognize the button.
- * @param thePropertySetName the name of the MEvent that is fired when the
- * property that it shows changes value.
- * @param setAction the action that should be registred with the buttons and
- * that's executed when one of the buttons is pressed.
- * @param horizontal when true the buttons should be layed out horizontaly.
+ *
+ * @param isDoubleBuffered see {@link JPanel}.
+ * @param title
+ * The title of the titledborder around the buttons. If the title
+ * is null, there is no border shown.
+ * @param labeltextsActioncommands
+ * A map of keys containing the texts for the buttons and values
+ * containing the actioncommand that permits the setAction to
+ * logically recognize the button.
+ * @param thePropertySetName
+ * the name of the MEvent that is fired when the property that it
+ * shows changes value.
+ * @param setAction
+ * the action that should be registred with the buttons and
+ * that's executed when one of the buttons is pressed.
+ * @param horizontal
+ * when true the buttons should be layed out horizontaly.
*/
public UMLRadioButtonPanel(
- boolean isDoubleBuffered,
- String title,
- Map labeltextsActioncommands,
- String thePropertySetName,
- Action setAction,
- boolean horizontal) {
+ boolean isDoubleBuffered,
+ String title,
+ List<String[]> labeltextsActioncommands,
+ String thePropertySetName,
+ Action setAction,
+ boolean horizontal) {
super(isDoubleBuffered);
setLayout(horizontal ? new GridLayout() : new GridLayout(0, 1));
setDoubleBuffered(true);
@@ -110,21 +116,100 @@
setButtons(labeltextsActioncommands, setAction);
setPropertySetName(thePropertySetName);
}
+
+ /**
+ * Constructs a new UMLRadioButtonPanel.
+ *
+ * @param title
+ * The title of the titledborder around the buttons.
+ * @param labeltextsActioncommands
+ * A map of keys containing the texts for the buttons and values
+ * containing the actioncommand that permits the setAction to
+ * logically recognize the button.
+ * @param thePropertySetName
+ * the name of the MEvent that is fired when the property that is
+ * showns changes value.
+ * @param setAction
+ * the action that should be registred with the buttons and
+ * that's executed when one of the buttons is pressed
+ * @param horizontal
+ * when true the buttons should be layed out horizontaly.
+ */
+ public UMLRadioButtonPanel(String title,
+ List<String[]> labeltextsActioncommands,
+ String thePropertySetName,
+ Action setAction,
+ boolean horizontal) {
+ this(true, title, labeltextsActioncommands,
+ thePropertySetName, setAction, horizontal);
+ }
+
+ /**
+ * Constructs a new UMLRadioButtonPanel.
+ *
+ * @param isDoubleBuffered See {@link JPanel}.
+ * @param title
+ * The title of the titledborder around the buttons. If the title
+ * is null, there is no border shown.
+ * @param labeltextsActioncommands
+ * A map of keys containing the texts for the buttons and values
+ * containing the actioncommand that permits the setAction to
+ * logically recognize the button.
+ * @param thePropertySetName
+ * the name of the MEvent that is fired when the property that it
+ * shows changes value.
+ * @param setAction
+ * the action that should be registred with the buttons and
+ * that's executed when one of the buttons is pressed.
+ * @param horizontal
+ * when true the buttons should be layed out horizontaly.
+ * @deprecated for 0.25.4 by tfmorris. Use List<String[]> form of
+ * constructor.
+ */
+ public UMLRadioButtonPanel(
+ boolean isDoubleBuffered,
+ String title,
+ Map<String, String> labeltextsActioncommands,
+ String thePropertySetName,
+ Action setAction,
+ boolean horizontal) {
+ this(isDoubleBuffered, title, toList(labeltextsActioncommands),
+ thePropertySetName, setAction, horizontal);
+ }
+
+ private static List<String[]> toList(Map<String, String> map) {
+ List<String[]> list = new ArrayList<String[]>();
+ for (String key : map.keySet()) {
+ list.add(new String[] {key, map.get(key)});
+ }
+ return list;
+ }
/**
* Constructs a new UMLRadioButtonPanel.
- * @param title The title of the titledborder around the buttons.
- * @param labeltextsActioncommands A map of keys containing the texts for
- * the buttons and values containing the actioncommand that permits the
- * setAction to logically recognize the button.
- * @param thePropertySetName the name of the MEvent that is fired when the
- * property that is showns changes value.
- * @param setAction the action that should be registred with the buttons and
- * that's executed when one of the buttons is pressed
- * @param horizontal when true the buttons should be layed out horizontaly.
+ *
+ * @param title
+ * The title of the titledborder around the buttons.
+ * @param labeltextsActioncommands
+ * A map of keys containing the texts for the buttons and values
+ * containing the actioncommand that permits the setAction to
+ * logically recognize the button.
+ * @param thePropertySetName
+ * the name of the MEvent that is fired when the property that is
+ * showns changes value.
+ * @param setAction
+ * the action that should be registred with the buttons and
+ * that's executed when one of the buttons is pressed
+ * @param horizontal
+ * when true the buttons should be layed out horizontaly.
+ * @deprecated for 0.25.4 by tfmorris. Use List<String[]> form of
+ * constructor. See
+ * {@link UMLParameterDirectionKindRadioButtonPanel} for an
+ * example of a subclass which has been converted to the new
+ * form of constructor.
*/
public UMLRadioButtonPanel(String title,
- Map labeltextsActioncommands,
+ Map<String, String> labeltextsActioncommands,
String thePropertySetName,
Action setAction,
boolean horizontal) {
@@ -133,32 +218,34 @@
}
/**
- * Initially constructs the buttons.
- *
- * @param labeltextsActioncommands A map of keys containing the
- * texts for the buttons and values containing the actioncommand
- * that permits the setAction to logically recognize the button.
- * @param setAction the action that should be registred with the
- * buttons and that's executed when one of the buttons is pressed
+ * Construct the buttons and place them in the panel as well as the button
+ * group.
*
- * TODO: This forces the buttons to be ordered in key map order,
- * an order which is arbitrary for a HashMap. This should be
- * changed to allow the UI designer to specify the order. - tfm
+ * @param labeltextsActioncommands
+ * A list of string arrays containing a pair of strings with the
+ * texts for the buttons (already localized) and string value for
+ * the actioncommand that permits the setAction to logically
+ * recognize the button.
+ * @param setAction
+ * the action that should be registred with the buttons and
+ * that's executed when one of the buttons is pressed
*/
- private void setButtons(Map labeltextsActioncommands, Action setAction) {
+ private void setButtons(List<String[]> labeltextsActioncommands,
+ Action setAction) {
Enumeration en = buttonGroup.getElements();
while (en.hasMoreElements()) {
AbstractButton button = (AbstractButton) en.nextElement();
buttonGroup.remove(button);
}
removeAll();
- Iterator it = labeltextsActioncommands.keySet().iterator();
- while (it.hasNext()) {
- String keyAndLabel = (String) it.next();
- JRadioButton button = new JRadioButton(keyAndLabel);
+
+ // Add an invisible button to be used when everything is off
+ buttonGroup.add(new JRadioButton());
+
+ for (String[] keyAndLabelX : labeltextsActioncommands) {
+ JRadioButton button = new JRadioButton(keyAndLabelX[0]);
button.addActionListener(setAction);
- String actionCommand =
- (String) labeltextsActioncommands.get(keyAndLabel);
+ String actionCommand = keyAndLabelX[1];
button.setActionCommand(actionCommand);
button.setFont(LookAndFeelMgr.getInstance().getStandardFont());
buttonGroup.add(button);
@@ -228,17 +315,25 @@
public abstract void buildModel();
/**
- * Selects the radiobutton with the given actionCommand
- * @param actionCommand The actionCommand of the button that should be
- * selected.
+ * Selects the radiobutton with the given actionCommand. If a null parameter
+ * is passed, all buttons in the group will be deselected.
+ *
+ * @param actionCommand
+ * The actionCommand of the button that should be selected or
+ * null to deselect all buttons.
*/
public void setSelected(String actionCommand) {
- Enumeration en = buttonGroup.getElements();
- ButtonModel model = null;
+ Enumeration<AbstractButton> en = buttonGroup.getElements();
+ if (actionCommand == null) {
+ // Our first button is invisible.
+ // Selecting it deselects all visible buttons.
+ en.nextElement().setSelected(true);
+ return;
+ }
while (en.hasMoreElements()) {
- model = ((AbstractButton) en.nextElement()).getModel();
- if (actionCommand.equals(model.getActionCommand())) {
- model.setSelected(true);
+ AbstractButton b = en.nextElement();
+ if (actionCommand.equals(b.getModel().getActionCommand())) {
+ b.setSelected(true);
break;
}
}
Modified: trunk/src_new/org/argouml/uml/ui/foundation/core/ActionSetParameterDirectionKind.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/ui/foundation/core/ActionSetParameterDirectionKind.java?view=diff&rev=12831&p1=trunk/src_new/org/argouml/uml/ui/foundation/core/ActionSetParameterDirectionKind.java&p2=trunk/src_new/org/argouml/uml/ui/foundation/core/ActionSetParameterDirectionKind.java&r1=12830&r2=12831
==============================================================================
--- trunk/src_new/org/argouml/uml/ui/foundation/core/ActionSetParameterDirectionKind.java (original)
+++ trunk/src_new/org/argouml/uml/ui/foundation/core/ActionSetParameterDirectionKind.java 2007-06-14 11:44:38-0700
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 1996-2006 The Regents of the University of California. All
+// Copyright (c) 1996-2007 The Regents of the University of California. All
// Rights Reserved. Permission to use, copy, modify, and distribute this
// software and its documentation without fee, and without a written
// agreement is hereby granted, provided that the above copyright notice
@@ -35,7 +35,7 @@
import org.tigris.gef.undo.UndoableAction;
/**
- * An action to set the concurrency of an operation.
+ * An action to set the direction of a parameter.
*
* @author mkl
*
@@ -64,7 +64,7 @@
* RETURN_COMMAND determines the kind of direction.
*/
public static final String RETURN_COMMAND = "return";
-
+
/**
* Constructor for ActionSetElementOwnershipSpecification.
*/
@@ -78,6 +78,7 @@
/*
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
+ @Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() instanceof JRadioButton) {
@@ -86,18 +87,19 @@
Object target = ((UMLRadioButtonPanel) source.getParent())
.getTarget();
if (Model.getFacade().isAParameter(target)) {
- Object m = /* (MModelElement) */target;
Object kind = null;
- if (actionCommand.equals(IN_COMMAND)) {
+ if (actionCommand == null) {
+ kind = null;
+ } else if (actionCommand.equals(IN_COMMAND)) {
kind = Model.getDirectionKind().getInParameter();
} else if (actionCommand.equals(OUT_COMMAND)) {
kind = Model.getDirectionKind().getOutParameter();
} else if (actionCommand.equals(INOUT_COMMAND)) {
kind = Model.getDirectionKind().getInOutParameter();
- } else {
+ } else if (actionCommand.equals(RETURN_COMMAND)) {
kind = Model.getDirectionKind().getReturnParameter();
}
- Model.getCoreHelper().setKind(m, kind);
+ Model.getCoreHelper().setKind(target, kind);
}
}
}
Modified: trunk/src_new/org/argouml/uml/ui/foundation/core/UMLParameterDirectionKindRadioButtonPanel.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/ui/foundation/core/UMLParameterDirectionKindRadioButtonPanel.java?view=diff&rev=12831&p1=trunk/src_new/org/argouml/uml/ui/foundation/core/UMLParameterDirectionKindRadioButtonPanel.java&p2=trunk/src_new/org/argouml/uml/ui/foundation/core/UMLParameterDirectionKindRadioButtonPanel.java&r1=12830&r2=12831
==============================================================================
--- trunk/src_new/org/argouml/uml/ui/foundation/core/UMLParameterDirectionKindRadioButtonPanel.java (original)
+++ trunk/src_new/org/argouml/uml/ui/foundation/core/UMLParameterDirectionKindRadioButtonPanel.java 2007-06-14 11:44:38-0700
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 1996-2006 The Regents of the University of California. All
+// Copyright (c) 1996-2007 The Regents of the University of California. All
// Rights Reserved. Permission to use, copy, modify, and distribute this
// software and its documentation without fee, and without a written
// agreement is hereby granted, provided that the above copyright notice
@@ -24,44 +24,54 @@
package org.argouml.uml.ui.foundation.core;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.ArrayList;
+import java.util.List;
+import org.argouml.i18n.Translator;
import org.argouml.model.Model;
import org.argouml.uml.ui.UMLRadioButtonPanel;
/**
- * A panel for the parameterdiretion (in, inout...) of a parameter.
+ * A panel for the ParameterDirectionKind (in, inout...) of a Parameter.
*
* @author mkl
*/
public class UMLParameterDirectionKindRadioButtonPanel extends
UMLRadioButtonPanel {
- private static Map labelTextsAndActionCommands = new HashMap();
+ private static List<String[]> labelTextsAndActionCommands =
+ new ArrayList<String[]>();
static {
- // TODO: i18n, use Translator
- labelTextsAndActionCommands.put("in",
- ActionSetParameterDirectionKind.IN_COMMAND);
- labelTextsAndActionCommands.put("out",
- ActionSetParameterDirectionKind.OUT_COMMAND);
- labelTextsAndActionCommands.put("inout",
- ActionSetParameterDirectionKind.INOUT_COMMAND);
- labelTextsAndActionCommands.put("return",
- ActionSetParameterDirectionKind.RETURN_COMMAND);
+ labelTextsAndActionCommands.add(new String[] {
+ Translator.localize("button.in"),
+ ActionSetParameterDirectionKind.IN_COMMAND
+ });
+ labelTextsAndActionCommands.add(new String[] {
+ Translator.localize("button.out"),
+ ActionSetParameterDirectionKind.OUT_COMMAND
+ });
+ labelTextsAndActionCommands.add(new String[] {
+ Translator.localize("button.inout"),
+ ActionSetParameterDirectionKind.INOUT_COMMAND
+ });
+ labelTextsAndActionCommands.add(new String[] {
+ Translator.localize("button.return"),
+ ActionSetParameterDirectionKind.RETURN_COMMAND
+ });
}
/**
* Constructor.
- *
- * @param title the title of the panel
- * @param horizontal determines the orientation
+ *
+ * @param title
+ * the title of the panel
+ * @param horizontal
+ * determines the orientation
*/
public UMLParameterDirectionKindRadioButtonPanel(String title,
boolean horizontal) {
- // TODO: i18n
- super(title, labelTextsAndActionCommands, "ParameterKind:",
+ super(title, labelTextsAndActionCommands, "kind",
ActionSetParameterDirectionKind.getInstance(), horizontal);
}
@@ -70,11 +80,12 @@
*/
public void buildModel() {
if (getTarget() != null) {
- Object target = /* (MModelElement) */getTarget();
+ Object target = getTarget();
Object kind = Model.getFacade().getKind(target);
- if (kind == null
- || kind.equals(
- Model.getDirectionKind().getInParameter())) {
+ if (kind == null) {
+ setSelected(null);
+ } else if (kind.equals(
+ Model.getDirectionKind().getInParameter())) {
setSelected(ActionSetParameterDirectionKind.IN_COMMAND);
} else if (kind.equals(
Model.getDirectionKind().getInOutParameter())) {
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.