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 207227
Collapse All | Expand All

(-)a/apisupport.ant/src/org/netbeans/modules/apisupport/project/resources/layer.xml (+130 lines)
Lines 3-8 Link Here
3
<filesystem>
3
<filesystem>
4
    <folder name="Projects">
4
    <folder name="Projects">
5
        <folder name="org-netbeans-modules-apisupport-project">
5
        <folder name="org-netbeans-modules-apisupport-project">
6
            <folder name="Actions">
7
                <file name="org-netbeans-modules-project-ui-NewFile$WithSubMenu.shadow">
8
                    <attr name="originalFile" stringvalue="Actions/Project/org-netbeans-modules-project-ui-NewFile$WithSubMenu.instance"/>
9
                    <attr name="position" intvalue="100"/>
10
                </file>
11
                <file name="sep-1.instance">
12
                    <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>                 
13
                    <attr name="position" intvalue="200"/>
14
                </file>
15
                <file name="org-netbeans-modules-project-ui-BuildProject.shadow">
16
                    <attr name="originalFile" stringvalue="Actions/Project/org-netbeans-modules-project-ui-BuildProject.instance"/>
17
                    <attr name="position" intvalue="300"/>
18
                </file>
19
                <file name="org-netbeans-modules-project-ui-CleanProject.shadow">
20
                    <attr name="originalFile" stringvalue="Actions/Project/org-netbeans-modules-project-ui-CleanProject.instance"/>
21
                    <attr name="position" intvalue="400"/>
22
                </file>
23
                <file name="org-netbeans-modules-project-ui-RebuildProject.shadow">
24
                    <attr name="originalFile" stringvalue="Actions/Project/org-netbeans-modules-project-ui-RebuildProject.instance"/>
25
                    <attr name="position" intvalue="500"/>
26
                </file>
27
                <file name="sep-2.instance">
28
                    <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>                 
29
                    <attr name="position" intvalue="600"/>
30
                </file>
31
                <file name="org-netbeans-modules-project-ui-RunProject.shadow">
32
                    <attr name="originalFile" stringvalue="Actions/Project/org-netbeans-modules-project-ui-RunProject.instance"/>
33
                    <attr name="position" intvalue="700"/>
34
                </file>
35
                <file name="org-netbeans-modules-debugger-ui-actions-DebugProjectAction.shadow">
36
                    <attr name="originalFile" stringvalue="Actions/Debug/org-netbeans-modules-debugger-ui-actions-DebugProjectAction.instance"/>
37
                    <attr name="position" intvalue="800"/>
38
                </file>
39
                <file name="org-netbeans-modules-apisupport-project-ui-NbModuleUnitTestAction.instance">
40
                    <attr name="instanceCreate" methodvalue="org.netbeans.modules.apisupport.project.ui.ModuleActions$ActionFactory.unitTestAction"/>
41
                    <attr name="position" intvalue="1000"/>
42
                </file>
43
                <file name="sep-3.instance">
44
                    <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>                 
45
                    <attr name="position" intvalue="1100"/>
46
                </file>
47
                <file name="org-netbeans-modules-apisupport-project-ui-CheckBundleAction.instance">
48
                    <attr name="instanceCreate" methodvalue="org.netbeans.modules.apisupport.project.ui.ModuleActions$ActionFactory.checkBundleAction"/>
49
                    <attr name="position" intvalue="1200"/>
50
                </file>
51
                <file name="sep-4.instance">
52
                    <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>                 
53
                    <attr name="position" intvalue="1300"/>
54
                </file>
55
                <file name="org-netbeans-modules-apisupport-project-ui-ReloadAction.instance">
56
                    <attr name="instanceCreate" methodvalue="org.netbeans.modules.apisupport.project.ui.ModuleActions$ActionFactory.reloadAction"/>
57
                    <attr name="position" intvalue="1400"/>
58
                </file>
59
                <file name="org-netbeans-modules-apisupport-project-ui-ReloadInIdeAction.instance">
60
                    <attr name="instanceCreate" methodvalue="org.netbeans.modules.apisupport.project.ui.ModuleActions$ActionFactory.reloadInIdeAction"/>
61
                    <attr name="position" intvalue="1500"/>
62
                </file>
63
                <file name="org-netbeans-modules-apisupport-project-ui-CreateNbmAction.instance">
