This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 193872
Collapse All | Expand All

(-)a/cnd.debugger.common2/src/org/netbeans/modules/cnd/debugger/common2/debugger/actions/AttachPanel.java (-1 / +5 lines)
Lines 98-103 Link Here
98
import org.netbeans.modules.cnd.debugger.common2.debugger.debugtarget.DebugTarget;
98
import org.netbeans.modules.cnd.debugger.common2.debugger.debugtarget.DebugTarget;
99
import org.netbeans.modules.cnd.debugger.common2.debugger.spi.UserAttachAction;
99
import org.netbeans.modules.cnd.debugger.common2.debugger.spi.UserAttachAction;
100
import org.netbeans.modules.cnd.utils.ui.ModalMessageDlg;
100
import org.netbeans.modules.cnd.utils.ui.ModalMessageDlg;
101
import org.netbeans.spi.debugger.ui.PersistentController;
101
import org.openide.util.Cancellable;
102
import org.openide.util.Cancellable;
102
import org.openide.util.Lookup;
103
import org.openide.util.Lookup;
103
import org.openide.util.NbBundle;
104
import org.openide.util.NbBundle;
Lines 911-917 Link Here
911
912
912
    // This class is made public, to support attach history
913
    // This class is made public, to support attach history
913
    // see org.netbeans.modules.debugger.ui.actions.ConnectorPanel.ok() method implementation
914
    // see org.netbeans.modules.debugger.ui.actions.ConnectorPanel.ok() method implementation
