diff -r 23740f21e651 nbbuild/antsrc/org/netbeans/nbbuild/CustomJavac.java --- a/nbbuild/antsrc/org/netbeans/nbbuild/CustomJavac.java Tue Oct 21 00:28:11 2008 -0400 +++ b/nbbuild/antsrc/org/netbeans/nbbuild/CustomJavac.java Thu Oct 23 10:09:40 2008 +0200 @@ -101,12 +101,10 @@ } } - @Override public void setErrorProperty(String errorProperty) { throw new UnsupportedOperationException(); } - @Override public void setUpdatedProperty(String updatedProperty) { throw new UnsupportedOperationException(); } @@ -125,7 +123,7 @@ try { Path cp = ((CustomJavac) getJavac()).javacClasspath; ClassLoader cl = new AntClassLoader(getJavac().getProject(), cp); - Class c = Class.forName("com.sun.tools.javac.Main", true, cl); + Class c = Class.forName("com.sun.tools.javac.Main", true, cl); getJavac().log("Running javac from " + c.getProtectionDomain().getCodeSource().getLocation(), Project.MSG_VERBOSE); Method compile = c.getMethod("compile", String[].class); int result = (Integer) compile.invoke(null, (Object) cmd.getArguments()); diff -r 23740f21e651 openide.awt/nbproject/project.xml --- a/openide.awt/nbproject/project.xml Tue Oct 21 00:28:11 2008 -0400 +++ b/openide.awt/nbproject/project.xml Thu Oct 23 10:09:40 2008 +0200 @@ -47,6 +47,14 @@ org.openide.awt + org.openide.filesystems + + + + 7.13 + + + org.openide.util diff -r 23740f21e651 openide.awt/src/org/netbeans/modules/openide/awt/ActionRegistrationProcessor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/openide.awt/src/org/netbeans/modules/openide/awt/ActionRegistrationProcessor.java Thu Oct 23 10:09:41 2008 +0200 @@ -0,0 +1,125 @@ +/* + * 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 javax.tools.Diagnostic.Kind; +import org.openide.awt.ActionRegistration; +import org.openide.filesystems.annotations.LayerBuilder; +import org.openide.filesystems.annotations.LayerBuilder.File; +import org.openide.filesystems.annotations.LayerGeneratingProcessor; +import org.openide.util.lookup.Service; + +/** + * + * @author Jaroslav Tulach + */ +@Service(Processor.class) +@SupportedSourceVersion(SourceVersion.RELEASE_6) +@SupportedAnnotationTypes("org.openide.awt.ActionRegistration") +public class ActionRegistrationProcessor extends LayerGeneratingProcessor { + @Override + protected boolean doProcess(Set annotations, RoundEnvironment roundEnv) { + for (Element e : roundEnv.getElementsAnnotatedWith(ActionRegistration.class)) { + ActionRegistration ar = e.getAnnotation(ActionRegistration.class); + File action; + try { + action = instanceFile(new LayerBuilder(layer(e)), e, "Actions/" + ar.category(), null, Action.class); + action.write(); + } catch (Exception x) { + processingEnv.getMessager().printMessage(Kind.ERROR, x.getLocalizedMessage()); + continue; + } + ActionRegistration.Menu menu = e.getAnnotation(ActionRegistration.Menu.class); + if (menu != null) { + try { + shadowFile( + new LayerBuilder(layer(e)), + action.getPath(), "Menu/" + menu.path(), null // NOI18N + ).position(menu.position()).write(); + } catch (Exception x) { + processingEnv.getMessager().printMessage(Kind.ERROR, x.getLocalizedMessage()); + continue; + } + } + ActionRegistration.Toolbar tb = e.getAnnotation(ActionRegistration.Toolbar.class); + if (tb != null) { + try { + shadowFile( + new LayerBuilder(layer(e)), + action.getPath(), "Toolbar/" + tb.path(), null // NOI18N + ).position(menu.position()).write(); + } catch (Exception x) { + processingEnv.getMessager().printMessage(Kind.ERROR, x.getLocalizedMessage()); + continue; + } + } + ActionRegistration.Shortcut cut = e.getAnnotation(ActionRegistration.Shortcut.class); + if (cut != null) { + try { + shadowFile( + new LayerBuilder(layer(e)), + action.getPath(), "Shortcut", cut.key() // NOI18N + ).position(menu.position()).write(); + } catch (Exception x) { + processingEnv.getMessager().printMessage(Kind.ERROR, x.getLocalizedMessage()); + continue; + } + } + } + + return true; + } + // temporary, XXX, replace with b.shadowFile + public File shadowFile(LayerBuilder b, String target, String folder, String name) { + if (name == null) { + name = target.replaceFirst("^.+/", "").replaceFirst("\\.[^./]+$", ""); // NOI18N + } + return b.file(folder + "/" + name + ".shadow").stringvalue("originalFile", target); // NOI18N + } +} diff -r 23740f21e651 openide.awt/src/org/openide/awt/ActionRegistration.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/openide.awt/src/org/openide/awt/ActionRegistration.java Thu Oct 23 10:09:41 2008 +0200 @@ -0,0 +1,74 @@ +/* + * 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 ""; + String displayName(); + boolean noIconInMenu() default false; + + String actionMapKey() default ""; + Class[] contextTypes() default {}; + + public @interface Menu { + String path(); + int position(); + } + public @interface Toolbar { + String path(); + int position(); + } + public @interface Shortcut { + String key(); + } +} diff -r 23740f21e651 openide.awt/test/unit/src/org/openide/awt/AnnotationActionTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/openide.awt/test/unit/src/org/openide/awt/AnnotationActionTest.java Thu Oct 23 10:09:41 2008 +0200 @@ -0,0 +1,173 @@ +/* + * 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.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.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 AnnotationActionTest extends NbTestCase implements PropertyChangeListener { + private FileObject folder; + private int changeCounter; + + public AnnotationActionTest(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 { + 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") + @ActionRegistration.Menu(path="Edit", position=30) + @ActionRegistration.Toolbar(path="Edit", position=30) + @ActionRegistration.Shortcut(key="D-X") + private static ActionListener myListener() { + myListenerCounter++; + return new MyListener(); + } + + 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 -r 23740f21e651 utilities/src/org/netbeans/modules/search/FindInFilesAction.java --- a/utilities/src/org/netbeans/modules/search/FindInFilesAction.java Tue Oct 21 00:28:11 2008 -0400 +++ b/utilities/src/org/netbeans/modules/search/FindInFilesAction.java Thu Oct 23 10:09:41 2008 +0200 @@ -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" +) +@ActionRegistration.Menu(path="Edit", position=2400) +@ActionRegistration.Shortcut(key="DS-F") public class FindInFilesAction extends CallableSystemAction implements ContextAwareAction, ChangeListener { diff -r 23740f21e651 utilities/src/org/netbeans/modules/utilities/Layer.xml --- a/utilities/src/org/netbeans/modules/utilities/Layer.xml Tue Oct 21 00:28:11 2008 -0400 +++ b/utilities/src/org/netbeans/modules/utilities/Layer.xml Thu Oct 23 10:09:41 2008 +0200 @@ -229,7 +229,7 @@ --> - + @@ -257,9 +257,11 @@ + @@ -302,9 +304,9 @@ - --> + -->