64
                    <attr name="instanceCreate" methodvalue="org.netbeans.modules.apisupport.project.ui.ModuleActions$ActionFactory.createNbmAction"/>
65
                    <attr name="position" intvalue="1600"/>
66
                </file>
67
                <file name="sep-5.instance">
68
                    <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>                 
69
                    <attr name="position" intvalue="1700"/>
70
                </file>
71
                <file name="org-netbeans-modules-project-ui-JavadocProject.shadow">
72
                    <attr name="originalFile" stringvalue="Actions/Project/org-netbeans-modules-project-ui-JavadocProject.instance"/>
73
                    <attr name="position" intvalue="1800"/>
74
                </file>
75
                <file name="org-netbeans-modules-apisupport-project-ui-ArchAction.instance">
76
                    <attr name="instanceCreate" methodvalue="org.netbeans.modules.apisupport.project.ui.ModuleActions$ActionFactory.archAction"/>
77
                    <attr name="position" intvalue="1900"/>
78
                </file>
79
                <file name="sep-6.instance">
80
                    <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>                 
81
                    <attr name="position" intvalue="2000"/>
82
                </file>
83
                <file name="org-netbeans-modules-project-ui-SetMainProject.shadow">
84
                    <attr name="originalFile" stringvalue="Actions/Project/org-netbeans-modules-project-ui-SetMainProject.instance"/>
85
                    <attr name="position" intvalue="2100"/>
86
                </file>
87
                <file name="org-netbeans-modules-project-ui-OpenSubprojects.shadow">
88
                    <attr name="originalFile" stringvalue="Actions/Project/org-netbeans-modules-project-ui-OpenSubprojects.instance"/>
89
                    <attr name="position" intvalue="2200"/>
90
                </file>
91
                <file name="org-netbeans-modules-project-ui-CloseProject.shadow">
92
                    <attr name="originalFile" stringvalue="Actions/Project/org-netbeans-modules-project-ui-CloseProject.instance"/>
93
                    <attr name="position" intvalue="2300"/>
94
                </file>
95
                <file name="sep-7.instance">
96
                    <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>                 
97
                    <attr name="position" intvalue="2400"/>
98
                </file>
99
                <file name="org-netbeans-modules-project-ui-RenameProject.shadow">
100
                    <attr name="originalFile" stringvalue="Actions/Project/org-netbeans-modules-project-ui-RenameProject.instance"/>
101
                    <attr name="position" intvalue="2500"/>
102
                </file>
103
                <file name="org-netbeans-modules-project-ui-MoveProject.shadow">
104
                    <attr name="originalFile" stringvalue="Actions/Project/org-netbeans-modules-project-ui-MoveProject.instance"/>
105
                    <attr name="position" intvalue="2600"/>
106
                </file>
107
                <file name="org-netbeans-modules-project-ui-CopyProject.shadow">
108
                    <attr name="originalFile" stringvalue="Actions/Project/org-netbeans-modules-project-ui-CopyProject.instance"/>
109
                    <attr name="position" intvalue="2700"/>
110
                </file>
111
                <file name="org-netbeans-modules-project-ui-DeleteProject.shadow">
112
                    <attr name="originalFile" stringvalue="Actions/Project/org-netbeans-modules-project-ui-DeleteProject.instance"/>
113
                    <attr name="position" intvalue="2800"/>
114
                </file>
115
                <file name="sep-8.instance">
116
                    <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>                 
117
                    <attr name="position" intvalue="2900"/>
118
                </file>
119
                <file name="org-openide-actions-FindAction.shadow">
120
                    <attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-FindAction.instance"/>
121
                    <attr name="position" intvalue="3000"/>
122
                </file>
123
                <file name="general.shadow">
124
                    <attr name="originalFile" stringvalue="Projects/Actions"/>
125
                    <attr name="position" intvalue="3100"/>
126
                </file>
127
                <file name="sep-9.instance">
128
                    <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
129
                    <attr name="position" intvalue="3200"/>
130
                </file>
131
                <file name="org-netbeans-modules-project-ui-CustomizeProject.shadow">
132
                    <attr name="originalFile" stringvalue="Actions/Project/org-netbeans-modules-project-ui-CustomizeProject.instance"/>
133
                    <attr name="position" intvalue="3300"/>
134
                </file>
135
            </folder>
6
            <folder name="Customizer">
