diff -r 428419c1ab32 -r af0aefefe222 java.hints.analyzer/src/org/netbeans/modules/java/hints/analyzer/ui/AnalyzerAction.java
--- a/java.hints.analyzer/src/org/netbeans/modules/java/hints/analyzer/ui/AnalyzerAction.java Tue Jun 17 13:36:09 2008 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common
- * Development and Distribution License("CDDL") (collectively, the
- * "License"). You may not use this file except in compliance with the
- * License. You can obtain a copy of the License at
- * http://www.netbeans.org/cddl-gplv2.html
- * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
- * specific language governing permissions and limitations under the
- * License. When distributing the software, include this License Header
- * Notice in each file and include the License file at
- * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the GPL Version 2 section of the License file that
- * accompanied this code. If applicable, add the following below the
- * License Header, with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * If you wish your version of this file to be governed by only the CDDL
- * or only the GPL Version 2, indicate your decision by adding
- * "[Contributor] elects to include this software in this distribution
- * under the [CDDL or GPL Version 2] license." If you do not indicate a
- * single choice of license, a recipient has the option to distribute
- * your version of this file under either the CDDL, the GPL Version 2 or
- * to extend the choice of license to its licensees as provided above.
- * However, if you add GPL Version 2 code and therefore, elected the GPL
- * Version 2 license, then the option applies only if the new code is
- * made subject to such option by the copyright holder.
- *
- * Contributor(s):
- *
- * Portions Copyrighted 2008 Sun Microsystems, Inc.
- */
-package org.netbeans.modules.java.hints.analyzer.ui;
-
-import java.awt.event.ActionEvent;
-import javax.swing.AbstractAction;
-import org.openide.util.NbBundle;
-import org.openide.windows.TopComponent;
-
-/**
- * Action which shows Analyzer component.
- */
-public class AnalyzerAction extends AbstractAction {
- public AnalyzerAction() {
- super(NbBundle.getMessage(AnalyzerAction.class, "CTL_AnalyzerAction"));
-// putValue(SMALL_ICON, new ImageIcon(Utilities.loadImage(AnalyzerTopComponent.ICON_PATH, true)));
- }
-
- public void actionPerformed(ActionEvent evt) {
- TopComponent win = AnalyzerTopComponent.findInstance();
- win.open();
- win.requestActive();
- }
-}
diff -r 428419c1ab32 -r af0aefefe222 java.hints.analyzer/src/org/netbeans/modules/java/hints/analyzer/ui/Bundle.properties
--- a/java.hints.analyzer/src/org/netbeans/modules/java/hints/analyzer/ui/Bundle.properties Tue Jun 17 13:36:09 2008 -0700
+++ b/java.hints.analyzer/src/org/netbeans/modules/java/hints/analyzer/ui/Bundle.properties Tue Jul 08 17:28:31 2008 +0200
@@ -38,6 +38,8 @@
# made subject to such option by the copyright holder.
CTL_AnalyzerAction=&Analyzer
+Actions/Window/org-netbeans-modules-java-hints-analyzer-ui-AnalyzerAction.instance=&Analyzer
+
CTL_AnalyzerTopComponent=Analyzer Window
CTL_TaskListAction=Task List
CTL_TaskListTopComponent=Task List
diff -r 428419c1ab32 -r af0aefefe222 o.n.core/src/org/netbeans/core/actions/Bundle.properties
--- a/o.n.core/src/org/netbeans/core/actions/Bundle.properties Tue Jun 17 13:36:09 2008 -0700
+++ b/o.n.core/src/org/netbeans/core/actions/Bundle.properties Tue Jul 08 17:28:31 2008 +0200
@@ -82,4 +82,5 @@ JumpPrevAction=&Previous Error
#LogAction
MSG_LogTab_name=IDE &Log File
+Actions/View/org-netbeans-core-actions-LogAction.instance=IDE &Log File
MSG_ShortLogTab_name=IDE Log File
diff -r 428419c1ab32 -r af0aefefe222 openide.awt/nbproject/project.properties
--- a/openide.awt/nbproject/project.properties Tue Jun 17 13:36:09 2008 -0700
+++ b/openide.awt/nbproject/project.properties Tue Jul 08 17:28:31 2008 +0200
@@ -46,4 +46,4 @@ javadoc.arch=${basedir}/arch.xml
#javadoc.apichanges=${basedir}/api/apichanges.xml
javadoc.apichanges=${basedir}/apichanges.xml
-spec.version.base=7.2.0
+spec.version.base=7.3.0
diff -r 428419c1ab32 -r af0aefefe222 openide.awt/nbproject/project.xml
--- a/openide.awt/nbproject/project.xml Tue Jun 17 13:36:09 2008 -0700
+++ b/openide.awt/nbproject/project.xml Tue Jul 08 17:28:31 2008 +0200
@@ -55,6 +55,15 @@ made subject to such option by the copyr
+
+
+ unit
+
+ org.openide.filesystems
+
+
+
+
org.openide.awt
diff -r 428419c1ab32 -r af0aefefe222 openide.awt/src/org/openide/awt/Actions.java
--- a/openide.awt/src/org/openide/awt/Actions.java Tue Jun 17 13:36:09 2008 -0700
+++ b/openide.awt/src/org/openide/awt/Actions.java Tue Jul 08 17:28:31 2008 +0200
@@ -66,6 +66,7 @@ import org.openide.util.Utilities;
import org.openide.util.Utilities;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
@@ -379,7 +380,49 @@ public class Actions extends Object {
return result;
}
+
+ //
+ // Factories
+ //
+
+ /** Creates new action which is always enabled.
+ * This method can also be used from
+ * XML Layer
+ * directly by following XML definition:
+ *
+ * <file name="your-pkg-action-id.instance">
+ * <attr name="instanceCreate" methodvalue="org.openide.awt.Actions.alwaysEnabled"/>
+ * <attr name="delegate" methodvalue="your.pkg.YourAction.factoryMethod"/>
+ * <attr name="SystemFileSystem.icon" stringvalue="your/pkg/YourComponent.png"/>
+ * <attr name="SystemFileSystem.localizingBundle" stringvalue="your.pkg.Bundle"/>
+ * <attr name="noIconInMenu" boolvalue="false"/>
+ * </file>
+ *
+ *
+ *
+ * @param delegate the task to perform when action is invoked
+ * @param displayName the name of the action
+ * @param iconBase the location to the actions icon
+ * @param noIconInMenu true if this icon shall not have an item in menu
+ * @since 7.3
+ */
+ public static Action alwaysEnabled(
+ ActionListener delegate, String displayName, String iconBase, boolean noIconInMenu
+ ) {
+ HashMap map = new HashMap();
+ map.put("delegate", delegate); // NOI18N
+ map.put("displayName", displayName); // NOI18N
+ map.put("iconBase", iconBase); // NOI18N
+ map.put("noIconInMenu", noIconInMenu); // NOI18N
+ return alwaysEnabled(map);
+ }
+ // for use from layers
+ static Action alwaysEnabled(Map map) {
+ return new AlwaysEnabledAction(map);
+ }
+
+
/** Extracts help from action.
*/
private static HelpCtx findHelp(Action a) {
diff -r 428419c1ab32 -r af0aefefe222 openide.awt/src/org/openide/awt/AlwaysEnabledAction.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/openide.awt/src/org/openide/awt/AlwaysEnabledAction.java Tue Jul 08 17:28:31 2008 +0200
@@ -0,0 +1,100 @@
+package org.openide.awt;
+
+import java.awt.EventQueue;
+import java.awt.Image;
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.net.URL;
+import java.util.Map;
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.Icon;
+import javax.swing.KeyStroke;
+import javax.swing.text.Keymap;
+import org.openide.util.ImageUtilities;
+import org.openide.util.Lookup;
+
+/** Lazily initialized always enabled action
+ *
+ * @author Jaroslav Tulach
+ */
+final class AlwaysEnabledAction extends AbstractAction {
+
+ private Map map;
+
+ public AlwaysEnabledAction(Map m) {
+ super();
+ this.map = m;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ assert EventQueue.isDispatchThread();
+ return true;
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ assert EventQueue.isDispatchThread();
+ Object listener = map.get("delegate");
+ if (!(listener instanceof ActionListener)) {
+ throw new NullPointerException();
+ }
+ ((ActionListener) listener).actionPerformed(e);
+ }
+
+ @Override
+ public Object getValue(String name) {
+ return extractCommonAttribute(map, this, name);
+ }
+
+ static final Object extractCommonAttribute(Map fo, Action action, String name) {
+ if (Action.NAME.equals(name)) {
+ String actionName = (String) fo.get("displayName"); // NOI18N
+ // NOI18N
+ //return Actions.cutAmpersand(actionName);
+ return actionName;
+ }
+ if (Action.MNEMONIC_KEY.equals(name)) {
+ String actionName = (String) fo.get("displayName"); // NOI18N
+ // NOI18N
+ int position = Mnemonics.findMnemonicAmpersand(actionName);
+
+ return position == -1 ? null : Character.valueOf(actionName.charAt(position + 1));
+ }
+ if (Action.SMALL_ICON.equals(name)) {
+ Object icon = fo == null ? null : fo.get("iconBase"); // NOI18N
+ if (icon instanceof Icon) {
+ return (Icon) icon;
+ }
+ if (icon instanceof Image) {
+ return ImageUtilities.image2Icon((Image)icon);
+ }
+ if (icon instanceof String) {
+ return ImageUtilities.loadImage((String)icon);
+ }
+ if (icon instanceof URL) {
+ return Toolkit.getDefaultToolkit().getImage((URL) icon);
+ }
+ Object image = fo.get("image"); // NOI18N
+ if (image instanceof Image) {
+ return ImageUtilities.image2Icon((Image)image);
+ }
+ }
+ if ("iconBase".equals(name)) { // NOI18N
+ return fo == null ? null : fo.get("iconBase"); // NOI18N
+ }
+ if ("noIconInMenu".equals(name)) { // NOI18N
+ return fo == null ? null : fo.get("noIconInMenu"); // NOI18N
+ }
+ if (Action.ACCELERATOR_KEY.equals(name)) {
+ Keymap map = Lookup.getDefault().lookup(Keymap.class);
+ if (map != null) {
+ KeyStroke[] arr = map.getKeyStrokesForAction(action);
+ return arr.length > 0 ? arr[0] : null;
+ }
+ }
+
+ return null;
+ }
+}
diff -r 428419c1ab32 -r af0aefefe222 openide.awt/test/unit/src/META-INF/MANIFEST.MF
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/openide.awt/test/unit/src/META-INF/MANIFEST.MF Tue Jul 08 17:28:31 2008 +0200
@@ -0,0 +1,3 @@
+OpenIDE-Module: org.openide.awt.test
+OpenIDE-Module-Layer: org/openide/awt/test-layer.xml
+OpenIDE-Public-Packages: -
diff -r 428419c1ab32 -r af0aefefe222 openide.awt/test/unit/src/org/openide/awt/AlwaysEnabledActionTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/openide.awt/test/unit/src/org/openide/awt/AlwaysEnabledActionTest.java Tue Jul 08 17:28:31 2008 +0200
@@ -0,0 +1,136 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * The Original Software is NetBeans. The Initial Developer of the Original
+ * Software is Sun Microsystems, Inc. Portions Copyright 2006 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ */
+
+package org.openide.awt;
+
+import java.awt.event.ActionListener;
+import javax.swing.Action;
+import org.netbeans.junit.NbTestCase;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileSystem;
+import org.openide.filesystems.Repository;
+import org.openide.util.ContextAwareAction;
+
+/**
+ *
+ * @author Jaroslav Tulach
+ */
+public class AlwaysEnabledActionTest extends NbTestCase {
+ private FileObject folder;
+
+ public AlwaysEnabledActionTest(String testName) {
+ super(testName);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ FileSystem fs = Repository.getDefault().getDefaultFileSystem();
+ folder = fs.findResource("actions/support/test");
+ assertNotNull("testing layer is loaded: ", folder);
+ }
+
+ @Override
+ protected boolean runInEQ() {
+ return true;
+ }
+
+ public void testIconIsCorrect() throws Exception {
+ myListenerCounter = 0;
+ myIconResourceCounter = 0;
+ Action a = readAction("testIconIsCorrect.instance");
+
+ assertNotNull("Action created", a);
+ assertEquals("No myListener called", 0, myListenerCounter);
+ assertEquals("No myIconURL called", 0, myIconResourceCounter);
+
+ Object name = a.getValue(a.NAME);
+ Object mnem = a.getValue(a.MNEMONIC_KEY);
+ Object smallIcon = a.getValue(a.SMALL_ICON);
+ //Object icon = a.getValue(a.ICON)
+
+ assertEquals("Right localized name", "Icon &Name Action", name);
+ assertEquals("Mnemonic is N", Character.valueOf('N'), mnem);
+ assertNotNull("small icon present", smallIcon);
+
+ assertEquals("once icon called", 1, myIconResourceCounter);
+
+
+ Object base = a.getValue("iconBase");
+ assertEquals("iconBase attribute is delegated", 2, myIconResourceCounter);
+
+ assertTrue("Always enabled", a.isEnabled());
+ a.setEnabled(false);
+ assertTrue("Still Always enabled", a.isEnabled());
+
+
+ assertEquals("No icon in menu", Boolean.TRUE, a.getValue("noIconInMenu"));
+
+ if (a instanceof ContextAwareAction) {
+ fail("Should not be context sensitive, otherwise it would have to implement equal correctly: " + a);
+ }
+ }
+
+ private static int myListenerCounter;
+ private static ActionListener myListener() {
+ myListenerCounter++;
+ return null;
+ }
+ private static int myIconResourceCounter;
+ private static String myIconResource() {
+ myIconResourceCounter++;
+ return "/org/openide/awt/TestIcon.png";
+ }
+
+
+ private Action readAction(String fileName) throws Exception {
+ FileObject fo = this.folder.getFileObject(fileName);
+ assertNotNull("file " + fileName, fo);
+
+ Object obj = fo.getAttribute("instanceCreate");
+ assertNotNull("File object has not null instanceCreate attribute", obj);
+
+ if (!(obj instanceof Action)) {
+ fail("Object needs to be action: " + obj);
+ }
+
+ return (Action)obj;
+ }
+}
diff -r 428419c1ab32 -r af0aefefe222 openide.awt/test/unit/src/org/openide/awt/TestBundle.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/openide.awt/test/unit/src/org/openide/awt/TestBundle.properties Tue Jul 08 17:28:31 2008 +0200
@@ -0,0 +1,43 @@
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+#
+# Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+#
+# The contents of this file are subject to the terms of either the GNU
+# General Public License Version 2 only ("GPL") or the Common
+# Development and Distribution License("CDDL") (collectively, the
+# "License"). You may not use this file except in compliance with the
+# License. You can obtain a copy of the License at
+# http://www.netbeans.org/cddl-gplv2.html
+# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+# specific language governing permissions and limitations under the
+# License. When distributing the software, include this License Header
+# Notice in each file and include the License file at
+# nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Sun in the GPL Version 2 section of the License file that
+# accompanied this code. If applicable, add the following below the
+# License Header, with the fields enclosed by brackets [] replaced by
+# your own identifying information:
+# "Portions Copyrighted [year] [name of copyright owner]"
+#
+# Contributor(s):
+#
+# The Original Software is NetBeans. The Initial Developer of the Original
+# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
+# Microsystems, Inc. All Rights Reserved.
+#
+# If you wish your version of this file to be governed by only the CDDL
+# or only the GPL Version 2, indicate your decision by adding
+# "[Contributor] elects to include this software in this distribution
+# under the [CDDL or GPL Version 2] license." If you do not indicate a
+# single choice of license, a recipient has the option to distribute
+# your version of this file under either the CDDL, the GPL Version 2 or
+# to extend the choice of license to its licensees as provided above.
+# However, if you add GPL Version 2 code and therefore, elected the GPL
+# Version 2 license, then the option applies only if the new code is
+# made subject to such option by the copyright holder.
+
+
+actions/support/test/testIconIsCorrect.instance=Icon &Name Action
+actions/support/test/testContext.instance=Open
+
diff -r 428419c1ab32 -r af0aefefe222 openide.awt/test/unit/src/org/openide/awt/TestIcon.png
Binary file openide.awt/test/unit/src/org/openide/awt/TestIcon.png has changed
diff -r 428419c1ab32 -r af0aefefe222 openide.awt/test/unit/src/org/openide/awt/test-layer.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/openide.awt/test/unit/src/org/openide/awt/test-layer.xml Tue Jul 08 17:28:31 2008 +0200
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 428419c1ab32 -r af0aefefe222 openide.filesystems/apichanges.xml
--- a/openide.filesystems/apichanges.xml Tue Jun 17 13:36:09 2008 -0700
+++ b/openide.filesystems/apichanges.xml Tue Jul 08 17:28:31 2008 +0200
@@ -46,6 +46,23 @@ made subject to such option by the copyr
Filesystems API
+
+
+ Attributes 'displayName' and 'image'
+
+
+
+
+
+
+ When using methodvalue in XML filesystem, one can add there
+ expect new values 'displayName' and 'image' available to methods
+ that accept java.util.Map
.
+
+
+
+
+
Added methods to interconvert URLs and traditional path entries
diff -r 428419c1ab32 -r af0aefefe222 openide.filesystems/manifest.mf
--- a/openide.filesystems/manifest.mf Tue Jun 17 13:36:09 2008 -0700
+++ b/openide.filesystems/manifest.mf Tue Jul 08 17:28:31 2008 +0200
@@ -1,5 +1,5 @@ Manifest-Version: 1.0
Manifest-Version: 1.0
OpenIDE-Module: org.openide.filesystems
-OpenIDE-Module-Specification-Version: 7.9
+OpenIDE-Module-Specification-Version: 7.10
OpenIDE-Module-Localizing-Bundle: org/openide/filesystems/Bundle.properties
diff -r 428419c1ab32 -r af0aefefe222 openide.filesystems/src/org/openide/filesystems/XMLFileSystem.java
--- a/openide.filesystems/src/org/openide/filesystems/XMLFileSystem.java Tue Jun 17 13:36:09 2008 -0700
+++ b/openide.filesystems/src/org/openide/filesystems/XMLFileSystem.java Tue Jul 08 17:28:31 2008 +0200
@@ -146,7 +146,10 @@ import org.xml.sax.helpers.DefaultHandle
* static Value methodName(Map attrs); // since 7.0
* static Value methodName(Map attrs, String attrName); // since 7.0
*
- * where Value
can be any java type.
+ * where Value
can be any java type. Since version 7.9 the Map
+ * attribute may also contain special values for keys displayName
and
+ * image
representing display name of the {@link FileObject} and its image
+ * respectively.
*
*
* @author Radek Matous
diff -r 428419c1ab32 -r af0aefefe222 openide.filesystems/src/org/openide/filesystems/XMLMapAttr.java
--- a/openide.filesystems/src/org/openide/filesystems/XMLMapAttr.java Tue Jun 17 13:36:09 2008 -0700
+++ b/openide.filesystems/src/org/openide/filesystems/XMLMapAttr.java Tue Jul 08 17:28:31 2008 +0200
@@ -40,6 +40,7 @@
*/
package org.openide.filesystems;
+import java.awt.Toolkit;
import org.openide.util.SharedClassObject;
import org.openide.util.Utilities;
import org.openide.util.io.NbMarshalledObject;
@@ -53,6 +54,7 @@ import java.net.URL;
import java.util.*;
import org.openide.util.Exceptions;
+import org.openide.util.NbBundle;
/**
@@ -338,6 +340,7 @@ final class XMLMapAttr implements Map {
return map.containsValue(p1);
}
+ @Override
public synchronized int hashCode() {
return map.hashCode();
}
@@ -367,6 +370,7 @@ final class XMLMapAttr implements Map {
return map.isEmpty();
}
+ @Override
public synchronized boolean equals(Object p1) {
return map.equals(p1);
}
@@ -982,6 +986,7 @@ final class XMLMapAttr implements Map {
return index;
}
+ @Override
public boolean equals(Object obj) {
if (obj instanceof Attr) {
Attr other = (Attr)obj;
@@ -995,6 +1000,7 @@ final class XMLMapAttr implements Map {
return false;
}
+ @Override
public int hashCode() {
return 743 + keyIndex << 8 + value.hashCode();
}
@@ -1140,10 +1146,12 @@ final class XMLMapAttr implements Map {
return fo.getAttribute(key);
}
+ @Override
public Object remove(Object key) {
throw new UnsupportedOperationException();
}
+ @Override
public Object put(String key, Object value) {
throw new UnsupportedOperationException();
}
@@ -1158,13 +1166,17 @@ final class XMLMapAttr implements Map {
public Iterator> iterator() {
class Iter implements Iterator> {
+ int fixed;
Enumeration attrs = fo.getAttributes();
-
+
public boolean hasNext() {
- return attrs.hasMoreElements();
+ return fixed < 2 || attrs.hasMoreElements();
}
-
+
public Map.Entry next() {
+ if (fixed < 2) {
+ return new LocEntry(fo, fixed++);
+ }
String s = attrs.nextElement();
return new FOEntry(fo, s);
}
@@ -1186,6 +1198,7 @@ final class XMLMapAttr implements Map {
return cnt;
}
+ @Override
public boolean remove(Object o) {
throw new UnsupportedOperationException();
}
@@ -1212,4 +1225,38 @@ final class XMLMapAttr implements Map {
throw new UnsupportedOperationException();
}
} // end of FOEntry
+ private static final class LocEntry implements Map.Entry {
+ private FileObject fo;
+ private int type;
+
+ private LocEntry(FileObject fo, int cnt) {
+ this.fo = fo;
+ this.type = cnt;
+ }
+
+ public String getKey() {
+ return type == 0 ? "displayName" : "image"; // NOI18N
+ }
+
+ public Object getValue() {
+ if (type == 0) {
+ String rb = (String) fo.getAttribute("SystemFileSystem.localizingBundle"); // NOI18N
+ if (rb == null) {
+ return fo.getNameExt();
+ }
+ return NbBundle.getBundle(rb).getString(fo.getPath());
+ } else if (type == 1) {
+ URL u = (URL) fo.getAttribute("SystemFileSystem.icon"); // NOI18N
+ if (u != null) {
+ return Toolkit.getDefaultToolkit().getImage(u);
+ }
+ }
+ return null;
+ }
+
+
+ public Object setValue(Object value) {
+ throw new UnsupportedOperationException();
+ }
+ } // end of LocEntry
}
diff -r 428419c1ab32 -r af0aefefe222 openide.windows/apichanges.xml
--- a/openide.windows/apichanges.xml Tue Jun 17 13:36:09 2008 -0700
+++ b/openide.windows/apichanges.xml Tue Jul 08 17:28:31 2008 +0200
@@ -48,6 +48,18 @@ made subject to such option by the copyr
+
+
+ TopComponent.openAction
+
+
+
+
+
+ Adding new factory method that creates an action to open a TopComponent
.
+
+
+
Added a group of resource bundle properties for customization
diff -r 428419c1ab32 -r af0aefefe222 openide.windows/manifest.mf
--- a/openide.windows/manifest.mf Tue Jun 17 13:36:09 2008 -0700
+++ b/openide.windows/manifest.mf Tue Jul 08 17:28:31 2008 +0200
@@ -1,6 +1,6 @@ Manifest-Version: 1.0
Manifest-Version: 1.0
OpenIDE-Module: org.openide.windows
-OpenIDE-Module-Specification-Version: 6.23
+OpenIDE-Module-Specification-Version: 6.24
OpenIDE-Module-Localizing-Bundle: org/openide/windows/Bundle.properties
AutoUpdate-Essential-Module: true
diff -r 428419c1ab32 -r af0aefefe222 openide.windows/nbproject/project.xml
--- a/openide.windows/nbproject/project.xml Tue Jun 17 13:36:09 2008 -0700
+++ b/openide.windows/nbproject/project.xml Tue Jul 08 17:28:31 2008 +0200
@@ -47,7 +47,7 @@ made subject to such option by the copyr
org.openide.windows
- org.openide.util
+ org.openide.awt
@@ -63,26 +63,26 @@ made subject to such option by the copyr
- org.openide.awt
+ org.openide.util
- 6.2
+ 7.15
-
-
- unit
-
- org.openide.windows
-
-
-
-
-
- qa-functional
-
+
+
+ unit
+
+ org.openide.windows
+
+
+
+
+
+ qa-functional
+
org.openide.windows
diff -r 428419c1ab32 -r af0aefefe222 openide.windows/src/org/openide/windows/OpenComponentAction.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/openide.windows/src/org/openide/windows/OpenComponentAction.java Tue Jul 08 17:28:31 2008 +0200
@@ -0,0 +1,87 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2008 Sun Microsystems, Inc.
+ */
+
+package org.openide.windows;
+
+import java.awt.EventQueue;
+import java.awt.Image;
+import java.awt.event.ActionEvent;
+import java.util.Map;
+import javax.swing.AbstractAction;
+
+import org.openide.util.ImageUtilities;
+
+/** Opens a top component.
+ *
+ * @author Jaroslav Tulach
+ */
+final class OpenComponentAction extends AbstractAction {
+ private TopComponent component;
+ private final Map,?> map;
+
+ OpenComponentAction(TopComponent component, String displayName, Image image) {
+ super(displayName);
+ this.component = component;
+ putValue(SMALL_ICON, ImageUtilities.image2Icon(image));
+ map = null;
+ }
+
+ OpenComponentAction(Map,?> map) {
+ super((String)map.get("displayName")); // NOI18N
+ this.map = map;
+ Image image = (Image)map.get("image"); // NOI18N
+ if (image != null) {
+ putValue(SMALL_ICON, ImageUtilities.image2Icon(image));
+ }
+ }
+
+ private TopComponent getTopComponent() {
+ assert EventQueue.isDispatchThread();
+ if (component != null) {
+ return component;
+ }
+ return component = (TopComponent)map.get("component"); // NOI18N
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ TopComponent win = getTopComponent();
+ win.open();
+ win.requestActive();
+ }
+}
diff -r 428419c1ab32 -r af0aefefe222 openide.windows/src/org/openide/windows/TopComponent.java
--- a/openide.windows/src/org/openide/windows/TopComponent.java Tue Jun 17 13:36:09 2008 -0700
+++ b/openide.windows/src/org/openide/windows/TopComponent.java Tue Jul 08 17:28:31 2008 +0200
@@ -65,6 +65,7 @@ import java.util.Arrays;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.LogRecord;
@@ -535,6 +536,32 @@ public class TopComponent extends JCompo
} else {
return actions;
}
+ }
+
+ /** Creates an action that opens and activates given TopComponent
,
+ * when invoked. This method can also be used from
+ * XML Layer
+ * directly by following XML definition:
+ *
+ * <file name="your-pkg-action-id.instance">
+ * <attr name="instanceCreate" methodvalue="org.openide.windows.TopComponent.openAction"/>
+ * <attr name="component" methodvalue="your.pkg.YourComponent.factoryMethod"/>
+ * <attr name="SystemFileSystem.icon" stringvalue="your/pkg/YourComponent.png"/>
+ * <attr name="SystemFileSystem.localizingBundle" stringvalue="your/pkg/Bundle"/>
+ * </file>
+ *
+ *
+ * @param component the component to open
+ * @param displayName the display name of the action
+ * @param image the image to associated with the action
+ *
+ * @since 6.24
+ */
+ public static Action openAction(TopComponent component, String displayName, Image image) {
+ return new OpenComponentAction(component, displayName, image);
+ }
+ static Action openAction(Map map) {
+ return new OpenComponentAction(map);
}
/** Set the close mode for the component.
diff -r 428419c1ab32 -r af0aefefe222 openide.windows/test/unit/src/org/openide/windows/OpenComponentActionTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/openide.windows/test/unit/src/org/openide/windows/OpenComponentActionTest.java Tue Jul 08 17:28:31 2008 +0200
@@ -0,0 +1,160 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2008 Sun Microsystems, Inc.
+ */
+
+package org.openide.windows;
+
+import java.awt.Image;
+import java.awt.event.ActionEvent;
+import java.awt.image.BufferedImage;
+import java.util.HashMap;
+import java.util.Map;
+import javax.swing.Action;
+import javax.swing.Icon;
+import org.netbeans.junit.NbTestCase;
+
+/**
+ *
+ * @author Jaroslav Tulach
+ */
+public class OpenComponentActionTest extends NbTestCase {
+
+ public OpenComponentActionTest(String testName) {
+ super(testName);
+ }
+
+ @Override
+ protected boolean runInEQ() {
+ return true;
+ }
+
+
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ TC.instance = null;
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testMethodCallDirectly() {
+ ActionEvent e = new ActionEvent(this, 0, "");
+ TC tc = new TC();
+ Image img = new BufferedImage(133, 133, BufferedImage.TYPE_INT_ARGB);
+ Action instance = TopComponent.openAction(tc, "Ahoj", img);
+ instance.actionPerformed(e);
+
+ tc.close();
+
+ assertEquals("Opened once", 1, tc.cntOpen);
+ assertEquals("Activated once", 1, tc.cntRequest);
+
+ Icon icon = (Icon) instance.getValue(Action.SMALL_ICON);
+ assertEquals("Width", 133, icon.getIconWidth());
+ assertEquals("Height", 133, icon.getIconHeight());
+ assertEquals("Name", "Ahoj", instance.getValue(Action.NAME));
+ }
+
+ public void testMapInstantiation() {
+ final Image img = new BufferedImage(133, 133, BufferedImage.TYPE_INT_ARGB);
+
+ Map m = new HashMap() {
+ @Override
+ public Object get(Object key) {
+ if ("component".equals(key)) {
+ return new TC();
+ }
+ if ("displayName".equals(key)) {
+ return "Ahoj";
+ }
+ if ("image".equals(key)) {
+ return img;
+ }
+ return null;
+ }
+ };
+
+ ActionEvent e = new ActionEvent(this, 0, "");
+ Action instance = TopComponent.openAction(m);
+
+ assertNull("No instance yet", TC.instance);
+ instance.actionPerformed(e);
+
+ assertNotNull("Instance created", TC.instance);
+ TC tc = TC.instance;
+ tc.close();
+
+ assertEquals("Opened once", 1, tc.cntOpen);
+ assertEquals("Activated once", 1, tc.cntRequest);
+
+ Icon icon = (Icon) instance.getValue(Action.SMALL_ICON);
+ assertEquals("Width", 133, icon.getIconWidth());
+ assertEquals("Height", 133, icon.getIconHeight());
+ assertEquals("Name", "Ahoj", instance.getValue(Action.NAME));
+ }
+
+
+ public static final class TC extends TopComponent {
+ static TC instance;
+
+ int cntOpen;
+ int cntRequest;
+
+ public TC() {
+ assertNull("No previous one", instance);
+ instance = this;
+ }
+
+ @Override
+ public void open() {
+ super.open();
+ cntOpen++;
+ }
+
+ @Override
+ public void requestActive() {
+ super.requestActive();
+ cntRequest++;
+ }
+ }
+}