+ * The default implementation returns null to indicate that no
+ * layer reading should be used
+ *
+ * @return the string name of the context on layer files to read/write acitons to
+ * @since JST-PENDING
+ */
+ protected String actionsContext () {
+ return null;
+ }
+
/** Get default actions.
* @return array of default system actions or null
if this loader
* does not have any actions.
@@ -160,6 +214,57 @@
return actions;
}
+ /** Actions manager.
+ */
+ private final DataLdrActions findManager () {
+ Object manager = getProperty (ACTION_MANAGER);
+ if (manager instanceof Class) {
+ return null;
+ }
+ DataLdrActions mgr = (DataLdrActions)manager;
+ boolean newlyCreated = false;
+ if (mgr == null) {
+ String context = actionsContext ();
+ if (context == null) {
+ // mark we have no context
+ putProperty (ACTION_MANAGER, getClass ());
+ return null;
+ }
+
+ FileObject fo = Repository.getDefault ().getDefaultFileSystem ().findResource (context);
+ if (fo == null) {
+ fo = Repository.getDefault ().getDefaultFileSystem ().getRoot ();
+ try {
+ fo = FileUtil.createFolder (fo, context);
+
+ } catch (IOException ex) {
+ ErrorManager.getDefault ().notify (ex);
+ }
+ newlyCreated = true;
+ }
+
+ mgr = new DataLdrActions (DataFolder.findFolder (fo), this);
+ if (newlyCreated) {
+ SystemAction[] arr = defaultActions ();
+ if (arr != null) {
+ mgr.setActions (arr);
+ }
+ }
+ putProperty (ACTION_MANAGER, mgr);
+ }
+ return mgr;
+ }
+
+ /** Allows the friend code (package and tests) to wait while actions
+ * are synchronized with the state of disk.
+ */
+ final void waitForActions () {
+ DataLdrActions mgr = findManager ();
+ if (mgr != null) {
+ mgr.waitFinished ();
+ }
+ }
+
/** Set actions.
*
Note that this method is public, not protected, so it is possible for anyone
* to modify the loader's popup actions externally (after finding the loader
@@ -172,7 +277,19 @@
* @see #getActions
*/
public final void setActions (SystemAction[] actions) {
- putProperty (PROP_ACTIONS, actions, true);
+ DataLdrActions mgr = findManager ();
+ if (mgr != null) {
+ mgr.setActions (actions);
+ } else {
+ putProperty (PROP_ACTIONS, actions, true);
+ }
+ }
+
+ /** Assigns this loader new array of swing actions.
+ * @param arr Listnull
if this loader does not have any
- * actions
- */
- protected SystemAction[] defaultActions () {
- return new SystemAction[] {
- SystemAction.get (org.openide.actions.NewTemplateAction.class),
- null,
- // SystemAction.get (org.openide.actions.OpenLocalExplorerAction.class),
- SystemAction.get (org.openide.actions.FileSystemAction.class),
- SystemAction.get (org.openide.actions.FindAction.class),
- null,
- SystemAction.get (org.openide.actions.CutAction.class),
- SystemAction.get (org.openide.actions.CopyAction.class),
- SystemAction.get (org.openide.actions.PasteAction.class),
- null,
- SystemAction.get (org.openide.actions.DeleteAction.class),
- SystemAction.get (org.openide.actions.RenameAction.class),
- null,
- SystemAction.get (org.openide.actions.ToolsAction.class),
- SystemAction.get (org.openide.actions.PropertiesAction.class)
- };
+ protected String actionsContext () {
+ return "Loaders/folder/any/Actions"; // NOI18N
}
/** Get the default display name of this loader.
Index: openide/loaders/src/org/openide/loaders/DataNode.java
===================================================================
RCS file: /cvs/openide/loaders/src/org/openide/loaders/DataNode.java,v
retrieving revision 1.16
diff -u -r1.16 DataNode.java
--- openide/loaders/src/org/openide/loaders/DataNode.java 6 Oct 2004 13:22:57 -0000 1.16
+++ openide/loaders/src/org/openide/loaders/DataNode.java 8 Nov 2004 08:23:52 -0000
@@ -302,6 +302,22 @@
* @see DataLoader#getActions
* @return array of actions or null
*/
+ public Action[] getActions (boolean context) {
+ if (systemActions == null) {
+ systemActions = createActions ();
+ }
+
+ if (systemActions != null) {
+ return systemActions;
+ }
+
+ return obj.getLoader ().getSwingActions ();
+ }
+
+ /** Get actions for this data object.
+ * @deprecated Use getActions(boolean)
+ * @return array of actions or null
+ */
public SystemAction[] getActions () {
if (systemActions == null) {
systemActions = createActions ();
@@ -314,6 +330,7 @@
return obj.getLoader ().getActions ();
}
+
/** Get default action. In the current implementation the
*null
is returned in case the underlying data
* object is a template. The templates should not have any default
Index: openide/test/unit/src/org/openide/loaders/DataLoaderGetActionsCompatibilityTest.java
===================================================================
RCS file: openide/test/unit/src/org/openide/loaders/DataLoaderGetActionsCompatibilityTest.java
diff -N openide/test/unit/src/org/openide/loaders/DataLoaderGetActionsCompatibilityTest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openide/test/unit/src/org/openide/loaders/DataLoaderGetActionsCompatibilityTest.java 8 Nov 2004 08:23:52 -0000
@@ -0,0 +1,260 @@
+/*
+ * Sun Public License Notice
+ *
+ * The contents of this file are subject to the Sun Public License
+ * Version 1.0 (the "License"). You may not use this file except in
+ * compliance with the License. A copy of the License is available at
+ * http://www.sun.com/
+ *
+ * The Original Code is NetBeans. The Initial Developer of the Original
+ * Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ */
+
+package org.openide.loaders;
+
+import junit.textui.TestRunner;
+
+import org.openide.filesystems.*;
+import org.openide.util.Lookup;
+import java.io.IOException;
+import java.util.*;
+import org.netbeans.junit.*;
+import java.beans.PropertyChangeListener;
+import javax.swing.Action;
+import org.openide.util.io.NbMarshalledObject;
+
+/** Check how the default behaviour of DataLoader without overriden
+ * actionsContext works.
+ *
+ * @author Jaroslav Tulach
+ */
+public class DataLoaderGetActionsCompatibilityTest extends NbTestCase {
+ /** sample data object */
+ private DataObject obj;
+ /** its node */
+ private org.openide.nodes.Node node;
+ /** monitor sfs */
+ private PCL sfs;
+
+ public DataLoaderGetActionsCompatibilityTest (String name) {
+ super(name);
+ }
+
+ public static void main(String[] args) {
+ if (args.length == 1) {
+ TestRunner.run (new DataLoaderGetActionsCompatibilityTest (args[0]));
+ } else {
+ TestRunner.run(new NbTestSuite(DataLoaderGetActionsCompatibilityTest.class));
+ }
+ }
+
+ /**
+ * Sets up the testing environment by creating testing folders
+ * on the system file system.
+ */
+ protected void setUp () throws Exception {
+ System.setProperty ("org.openide.util.Lookup", "org.openide.loaders.DataLoaderGetActionsCompatibilityTest$Lkp");
+ assertEquals ("Our lookup is installed", Lookup.getDefault ().getClass (), Lkp.class);
+
+ MyDL loader = (MyDL)MyDL.getLoader (MyDL.class);
+
+ FileSystem dfs = Repository.getDefault().getDefaultFileSystem();
+ dfs.refresh (true);
+
+ FileObject fo = FileUtil.createData (dfs.getRoot (), "a.txt");
+ obj = DataObject.find (fo);
+
+ assertEquals ("The correct loader", loader, obj.getLoader ());
+
+ node = obj.getNodeDelegate ();
+
+ sfs = new PCL ();
+ dfs.addFileChangeListener (sfs);
+ }
+
+ /**
+ * Deletes the folders created in method setUp().
+ */
+ protected void tearDown() throws Exception {
+ obj.getLoader ().setActions (new org.openide.util.actions.SystemAction[0]);
+
+ int l = node.getActions (false).length;
+ if (l != 0) {
+ fail ("Not empty actions at the end!!!");
+ }
+ Repository.getDefault ().getDefaultFileSystem ().removeFileChangeListener (sfs);
+
+ // no suspicious activity on getDefaultFileSystem
+ sfs.assertEvent (0, null);
+ }
+
+ public void testDefaultActionContextReturnsNull () {
+ assertNull (obj.getLoader ().actionsContext ());
+ }
+
+ public void testDefaultActionsUsedWhenCreatedForTheFirstTime () throws Exception {
+ SndDL loader = (SndDL)SndDL.getLoader (SndDL.class);
+
+ org.openide.util.actions.SystemAction[] arr = loader.getActions ();
+
+ assertEquals (
+ "Arrays of actions are the same",
+ java.util.Arrays.asList (loader.defaultActions ()),
+ java.util.Arrays.asList (arr)
+ );
+ }
+
+ /** Test to check that the deserialization of actions works as expected.
+ */
+ public void testNoDeserializationOfActions () throws Exception {
+ assertEquals("No actions at the start", 0, node.getActions(false).length);
+
+ PCL pcl = new PCL ();
+ obj.getLoader ().addPropertyChangeListener (pcl);
+
+ obj.getLoader ().setActions (new org.openide.util.actions.SystemAction[] {
+ org.openide.util.actions.SystemAction.get (org.openide.actions.PropertiesAction.class)
+ });
+
+ pcl.assertEvent (1, "actions");
+
+ Action [] res = node.getActions(false);
+ assertEquals("There should be exactly one action.", 1, res.length);
+
+ NbMarshalledObject m = new NbMarshalledObject (obj.getLoader ());
+
+ obj.getLoader ().setActions (new org.openide.util.actions.SystemAction[0]);
+
+ pcl.assertEvent (2, "actions");
+ assertEquals("No actions after setting empty array", 0, node.getActions(false).length);
+
+ assertEquals ("Loader deserialized", obj.getLoader (), m.get ());
+ res = node.getActions(false);
+ assertEquals("One action", 1, res.length);
+ assertEquals (
+ "and that is the property action",
+ org.openide.util.actions.SystemAction.get (org.openide.actions.PropertiesAction.class),
+ res[0]
+ );
+
+ obj.getLoader ().removePropertyChangeListener (pcl);
+ }
+
+ /** Loader that does not override the actionsContext.
+ */
+ private static class MyDL extends UniFileLoader {
+ public MyDL () {
+ super ("org.openide.loaders.DataObject");
+ getExtensions ().addExtension ("txt");
+ }
+
+ protected org.openide.loaders.MultiDataObject createMultiObject (FileObject primaryFile) throws org.openide.loaders.DataObjectExistsException, IOException {
+
+
+
+ return new MultiDataObject (primaryFile, this);
+ }
+
+ protected org.openide.util.actions.SystemAction[] defaultActions () {
+ return new org.openide.util.actions.SystemAction[0];
+ }
+
+ } // end of MyDL
+
+ //
+ // Our fake lookup
+ //
+ public static final class Lkp extends org.openide.util.lookup.AbstractLookup {
+ public Lkp () throws Exception {
+ this (new org.openide.util.lookup.InstanceContent ());
+ }
+
+ private Lkp (org.openide.util.lookup.InstanceContent ic) throws Exception {
+ super (ic);
+
+ TestUtilHid.destroyLocalFileSystem (Lkp.class.getName ());
+ ic.add (new Repository (TestUtilHid.createLocalFileSystem (Lkp.class.getName (), new String[0])));
+ ic.add (new Pool ());
+// ic.add (new EM ());
+ }
+ }
+
+
+ private static final class Pool extends DataLoaderPool {
+
+ protected java.util.Enumeration loaders () {
+ return org.openide.util.Enumerations.singleton (
+ DataLoader.getLoader(MyDL.class)
+ );
+ }
+
+ } // end of Pool
+
+ private final class PCL implements org.openide.filesystems.FileChangeListener, java.beans.PropertyChangeListener {
+ int cnt;
+ String name;
+
+ public void propertyChange (java.beans.PropertyChangeEvent ev) {
+ name = ev.getPropertyName();
+ cnt++;
+ }
+
+ public void assertEvent (int cnt, String name) {
+ obj.getLoader ().waitForActions ();
+
+ if (cnt != this.cnt) {
+ fail ("Excepted more changes then we got: expected: " + cnt + " we got: " + this.cnt + " with name: " + this.name);
+ }
+ }
+
+ public void fileAttributeChanged(org.openide.filesystems.FileAttributeEvent fe) {
+ cnt++;
+ name = "fileAttributeChanged";
+ }
+
+ public void fileChanged(org.openide.filesystems.FileEvent fe) {
+ cnt++;
+ name = "fileChanged";
+ }
+
+ public void fileDataCreated(org.openide.filesystems.FileEvent fe) {
+ cnt++;
+ name = "fileDataCreated";
+ }
+
+ public void fileDeleted(org.openide.filesystems.FileEvent fe) {
+ cnt++;
+ name = "fileDeleted";
+ }
+
+ public void fileFolderCreated(org.openide.filesystems.FileEvent fe) {
+ cnt++;
+ name = "fileFolderCreated";
+ }
+
+ public void fileRenamed(org.openide.filesystems.FileRenameEvent fe) {
+ cnt++;
+ name = "fileRenamed";
+ }
+ } // end of PCL
+
+ public static final class SndDL extends MyDL {
+ public SndDL () {
+ getExtensions ().addExtension ("bla");
+ }
+
+ protected org.openide.util.actions.SystemAction[] defaultActions () {
+ return new org.openide.util.actions.SystemAction[] {
+ org.openide.util.actions.SystemAction.get (org.openide.actions.CutAction.class),
+ null,
+ org.openide.util.actions.SystemAction.get (org.openide.actions.CopyAction.class),
+ null,
+ org.openide.util.actions.SystemAction.get (org.openide.actions.DeleteAction.class),
+
+ };
+ }
+
+ }
+
+}
Index: openide/test/unit/src/org/openide/loaders/DataLoaderGetActionsTest.java
===================================================================
RCS file: openide/test/unit/src/org/openide/loaders/DataLoaderGetActionsTest.java
diff -N openide/test/unit/src/org/openide/loaders/DataLoaderGetActionsTest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openide/test/unit/src/org/openide/loaders/DataLoaderGetActionsTest.java 8 Nov 2004 08:23:52 -0000
@@ -0,0 +1,347 @@
+/*
+ * Sun Public License Notice
+ *
+ * The contents of this file are subject to the Sun Public License
+ * Version 1.0 (the "License"). You may not use this file except in
+ * compliance with the License. A copy of the License is available at
+ * http://www.sun.com/
+ *
+ * The Original Code is NetBeans. The Initial Developer of the Original
+ * Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ */
+
+package org.openide.loaders;
+
+import junit.textui.TestRunner;
+
+import org.openide.filesystems.*;
+import org.openide.util.Lookup;
+import java.io.IOException;
+import java.util.*;
+import org.netbeans.junit.*;
+import java.beans.PropertyChangeListener;
+import javax.swing.Action;
+import org.openide.util.io.NbMarshalledObject;
+
+/** Tests the proposed behaviour of DataLoader.getActions that is going
+ * to read its values from layer.
+ *
+ * @author Jaroslav Tulach (taken from openidex/enode by David Strupl)
+ */
+public class DataLoaderGetActionsTest extends NbTestCase {
+ /** root folder FileObject */
+ private FileObject root;
+ /** sample data object */
+ private DataObject obj;
+ /** its node */
+ private org.openide.nodes.Node node;
+
+ public DataLoaderGetActionsTest (String name) {
+ super(name);
+ }
+
+ public static void main(String[] args) {
+ if (args.length == 1) {
+ TestRunner.run (new DataLoaderGetActionsTest (args[0]));
+ } else {
+ TestRunner.run(new NbTestSuite(DataLoaderGetActionsTest.class));
+ }
+ }
+
+ /**
+ * Sets up the testing environment by creating testing folders
+ * on the system file system.
+ */
+ protected void setUp () throws Exception {
+ System.setProperty ("org.openide.util.Lookup", "org.openide.loaders.DataLoaderGetActionsTest$Lkp");
+ assertEquals ("Our lookup is installed", Lookup.getDefault ().getClass (), Lkp.class);
+
+ MyDL loader = (MyDL)MyDL.getLoader (MyDL.class);
+
+ FileSystem dfs = Repository.getDefault().getDefaultFileSystem();
+ dfs.refresh (true);
+ root = FileUtil.createFolder (dfs.getRoot (), loader.actionsContext ());
+
+
+ FileObject fo = FileUtil.createData (dfs.getRoot (), "a.txt");
+ obj = DataObject.find (fo);
+
+ assertEquals ("The correct loader", loader, obj.getLoader ());
+
+ node = obj.getNodeDelegate ();
+ }
+
+ /**
+ * Deletes the folders created in method setUp().
+ */
+ protected void tearDown() throws Exception {
+ FileObject[] arr = root.getChildren ();
+ for (int i = 0; i < arr.length; i++) {
+ arr[i].delete();
+ }
+ int l = node.getActions (false).length;
+ if (l != 0) {
+ System.err.println("Not empty actions at the end!!!");
+ }
+ }
+
+ /**
+ * This test tests the presence of declarative actions from
+ * system file system without the hierarchical flag set (the ExtensibleNode
+ * instance is created with constructor ExtensibleNode("test", false).
+ * The tests performs following steps:
+ *
+ */
+ public void testCreateAndDeleteAction() throws Exception {
+ assertEquals("No actions at the start", 0, node.getActions(false).length);
+ FileObject test = root;
+
+ PCL pcl = new PCL ();
+ obj.getLoader ().addPropertyChangeListener (pcl);
+
+ FileObject a1 = test.createData("org-openide-actions-PropertiesAction.instance");
+
+ pcl.assertEvent (1, "actions");
+
+ Action [] res = node.getActions(false);
+ assertEquals("There should be exactly one action.", 1, res.length);
+ a1.delete();
+
+ pcl.assertEvent (2, "actions");
+ assertEquals("No actions after deleting", 0, node.getActions(false).length);
+
+ obj.getLoader ().removePropertyChangeListener (pcl);
+ }
+
+ /**
+ * An attempt to create a simple stress test. Just calls
+ * the testCreateAndDeleteAction
100 times.
+ */
+ public void testRepetitiveDeleting() throws Exception {
+ for (int i = 0; i < 10; i++) {
+ testCreateAndDeleteAction();
+ }
+ }
+
+ /**
+ * This test should test behaviour of the getActions method when
+ * there is some alien object specified in the configuration folder.
+ * The testing object is of type Integer (instead of javax.swing.Action).
+ */
+ public void testWrongActionObjectInConfig() throws Exception {
+ assertEquals("No actions at the start", 0, node.getActions(false).length);
+ FileObject test = root;
+ FileObject a1 = test.createData("java-lang-String.instance");
+ Action [] res = node.getActions(false);
+ assertEquals("There should be zero actions.", 0, res.length);
+ }
+
+ /**
+ * This test checks whether the JSeparator added from the configuration
+ * file is reflected in the resulting popup.
+ * The tests performs following steps:
+ *
+ */
+ public void testAddingSeparators() throws Exception {
+ org.openide.nodes.Node en1 = node;
+ assertEquals("No actions at the start", 0, en1.getActions(false).length);
+ FileObject test = root;
+ FileObject a1 = test.createData("1[org-openide-actions-PropertiesAction].instance");
+ FileObject sep = test.createData("2[javax-swing-JSeparator].instance");
+ FileObject a2 = test.createData("3[org-openide-actions-CutAction].instance");
+ javax.swing.Action[] actions = en1.getActions(false);
+ assertEquals("Actions array should contain 3 elements", 3, actions.length);
+ assertNull("separator should create null element in the array", actions[1]);
+ javax.swing.JPopupMenu jp = org.openide.util.Utilities.actionsToPopup(actions, org.openide.util.lookup.Lookups.singleton(en1));
+ assertEquals("Popup should contain 3 components", 3, jp.getComponentCount());
+ assertTrue("Separator should be second", jp.getComponent(1) instanceof javax.swing.JSeparator);
+ }
+
+ /** Test to see whether a compatibility behaviour is still kept. E.g.
+ * if one adds actions using DataLoader.setActions they really will be
+ * there.
+ */
+ public void testCompatibilityIsPropagatedToDisk () throws Exception {
+ assertEquals("No actions at the start", 0, node.getActions(false).length);
+ FileObject test = root;
+
+ PCL pcl = new PCL ();
+ obj.getLoader ().addPropertyChangeListener (pcl);
+
+ obj.getLoader ().setActions (new org.openide.util.actions.SystemAction[] {
+ org.openide.util.actions.SystemAction.get (org.openide.actions.PropertiesAction.class)
+ });
+
+ pcl.assertEvent (1, "actions");
+
+ Action [] res = node.getActions(false);
+ assertEquals("There should be exactly one action.", 1, res.length);
+ assertEquals("One file created", 1, test.getChildren ().length);
+
+ obj.getLoader ().setActions (new org.openide.util.actions.SystemAction[0]);
+
+ pcl.assertEvent (2, "actions");
+ assertEquals("No actions after deleting", 0, node.getActions(false).length);
+
+ assertEquals("file disappeared", 0, test.getChildren ().length);
+ obj.getLoader ().removePropertyChangeListener (pcl);
+ }
+
+ /** Test to check that the deserialization of actions is completely ignored.
+ */
+ public void testNoDeserializationOfActions () throws Exception {
+ assertEquals("No actions at the start", 0, node.getActions(false).length);
+ FileObject test = root;
+
+ PCL pcl = new PCL ();
+ obj.getLoader ().addPropertyChangeListener (pcl);
+
+ obj.getLoader ().setActions (new org.openide.util.actions.SystemAction[] {
+ org.openide.util.actions.SystemAction.get (org.openide.actions.PropertiesAction.class)
+ });
+
+ pcl.assertEvent (1, "actions");
+
+ Action [] res = node.getActions(false);
+ assertEquals("There should be exactly one action.", 1, res.length);
+ assertEquals("One file created", 1, test.getChildren ().length);
+
+ NbMarshalledObject m = new NbMarshalledObject (obj.getLoader ());
+
+ obj.getLoader ().setActions (new org.openide.util.actions.SystemAction[0]);
+
+ pcl.assertEvent (2, "actions");
+ assertEquals("No actions after deleting", 0, node.getActions(false).length);
+
+ assertEquals("file disappeared", 0, test.getChildren ().length);
+
+ assertEquals ("Loader deserialized", obj.getLoader (), m.get ());
+ assertEquals("Still no actions", 0, node.getActions(false).length);
+
+ obj.getLoader ().removePropertyChangeListener (pcl);
+ }
+
+ public void testDefaultActionsUsedWhenCreatedForTheFirstTime () throws Exception {
+ SndDL loader = (SndDL)SndDL.getLoader (SndDL.class);
+
+ org.openide.util.actions.SystemAction[] arr = loader.getActions ();
+
+ assertEquals (
+ "Arrays of actions are the same",
+ java.util.Arrays.asList (loader.defaultActions ()),
+ java.util.Arrays.asList (arr)
+ );
+ }
+
+ private static class MyDL extends UniFileLoader {
+ public MyDL () {
+ super ("org.openide.loaders.DataObject");
+ getExtensions ().addExtension ("txt");
+ }
+
+ /** Returns the name of the folder to read the actions from
+ */
+ protected String actionsContext () {
+ return "test";
+ }
+
+ protected org.openide.loaders.MultiDataObject createMultiObject (FileObject primaryFile) throws org.openide.loaders.DataObjectExistsException, IOException {
+
+
+
+ return new MultiDataObject (primaryFile, this);
+ }
+
+ protected org.openide.util.actions.SystemAction[] defaultActions () {
+ return new org.openide.util.actions.SystemAction[0];
+ }
+
+ } // end of MyDL
+
+ //
+ // Our fake lookup
+ //
+ public static final class Lkp extends org.openide.util.lookup.AbstractLookup {
+ public Lkp () throws Exception {
+ this (new org.openide.util.lookup.InstanceContent ());
+ }
+
+ private Lkp (org.openide.util.lookup.InstanceContent ic) throws Exception {
+ super (ic);
+
+ TestUtilHid.destroyLocalFileSystem (Lkp.class.getName ());
+ ic.add (new Repository (TestUtilHid.createLocalFileSystem (Lkp.class.getName (), new String[0])));
+ ic.add (new Pool ());
+// ic.add (new EM ());
+ }
+ }
+
+
+ private static final class Pool extends DataLoaderPool {
+
+ protected java.util.Enumeration loaders () {
+ return new org.openide.util.enum.SingletonEnumeration (
+ DataLoader.getLoader(MyDL.class)
+ );
+ }
+
+ } // end of Pool
+
+ private final class PCL
+ implements java.beans.PropertyChangeListener {
+ int cnt;
+ String name;
+
+ public void propertyChange (java.beans.PropertyChangeEvent ev) {
+ name = ev.getPropertyName();
+ cnt++;
+ }
+
+ public void assertEvent (int cnt, String name) {
+ obj.getLoader ().waitForActions ();
+
+ if (cnt > this.cnt) {
+ fail ("Excepted more changes then we got: expected: " + cnt + " we got: " + this.cnt);
+ }
+ assertEquals ("same name", name, this.name);
+ }
+ } // end of PCL
+
+ public static final class SndDL extends MyDL {
+ public SndDL () {
+ getExtensions ().addExtension ("bla");
+ }
+
+ protected org.openide.util.actions.SystemAction[] defaultActions () {
+ return new org.openide.util.actions.SystemAction[] {
+ org.openide.util.actions.SystemAction.get (org.openide.actions.CutAction.class),
+ null,
+ org.openide.util.actions.SystemAction.get (org.openide.actions.CopyAction.class),
+ null,
+ org.openide.util.actions.SystemAction.get (org.openide.actions.DeleteAction.class),
+
+ };
+ }
+
+ protected String actionsContext () {
+ return "2ndtestdir";
+ }
+
+ }
+
+}
Index: openide/src/org/openide/explorer/propertysheet/PropertySheet.java
===================================================================
RCS file: /cvs/openide/src/org/openide/explorer/propertysheet/PropertySheet.java,v
retrieving revision 1.165
diff -u -r1.165 PropertySheet.java
--- openide/src/org/openide/explorer/propertysheet/PropertySheet.java 16 Aug 2004 12:59:47 -0000 1.165
+++ openide/src/org/openide/explorer/propertysheet/PropertySheet.java 8 Nov 2004 08:23:52 -0000
@@ -1016,35 +1016,39 @@
private final class PCL implements PropertyChangeListener {
/** Receives property change events directed to PropertyChangeListeners,
* not NodeListeners */
- public void propertyChange(PropertyChangeEvent evt) {
- String nm = evt.getPropertyName();
- if (Node.PROP_COOKIE.equals(nm) ||
- //weed out frequently abused property changes
- Node.PROP_ICON.equals(nm) ||
- Node.PROP_PARENT_NODE.equals(nm) ||
- Node.PROP_OPENED_ICON.equals(nm) ||
- Node.PROP_LEAF.equals(nm)) {
- ErrorManager.getDefault().log (ErrorManager.WARNING,
- "Recived bogus property change " + nm + " from " +
- evt.getSource() + ". This should ony be fired to" +
- "NodeListeners, not general property change listeners"); //NOI18N
- } else if (isDescriptionVisible() && (
- Node.PROP_DISPLAY_NAME.equals(nm) ||
- Node.PROP_SHORT_DESCRIPTION.equals(nm))) {
- Node n = (Node) evt.getSource();
- /*
- fallbackTitle = n.getDisplayName();
- fallbackDescription = n.getShortDescription();
- if (infoPanel != null) {
- table.fireChange();
- infoPanel.getBottomComponent().repaint();
+ public void propertyChange(final PropertyChangeEvent evt) {
+ javax.swing.SwingUtilities.invokeLater (new Runnable () {
+ public void run () {
+ String nm = evt.getPropertyName();
+ if (Node.PROP_COOKIE.equals(nm) ||
+ //weed out frequently abused property changes
+ Node.PROP_ICON.equals(nm) ||
+ Node.PROP_PARENT_NODE.equals(nm) ||
+ Node.PROP_OPENED_ICON.equals(nm) ||
+ Node.PROP_LEAF.equals(nm)) {
+ ErrorManager.getDefault().log (ErrorManager.WARNING,
+ "Recived bogus property change " + nm + " from " +
+ evt.getSource() + ". This should ony be fired to" +
+ "NodeListeners, not general property change listeners"); //NOI18N
+ } else if (isDescriptionVisible() && (
+ Node.PROP_DISPLAY_NAME.equals(nm) ||
+ Node.PROP_SHORT_DESCRIPTION.equals(nm))) {
+ Node n = (Node) evt.getSource();
+ /*
+ fallbackTitle = n.getDisplayName();
+ fallbackDescription = n.getShortDescription();
+ if (infoPanel != null) {
+ table.fireChange();
+ infoPanel.getBottomComponent().repaint();
+ }
+ */
+ } else if (nm == null) {
+ setCurrentNode(currNode);
+ } else {
+ table.repaintProperty(nm);
+ }
}
- */
- } else if (nm == null) {
- setCurrentNode(currNode);
- } else {
- table.repaintProperty(nm);
- }
+ });
}
}
}
Index: openide/test/unit/src/org/openide/options/SystemOptionTest.java
===================================================================
RCS file: /cvs/openide/test/unit/src/org/openide/options/SystemOptionTest.java,v
retrieving revision 1.4
diff -u -r1.4 SystemOptionTest.java
--- openide/test/unit/src/org/openide/options/SystemOptionTest.java 8 Sep 2004 11:37:49 -0000 1.4
+++ openide/test/unit/src/org/openide/options/SystemOptionTest.java 8 Nov 2004 08:23:52 -0000
@@ -155,6 +155,24 @@
}
+ public void testTheProblemWithI18NOptions () throws Exception {
+ I18NLikeOption s = (I18NLikeOption)I18NLikeOption.findObject (I18NLikeOption.class, true);
+
+ assertFalse ("Not set by default", s.isAdvancedWizard ());
+ s.setAdvancedWizard (true);
+ assertTrue ("Changes to true", s.isAdvancedWizard ());
+ s.reset ();
+
+ assertFalse ("Is cleared", s.isAdvancedWizard ());
+
+ s.setAdvancedWizard (true);
+ assertTrue ("yes again", s.isAdvancedWizard ());
+ s.setAdvancedWizard (false);
+ assertFalse ("no again", s.isAdvancedWizard ());
+ s.reset ();
+ assertFalse ("still no", s.isAdvancedWizard ());
+ }
+
// XXX test that serialization works and matches deserialization
// (hint: use MaskingURLClassLoader from SharedClassObjectTest)
@@ -293,5 +311,29 @@
putProperty("z", new Cell(z.toString(), saveNatural));
}
}
-
+
+ public static class I18NLikeOption extends SystemOption {
+ public static final String PROP_ADVANCED_WIZARD = "advancedWizard";
+
+ /** Implements superclass abstract method. */
+ public String displayName() {
+ return "I18NLikeOption";
+ }
+
+ /** Getter for init advanced wizard property. */
+ public boolean isAdvancedWizard() {
+ // Lazy init.
+ if(getProperty(PROP_ADVANCED_WIZARD) == null)
+ return false;
+
+ return ((Boolean)getProperty(PROP_ADVANCED_WIZARD)).booleanValue();
+ }
+
+ /** Setter for init advanced wizard property. */
+ public void setAdvancedWizard(boolean generateField) {
+ // Stores in class-wide state and fires property changes if needed:
+ putProperty(PROP_ADVANCED_WIZARD, generateField ? Boolean.TRUE : Boolean.FALSE, true);
+ }
+
+ }
}
Index: projects/projectui/src/org/netbeans/modules/project/ui/Hacks.java
===================================================================
RCS file: /cvs/projects/projectui/src/org/netbeans/modules/project/ui/Hacks.java,v
retrieving revision 1.15
diff -u -r1.15 Hacks.java
--- projects/projectui/src/org/netbeans/modules/project/ui/Hacks.java 31 Aug 2004 12:28:51 -0000 1.15
+++ projects/projectui/src/org/netbeans/modules/project/ui/Hacks.java 8 Nov 2004 08:23:52 -0000
@@ -38,7 +38,7 @@
/** @author Petr Hrebejk */
static void hackFolderActions() {
-
+ /*
DataLoaderPool dataLoaderPool = (DataLoaderPool) Lookup.getDefault().lookup(DataLoaderPool.class);
DataLoader folderLoader = dataLoaderPool.firstProducerOf(DataFolder.class);
@@ -48,7 +48,7 @@
actions.set(index , SystemAction.get(Actions.SystemNewFile.class));
folderLoader.setActions((SystemAction[])actions.toArray(new SystemAction[actions.size()]));
}
-
+*/
}
private static Object windowSystemImpl = null;
Index: projects/projectui/src/org/netbeans/modules/project/ui/resources/layer.xml
===================================================================
RCS file: /cvs/projects/projectui/src/org/netbeans/modules/project/ui/resources/layer.xml,v
retrieving revision 1.41
diff -u -r1.41 layer.xml
--- projects/projectui/src/org/netbeans/modules/project/ui/resources/layer.xml 20 Oct 2004 13:43:36 -0000 1.41
+++ projects/projectui/src/org/netbeans/modules/project/ui/resources/layer.xml 8 Nov 2004 08:23:52 -0000
@@ -593,5 +593,19 @@