136
            <folder name="Customizer">
7
                <file name="Formatting.instance">
137
                <file name="Formatting.instance">
8
                    <attr name="instanceOf" stringvalue="org.netbeans.spi.project.ui.support.ProjectCustomizer$CompositeCategoryProvider"/>
138
                    <attr name="instanceOf" stringvalue="org.netbeans.spi.project.ui.support.ProjectCustomizer$CompositeCategoryProvider"/>
(-)a/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/ModuleActions.java (-182 / +269 lines)
Lines 44-50 Link Here
44
44
45
package org.netbeans.modules.apisupport.project.ui;
45
package org.netbeans.modules.apisupport.project.ui;
46
46
47
import java.awt.event.ActionEvent;
48
import java.io.IOException;
47
import java.io.IOException;
49
import java.util.ArrayList;
48
import java.util.ArrayList;
50
import java.util.Arrays;
49
import java.util.Arrays;
Lines 60-66 Link Here
60
import java.util.Set;
59
import java.util.Set;
61
import java.util.regex.Pattern;
60
import java.util.regex.Pattern;
62
import javax.lang.model.element.TypeElement;
61
import javax.lang.model.element.TypeElement;
63
import javax.swing.AbstractAction;
64
import javax.swing.Action;
62
import javax.swing.Action;
65
import org.apache.tools.ant.module.api.support.ActionUtils;
63
import org.apache.tools.ant.module.api.support.ActionUtils;
66
import org.netbeans.api.annotations.common.CheckForNull;
64
import org.netbeans.api.annotations.common.CheckForNull;
Lines 70-75 Link Here
70
import org.netbeans.api.java.project.runner.JavaRunner;
68
import org.netbeans.api.java.project.runner.JavaRunner;
71
import org.netbeans.api.java.source.ElementHandle;
69
import org.netbeans.api.java.source.ElementHandle;
72
import org.netbeans.api.java.source.SourceUtils;
70
import org.netbeans.api.java.source.SourceUtils;
71
import org.netbeans.api.project.Project;
73
import org.netbeans.api.project.ProjectManager;
72
import org.netbeans.api.project.ProjectManager;
74
import org.netbeans.modules.apisupport.project.NbModuleProject;
73
import org.netbeans.modules.apisupport.project.NbModuleProject;
75
import org.netbeans.modules.apisupport.project.NbModuleType;
74
import org.netbeans.modules.apisupport.project.NbModuleType;
Lines 88-98 Link Here
88
import org.netbeans.spi.project.support.ant.GeneratedFilesHelper;
87
import org.netbeans.spi.project.support.ant.GeneratedFilesHelper;
89
import org.netbeans.spi.project.ui.support.CommonProjectActions;
88
import org.netbeans.spi.project.ui.support.CommonProjectActions;
90
import org.netbeans.spi.project.ui.support.DefaultProjectOperations;
89
import org.netbeans.spi.project.ui.support.DefaultProjectOperations;
90
import org.netbeans.spi.project.ui.support.ProjectActionPerformer;
91
import org.netbeans.spi.project.ui.support.ProjectSensitiveActions;
91
import org.netbeans.spi.project.ui.support.ProjectSensitiveActions;
92
import org.openide.DialogDisplayer;
92
import org.openide.DialogDisplayer;
93
import org.openide.ErrorManager;
93
import org.openide.ErrorManager;
94
import org.openide.NotifyDescriptor;
94
import org.openide.NotifyDescriptor;
95
import org.openide.actions.FindAction;
95
import org.openide.awt.DynamicMenuContent;
96
import org.openide.filesystems.FileObject;
96
import org.openide.filesystems.FileObject;
97
import org.openide.filesystems.FileUtil;
97
import org.openide.filesystems.FileUtil;
98
import org.openide.util.Exceptions;
98
import org.openide.util.Exceptions;
Lines 102-108 Link Here
102
import org.openide.util.RequestProcessor;
102
import org.openide.util.RequestProcessor;
103
import org.openide.util.Task;
103
import org.openide.util.Task;
104
import org.openide.util.Utilities;
104
import org.openide.util.Utilities;
105
import org.openide.util.actions.SystemAction;
105
import org.openide.util.lookup.Lookups;
106
106
107
public final class ModuleActions implements ActionProvider, ExecProject {
107
public final class ModuleActions implements ActionProvider, ExecProject {
108
    static final String TEST_USERDIR_LOCK_PROP_NAME = "run.args.ide";    // NOI18N
108
    static final String TEST_USERDIR_LOCK_PROP_NAME = "run.args.ide";    // NOI18N
Lines 115-120 Link Here
115
115
116
    private static final RequestProcessor RP = new RequestProcessor(ModuleActions.class);
116
    private static final RequestProcessor RP = new RequestProcessor(ModuleActions.class);
117
117
118
    final public static class ActionFactory {
119
        public static Action unitTestAction() {
120
            Action a = ProjectSensitiveActions.projectSensitiveAction(new ProjectActionPerformer() {
121
122
                @Override
123
                public boolean enable(Project project) {
124
                    if (!(project instanceof NbModuleProject)) return false;
125
                    if (!((NbModuleProject)project).supportedTestTypes().contains("unit")) return false; // NOI18N
126
                    
127
                    ActionProvider ap = project.getLookup().lookup(ActionProvider.class);
128
                    if (ap == null)  return false;
129
                    
130
                    return ap.isActionEnabled(ActionProvider.COMMAND_TEST, Lookups.singleton(project));
131
                }
132
133
                @Override
134
                public void perform(Project project) {
135
                    assert project != null;
136
                    
137
                    ActionProvider ap = project.getLookup().lookup(ActionProvider.class);
138
                    if (ap != null) {
139
                        ap.invokeAction(ActionProvider.COMMAND_TEST, Lookups.singleton(project));
140
                    }
141
                }
142
            }, NbBundle.getMessage(ModuleActions.class, "ACTION_test"), null); // NOi18N
143
            
144
            a.putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true);
145
            
146
            return a;
147
        }
148
        
149
        public static Action checkBundleAction() {
150
            final Action[] as = new Action[1];
151
            Action a = ProjectSensitiveActions.projectSensitiveAction(new ProjectActionPerformer() {
152
153
                @Override
154
                public boolean enable(Project project) {
155
                    if (!(project instanceof NbModuleProject)) return false;
156
                    
157
                    NbModuleProject nProject = (NbModuleProject)project;
158
                    
159
                    if (as[0] != null)  {
160
                        as[0].putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, nProject.getModuleType() != NbModuleType.NETBEANS_ORG);
161
                    }
162
                    
163
                    return findMonitorXml(nProject) != null && 
164
                           nProject.getPathWithinNetBeansOrg() != null;
165
                }
166
167
                @Override
168
                public void perform(Project project) {
169
                    assert project != null;
170
                    assert project instanceof NbModuleProject;
171
                    
172
                    Properties props = new Properties();
173
                    
174
                    NbModuleProject nProject = (NbModuleProject)project;
175
                    props.put("modules", nProject.getPathWithinNetBeansOrg()); // NOI18N
176
                    props.put("fixedmodules", ""); // NOI18N
177
                    try {
178
                        ActionUtils.runTarget(findMonitorXml(nProject), new String[] {"check-bundle-usage"}, props); // NOI18N
179
                    } catch (IOException e) {
180
                        Util.err.notify(e);
181
                    }
182
                }
183
                
184
                private FileObject findMonitorXml(NbModuleProject project) {
185
                    return project.getNbrootFileObject("nbbuild/monitor.xml"); // NOI18N
186
                }
187
            }, NbBundle.getMessage(ModuleActions.class, "ACTION_unused_bundle_keys"), null);
188
            
189
            as[0] = a;            
190
            return a;
191
        }
192
        
193
        public static Action reloadAction() {
194
            Action a = ProjectSensitiveActions.projectSensitiveAction(new ProjectActionPerformer() {
195
196
                @Override
197
                public boolean enable(Project project) {
198
                    if (!(project instanceof NbModuleProject)) return false;
199
                    
200
                    NbModuleProject nProject = (NbModuleProject)project;
201
                    
202
                    if (findBuildXml(nProject) == null) {
203
                        return false;
204
                    }
205
                    if (Boolean.parseBoolean(nProject.evaluator().getProperty("is.autoload")) || Boolean.parseBoolean(nProject.evaluator().getProperty("is.eager"))) { // NOI18N
206
                        return false; // #86395
207
                    }
208
                    return nProject.getTestUserDirLockFile().isFile();
209
                }
210
211
                @Override
212
                public void perform(Project project) {
213
                    assert project != null;
214
                    assert project instanceof NbModuleProject;
215
                    
216
                    NbModuleProject nProject = (NbModuleProject)project;
217
                    
218
                    if (!verifySufficientlyNewHarness(nProject)) {
219
                        return;
220
                    }
221
                    
222
                    try {
223
                        ActionUtils.runTarget(findBuildXml(nProject), new String[]{"reload"}, null);
224
                    } catch (IOException e) {
225
                        Util.err.notify(e);
226
                    }
227
                }
228
            }, NbBundle.getMessage(ModuleActions.class, "ACTION_reload"), null);
229
            
230
            return a;
231
        }
232
    
233
        public static Action reloadInIdeAction() {
234
            Action a = ProjectSensitiveActions.projectSensitiveAction(new ProjectActionPerformer() {
235
236
                @Override
237
                public boolean enable(Project project) {
238
                    if (!(project instanceof NbModuleProject)) return false;
239
                    
240
                    NbModuleProject nProject = (NbModuleProject)project;
241
                    if (findBuildXml(nProject) == null) {
242
                        return false;
243
                    }
244
                    if (Boolean.parseBoolean(nProject.evaluator().getProperty("is.autoload")) || Boolean.parseBoolean(nProject.evaluator().getProperty("is.eager"))) { // NOI18N
245
                        return false; // #86395
246
                    }
247
                    NbModuleType type = nProject.getModuleType();
248
                    if (type == NbModuleType.NETBEANS_ORG) {
249
                        return true;
250
                    } else if (type == NbModuleType.STANDALONE) {
251
                        NbPlatform p = nProject.getPlatform(false);
252
                        return p != null && p.isDefault();
253
                    } else {
254
                        assert type == NbModuleType.SUITE_COMPONENT : type;
255
                        try {
256
                            SuiteProject suite = SuiteUtils.findSuite(project);
257
                            if (suite == null) {
258
                                return false;
259
                            }
260
                            NbPlatform p = suite.getPlatform(false);
261
                            if (/* #67148 */p == null || !p.isDefault()) {
262
                                return false;
263
                            }
264
                            return SuiteProperties.getArrayProperty(suite.getEvaluator(), SuiteProperties.ENABLED_CLUSTERS_PROPERTY).length == 0 &&
265
                                    SuiteProperties.getArrayProperty(suite.getEvaluator(), SuiteProperties.DISABLED_CLUSTERS_PROPERTY).length == 0 &&
266
                                    SuiteProperties.getArrayProperty(suite.getEvaluator(), SuiteProperties.DISABLED_MODULES_PROPERTY).length == 0;
267
                        } catch (IOException e) {
268
                            Util.err.notify(ErrorManager.INFORMATIONAL, e);
269
                            return false;
270
                        }
271
                    }
272
                }
273
274
                @Override
275
                public void perform(Project project) {
276
                    assert project != null;
277
                    assert project instanceof NbModuleProject;
278
                    
279
                    NbModuleProject nProject = (NbModuleProject)project;
280
                    
281
                    if (!verifySufficientlyNewHarness(nProject)) {
282
                        return;
283
                    }
284
                    if (ModuleUISettings.getDefault().getConfirmReloadInIDE()) {
285
                        NotifyDescriptor d = new NotifyDescriptor.Confirmation(
286
                                NbBundle.getMessage(ModuleActions.class, "LBL_reload_in_ide_confirm"),
287
                                NbBundle.getMessage(ModuleActions.class, "LBL_reload_in_ide_confirm_title"),
288
                                NotifyDescriptor.OK_CANCEL_OPTION);
289
                        if (DialogDisplayer.getDefault().notify(d) != NotifyDescriptor.OK_OPTION) {
290
                            return;
291
                        }
292
                        ModuleUISettings.getDefault().setConfirmReloadInIDE(false); // do not ask again
293
                    }
294
                    try {
295
                        ActionUtils.runTarget(findBuildXml(nProject), new String[]{"reload-in-ide"}, null);
296
                    } catch (IOException e) {
297
                        Util.err.notify(e);
298
                    }
299
                }
300
            }, NbBundle.getMessage(ModuleActions.class, "ACTION_reload_in_ide"), null);
301
            
302
            return a;
303
        }
304
        
305
        public static Action createNbmAction() {
306
            Action a = ProjectSensitiveActions.projectSensitiveAction(new ProjectActionPerformer() {
307
                @Override
308
                public boolean enable(Project project) {
309
                    if (!(project instanceof NbModuleProject)) return false;
310
                    
311
                    return findBuildXml((NbModuleProject)project) != null;
312
                }
313
314
                @Override
315
                public void perform(Project project) {
316
                    assert project != null;
317
                    assert project instanceof NbModuleProject;
318
                    
319
                    NbModuleProject nProject = (NbModuleProject)project;
320
                    
321
                    if (!verifySufficientlyNewHarness(nProject)) {
322
                        return;
323
                    }
324
                    try {
325
                        ActionUtils.runTarget(findBuildXml(nProject), new String[]{"nbm"}, null);
326
                    } catch (IOException e) {
327
                        Util.err.notify(e);
328
                    }
329
                }
330
            }, NbBundle.getMessage(ModuleActions.class, "ACTION_nbm"), null);
331
            return a;
332
        }
333
        
334
        public static Action archAction() {
335
            Action a = ProjectSensitiveActions.projectSensitiveAction(new ProjectActionPerformer() {
336
                @Override
337
                public boolean enable(Project project) {
338
                    if (!(project instanceof NbModuleProject)) return false;
339
                    
340
                    return findBuildXml((NbModuleProject)project) != null;
341
                }
342
343
                @Override
344
                public void perform(Project project) {
345
                    assert project != null;
346
                    assert project instanceof NbModuleProject;
347
                    
348
                    final NbModuleProject nProject = (NbModuleProject)project;
349
                    
350
                    if (!verifySufficientlyNewHarness(nProject)) {
351
                        return;
352
                    }
353
                    ProjectManager.mutex().writeAccess(new Mutex.Action<Void>() {
354
                        public Void run() {
355
                            String prop = "javadoc.arch"; // NOI18N
356
                            if (nProject.evaluator().getProperty(prop) == null) {
357
                                // User has not yet configured an arch desc. Assume we should just do it for them.
358
                                EditableProperties props = nProject.getHelper().getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
359
                                props.setProperty(prop, "${basedir}/arch.xml"); // NOI18N
360
                                nProject.getHelper().putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, props);
361
                                try {
362
                                    ProjectManager.getDefault().saveProject(nProject);
363
                                } catch (IOException e) {
364
                                    Util.err.notify(e);
365
                                }
366
                            }
367
                            return null;
368
                        }
369
                    });
370
                    try {
371
                        ActionUtils.runTarget(findBuildXml(nProject), new String[] {"arch-nb"}, null); // NOI18N
372
                    } catch (IOException e) {
373
                        Util.err.notify(e);
374
                    }
375
                }
376
            }, NbBundle.getMessage(ModuleActions.class, "ACTION_arch"), null);
377
            
378
            return a;
379
        }
