Author: bobtarling
Date: 2010-04-10 03:17:55-0700
New Revision: 18236
Added:
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UmlControl.java
Modified:
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/RowSelector.java
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLComboBoxNavigator.java
Log:
Issue 6059: Make dropdown buttons with just a single item into standard toolbuttons instead.
Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/RowSelector.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/RowSelector.java?view=diff&pathrev=18236&r1=18235&r2=18236
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/RowSelector.java (original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/RowSelector.java 2010-04-10 03:17:55-0700
@@ -89,6 +89,7 @@
import org.tigris.toolbar.ToolBar;
import org.tigris.toolbar.ToolBarFactory;
import org.tigris.toolbar.toolbutton.PopupToolBoxButton;
+import org.tigris.toolbar.toolbutton.ToolButton;
/**
* A control for displaying the contents of a list model elements in a panel
@@ -98,7 +99,7 @@
* @author Bob Tarling
* @since 0.29.2
*/
-class RowSelector extends JPanel
+class RowSelector extends UmlControl
implements MouseListener, ListDataListener, ListSelectionListener {
/**
@@ -358,13 +359,25 @@
}
if (!actions.isEmpty()) {
- PopupToolBoxButton tb = new PopupToolBoxButton(actions.get(0), actions.size(), 1, true);
- for (Action action : actions) {
- tb.add(action);
- }
- JPanel buttonPanel =
- new JPanel(new FlexiGridLayout(2, 1, FlexiGridLayout.ROWCOLPREFERRED));
- buttonPanel.add(tb);
+ final JPanel buttonPanel =
+ createSingleButtonPanel(actions);
+
+// new JPanel(new FlexiGridLayout(2, 1, FlexiGridLayout.ROWCOLPREFERRED));
+// final ToolButton tb;
+// if (actions.size() == 1) {
+// tb = new ToolButton(actions.get(0));
+// } else {
+// PopupToolBoxButton ptb = new PopupToolBoxButton(actions.get(0), actions.size(), 1, true);
+// for (Action action : actions) {
+// ptb.add(action);
+// }
+// tb = ptb;
+// }
+// final ToolBarFactory tbf = new ToolBarFactory(new Object[] {});
+// JToolBar toolbar = tbf.createToolBar();
+// toolbar.setRollover(true);
+// toolbar.add(tb);
+// buttonPanel.add(toolbar);
add(buttonPanel, BorderLayout.WEST);
}
}
Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLComboBoxNavigator.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLComboBoxNavigator.java?view=diff&pathrev=18236&r1=18235&r2=18236
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLComboBoxNavigator.java (original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLComboBoxNavigator.java 2010-04-10 03:17:55-0700
@@ -52,11 +52,14 @@
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JPanel;
+import javax.swing.JToolBar;
import org.argouml.application.helpers.ResourceLoaderWrapper;
import org.argouml.ui.targetmanager.TargetManager;
import org.tigris.swidgets.FlexiGridLayout;
+import org.tigris.toolbar.ToolBarFactory;
import org.tigris.toolbar.toolbutton.PopupToolBoxButton;
+import org.tigris.toolbar.toolbutton.ToolButton;
/**
* This class implements a panel that adds a navigation button to the right of
@@ -65,7 +68,7 @@
* @author Curt Arnold
* @since 0.9
*/
-public class UMLComboBoxNavigator extends JPanel implements ActionListener,
+public class UMLComboBoxNavigator extends UmlControl implements ActionListener,
ItemListener {
private static ImageIcon icon = ResourceLoaderWrapper
@@ -101,14 +104,26 @@
if (model instanceof UMLComboBoxModel) {
final List<Action> actions = ((UMLComboBoxModel) model).getActions();
if (!actions.isEmpty()) {
- PopupToolBoxButton tb = new PopupToolBoxButton(actions.get(0), actions.size(), 1, true);
- for (Action action : actions) {
- tb.add(action);
- }
- JPanel buttonPanel =
- new JPanel(new FlexiGridLayout(2, 1, FlexiGridLayout.ROWCOLPREFERRED));
- buttonPanel.add(tb);
+ final JPanel buttonPanel =
+ createSingleButtonPanel(actions);
+// new JPanel(new FlexiGridLayout(2, 1, FlexiGridLayout.ROWCOLPREFERRED));
+// final ToolButton tb;
+// if (actions.size() == 1) {
+// tb = new ToolButton(actions.get(0));
+// } else {
+// PopupToolBoxButton ptb = new PopupToolBoxButton(actions.get(0), actions.size(), 1, true);
+// for (Action action : actions) {
+// ptb.add(action);
+// }
+// tb = ptb;
+// }
+// final ToolBarFactory tbf = new ToolBarFactory(new Object[] {});
+// JToolBar toolbar = tbf.createToolBar();
+// toolbar.setRollover(true);
+// toolbar.add(tb);
+// buttonPanel.add(toolbar);
add(buttonPanel, BorderLayout.WEST);
+
}
}
Object item = theComboBox.getSelectedItem();
Added: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UmlControl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UmlControl.java?view=markup&pathrev=18236
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UmlControl.java 2010-04-10 03:17:55-0700
@@ -0,0 +1,73 @@
+/* $Id$
+ *******************************************************************************
+ * Copyright (c) 2010 Contributors - see below
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bob Tarling
+ *******************************************************************************
+ */
+
+package org.argouml.core.propertypanels.ui;
+
+import java.awt.LayoutManager;
+import java.util.List;
+
+import javax.swing.Action;
+import javax.swing.JPanel;
+import javax.swing.JToolBar;
+
+import org.tigris.swidgets.FlexiGridLayout;
+import org.tigris.toolbar.ToolBarFactory;
+import org.tigris.toolbar.toolbutton.PopupToolBoxButton;
+import org.tigris.toolbar.toolbutton.ToolButton;
+
+/**
+ * The base class for controls on a panel.
+ *
+ * @author Bob Tarling
+ */
+class UmlControl extends JPanel {
+
+ /**
+ * The uid
+ */
+ private static final long serialVersionUID = -826243573886719300L;
+
+ public UmlControl(LayoutManager layout) {
+ super(layout);
+ }
+
+ /**
+ * Create a JPanel containing a single button to access the given actions.
+ * If there if more than one button then a drop down button is created
+ * with the actions otherwise there is a simple button for the single
+ * action.
+ * @param actions the actions from which to generate the panel
+ * @return the panel containing the actions required.
+ */
+ protected JPanel createSingleButtonPanel(List<Action> actions) {
+ JPanel buttonPanel =
+ new JPanel(new FlexiGridLayout(2, 1, FlexiGridLayout.ROWCOLPREFERRED));
+ final ToolButton tb;
+ if (actions.size() == 1) {
+ tb = new ToolButton(actions.get(0));
+ tb.setHideActionText(true);
+ } else {
+ PopupToolBoxButton ptb = new PopupToolBoxButton(actions.get(0), actions.size(), 1, true);
+ for (Action action : actions) {
+ ptb.add(action);
+ }
+ tb = ptb;
+ }
+ final ToolBarFactory tbf = new ToolBarFactory(new Object[] {});
+ JToolBar toolbar = tbf.createToolBar();
+ toolbar.setRollover(true);
+ toolbar.add(tb);
+ buttonPanel.add(toolbar);
+ return buttonPanel;
+ }
+}
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2544351
To unsubscribe from this discussion, e-mail: [[email protected]].
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.