[hg] main-silver: #223759: Assure consistent connector and it's ...

  • From:
  • To:
  • Subject: [hg] main-silver: #223759: Assure consistent connector and it's ...
  • Date: Mon, 17 Dec 2012 10:17:49 -0800

changeset 80e6ba46801d in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/80e6ba46801d
description:
        #223759: Assure consistent connector and it's arguments fields.

diffstat:

 debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/ConnectPanel.java 
            |  70 +++++++--
 
spi.debugger.ui/src/org/netbeans/modules/debugger/ui/actions/DebugMainProjectAction.java
 |  20 ++-
 2 files changed, 70 insertions(+), 20 deletions(-)

diffs (191 lines):

diff --git 
a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/ConnectPanel.java
 
b/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/ConnectPanel.java
--- 
a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/ConnectPanel.java
+++ 
b/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/ConnectPanel.java
@@ -120,6 +120,7 @@
     private final List<Connector>   connectors;
     /** Combo with list of all AttachingConnector names.*/
     private JComboBox               cbConnectors;
+    private Connector               selectedConnector;
     /** List of JTextFields containing all parameters of curentConnector. */
     private JTextField[]            tfParams;
     private ConnectController       controller;
@@ -241,6 +242,7 @@
             cbConnectors.addActionListener (this);
         }
         cbConnectors.setSelectedIndex (defaultIndex);
+        selectedConnector = connectors.get(defaultIndex);
         setCursor(standardCursor);
     }
 
@@ -252,6 +254,7 @@
         removeAll();
         
         Connector connector = connectors.get (index);
+        selectedConnector = connector;
 
         GridBagConstraints c;
         GridBagLayout layout = new GridBagLayout ();