380
    }
381
    
118
    @Override
382
    @Override
119
    public Task execute(String... args) throws IOException {
383
    public Task execute(String... args) throws IOException {
120
        StringBuilder sb = new StringBuilder();
384
        StringBuilder sb = new StringBuilder();
Lines 128-175 Link Here
128
    }
392
    }
129
    
393
    
130
    static Action[] getProjectActions(NbModuleProject project) {
394
    static Action[] getProjectActions(NbModuleProject project) {
131
        List<Action> actions = new ArrayList<Action>();
395
         return CommonProjectActions.forType("org-netbeans-modules-apisupport-project");
132
        actions.add(CommonProjectActions.newFileAction());
133
        actions.add(null);
134
        actions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_BUILD, NbBundle.getMessage(ModuleActions.class, "ACTION_build"), null));
135
        actions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_REBUILD, NbBundle.getMessage(ModuleActions.class, "ACTION_rebuild"), null));
136
        actions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_CLEAN, NbBundle.getMessage(ModuleActions.class, "ACTION_clean"), null));
137
        actions.add(null);
138
        actions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_RUN, NbBundle.getMessage(ModuleActions.class, "ACTION_run"), null));
139
        actions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_DEBUG, NbBundle.getMessage(ModuleActions.class, "ACTION_debug"), null));