914
    public class AttachController implements Controller {
915
    public class AttachController implements PersistentController {
915
916
916
        private final PropertyChangeSupport pcs =
917
        private final PropertyChangeSupport pcs =
917
                new PropertyChangeSupport(this);
918
                new PropertyChangeSupport(this);
Lines 1028-1033 Link Here
1028
        private static final String HOST_NAME_PROP = "host_name"; //NOI18N
1029
        private static final String HOST_NAME_PROP = "host_name"; //NOI18N
1029
        private static final String NO_EXISTING_PROCESS = "qwdq123svdfv"; //NOI18N
1030
        private static final String NO_EXISTING_PROCESS = "qwdq123svdfv"; //NOI18N
1030
1031
1032
        @Override
1031
        public boolean load(Properties props) {
1033
        public boolean load(Properties props) {
1032
            Vector<Vector<String>> processes = psData.processes(Pattern.compile(props.getString(COMMAND_PROP, NO_EXISTING_PROCESS)));
1034
            Vector<Vector<String>> processes = psData.processes(Pattern.compile(props.getString(COMMAND_PROP, NO_EXISTING_PROCESS)));
1033
            if (processes.isEmpty()) {
1035
            if (processes.isEmpty()) {
Lines 1053-1058 Link Here
1053
            return true;
1055
            return true;
1054
        }
1056
        }
1055
1057
1058
        @Override
1056
        public void save(Properties props) {
1059
        public void save(Properties props) {
1057
            String selectedCommand = getSelectedProcessCommand();
1060
            String selectedCommand = getSelectedProcessCommand();
1058
            if (selectedCommand != null) {
1061
            if (selectedCommand != null) {
Lines 1064-1069 Link Here
1064
            }
1067
            }
1065
        }
1068
        }
1066
1069
1070
        @Override
1067
        public String getDisplayName() {
1071
        public String getDisplayName() {
1068
            String selectedCommand = getSelectedProcessCommand();
1072
            String selectedCommand = getSelectedProcessCommand();
1069
            if (selectedCommand != null) {
1073
            if (selectedCommand != null) {
(-)a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/ConnectPanel.java (-5 / +8 lines)
Lines 46-54 Link Here
46
46
47
import com.sun.jdi.Bootstrap;
47
import com.sun.jdi.Bootstrap;
48
import com.sun.jdi.VirtualMachineManager;
48
import com.sun.jdi.VirtualMachineManager;
49
import com.sun.jdi.connect.Connector.Argument;
50
import com.sun.jdi.connect.*;
49
import com.sun.jdi.connect.*;
51
50
51
import com.sun.jdi.connect.Connector.Argument;
52
import java.awt.Cursor;
52
import java.awt.Cursor;
53
import java.awt.Dimension;
53
import java.awt.Dimension;
54
import java.awt.GridBagConstraints;
54
import java.awt.GridBagConstraints;
Lines 82-98 Link Here
82
import javax.swing.event.DocumentEvent;
82
import javax.swing.event.DocumentEvent;
83
import javax.swing.event.DocumentListener;
83
import javax.swing.event.DocumentListener;
84
import org.netbeans.api.debugger.DebuggerEngine;
84
import org.netbeans.api.debugger.DebuggerEngine;
85
85
import org.netbeans.api.debugger.DebuggerInfo;
86
import org.netbeans.api.debugger.DebuggerManager;
86
import org.netbeans.api.debugger.DebuggerManager;
87
import org.netbeans.api.debugger.DebuggerInfo;
88
import org.netbeans.api.debugger.Properties;
87
import org.netbeans.api.debugger.Properties;
88
import org.netbeans.api.debugger.jpda.AttachingDICookie;
89
import org.netbeans.api.debugger.jpda.DebuggerStartException;
89
import org.netbeans.api.debugger.jpda.DebuggerStartException;
90
import org.netbeans.api.debugger.jpda.JPDADebugger;
90
import org.netbeans.api.debugger.jpda.JPDADebugger;
91
import org.netbeans.api.debugger.jpda.AttachingDICookie;
92
import org.netbeans.api.debugger.jpda.ListeningDICookie;
91
import org.netbeans.api.debugger.jpda.ListeningDICookie;
93
import org.netbeans.api.progress.ProgressHandle;
92
import org.netbeans.api.progress.ProgressHandle;
94
import org.netbeans.api.progress.ProgressHandleFactory;
93
import org.netbeans.api.progress.ProgressHandleFactory;
95
import org.netbeans.spi.debugger.ui.Controller;
94
import org.netbeans.spi.debugger.ui.Controller;
95
import org.netbeans.spi.debugger.ui.PersistentController;
96
import org.openide.DialogDisplayer;
96
import org.openide.DialogDisplayer;
97
import org.openide.ErrorManager;
97
import org.openide.ErrorManager;
98
import org.openide.NotifyDescriptor;
98
import org.openide.NotifyDescriptor;
Lines 647-653 Link Here
647
        }
647
        }
648
    }
648
    }
649
649
650
    public class ConnectController implements Controller {
650
    public class ConnectController implements PersistentController {
651
651
652
        PropertyChangeSupport pcs = new PropertyChangeSupport(this);
652
        PropertyChangeSupport pcs = new PropertyChangeSupport(this);
653
        private boolean valid = true;
653
        private boolean valid = true;
Lines 751-756 Link Here
751
            return true;
751
            return true;
752
        }
752
        }
753
753
754
        @Override
754
        public boolean load(final Properties props) {
755
        public boolean load(final Properties props) {
755
            assert !SwingUtilities.isEventDispatchThread();
756
            assert !SwingUtilities.isEventDispatchThread();
756
            waitForConnectorsLoad();
757
            waitForConnectorsLoad();
Lines 784-789 Link Here
784
            return true;
785
            return true;
785
        }
786
        }
786
787
788
        @Override
787
        public void save(Properties props) {
789
        public void save(Properties props) {
788
            assert connectorsLoaded.get();
790
            assert connectorsLoaded.get();
789
            final Connector[] connectorPtr = new Connector[] { null };
791
            final Connector[] connectorPtr = new Connector[] { null };
Lines 832-837 Link Here
832
            props.setString ("attaching_connector", connector.name());
834
            props.setString ("attaching_connector", connector.name());
833
        }
835
        }
834
836
837
        @Override
835
        public String getDisplayName() {
838
        public String getDisplayName() {
836
            assert connectorsLoaded.get();
839
            assert connectorsLoaded.get();
837
            final Connector connector = selectedConnector;
840
            final Connector connector = selectedConnector;
(-)a/spi.debugger.ui/apichanges.xml (+19 lines)
Lines 192-197 Link Here
192
        <issue number="217953"/>
192
        <issue number="217953"/>
193
    </change>
193
    </change>
194
194
195
    <change id="PersistentController">
196
        <api name="DebuggerCoreSPI"/>
197
        <summary><code>PersistentController</code> interface added.</summary>
198
        <version major="2" minor="45"/>
199
        <date day="4" month="7" year="2014"/>
200
        <author login="mentlicher"/>
201
        <compatibility binary="compatible" source="compatible" addition="yes" semantic="compatible"/>
202
        <description>
203
            <p>
204
                <code>PersistentController</code> interface introduced
205
                to provide persistence mechanism to attach controllers.
206
                Debug action provides access to history of customized attach
207
                controllers.
208
            </p>
209
        </description>
210
        <class package="org.netbeans.spi.debugger.ui" name="PersistentController"/>
211
        <issue number="193872"/>
212
    </change>
213
195
</changes>
214
</changes>
196
215
197
  <!-- Now the surrounding HTML text and document structure: -->
216
  <!-- Now the surrounding HTML text and document structure: -->
(-)a/spi.debugger.ui/manifest.mf (-1 / +1 lines)
Lines 2-7 Link Here
2
OpenIDE-Module: org.netbeans.spi.debugger.ui/1
2
OpenIDE-Module: org.netbeans.spi.debugger.ui/1
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/debugger/ui/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/debugger/ui/Bundle.properties
4
OpenIDE-Module-Layer: org/netbeans/modules/debugger/resources/mf-layer.xml
4
OpenIDE-Module-Layer: org/netbeans/modules/debugger/resources/mf-layer.xml
5
OpenIDE-Module-Specification-Version: 2.44
5
OpenIDE-Module-Specification-Version: 2.45
6
OpenIDE-Module-Provides: org.netbeans.spi.debugger.ui
6
OpenIDE-Module-Provides: org.netbeans.spi.debugger.ui
7
OpenIDE-Module-Install: org/netbeans/modules/debugger/ui/DebuggerModule.class
7
OpenIDE-Module-Install: org/netbeans/modules/debugger/ui/DebuggerModule.class
(-)a/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/actions/ConnectorPanel.java (-22 / +8 lines)
Lines 71-76 Link Here
71
71
72
import org.netbeans.spi.debugger.ui.AttachType;
72
import org.netbeans.spi.debugger.ui.AttachType;
73
import org.netbeans.spi.debugger.ui.Controller;
73
import org.netbeans.spi.debugger.ui.Controller;
74
import org.netbeans.spi.debugger.ui.PersistentController;
74
import org.openide.awt.Mnemonics;
75
import org.openide.awt.Mnemonics;
75
76
76
import org.openide.util.Exceptions;
77
import org.openide.util.Exceptions;
Lines 268-297 Link Here
268
                }
269
                }
269
            } // for
270
            } // for
270
        }
271
        }
