diff --git a/openide.awt/nbproject/project.properties b/openide.awt/nbproject/project.properties
--- a/openide.awt/nbproject/project.properties
+++ b/openide.awt/nbproject/project.properties
@@ -47,3 +47,4 @@
javadoc.apichanges=${basedir}/apichanges.xml
spec.version.base=7.4.0
+cp.extra=${nb_all}/libs.javacapi/external/javac-api-nb-7.0-b07.jar
diff --git a/openide.awt/nbproject/project.xml b/openide.awt/nbproject/project.xml
--- a/openide.awt/nbproject/project.xml
+++ b/openide.awt/nbproject/project.xml
@@ -47,6 +47,14 @@
org.openide.awt
+ org.openide.filesystems
+
+
+
+ 7.13
+
+
+
org.openide.util
diff --git a/openide.awt/src/org/netbeans/modules/openide/awt/ActionRegistrationProcessor.java b/openide.awt/src/org/netbeans/modules/openide/awt/ActionRegistrationProcessor.java
new file mode 100644
--- /dev/null
+++ b/openide.awt/src/org/netbeans/modules/openide/awt/ActionRegistrationProcessor.java
@@ -0,0 +1,88 @@
+/*
+ * 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.openide.awt;
+
+import java.util.Set;
+import javax.annotation.processing.Processor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.swing.Action;
+import org.openide.awt.ActionRegistration;
+import org.openide.filesystems.annotations.LayerBuilder.File;
+import org.openide.filesystems.annotations.LayerGeneratingProcessor;
+import org.openide.filesystems.annotations.LayerGenerationException;
+import org.openide.util.Utilities;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ * @author Jaroslav Tulach
+ */
+@ServiceProvider(service=Processor.class)
+@SupportedSourceVersion(SourceVersion.RELEASE_6)
+@SupportedAnnotationTypes("org.openide.awt.ActionRegistration")
+public class ActionRegistrationProcessor extends LayerGeneratingProcessor {
+ @Override
+ protected boolean handleProcess(Set extends TypeElement> annotations, RoundEnvironment roundEnv) throws LayerGenerationException {
+ for (Element e : roundEnv.getElementsAnnotatedWith(ActionRegistration.class)) {
+ ActionRegistration ar = e.getAnnotation(ActionRegistration.class);
+ File action = layer(e).instanceFile("Actions/" + ar.category(), null, Action.class);
+ action.write();
+ for (ActionRegistration.Menu menu : ar.menus()) {
+ layer(e).shadowFile(action.getPath(), "Menu/" + menu.path(), null).position(menu.position()).write();
+ }
+ for (ActionRegistration.Toolbar tb : ar.toolbars()) {
+ layer(e).shadowFile(action.getPath(), "Toolbar/" + tb.path(), null).position(tb.position()).write();
+ }
+ for (ActionRegistration.Shortcut cut : ar.shortcuts()) {
+ String key = cut.key();
+ if (Utilities.stringToKey(key) == null) {
+ throw new LayerGenerationException(key + " is not a valid shortcut name", e);
+ }
+ layer(e).shadowFile(action.getPath(), "Shortcut", key).write();
+ }
+ }
+ return true;
+ }
+}
diff --git a/openide.awt/src/org/openide/awt/ActionRegistration.java b/openide.awt/src/org/openide/awt/ActionRegistration.java
new file mode 100644
--- /dev/null
+++ b/openide.awt/src/org/openide/awt/ActionRegistration.java
@@ -0,0 +1,81 @@
+/*
+ * 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.awt;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ *
+ * @author Jaroslav Tulach
+ */
+@Retention(RetentionPolicy.SOURCE)
+@Target({ ElementType.TYPE, ElementType.METHOD })
+public @interface ActionRegistration {
+ String category();
+
+ String iconbase() default ""; // XXX unused
+ String displayName(); // XXX unused
+ boolean noIconInMenu() default false; // XXX unused
+
+ String actionMapKey() default ""; // XXX unused
+ Class>[] contextTypes() default {}; // XXX unused
+
+ Menu[] menus() default {};
+ Toolbar[] toolbars() default {};
+ Shortcut[] shortcuts() default {};
+
+ @Target({})
+ public @interface Menu {
+ String path();
+ int position();
+ }
+ @Target({})
+ public @interface Toolbar {
+ String path();
+ int position();
+ }
+ @Target({})
+ public @interface Shortcut {
+ String key();
+ }
+}
diff --git a/openide.awt/test/unit/src/org/netbeans/modules/openide/awt/ActionRegistrationProcessorTest.java b/openide.awt/test/unit/src/org/netbeans/modules/openide/awt/ActionRegistrationProcessorTest.java
new file mode 100644
--- /dev/null
+++ b/openide.awt/test/unit/src/org/netbeans/modules/openide/awt/ActionRegistrationProcessorTest.java
@@ -0,0 +1,175 @@
+/*
+ * 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.netbeans.modules.openide.awt;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import org.netbeans.junit.NbTestCase;
+import org.openide.awt.ActionRegistration;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileSystem;
+import org.openide.filesystems.Repository;
+import org.openide.util.ContextAwareAction;
+import org.openide.util.Lookup;
+
+/**
+ *
+ * @author Jaroslav Tulach
+ */
+public class ActionRegistrationProcessorTest extends NbTestCase implements PropertyChangeListener {
+ private FileObject folder;
+ private int changeCounter;
+
+ public ActionRegistrationProcessorTest(String testName) {
+ super(testName);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ FileSystem fs = Repository.getDefault().getDefaultFileSystem();
+ folder = fs.findResource("Toolbar/Edit/");
+ assertNotNull("testing layer is loaded: ", folder);
+
+ myListenerCalled = 0;
+ myListenerCounter = 0;
+ MyAction.last = null;
+ }
+
+ @Override
+ protected boolean runInEQ() {
+ return true;
+ }
+
+ public void testIconIsCorrect() throws Exception {
+ // XXX test in no way matches what is being actually registered, rewrite...
+ myListenerCounter = 0;
+ Action a = readAction("testIconIsCorrect.instance");
+
+ assertNotNull("Action created", a);
+ assertEquals("No myListener called", 0, myListenerCounter);
+
+ 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);
+
+
+ assertTrue("Always enabled", a.isEnabled());
+ a.setEnabled(false);
+ assertTrue("Still Always enabled", a.isEnabled());
+
+ a.actionPerformed(new ActionEvent(this, 0, "kuk"));
+
+ assertEquals("Listener invoked", 1, myListenerCounter);
+
+
+ assertEquals("No icon in menu", Boolean.TRUE, a.getValue("noIconInMenu"));
+ }
+
+
+ private static int myListenerCounter;
+ private static int myListenerCalled;
+ @ActionRegistration(category="Testing", displayName="#Always",
+ menus=@ActionRegistration.Menu(path="Edit", position=30),
+ toolbars=@ActionRegistration.Toolbar(path="Edit", position=30),
+ shortcuts=@ActionRegistration.Shortcut(key="D-X"))
+ private static Action myAction() {
+ myListenerCounter++;
+ return new MyAction();
+ }
+
+ 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;
+ }
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ changeCounter++;
+ }
+
+ private static class MyListener implements ActionListener {
+ public void actionPerformed(ActionEvent e) {
+ myListenerCalled++;
+ }
+ }
+ private static class MyAction extends AbstractAction {
+ static MyAction last;
+
+ MyAction() {
+ last = this;
+ setEnabled(false);
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ myListenerCalled++;
+ }
+ }
+ private static class MyContextAction extends MyAction
+ implements ContextAwareAction {
+ static int clones;
+ static Lookup lkp;
+
+ public Action createContextAwareInstance(Lookup actionContext) {
+ clones++;
+ lkp = actionContext;
+ return new MyContextAction();
+ }
+ }
+
+}
diff --git a/utilities/src/org/netbeans/modules/search/FindInFilesAction.java b/utilities/src/org/netbeans/modules/search/FindInFilesAction.java
--- a/utilities/src/org/netbeans/modules/search/FindInFilesAction.java
+++ b/utilities/src/org/netbeans/modules/search/FindInFilesAction.java
@@ -58,6 +58,7 @@
import javax.swing.event.ChangeListener;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
+import org.openide.awt.ActionRegistration;
import org.openide.util.ContextAwareAction;
import org.openide.util.Lookup;
import org.openide.util.Mutex;
@@ -91,6 +92,13 @@
*
* @author Marian Petras
*/
+@ActionRegistration(
+ category="Edit",
+ iconbase="org/openide/resources/actions/find.gif",
+ displayName="#LBL_Action_FindInFiles",
+ menus = @ActionRegistration.Menu(path="Edit", position=2400),
+ shortcuts = @ActionRegistration.Shortcut(key="DS-F")
+)
public class FindInFilesAction extends CallableSystemAction
implements ContextAwareAction, ChangeListener {
diff --git a/utilities/src/org/netbeans/modules/utilities/Layer.xml b/utilities/src/org/netbeans/modules/utilities/Layer.xml
--- a/utilities/src/org/netbeans/modules/utilities/Layer.xml
+++ b/utilities/src/org/netbeans/modules/utilities/Layer.xml
@@ -229,7 +229,6 @@
-->
-
@@ -256,9 +255,6 @@
-
-
-
@@ -303,8 +299,6 @@
-->
-
-