140
        actions.addAll(Utilities.actionsForPath("Projects/Profiler_Actions_temporary")); //NOI18N
141
        if (project.supportedTestTypes().contains("unit")) { // NOI18N
142
            actions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_TEST, NbBundle.getMessage(ModuleActions.class, "ACTION_test"), null));
143
        }
144
        actions.add(null);
145
        boolean isNetBeansOrg = project.getModuleType() == NbModuleType.NETBEANS_ORG;
146
        if (isNetBeansOrg) {
147
            actions.add(createCheckBundleAction(project, NbBundle.getMessage(ModuleActions.class, "ACTION_unused_bundle_keys")));
148
            actions.add(null);
149
        }
150
        actions.add(createReloadAction(project, new String[] {"reload"}, NbBundle.getMessage(ModuleActions.class, "ACTION_reload"), false));
151
        actions.add(createReloadAction(project, new String[] {"reload-in-ide"}, NbBundle.getMessage(ModuleActions.class, "ACTION_reload_in_ide"), true));
152
        actions.add(createSimpleAction(project, new String[] {"nbm"}, NbBundle.getMessage(ModuleActions.class, "ACTION_nbm")));
153
        actions.add(null);
154
        actions.add(ProjectSensitiveActions.projectCommandAction(JavaProjectConstants.COMMAND_JAVADOC, NbBundle.getMessage(ModuleActions.class, "ACTION_javadoc"), null));
