This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 149136
Collapse All | Expand All

(-)a/nbbuild/antsrc/org/netbeans/nbbuild/CustomJavac.java (-3 / +1 lines)
Lines 101-112 Link Here
101
        }
101
        }
102
    }
102
    }
103
103
104
    @Override
105
    public void setErrorProperty(String errorProperty) {
104
    public void setErrorProperty(String errorProperty) {
106
        throw new UnsupportedOperationException();
105
        throw new UnsupportedOperationException();
107
    }
106
    }
108
107
109
    @Override
110
    public void setUpdatedProperty(String updatedProperty) {
108
    public void setUpdatedProperty(String updatedProperty) {
111
        throw new UnsupportedOperationException();
109
        throw new UnsupportedOperationException();
112
    }
110
    }
Lines 125-131 Link Here
125
            try {
123
            try {
126
                Path cp = ((CustomJavac) getJavac()).javacClasspath;
124
                Path cp = ((CustomJavac) getJavac()).javacClasspath;
127
                ClassLoader cl = new AntClassLoader(getJavac().getProject(), cp);
125
                ClassLoader cl = new AntClassLoader(getJavac().getProject(), cp);
128
                Class c = Class.forName("com.sun.tools.javac.Main", true, cl);
126
                Class<?> c = Class.forName("com.sun.tools.javac.Main", true, cl);
129
                getJavac().log("Running javac from " + c.getProtectionDomain().getCodeSource().getLocation(), Project.MSG_VERBOSE);
127
                getJavac().log("Running javac from " + c.getProtectionDomain().getCodeSource().getLocation(), Project.MSG_VERBOSE);
130
                Method compile = c.getMethod("compile", String[].class);
128
                Method compile = c.getMethod("compile", String[].class);
131
                int result = (Integer) compile.invoke(null, (Object) cmd.getArguments());
129
                int result = (Integer) compile.invoke(null, (Object) cmd.getArguments());
(-)a/openide.awt/nbproject/project.xml (+8 lines)
Lines 47-52 Link Here
47
            <code-name-base>org.openide.awt</code-name-base>
47
            <code-name-base>org.openide.awt</code-name-base>
48
            <module-dependencies>
48
            <module-dependencies>
49
                <dependency>
49
                <dependency>
50
                    <code-name-base>org.openide.filesystems</code-name-base>
51
                    <build-prerequisite/>
52
                    <compile-dependency/>
53
                    <run-dependency>
54
                        <specification-version>7.13</specification-version>
55
                    </run-dependency>
56
                </dependency>
57
                <dependency>
50
                    <code-name-base>org.openide.util</code-name-base>
58
                    <code-name-base>org.openide.util</code-name-base>
51
                    <build-prerequisite/>
59
                    <build-prerequisite/>
52
                    <compile-dependency/>
60
                    <compile-dependency/>
(-)23740f21e651 (+125 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.openide.awt;
41
42
import java.util.Set;
43
import javax.annotation.processing.Processor;
44
import javax.annotation.processing.RoundEnvironment;
45
import javax.annotation.processing.SupportedAnnotationTypes;
46
import javax.annotation.processing.SupportedSourceVersion;
47
import javax.lang.model.SourceVersion;
48
import javax.lang.model.element.Element;
49
import javax.lang.model.element.TypeElement;
50
import javax.swing.Action;
51
import javax.tools.Diagnostic.Kind;
52
import org.openide.awt.ActionRegistration;
53
import org.openide.filesystems.annotations.LayerBuilder;
54
import org.openide.filesystems.annotations.LayerBuilder.File;
55
import org.openide.filesystems.annotations.LayerGeneratingProcessor;
56
import org.openide.util.lookup.Service;
57
58
/**
59
 *
60
 * @author Jaroslav Tulach <jtulach@netbeans.org>
61
 */
62
@Service(Processor.class)
63
@SupportedSourceVersion(SourceVersion.RELEASE_6)
64
@SupportedAnnotationTypes("org.openide.awt.ActionRegistration")
65
public class ActionRegistrationProcessor extends LayerGeneratingProcessor {
66
    @Override
67
    protected boolean doProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
68
        for (Element e : roundEnv.getElementsAnnotatedWith(ActionRegistration.class)) {
69
            ActionRegistration ar = e.getAnnotation(ActionRegistration.class);
70
            File action;
71
            try {
72
                action = instanceFile(new LayerBuilder(layer(e)), e, "Actions/" + ar.category(), null, Action.class);
73
                action.write();
74
            } catch (Exception x) {
75
                processingEnv.getMessager().printMessage(Kind.ERROR, x.getLocalizedMessage());
76
                continue;
77
            }
78
            ActionRegistration.Menu menu = e.getAnnotation(ActionRegistration.Menu.class);
79
            if (menu != null) {
80
                try {
81
                    shadowFile(
82
                        new LayerBuilder(layer(e)),
83
                        action.getPath(), "Menu/" + menu.path(), null // NOI18N
84
                    ).position(menu.position()).write();
85
                } catch (Exception x) {
86
                    processingEnv.getMessager().printMessage(Kind.ERROR, x.getLocalizedMessage());
87
                    continue;
88
                }
89
            }
90
            ActionRegistration.Toolbar tb = e.getAnnotation(ActionRegistration.Toolbar.class);
91
            if (tb != null) {
92
                try {
93
                    shadowFile(
94
                        new LayerBuilder(layer(e)),
95
                        action.getPath(), "Toolbar/" + tb.path(), null // NOI18N
96
                    ).position(menu.position()).write();
97
                } catch (Exception x) {
98
                    processingEnv.getMessager().printMessage(Kind.ERROR, x.getLocalizedMessage());
99
                    continue;
100
                }
101
            }
102
            ActionRegistration.Shortcut cut = e.getAnnotation(ActionRegistration.Shortcut.class);
103
            if (cut != null) {
104
                try {
105
                    shadowFile(
106
                        new LayerBuilder(layer(e)),
107
                        action.getPath(), "Shortcut", cut.key() // NOI18N
108
                    ).position(menu.position()).write();
109
                } catch (Exception x) {
110
                    processingEnv.getMessager().printMessage(Kind.ERROR, x.getLocalizedMessage());
111
                    continue;
112
                }
113
            }
114
        }
115
116
        return true;
117
    }
118
    // temporary, XXX, replace with b.shadowFile
119
    public File shadowFile(LayerBuilder b, String target, String folder, String name) {
120
        if (name == null) {
121
            name = target.replaceFirst("^.+/", "").replaceFirst("\\.[^./]+$", ""); // NOI18N
122
        }
123
        return b.file(folder + "/" + name + ".shadow").stringvalue("originalFile", target); // NOI18N
124
    }
125
}
(-)23740f21e651 (+74 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
38
 */
39
40
package org.openide.awt;
41
42
import java.lang.annotation.ElementType;
43
import java.lang.annotation.Retention;
44
import java.lang.annotation.RetentionPolicy;
45
import java.lang.annotation.Target;
46
47
/**
48
 *
49
 * @author Jaroslav Tulach <jtulach@netbeans.org>
50
 */
51
@Retention(RetentionPolicy.SOURCE)
52
@Target({ ElementType.TYPE, ElementType.METHOD })
53
public @interface ActionRegistration {
54
    String category();
55
56
    String iconbase() default "";
57
    String displayName();
58
    boolean noIconInMenu() default false;
59
60
    String actionMapKey() default "";
61
    Class<?>[] contextTypes() default {};
62
63
    public @interface Menu {
64
        String path();
65
        int position();
66
    }
67
    public @interface Toolbar {
68
        String path();
69
        int position();
70
    }
71
    public @interface Shortcut {
72
        String key();
73
    }
74
}
(-)23740f21e651 (+173 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
42
package org.openide.awt;
43
44
import java.awt.event.ActionEvent;
45
import java.awt.event.ActionListener;
46
import java.beans.PropertyChangeEvent;
47
import java.beans.PropertyChangeListener;
48
import javax.swing.AbstractAction;
49
import javax.swing.Action;
50
import org.netbeans.junit.NbTestCase;
51
import org.openide.filesystems.FileObject;
52
import org.openide.filesystems.FileSystem;
53
import org.openide.filesystems.Repository;
54
import org.openide.util.ContextAwareAction;
55
import org.openide.util.Lookup;
56
57
/**
58
 *
59
 * @author Jaroslav Tulach
60
 */
61
public class AnnotationActionTest extends NbTestCase implements PropertyChangeListener {
62
    private FileObject folder;
63
    private int changeCounter;
64
    
65
    public AnnotationActionTest(String testName) {
66
        super(testName);
67
    }
68
    
69
    @Override
70
    protected void setUp() throws Exception {
71
        FileSystem fs = Repository.getDefault().getDefaultFileSystem();
72
        folder = fs.findResource("Toolbar/Edit/");
73
        assertNotNull("testing layer is loaded: ", folder);
74
75
        myListenerCalled = 0;
76
        myListenerCounter = 0;
77
        MyAction.last = null;
78
    }
79
    
80
    @Override
81
    protected boolean runInEQ() {
82
        return true;
83
    }
84
85
    public void testIconIsCorrect() throws Exception {
86
        myListenerCounter = 0;
87
        Action a = readAction("testIconIsCorrect.instance");
88
        
89
        assertNotNull("Action created", a);
90
        assertEquals("No myListener called", 0, myListenerCounter);
91
        
92
        Object name = a.getValue(a.NAME);
93
        Object mnem = a.getValue(a.MNEMONIC_KEY);
94
        Object smallIcon = a.getValue(a.SMALL_ICON);
95
        //Object icon = a.getValue(a.ICON)
96
            
97
        assertEquals("Right localized name", "Icon &Name Action", name);
98
        assertEquals("Mnemonic is N", Character.valueOf('N'), mnem);
99
        assertNotNull("small icon present", smallIcon);
100
101
        
102
        assertTrue("Always enabled", a.isEnabled());
103
        a.setEnabled(false);
104
        assertTrue("Still Always enabled", a.isEnabled());
105
106
        a.actionPerformed(new ActionEvent(this, 0, "kuk"));
107
108
        assertEquals("Listener invoked", 1, myListenerCounter);
109
        
110
        
111
        assertEquals("No icon in menu", Boolean.TRUE, a.getValue("noIconInMenu"));
112
    }
113
114
    
115
    private static int myListenerCounter;
116
    private static int myListenerCalled;
117
    @ActionRegistration(category="Testing", displayName="#Always")
118
    @ActionRegistration.Menu(path="Edit", position=30)
119
    @ActionRegistration.Toolbar(path="Edit", position=30)
120
    @ActionRegistration.Shortcut(key="D-X")
121
    private static ActionListener myListener() {
122
        myListenerCounter++;
123
        return new MyListener();
124
    }
125
    
126
    private Action readAction(String fileName) throws Exception {
127
        FileObject fo = this.folder.getFileObject(fileName);
128
        assertNotNull("file " + fileName, fo);
129
        
130
        Object obj = fo.getAttribute("instanceCreate");
131
        assertNotNull("File object has not null instanceCreate attribute", obj);
132
        
133
        if (!(obj instanceof Action)) {
134
            fail("Object needs to be action: " + obj);
135
        }
136
        
137
        return (Action)obj;
138
    }
139
140
    public void propertyChange(PropertyChangeEvent evt) {
141
        changeCounter++;
142
    }
143
144
    private static class MyListener implements ActionListener {
145
        public void actionPerformed(ActionEvent e) {
146
            myListenerCalled++;
147
        }
148
    }
149
    private static class MyAction extends AbstractAction {
150
        static MyAction last;
151
152
        MyAction() {
153
            last = this;
154
            setEnabled(false);
155
        }
156
157
        public void actionPerformed(ActionEvent e) {
158
            myListenerCalled++;
159
        }
160
    }
161
    private static class MyContextAction extends MyAction
162
    implements ContextAwareAction {
163
        static int clones;
164
        static Lookup lkp;
165
166
        public Action createContextAwareInstance(Lookup actionContext) {
167
            clones++;
168
            lkp = actionContext;
169
            return new MyContextAction();
170
        }
171
    }
172
173
}
(-)a/utilities/src/org/netbeans/modules/search/FindInFilesAction.java (+8 lines)
Lines 58-63 Link Here
58
import javax.swing.event.ChangeListener;
58
import javax.swing.event.ChangeListener;
59
import org.openide.DialogDisplayer;
59
import org.openide.DialogDisplayer;
60
import org.openide.NotifyDescriptor;
60
import org.openide.NotifyDescriptor;
61
import org.openide.awt.ActionRegistration;
61
import org.openide.util.ContextAwareAction;
62
import org.openide.util.ContextAwareAction;
62
import org.openide.util.Lookup;
63
import org.openide.util.Lookup;
63
import org.openide.util.Mutex;
64
import org.openide.util.Mutex;
Lines 91-96 Link Here
91
 *
92
 *
92
 * @author  Marian Petras
93
 * @author  Marian Petras
93
 */
94
 */
95
@ActionRegistration(
96
    category="Edit",
97
    iconbase="org/openide/resources/actions/find.gif",
98
    displayName="#LBL_Action_FindInFiles"
99
)
100
@ActionRegistration.Menu(path="Edit", position=2400)
101
@ActionRegistration.Shortcut(key="DS-F")
94
public class FindInFilesAction extends CallableSystemAction
102
public class FindInFilesAction extends CallableSystemAction
95
                               implements ContextAwareAction, ChangeListener {
103
                               implements ContextAwareAction, ChangeListener {
96
104
(-)a/utilities/src/org/netbeans/modules/utilities/Layer.xml (-2 / +4 lines)
Lines 229-235 Link Here
229
        -->
229
        -->
230
        
230
        
231
        <folder name="Edit">
231
        <folder name="Edit">
232
            <file name="org-netbeans-modules-search-FindInFilesAction.instance"/>
232
            <!--<file name="org-netbeans-modules-search-FindInFilesAction.instance"/>-->
233
            <file name="org-netbeans-modules-search-ReplaceInFilesAction.instance"/>
233
            <file name="org-netbeans-modules-search-ReplaceInFilesAction.instance"/>
234
        </folder> <!-- Edit -->
234
        </folder> <!-- Edit -->
235
235
Lines 257-265 Link Here
257
                <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
257
                <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
258
                <attr name="position" intvalue="2300"/>
258
                <attr name="position" intvalue="2300"/>
259
            </file>
259
            </file>
260
            <!--
260
            <file name="org-netbeans-modules-search-FindInFilesAction.instance">
261
            <file name="org-netbeans-modules-search-FindInFilesAction.instance">
261
                <attr name="position" intvalue="2400"/>
262
                <attr name="position" intvalue="2400"/>
262
            </file>
263
            </file>
264
            -->
263
            <file name="org-netbeans-modules-search-ReplaceInFilesAction.instance">
265
            <file name="org-netbeans-modules-search-ReplaceInFilesAction.instance">
264
                <attr name="position" intvalue="2500"/>
266
                <attr name="position" intvalue="2500"/>
265
            </file>
267
            </file>
Lines 302-310 Link Here
302
        <file name="D-O.instance">
304
        <file name="D-O.instance">
303
    	    <attr name="instanceClass" stringvalue="org.netbeans.modules.openfile.OpenFileAction"/>
305
    	    <attr name="instanceClass" stringvalue="org.netbeans.modules.openfile.OpenFileAction"/>
304
	</file>
306
	</file>
305
        -->
306
        <file name="DS-F.shadow">
307
        <file name="DS-F.shadow">
307
    	    <attr name="originalFile" stringvalue="Actions/Edit/org-netbeans-modules-search-FindInFilesAction.instance"/>
308
    	    <attr name="originalFile" stringvalue="Actions/Edit/org-netbeans-modules-search-FindInFilesAction.instance"/>
309
        -->
308
	</file>
310
	</file>
309
        <file name="DS-H.shadow">
311
        <file name="DS-H.shadow">
310
    	    <attr name="originalFile" stringvalue="Actions/Edit/org-netbeans-modules-search-ReplaceInFilesAction.instance"/>
312
    	    <attr name="originalFile" stringvalue="Actions/Edit/org-netbeans-modules-search-ReplaceInFilesAction.instance"/>

Return to bug 149136