271
        Method saveMethod = null;
272
        Method displayNameMethod = null;
273
        try {
274
            saveMethod = controller.getClass().getMethod("save", Properties.class);
275
            displayNameMethod = controller.getClass().getMethod("getDisplayName");
276
        } catch (NoSuchMethodException ex) {
277
        } catch (SecurityException ex) {
278
        }
279
        String dispName = null;
272
        String dispName = null;
280
        if (saveMethod != null && displayNameMethod != null) {
273
        if (controller instanceof PersistentController) {
274
            PersistentController pController = (PersistentController) controller;
281
            Properties slot = props.getProperties("slot_" + freeSlot);
275
            Properties slot = props.getProperties("slot_" + freeSlot);
282
            try {
276
            dispName = pController.getDisplayName();
283
                dispName = (String) displayNameMethod.invoke(controller);
277
            if (dispName != null && dispName.trim().length() > 0) {
284
                if (dispName != null && dispName.trim().length() > 0) {
278
                slot.setString("display_name", dispName);
285
                    slot.setString("display_name", dispName);
279
                pController.save(slot.getProperties("values"));
286
                    saveMethod.invoke(controller, slot.getProperties("values"));
280
                slot.setString("attach_type", defaultAttachTypeName);
287
                    slot.setString("attach_type", defaultAttachTypeName);
288
                }
289
            } catch (IllegalAccessException ex) {
290
                Exceptions.printStackTrace(ex); // [TODO]
291
            } catch (IllegalArgumentException ex) {
292
                Exceptions.printStackTrace(ex); // [TODO]
293
            } catch (InvocationTargetException ex) {
294
                Exceptions.printStackTrace(ex); // [TODO]
295
            }
281
            }
296
        }
282
        }