155
        actions.add(createArchAction(project));
156
        actions.add(null);
157
        actions.add(CommonProjectActions.setAsMainProjectAction());
158
        actions.add(CommonProjectActions.openSubprojectsAction());
159
        actions.add(CommonProjectActions.closeProjectAction());
160
        actions.add(null);
161
        actions.add(CommonProjectActions.renameProjectAction());
162
        actions.add(CommonProjectActions.moveProjectAction());
163
        actions.add(CommonProjectActions.copyProjectAction());
164
        actions.add(CommonProjectActions.deleteProjectAction());
165
        
166
        actions.add(null);
167
        actions.add(SystemAction.get(FindAction.class));
168
        // Honor #57874 contract:
169
        actions.addAll(Utilities.actionsForPath("Projects/Actions")); // NOI18N
170
        actions.add(null);
171
        actions.add(CommonProjectActions.customizeProjectAction());
172
        return actions.toArray(new Action[actions.size()]);
173
    }
396
    }
174
    
397
    
175
    private final NbModuleProject project;
398
    private final NbModuleProject project;
Lines 634-773 Link Here
634
857
635
        return false;
858
        return false;
636
    }
859
    }
637
    
638
    private static Action createSimpleAction(final NbModuleProject project, final String[] targetNames, String displayName) {
639
        return new AbstractAction(displayName) {
640
            public @Override boolean isEnabled() {
641
                return findBuildXml(project) != null;
642
            }
643
            public void actionPerformed(ActionEvent ignore) {
644
                if (!verifySufficientlyNewHarness(project)) {
645
                    return;
646
                }
647
                try {
648
                    ActionUtils.runTarget(findBuildXml(project), targetNames, null);
649
                } catch (IOException e) {
650
                    Util.err.notify(e);
651
                }
652
            }
653
        };
654
    }
