# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: /home/work/trunk/nb_all/openide/awt
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: test/unit/src/org/openide/awt/ActionsTest.java
*** /home/work/trunk/nb_all/openide/awt/test/unit/src/org/openide/awt/ActionsTest.java Base (1.3)
--- /home/work/trunk/nb_all/openide/awt/test/unit/src/org/openide/awt/ActionsTest.java Locally Modified (Based On 1.3)
***************
*** 28,33 ****
--- 28,34 ----
import java.util.Map;
import java.util.Observable;
import javax.swing.AbstractAction;
+ import javax.swing.AbstractButton;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.JButton;
***************
*** 90,96 ****
}
protected void setUp() {
! MockServices.setServices(new Class[] {TestKeymap.class});
assertNotNull("Keymap has to be in lookup", Lookup.getDefault().lookup(Keymap.class));
}
--- 91,97 ----
}
protected void setUp() {
! MockServices.setServices(new Class[] {TestKeymap.class, TestConnector.class});
assertNotNull("Keymap has to be in lookup", Lookup.getDefault().lookup(Keymap.class));
}
***************
*** 331,336 ****
--- 332,357 ----
f.setVisible(false);
}
+ /**
+ * Tests whether the ButtonActionConnector is being called. The testing
+ * implementation is set to "active" only for this test - so the other
+ * tests should retain the behaviour like running without the
+ * ButtonActionConnector.
+ */
+ public void testButtonActionConnector() throws Exception {
+ TestConnector tc = Lookup.getDefault().lookup(TestConnector.class);
+ tc.setActive(true);
+ Action action = new ActionsTest.TestAction();
+ JButton button = new JButton();
+ Actions.connect(button, action);
+ assertEquals(1, tc.getConnectCalled());
+ JMenuItem jmi = new JMenuItem();
+ Actions.connect(jmi, action, false);
+ assertEquals(3, tc.getConnectCalled());
+ tc.setActive(false);
+ }
+
+
protected boolean runInEQ() {
return true;
}
***************
*** 482,488 ****
--- 503,542 ----
}
+ public static final class TestConnector implements Actions.ButtonActionConnector {
+
+ private int called = 0;
+ private boolean active = false;
+
+ public TestConnector() {}
+
+ public boolean connect(AbstractButton button, Action action) {
+ if (!active) {
+ return false;
}
+ called +=1;
+ return true;
+ }
+
+ public boolean connect(JMenuItem item, Action action, boolean popup) {
+ if (!active) {
+ return false;
+ }
+ called += 2;
+ return true;
+ }
+
+ public int getConnectCalled() {
+ return called;
+ }
+ public void setActive(boolean a) {
+ called = 0;
+ active = a;
+ }
+ }
+
+ }
Index: src/org/openide/awt/Actions.java
*** /home/work/trunk/nb_all/openide/awt/src/org/openide/awt/Actions.java Base (1.14)
--- /home/work/trunk/nb_all/openide/awt/src/org/openide/awt/Actions.java Locally Modified (Based On 1.14)
***************
*** 149,154 ****
--- 149,158 ----
* @since 3.29
*/
public static void connect(JMenuItem item, Action action, boolean popup) {
+ ButtonActionConnector bac = Lookup.getDefault().lookup(ButtonActionConnector.class);
+ if ((bac != null) && (bac.connect(item, action, popup))) {
+ return;
+ }
Bridge b = new MenuBridge(item, action, popup);
if (item instanceof Actions.MenuItem) {
***************
*** 251,256 ****
--- 255,264 ----
* @since 3.29
*/
public static void connect(AbstractButton button, Action action) {
+ ButtonActionConnector bac = Lookup.getDefault().lookup(ButtonActionConnector.class);
+ if ((bac != null) && (bac.connect(button, action))) {
+ return;
+ }
Bridge b = new ButtonBridge(button, action);
b.updateState(null);
}
***************
*** 1301,1306 ****
--- 1309,1338 ----
}
+ /**
+ * SPI for being able to supply alternative implementation of
+ * connection between actions and the presenters. The implementations
+ * of this interface are being looked up in the default lookup.
+ * If there is no implemenation in the lookup the default implementation
+ * is used.
+ * @see org.openide.util.Lookup#getDefault();
+ */
+ public static interface ButtonActionConnector {
+ /**
+ * Connects the action to the supplied button.
+ * @returns true if the connection was successfull and no
+ * further actions are needed. If false is returned the
+ * default connect implementation is called
+ */
+ public boolean connect(AbstractButton button, Action action);
+ /**
+ * Connects the action to the supplied JMenuItem.
+ * @returns true if the connection was successfull and no
+ * further actions are needed. If false is returned the
+ * default connect implementation is called
+ */
+ public boolean connect(JMenuItem item, Action action, boolean popup);
+ }
private static class DisabledButtonFilter extends RGBImageFilter {
DisabledButtonFilter() {
Index: nbproject/project.properties
*** /home/work/trunk/nb_all/openide/awt/nbproject/project.properties Base (1.8)
--- /home/work/trunk/nb_all/openide/awt/nbproject/project.properties Locally Modified (Based On 1.8)
***************
*** 16,21 ****
--- 16,23 ----
# Microsystems, Inc. All Rights Reserved.
is.autoload=true
+ javac.compilerargs=-Xlint:unchecked
+ javac.source=1.5
javadoc.main.page=org/openide/awt/doc-files/api.html
javadoc.arch=${basedir}/arch.xml
#javadoc.docfiles=${basedir}/api/doc
***************
*** 22,25 ****
#javadoc.apichanges=${basedir}/api/apichanges.xml
javadoc.apichanges=${basedir}/apichanges.xml
! spec.version.base=6.8.0
--- 24,27 ----
#javadoc.apichanges=${basedir}/api/apichanges.xml
javadoc.apichanges=${basedir}/apichanges.xml
! spec.version.base=6.9
Index: apichanges.xml
*** /home/work/trunk/nb_all/openide/awt/apichanges.xml Base (1.8)
--- /home/work/trunk/nb_all/openide/awt/apichanges.xml Locally Modified (Based On 1.8)
***************
*** 23,28 ****
--- 23,45 ----
AWT API
+
+
+ Actions.ButtonActionConnector interface added
+
+
+
+
+
+ The addition enables to plug in additional logic for action enabling and disabling
+ based on for example authorization information. The added SPI interface is being
+ looked up in the default lookup. If there is no implementation the original behaviour
+ is preserverd.
+
+
+
+
+