diff -r 03fd5905bd9c spi.debugger.ui/apichanges.xml --- a/spi.debugger.ui/apichanges.xml Wed Sep 17 10:57:34 2008 +0200 +++ b/spi.debugger.ui/apichanges.xml Wed Sep 17 11:57:53 2008 +0200 @@ -111,6 +111,26 @@ + + + AttachType.getController() and + BreakpointType.getController() methods added. + + + + + +

+ AttachType.getController() and BreakpointType.getController() + methods added, because of the clash of Controller.isValid() and + javax.swing.JComponent.isValid() methods. + This cause problems when using false validity in some cases, + therefore a separate implementation of Controller interface is necessary. +

+
+ +
+ diff -r 03fd5905bd9c spi.debugger.ui/manifest.mf --- a/spi.debugger.ui/manifest.mf Wed Sep 17 10:57:34 2008 +0200 +++ b/spi.debugger.ui/manifest.mf Wed Sep 17 11:57:53 2008 +0200 @@ -2,6 +2,6 @@ OpenIDE-Module: org.netbeans.spi.debugger.ui/1 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/debugger/ui/Bundle.properties OpenIDE-Module-Layer: org/netbeans/modules/debugger/resources/mf-layer.xml -OpenIDE-Module-Specification-Version: 2.13 +OpenIDE-Module-Specification-Version: 2.14 OpenIDE-Module-Provides: org.netbeans.spi.debugger.ui OpenIDE-Module-Install: org/netbeans/modules/debugger/ui/DebuggerModule.class diff -r 03fd5905bd9c spi.debugger.ui/src/org/netbeans/modules/debugger/ui/actions/AddBreakpointPanel.java --- a/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/actions/AddBreakpointPanel.java Wed Sep 17 10:57:34 2008 +0200 +++ b/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/actions/AddBreakpointPanel.java Wed Sep 17 11:57:53 2008 +0200 @@ -84,7 +84,6 @@ private ArrayList types = new ArrayList (); /** Currently selected type. */ private BreakpointType type; - private JComponent customizer; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; @@ -135,7 +134,7 @@ } public Controller getController () { - return (Controller) customizer; + return type.getController(); } @@ -270,7 +269,7 @@ DebuggerManager d = DebuggerManager.getDebuggerManager (); BreakpointType old = type; type = t; - customizer = type.getCustomizer (); + JComponent customizer = type.getCustomizer (); if (customizer == null) return; //Set HelpCtx. This method must be called _before_ the customizer diff -r 03fd5905bd9c spi.debugger.ui/src/org/netbeans/modules/debugger/ui/actions/ConnectorPanel.java --- a/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/actions/ConnectorPanel.java Wed Sep 17 10:57:34 2008 +0200 +++ b/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/actions/ConnectorPanel.java Wed Sep 17 11:57:53 2008 +0200 @@ -83,7 +83,7 @@ /** Contains list of installed AttachTypes.*/ private List attachTypes; /** Currentlydisplayed panel.*/ - private Controller currentPanel; + private Controller controller; /** Current attach type, which is stored into settings for the next invocation. */ private AttachType currentAttachType; @@ -164,7 +164,7 @@ c.gridwidth = 0; AttachType attachType = (AttachType) attachTypes.get (index); JComponent customizer = attachType.getCustomizer (); - currentPanel = (Controller) customizer; + controller = attachType.getController(); firePropertyChange(PROP_TYPE, null, customizer); this.currentAttachType = attachType; add (customizer, c); @@ -187,17 +187,19 @@ } Controller getController() { - return currentPanel; + return controller; } boolean cancel () { - return currentPanel.cancel (); + if (controller == null) return true; + return controller.cancel (); } boolean ok () { String defaultAttachTypeName = currentAttachType.getClass().getName(); Properties.getDefault().getProperties("debugger").setString("last_attach_type", defaultAttachTypeName); - boolean ok = currentPanel.ok (); + if (controller == null) return true; + boolean ok = controller.ok (); if (ok) { GestureSubmitter.logAttach(defaultAttachTypeName); } diff -r 03fd5905bd9c spi.debugger.ui/src/org/netbeans/spi/debugger/ui/AttachType.java --- a/spi.debugger.ui/src/org/netbeans/spi/debugger/ui/AttachType.java Wed Sep 17 10:57:34 2008 +0200 +++ b/spi.debugger.ui/src/org/netbeans/spi/debugger/ui/AttachType.java Wed Sep 17 11:57:53 2008 +0200 @@ -61,9 +61,37 @@ /** * Returns visual customizer for this Attach Type. Customizer can - * optionally implement {@link Controller} intarface. + * optionally implement {@link Controller} intarface. In that case please + * notice the clash of {@link Controller#isValid()} method with + * {@link javax.swing.JComponent#isValid()} and consider extending + * {@link #getController()} method in case you need to provide + * false validity in some cases. * * @return visual customizer for this Attach Type */ public abstract JComponent getCustomizer (); + + /** + * Return the implementation of {@link Controller} interface.
+ * In cases when it's not desired to implement {@link Controller} interface + * by the JComponent returned from {@link #getCustomizer()} method, because + * of the clash of {@link Controller#isValid()} method with + * {@link javax.swing.JComponent#isValid()}, an explicit implementation + * can be returned by overriding this method. + * The default implementation returns the result of {@link #getCustomizer()} + * if that implements the {@link Controller} interface, or null + * otherwise. + * + * @return Controller implementation or null. + * @since 2.14 + */ + public Controller getController() { + JComponent c = getCustomizer(); + if (c instanceof Controller) { + return ((Controller) c); + } else { + return null; + } + } + } \ No newline at end of file diff -r 03fd5905bd9c spi.debugger.ui/src/org/netbeans/spi/debugger/ui/BreakpointType.java --- a/spi.debugger.ui/src/org/netbeans/spi/debugger/ui/BreakpointType.java Wed Sep 17 10:57:34 2008 +0200 +++ b/spi.debugger.ui/src/org/netbeans/spi/debugger/ui/BreakpointType.java Wed Sep 17 11:57:53 2008 +0200 @@ -68,11 +68,38 @@ /** * Returns visual customizer for this breakpoint type. Customizer can - * optionally implement {@link Controller} intarface. + * optionally implement {@link Controller} intarface. In that case please + * notice the clash of {@link Controller#isValid()} method with + * {@link javax.swing.JComponent#isValid()} and consider extending + * {@link #getController()} method in case you need to provide + * false validity in some cases. * * @return visual customizer for this breakpoint type */ public abstract JComponent getCustomizer (); + + /** + * Return the implementation of {@link Controller} interface.
+ * In cases when it's not desired to implement {@link Controller} interface + * by the JComponent returned from {@link #getCustomizer()} method, because + * of the clash of {@link Controller#isValid()} method with + * {@link javax.swing.JComponent#isValid()}, an explicit implementation + * can be returned by overriding this method. + * The default implementation returns the result of {@link #getCustomizer()} + * if that implements the {@link Controller} interface, or null + * otherwise. + * + * @return Controller implementation or null. + * @since 2.14 + */ + public Controller getController() { + JComponent c = getCustomizer(); + if (c instanceof Controller) { + return ((Controller) c); + } else { + return null; + } + } /** * Should return true of this breakpoint type should be default one in diff -r 03fd5905bd9c spi.debugger.ui/src/org/netbeans/spi/debugger/ui/Controller.java --- a/spi.debugger.ui/src/org/netbeans/spi/debugger/ui/Controller.java Wed Sep 17 10:57:34 2008 +0200 +++ b/spi.debugger.ui/src/org/netbeans/spi/debugger/ui/Controller.java Wed Sep 17 11:57:53 2008 +0200 @@ -75,6 +75,13 @@ /** * Return true whether value of this customizer * is valid (and OK button can be enabled). + *

+ * Please note that if this interface is implemented by a class that extends + * {@link javax.swing.JComponent}, this method clashes with + * {@link javax.swing.JComponent#isValid()} method. Thus in case you need + * to provide false validity in some cases, please implement + * this by a different class and override {@link AttachType#getController()}, + * resp. {@link BreakpointType#getController()}. * * @return true whether value of this customizer * is valid