655
    
656
    private static Action createCheckBundleAction(final NbModuleProject project, String displayName) {
657
        return new AbstractAction(displayName) {
658
            public @Override boolean isEnabled() {
659
                return findMonitorXml() != null && project.getPathWithinNetBeansOrg() != null;
660
            }
661
            public void actionPerformed(ActionEvent ignore) {
662
                Properties props = new Properties();
663
                props.put("modules", project.getPathWithinNetBeansOrg()); // NOI18N
664
                props.put("fixedmodules", ""); // NOI18N
665
                try {
666
                    ActionUtils.runTarget(findMonitorXml(), new String[] {"check-bundle-usage"}, props); // NOI18N
667
                } catch (IOException e) {
668
                    Util.err.notify(e);
669
                }
670
            }
671
            private FileObject findMonitorXml() {
672
                return project.getNbrootFileObject("nbbuild/monitor.xml"); // NOI18N
673
            }
674
        };
675
    }
676
    
677
    private static Action createReloadAction(final NbModuleProject project, final String[] targetNames, String displayName, final boolean inIDE) {
678
        return new AbstractAction(displayName) {
679
            public @Override boolean isEnabled() {
680
                if (findBuildXml(project) == null) {
681
                    return false;
682
                }
683
                if (Boolean.parseBoolean(project.evaluator().getProperty("is.autoload")) || Boolean.parseBoolean(project.evaluator().getProperty("is.eager"))) { // NOI18N
684
                    return false; // #86395
685
                }
686
                if (!inIDE) {
687
                    return project.getTestUserDirLockFile().isFile();
688
                }
689
                NbModuleType type = project.getModuleType();
690
                if (type == NbModuleType.NETBEANS_ORG) {
691
                    return true;
692
                } else if (type == NbModuleType.STANDALONE) {
693
                    NbPlatform p = project.getPlatform(false);
694
                    return p != null && p.isDefault();
695
                } else {
696
                    assert type == NbModuleType.SUITE_COMPONENT : type;
697
                    try {
698
                        SuiteProject suite = SuiteUtils.findSuite(project);
699
                        if (suite == null) {
700
                            return false;
701
                        }
702
                        NbPlatform p = suite.getPlatform(false);
703
                        if (/* #67148 */p == null || !p.isDefault()) {
704
                            return false;
705
                        }
706
                        return SuiteProperties.getArrayProperty(suite.getEvaluator(), SuiteProperties.ENABLED_CLUSTERS_PROPERTY).length == 0 &&
707
                                SuiteProperties.getArrayProperty(suite.getEvaluator(), SuiteProperties.DISABLED_CLUSTERS_PROPERTY).length == 0 &&
708
                                SuiteProperties.getArrayProperty(suite.getEvaluator(), SuiteProperties.DISABLED_MODULES_PROPERTY).length == 0;
709
                    } catch (IOException e) {
710
                        Util.err.notify(ErrorManager.INFORMATIONAL, e);
711
                        return false;
712
                    }
713
                }
714
            }
715
            public void actionPerformed(ActionEvent ignore) {
716
                if (!verifySufficientlyNewHarness(project)) {
717
                    return;
718
                }
719
                if (inIDE && ModuleUISettings.getDefault().getConfirmReloadInIDE()) {
720
                    NotifyDescriptor d = new NotifyDescriptor.Confirmation(
721
                            NbBundle.getMessage(ModuleActions.class, "LBL_reload_in_ide_confirm"),
722
                            NbBundle.getMessage(ModuleActions.class, "LBL_reload_in_ide_confirm_title"),
723
                            NotifyDescriptor.OK_CANCEL_OPTION);
724
                    if (DialogDisplayer.getDefault().notify(d) != NotifyDescriptor.OK_OPTION) {
725
                        return;
726
                    }
727
                    ModuleUISettings.getDefault().setConfirmReloadInIDE(false); // do not ask again
728
                }
729
                try {
730
                    ActionUtils.runTarget(findBuildXml(project), targetNames, null);
731
                } catch (IOException e) {
732
                    Util.err.notify(e);
733
                }
734
            }
735
        };
736
    }
