Index: core/src/org/netbeans/core/ui/MountNode.java =================================================================== RCS file: /cvs/core/src/org/netbeans/core/ui/MountNode.java,v retrieving revision 1.7 diff -u -t -r1.7 MountNode.java --- core/src/org/netbeans/core/ui/MountNode.java 25 Sep 2001 13:07:36 -0000 1.7 +++ core/src/org/netbeans/core/ui/MountNode.java 3 Oct 2001 09:04:24 -0000 @@ -373,6 +373,16 @@ } }; } + + private static final SystemAction[] MOVEUPDOWN = new SystemAction[] { + SystemAction.get(MoveUpAction.class), + SystemAction.get(MoveDownAction.class), + null, + }; + + public SystemAction[] getActions() { + return SystemAction.linkActions(MOVEUPDOWN, super.getActions()); + } public PropertySet[] getPropertySets () { Node.PropertySet[] s = sets; Index: openide/src/org/openide/loaders/DataFolder.java =================================================================== RCS file: /cvs/openide/src/org/openide/loaders/DataFolder.java,v retrieving revision 1.114 diff -u -t -r1.114 DataFolder.java --- openide/src/org/openide/loaders/DataFolder.java 20 Sep 2001 11:35:07 -0000 1.114 +++ openide/src/org/openide/loaders/DataFolder.java 3 Oct 2001 09:04:31 -0000 @@ -872,12 +872,15 @@ /* Invokes a dialog for reordering subnodes. */ public void reorder () { + /* IndexedCustomizer ic = new IndexedCustomizer(); ic.setObject(this); // turn off immediate reorder so that children are reordered // at once when closing the dialog ic.setImmediateReorder(false); ic.show(); + */ + Index.Support.showIndexedCustomizer(this); } /** Fires notification about reordering to all Index: openide/src/org/openide/nodes/Index.java =================================================================== RCS file: /cvs/openide/src/org/openide/nodes/Index.java,v retrieving revision 1.20 diff -u -t -r1.20 Index.java --- openide/src/org/openide/nodes/Index.java 27 Jun 2001 13:42:12 -0000 1.20 +++ openide/src/org/openide/nodes/Index.java 3 Oct 2001 09:04:33 -0000 @@ -7,12 +7,14 @@ * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original - * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun * Microsystems, Inc. All Rights Reserved. */ package org.openide.nodes; +import java.awt.Container; +import javax.swing.JPanel; import java.util.ArrayList; import java.util.List; import java.util.Iterator; @@ -23,6 +25,8 @@ import javax.swing.event.ChangeListener; import javax.swing.event.ChangeEvent; +import org.openide.DialogDescriptor; +import org.openide.TopManager; import org.openide.util.Mutex; import org.openide.util.NotImplementedException; @@ -234,6 +238,7 @@ /** Reorder the nodes with dialog; should be overridden if needed. */ public void reorder () { + /* Mutex.EVENT.readAccess (new Mutex.Action () { public Object run () { IndexedCustomizer ic = new IndexedCustomizer (); @@ -242,6 +247,60 @@ return null; } }); + */ + showIndexedCustomizer(this); + } + + /** Utility method to create and show an indexed customizer. + * Displays some sort of dialog permitting the index cookie to be reordered. + * Blocks until the reordering is performed (or cancelled). + * @param idx the index cookie to reorder based on + * @since XXX + */ + public static void showIndexedCustomizer(Index idx) { + ICShower shower = null; + try { + shower = (ICShower)TMICShower.class.newInstance(); + } catch (ThreadDeath td) { + throw td; + } catch (Throwable t) { + // expected for standalone use, ignore + } + if (shower != null) { + shower.showIndexedCustomizer(idx); + return; + } + // Fallthrough, standalone mode: + final IndexedCustomizer ic = new IndexedCustomizer(); + ic.setObject(idx); + ic.setImmediateReorder(false); + Mutex.EVENT.readAccess(new Mutex.Action() { + public Object run() { + ic.show(); + return null; + } + }); + } + private static interface ICShower { + void showIndexedCustomizer(Index idx); + } + /** Better implementation that knows about TopManager. + * Interacts better with window system. + */ + private static final class TMICShower implements ICShower { + public void showIndexedCustomizer(Index idx) { + Container p = new JPanel(); + IndexedCustomizer ic = new IndexedCustomizer(p, false); + ic.setObject(idx); + ic.setImmediateReorder(false); + DialogDescriptor dd = new DialogDescriptor(p, Node.getString("LAB_order")); + dd.setModal(true); + dd.setOptionType(DialogDescriptor.DEFAULT_OPTION); + Object result = TopManager.getDefault().notify(dd); + if (result == DialogDescriptor.OK_OPTION) { + ic.doClose(); + } + } } /** Get the node count. Subclasses must provide this. @@ -324,9 +383,12 @@ public void reorder () { try { PR.enterReadAccess (); + /* IndexedCustomizer ic = new IndexedCustomizer(); ic.setObject(Index.ArrayChildren.this); ic.show(); + */ + Support.showIndexedCustomizer(this); } finally { PR.exitReadAccess (); } @@ -500,18 +562,3 @@ } } - -/* -* $Log: -* 7 src-jtulac1.6 11/16/98 David Simonek -* 6 src-jtulac1.5 11/6/98 David Simonek -* 5 src-jtulac1.4 11/4/98 David Simonek -* 4 src-jtulac1.3 11/4/98 David Simonek Put at position method -* was added - put(key, -* node, index) Position -* array now thread-safe -* 3 src-jtulac1.2 10/30/98 Petr Hamernik -* 2 src-jtulac1.1 10/28/98 Jaroslav Tulach -* 1 src-jtulac1.0 10/28/98 Jaroslav Tulach -* $ -*/ Index: openide/src/org/openide/nodes/IndexedCustomizer.java =================================================================== RCS file: /cvs/openide/src/org/openide/nodes/IndexedCustomizer.java,v retrieving revision 1.26 diff -u -t -r1.26 IndexedCustomizer.java --- openide/src/org/openide/nodes/IndexedCustomizer.java 8 Mar 2001 16:48:03 -0000 1.26 +++ openide/src/org/openide/nodes/IndexedCustomizer.java 3 Oct 2001 09:04:36 -0000 @@ -7,7 +7,7 @@ * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original - * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun * Microsystems, Inc. All Rights Reserved. */ @@ -42,6 +42,8 @@ *

This class is final only for performance reasons. * * @author Jan Jancura, Ian Formanek, Dafe Simonek +* @deprecated Better to use Index.Support.showIndexedCustomizer which behaves better +* with the window system. */ public final class IndexedCustomizer extends JDialog implements java.beans.Customizer { @@ -76,9 +78,20 @@ static final long serialVersionUID =-8731362267771694641L; /** Construct a new customizer. */ public IndexedCustomizer () { + this(null, true); + } + /** Construct a dummy customizer. + * Might not actually be used as a JDialog, however its GUI + * layout and logic will be used. + * Cf. #9323. + * @param c a container on which to draw the GUI + * @param closeButton if true, add a Close button and other dialog logic, else no + */ + IndexedCustomizer(Container p, boolean closeButton) { super (TMUtil.mainWindow (), true); GridBagConstraints constraints; + if (closeButton) { setDefaultCloseOperation (javax.swing.JDialog.DISPOSE_ON_CLOSE); // attach cancel also to Escape key getRootPane().registerKeyboardAction( @@ -93,8 +106,9 @@ ); setTitle(Node.getString("LAB_order")); + } // closeButton - JComponent p = (JComponent)getContentPane (); + if (p == null) p = getContentPane (); p.setLayout (new GridBagLayout()); @@ -146,8 +160,10 @@ p.add(new JScrollPane(control), constraints); JPanel bb = new JPanel (); + if (closeButton) { buttonClose = new JButton (Node.getString("Button_close")); buttonClose.setMnemonic(Node.getString("Button_close_Mnemonic").charAt(0)); + } buttonUp = new JButton (Node.getString("Button_up")); buttonUp.setMnemonic(Node.getString("Button_up_Mnemonic").charAt(0)); buttonDown = new JButton (Node.getString("Button_down")); @@ -176,12 +192,14 @@ constraints.weighty = 1.0; bb.add(new JPanel(), constraints); + if (closeButton) { constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 3; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.insets = new Insets(11, 0, 0, 0); bb.add(buttonClose, constraints); + } buttonUp.addActionListener (new ActionListener () { public void actionPerformed (ActionEvent e) { @@ -205,20 +223,14 @@ } }); + if (closeButton) { buttonClose.addActionListener (new ActionListener () { public void actionPerformed (ActionEvent e) { - if ((!immediateReorder) && (index != null) && - (permutation != null)) { - int[] realPerm = new int[permutation.length]; - for (int i = 0; i < realPerm.length; i++) { - realPerm[permutation[i]] = i; - //System.out.println (i + "-->" + permutation[i]); // NOI18N - } - index.reorder(realPerm); - } + doClose(); dispose (); } }); + } buttonUp.setEnabled (false); buttonDown.setEnabled (false); @@ -234,13 +246,30 @@ // some deadlocks on windows... //dragSupport = new IndexedDragSource(control); //dropSupport = new IndexedDropTarget(this, dragSupport); + if (closeButton) { pack(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension dialogSize = getSize(); setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-dialogSize.height)/2); buttonClose.requestFocus (); // to get shortcuts to work + } } - + + /** Simulate behavior of the Close button, minus actual dialog disposal. + * Might do the same as setImmediateReorder(true), but I am not sure. + */ + void doClose() { + if ((!immediateReorder) && (index != null) && + (permutation != null)) { + int[] realPerm = new int[permutation.length]; + for (int i = 0; i < realPerm.length; i++) { + realPerm[permutation[i]] = i; + //System.out.println (i + "-->" + permutation[i]); // NOI18N + } + index.reorder(realPerm); + } + } + // other methods ................................................................................ Index: openide/src/org/openide/nodes/IndexedNode.java =================================================================== RCS file: /cvs/openide/src/org/openide/nodes/IndexedNode.java,v retrieving revision 1.7 diff -u -t -r1.7 IndexedNode.java --- openide/src/org/openide/nodes/IndexedNode.java 29 Jan 2001 16:53:55 -0000 1.7 +++ openide/src/org/openide/nodes/IndexedNode.java 3 Oct 2001 09:04:36 -0000 @@ -58,9 +58,10 @@ * @return the component */ public java.awt.Component getCustomizer () { - IndexedCustomizer customizer = new IndexedCustomizer (); + java.awt.Container c = new javax.swing.JPanel(); + IndexedCustomizer customizer = new IndexedCustomizer (c, true); customizer.setObject(indexImpl); - return customizer; + return c; } /** Get a cookie.