@@ -377,7 +380,8 @@
      */
     @Override
     public void actionPerformed (ActionEvent e) {
-        refresh (((JComboBox) e.getSource ()).getSelectedIndex (), 
Properties.getDefault ().getProperties ("debugger"));
+        int selectedIndex = ((JComboBox) e.getSource ()).getSelectedIndex ();
+        refresh (selectedIndex, Properties.getDefault ().getProperties 
("debugger"));
         Window w = SwingUtilities.getWindowAncestor(this);
         if (w != null) {
             w.pack ();  // ugly hack...
@@ -494,6 +498,7 @@
         JTextField[]        tfParams, 
         Connector           connector
     ) {
+        assert SwingUtilities.isEventDispatchThread();
         // 1) get default set of args
         Map<String, Argument> args = connector.defaultArguments ();
 
@@ -590,10 +595,9 @@
 
     private void checkValid() {
         assert connectorsLoaded.get();
-        int index = cbConnectors.getSelectedIndex ();
-        final Connector connector = connectors.get (index);
+        assert SwingUtilities.isEventDispatchThread() : "Called outside of 
AWT.";
         int i, k = tfParams.length;
-        Map args = connector.defaultArguments ();
+        Map args = selectedConnector.defaultArguments ();
         for (i = 0; i < k; i++) {
             JTextField tf = tfParams [i];
             String paramName = tf.getName ();
@@ -655,8 +659,8 @@
         @Override
         public boolean ok () {
             assert connectorsLoaded.get();
-            int index = cbConnectors.getSelectedIndex ();
-            final Connector connector = connectors.get (index);
+            assert SwingUtilities.isEventDispatchThread() : "Called outside 
of AWT.";
+            final Connector connector = selectedConnector;
             final Map<String, Argument> args = getEditedArgs (tfParams, 
connector);
             if (args == null) {
                 return true;
@@ -746,32 +750,65 @@
             return true;
         }
 
-        public boolean load(Properties props) {
+        public boolean load(final Properties props) {
             assert !SwingUtilities.isEventDispatchThread();
             waitForConnectorsLoad();
             String connectorName = props.getString ("attaching_connector", 
"");
             int index, k = connectors.size ();
-            boolean found = false;
+            int indexToSelect = -1;
             for (index = 0; index < k; index++) {
                 Connector connector = connectors.get (index);
                 if (connector.name ().equals (connectorName)) {
-                    cbConnectors.setSelectedIndex(index);
-                    found = true;
+                    indexToSelect = index;
                     break;
                 }
             }
-            if (!found) {
+            if (indexToSelect < 0) {
                 return false;
             }
-            refresh(index, props);
+            final int si = indexToSelect;
+            try {
+                SwingUtilities.invokeAndWait(new Runnable() {
+                    @Override
+                    public void run() {
+                        cbConnectors.setSelectedIndex(si);
+                        refresh(si, props);
+                    }
+                });
+            } catch (InterruptedException ex) {
+                Exceptions.printStackTrace(ex);
+            } catch (InvocationTargetException ex) {
+                Exceptions.printStackTrace(ex);
+            }
             return true;
         }
 
         public void save(Properties props) {
             assert connectorsLoaded.get();
-            int index = cbConnectors.getSelectedIndex ();
-            final Connector connector = connectors.get (index);
-            final Map<String, Argument> args = getEditedArgs (tfParams, 
connector);
+            final Connector[] connectorPtr = new Connector[] { null };
+            final Map[] argsPtr = new Map[] { null };
+            if (SwingUtilities.isEventDispatchThread()) {
+                connectorPtr[0] = selectedConnector;
+                argsPtr[0] = getEditedArgs (tfParams, selectedConnector);
+            } else {
+                try {
+                    SwingUtilities.invokeAndWait(new Runnable() {
+                        @Override
+                        public void run() {
+                            connectorPtr[0] = selectedConnector;
+                            argsPtr[0] = getEditedArgs (tfParams, 
selectedConnector);
+                        }
+                    });
+                } catch (InterruptedException ex) {
+                    Exceptions.printStackTrace(ex);
+                    return ;
+                } catch (InvocationTargetException ex) {
+                    Exceptions.printStackTrace(ex);
+                    return ;
+                }
+            }
+            final Connector connector = connectorPtr[0];
+            final Map<String, Argument> args = argsPtr[0];
             if (args == null) {
                 return;  // nothing stored
             }
@@ -796,8 +833,7 @@
 
         public String getDisplayName() {
             assert connectorsLoaded.get();
-            int index = cbConnectors.getSelectedIndex ();
-            final Connector connector = connectors.get (index);
+            final Connector connector = selectedConnector;
             final Map<String, Argument> args = getEditedArgs (tfParams, 
connector);
             if (args == null) {
                 return "";  // NOI18N
diff --git 
a/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/actions/DebugMainProjectAction.java
 
b/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/actions/DebugMainProjectAction.java
--- 
a/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/actions/DebugMainProjectAction.java
+++ 
b/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/actions/DebugMainProjectAction.java
@@ -287,7 +287,7 @@
                     Exceptions.printStackTrace(ex);
                     return ;
                 }
-                Controller controller = controllerPtr[0];
+                final Controller controller = controllerPtr[0];
                 Method loadMethod = null;
                 try {
                     loadMethod = controller.getClass().getMethod("load", 
Properties.class);
@@ -304,8 +304,22 @@
                 } catch (IllegalArgumentException ex) {
                 } catch (InvocationTargetException ex) {
                 }
-                boolean passed = controller.ok();
-                if (passed) {
+                final boolean[] passedPtr = new boolean[] { false };
+                try {
+                    SwingUtilities.invokeAndWait(new Runnable() {
+                        @Override
+                        public void run() {
+                            passedPtr[0] = controller.ok();
+                        }
+                    });
+                } catch (InterruptedException ex) {
+                    Exceptions.printStackTrace(ex);
+                    return ;
+                } catch (InvocationTargetException ex) {
+                    Exceptions.printStackTrace(ex);
+                    return ;
+                }
+                if (passedPtr[0]) {
                     makeFirst(index);
                     GestureSubmitter.logAttach(attachTypeName);
                 }

[hg] main-silver: #223759: Assure consistent connector and it's ...

mentlicher 12/17/2012

Project Features

About this Project

Debugger was started in November 2009, is owned by tpavek, and has 29 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close