297
283
(-)a/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/actions/DebugMainProjectAction.java (-17 / +11 lines)
Lines 69-74 Link Here
69
import org.netbeans.api.project.ui.OpenProjects;
69
import org.netbeans.api.project.ui.OpenProjects;
70
import org.netbeans.spi.debugger.ui.AttachType;
70
import org.netbeans.spi.debugger.ui.AttachType;
71
import org.netbeans.spi.debugger.ui.Controller;
71
import org.netbeans.spi.debugger.ui.Controller;
72
import org.netbeans.spi.debugger.ui.PersistentController;
72
import org.netbeans.spi.project.ActionProvider;
73
import org.netbeans.spi.project.ActionProvider;
73
import org.netbeans.spi.project.ui.support.MainProjectSensitiveActions;
74
import org.netbeans.spi.project.ui.support.MainProjectSensitiveActions;
74
import org.openide.awt.Actions;
75
import org.openide.awt.Actions;
Lines 266-272 Link Here
266
            } // for
267
            } // for
267
            if (att != null) {
268
            if (att != null) {
268
                final AttachType attachType = att;
269
                final AttachType attachType = att;
269
                final Controller[] controllerPtr = new Controller[] { null };
270
                final PersistentController[] controllerPtr = new PersistentController[] { null };
270
                try {
271
                try {
271
                    SwingUtilities.invokeAndWait(new Runnable() {
272
                    SwingUtilities.invokeAndWait(new Runnable() {
272
                        @Override
273
                        @Override
Lines 277-283 Link Here
277
                                Exceptions.printStackTrace(new IllegalStateException("FIXME: JComponent "+customizer+" must not implement Controller interface!"));
278
                                Exceptions.printStackTrace(new IllegalStateException("FIXME: JComponent "+customizer+" must not implement Controller interface!"));
278
                                controller = (Controller) customizer;
279
                                controller = (Controller) customizer;
279
                            }
280
                            }
280
                            controllerPtr[0] = controller;
281
                            if (controller instanceof PersistentController) {
282
                                controllerPtr[0] = (PersistentController) controller;
283
                            }
281
                        }
284
                        }
282
                    });
285
                    });
283
                } catch (InterruptedException ex) {
286
                } catch (InterruptedException ex) {
Lines 287-308 Link Here
287
                    Exceptions.printStackTrace(ex);
290
                    Exceptions.printStackTrace(ex);
288
                    return ;
291
                    return ;
289
                }
292
                }
290
                final Controller controller = controllerPtr[0];
293
                final PersistentController controller = controllerPtr[0];
291
                Method loadMethod = null;
294
                if (controller == null) {
292
                try {
295
                    return ;
293
                    loadMethod = controller.getClass().getMethod("load", Properties.class);
294
                } catch (NoSuchMethodException ex) {
295
                } catch (SecurityException ex) {
296
                }
296
                }
297
                if (loadMethod == null) { return; }
297
                boolean result = controller.load(props.getProperties("slot_" + usedSlots[index]).getProperties("values"));
298
                try {
298
                if (!result) {
299
                    Boolean result = (Boolean)loadMethod.invoke(controller, props.getProperties("slot_" + usedSlots[index]).getProperties("values"));
299
                    return; // [TODO] not loaded, cannot be used to attach
300
                    if (!result) {
301
                        return; // [TODO] not loaded, cannot be used to attach
302
                    }
303
                } catch (IllegalAccessException ex) {
304
                } catch (IllegalArgumentException ex) {
305
                } catch (InvocationTargetException ex) {
306
                }
300
                }
307
                final boolean[] passedPtr = new boolean[] { false };
301
                final boolean[] passedPtr = new boolean[] { false };
308
                try {
302
                try {
(-)a/spi.debugger.ui/src/org/netbeans/spi/debugger/ui/PersistentController.java (+73 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2014 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2014 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.spi.debugger.ui;
44
45
import org.netbeans.api.debugger.Properties;
46
47
/**
48
 * Controller, that is able to persist it's customized state.
49
 * 
50
 * @author Martin Entlicher
51
 * @since 2.45
52
 */
53
public interface PersistentController extends Controller {
54
    
55
    /**
56
     * Display name, that characterizes the current customized state of this controller.
57
     * @return The display name
58
     */
59
    String getDisplayName();
60
    
61
    /**
62
     * Load customized state from properties.
63
     * @param props The properties to load the state from.
64
     * @return <code>true</code> if the properties were successfully loaded, false otherwise.
65
     */
66
    boolean load(Properties props);
67
    
68
    /**
69
     * Save customized state into properties.
70
     * @param props The properties to save the state to.
71
     */
72
    void save(Properties props);
73
}

Return to bug 193872