svn commit: r18643 - trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/RowSelector.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: bobtarling
Date: 2010-08-15 09:56:41-0700
New Revision: 18643

Modified:
   trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/RowSelector.java

Log:
Create popup menu for lists

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=18643&r1=18642&r2=18643
==============================================================================
--- 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-08-15 09:56:41-0700
@@ -56,6 +56,7 @@
 import javax.swing.JLabel;
 import javax.swing.JList;
 import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
 import javax.swing.JScrollPane;
 import javax.swing.JTable;
 import javax.swing.JToolBar;
@@ -130,6 +131,8 @@
     
     private static final Set<String> EXPANDED_CONTROLS = new TreeSet<String>();
     
+    private final ArrayList actions;
+    
     static {
         // Extract the icon that is used by the tree control
         // for the current look and feel
@@ -323,6 +326,7 @@
         }
         
 
+        actions = new ArrayList<Action>(6);
         if (!expandable && !expanded) {
             jscroll.setVerticalScrollBarPolicy(
                     JScrollPane.VERTICAL_SCROLLBAR_NEVER);
@@ -335,7 +339,6 @@
             moveBottomAction = null;
             if (!readonly) {
                 // Create popup toolbutton if we have a single row
-                final ArrayList<Action> actions = new ArrayList<Action>(6);
     
                 for (Object meta : metaTypes) {
                     if (Model.getUmlFactory().isContainmentValid(
@@ -383,9 +386,6 @@
             if (!readonly) {
         	// TODO: Lets build this into a separate buildToolbar method
         		
-                // Create actions and expander if we have multiple rows
-                final ArrayList actions = new ArrayList(6);
-                
                 // Create add and remove buttons if needed first
                 if (addAction != null) {
                     actions.add(addAction);
@@ -500,6 +500,7 @@
                     getList().addListSelectionListener(moveBottomAction);
                 }
             }
+            getList().addMouseListener(this);
             
             getModel().addListDataListener(this);
         }
@@ -545,7 +546,9 @@
     }
 
     public void mouseClicked(MouseEvent e) {
-        toggleExpansion();
+	if (e.getSource() == this) {
+            toggleExpansion();
+	}
     }
 
     public void mouseEntered(MouseEvent e) {
@@ -559,13 +562,33 @@
     }
 
     public void mousePressed(MouseEvent e) {
-        // TODO Auto-generated method stub
-
+        if (e.isPopupTrigger()) {
+            JPopupMenu popup = new JPopupMenu();
+            for (Object action : actions) {
+        	if (action instanceof Action) {
+        	    popup.add((Action) action);
+        	}
+            }
+            if (popup.getComponentCount() > 0) {
+                popup.show(this, e.getX(), e.getY());
+            }
+            e.consume();
+        }
     }
 
     public void mouseReleased(MouseEvent e) {
-        // TODO Auto-generated method stub
-
+        if (e.isPopupTrigger()) {
+            JPopupMenu popup = new JPopupMenu();
+            for (Object action : actions) {
+        	if (action instanceof Action) {
+        	    popup.add((Action) action);
+        	}
+            }
+            if (popup.getComponentCount() > 0) {
+                popup.show(this, e.getX(), e.getY());
+            }
+            e.consume();
+        }
     }
 
     /**
@@ -628,6 +651,7 @@
                 getList().removeListSelectionListener(moveDownAction);
                 getList().removeListSelectionListener(moveTopAction);
                 getList().removeListSelectionListener(moveBottomAction);
+                getList().removeMouseListener(this);
             }
     	}
         this.removeMouseListener(this);

------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2647152

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.