737
    
738
    private static Action createArchAction(final NbModuleProject project) {
739
        return new AbstractAction(NbBundle.getMessage(ModuleActions.class, "ACTION_arch")) {
740
            public @Override boolean isEnabled() {
741
                return findBuildXml(project) != null;
742
            }
743
            public void actionPerformed(ActionEvent ignore) {
744
                if (!verifySufficientlyNewHarness(project)) {
745
                    return;
746
                }
747
                ProjectManager.mutex().writeAccess(new Mutex.Action<Void>() {
748
                    public Void run() {
749
                        String prop = "javadoc.arch"; // NOI18N
750
                        if (project.evaluator().getProperty(prop) == null) {
751
                            // User has not yet configured an arch desc. Assume we should just do it for them.
752
                            EditableProperties props = project.getHelper().getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
753
                            props.setProperty(prop, "${basedir}/arch.xml"); // NOI18N
754
                            project.getHelper().putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, props);
755
                            try {
756
                                ProjectManager.getDefault().saveProject(project);
757
                            } catch (IOException e) {
758
                                Util.err.notify(e);
759
                            }
760
                        }
761
                        return null;
762
                    }
763
                });
764
                try {
765
                    ActionUtils.runTarget(findBuildXml(project), new String[] {"arch-nb"}, null); // NOI18N
766
                } catch (IOException e) {
767
                    Util.err.notify(e);
768
                }
769
            }
770
        };
771
    }
772
    
773
}
860
}

Return to bug 207227