org.netbeans.spi.project.ActionProvider Java Examples
The following examples show how to use
org.netbeans.spi.project.ActionProvider.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Actions.java From netbeans with Apache License 2.0 | 6 votes |
public static synchronized Action deleteProject() { final Action a = new ProjectAction( ActionProvider.COMMAND_DELETE, NbBundle.getMessage(Actions.class, "LBL_DeleteProjectAction_Name"), null, null ); try { final Action delete = org.openide.awt.Actions.forID("Edit", "org.openide.actions.DeleteAction"); a.putValue(Action.ACCELERATOR_KEY, delete.getValue(Action.ACCELERATOR_KEY)); delete.addPropertyChangeListener(new PropertyChangeListener() { public @Override void propertyChange(PropertyChangeEvent evt) { a.putValue(Action.ACCELERATOR_KEY, delete.getValue(Action.ACCELERATOR_KEY)); } }); } catch (Exception x) { Exceptions.printStackTrace(x); } return a; }
Example #2
Source File: ActiveBrowserAction.java From netbeans with Apache License 2.0 | 6 votes |
public static boolean commandSupported( Project project, String command, Lookup context ) { //We have to look whether the command is supported by the project ActionProvider ap = project.getLookup().lookup(ActionProvider.class); if ( ap != null ) { List<String> commands = Arrays.asList(ap.getSupportedActions()); if ( commands.contains( command ) ) { try { if (context == null || ap.isActionEnabled(command, context)) { //System.err.println("cS: true project=" + project + " command=" + command + " context=" + context); return true; } } catch (IllegalArgumentException x) { Logger.getLogger(ActiveBrowserAction.class.getName()).log(Level.INFO, "#213589: possible race condition in MergedActionProvider", x); } } } //System.err.println("cS: false project=" + project + " command=" + command + " context=" + context); return false; }
Example #3
Source File: J2eeActionsProvider.java From netbeans with Apache License 2.0 | 6 votes |
@Override public boolean isActionEnable(String action, Project project, Lookup lookup) { final String packagingType = project.getLookup().lookup(NbMavenProject.class).getPackagingType(); if ("app-client".equals(packagingType)) { return false; } switch (action) { case ACT_DEBUG: case ACT_RUN: case ACT_PROFILE: //only enable for doc root fileobjects.. return true; case ActionProvider.COMMAND_RUN: case ActionProvider.COMMAND_DEBUG: case ActionProvider.COMMAND_PROFILE: //performance, don't read the xml file to figure enablement.. return true; default: return false; } }
Example #4
Source File: ActionsUtil.java From netbeans with Apache License 2.0 | 6 votes |
/** * Tests whether given command is available on the project and whether * the action as to be enabled in current Context * @param project Project to test * @param command Command for test * @param context Lookup representing current context or null if context * does not matter. */ public static boolean commandSupported( Project project, String command, Lookup context ) { //We have to look whether the command is supported by the project ActionProvider ap = project.getLookup().lookup(ActionProvider.class); if ( ap != null ) { List<String> commands = Arrays.asList(ap.getSupportedActions()); if ( commands.contains( command ) ) { try { if (context == null || ap.isActionEnabled(command, context)) { //System.err.println("cS: true project=" + project + " command=" + command + " context=" + context); return true; } } catch (IllegalArgumentException x) { Logger.getLogger(ActionsUtil.class.getName()).log(Level.INFO, "#213589: possible race condition in MergedActionProvider", x); } } } //System.err.println("cS: false project=" + project + " command=" + command + " context=" + context); return false; }
Example #5
Source File: J2SEActionProviderTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testBuildWithDirtyListFirstTime() throws Exception { // #119777 J2SEProject prj = (J2SEProject) pp; EditableProperties ep = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); ep.put(ProjectProperties.TRACK_FILE_CHANGES, "true"); helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep); // Use a new instance, since the old one will already have a dirty list from setUp(): actionProvider = new J2SEActionProvider(prj, prj.getUpdateHelper()); ep = helper.getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH); ep.put(ProjectProperties.DO_DEPEND, "false"); helper.putProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH, ep); Properties p = new Properties(); MainClassChooser.unitTestingSupport_hasMainMethodResult = true; try { assertEquals("[run]", Arrays.toString(actionProvider.getTargetNames(ActionProvider.COMMAND_RUN, Lookup.EMPTY, p))); assertEquals("{}", p.toString()); assertEquals("[run]", Arrays.toString(actionProvider.getTargetNames(ActionProvider.COMMAND_RUN, Lookup.EMPTY, p))); assertEquals("{includes=nothing whatsoever}", p.toString()); } finally { MainClassChooser.unitTestingSupport_hasMainMethodResult = null; } }
Example #6
Source File: BuildNBMSTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testBuildNBMS() throws Exception { SuiteActions p = (SuiteActions) suite.getLookup().lookup(ActionProvider.class); assertNotNull("Provider is here", p); List l = Arrays.asList(p.getSupportedActions()); assertTrue("We support nbms: " + l, l.contains("nbms")); DialogDisplayerImpl.returnFromNotify(DialogDescriptor.NO_OPTION); ExecutorTask task = p.invokeActionImpl("nbms", suite.getLookup()); assertNotNull("did not even run task", task); task.waitFinished(); FileObject nbmFo = suite.getProjectDirectory().getFileObject("build/updates/org-example-mod1.nbm"); FileObject updatesXml = suite.getProjectDirectory().getFileObject("build/updates/updates.xml"); assertNotNull("Nbm build/updates/org-example-mod1.nbm doesn't exist",nbmFo); assertNotNull("build/updates/updates.xml doesn't exist",updatesXml); }
Example #7
Source File: NbmActionGoalProvider.java From netbeans with Apache License 2.0 | 6 votes |
public @Override NetbeansActionMapping getMappingForAction(String actionName, Project project) { if (RELOAD_TARGET.equals(actionName) && hasNbm(project)) { Project app = MavenNbModuleImpl.findAppProject(project); if (app != null) { return platformDelegate.getMappingForAction(actionName, app); } } if (!ActionProvider.COMMAND_RUN.equals(actionName) && !ActionProvider.COMMAND_DEBUG.equals(actionName) && !ActionProvider.COMMAND_PROFILE.equals(actionName) && !ActionProvider.COMMAND_TEST.equals(actionName) && !NBMRELOAD.equals(actionName)) { return null; } if (isPlatformApp(project)) { return platformDelegate.getMappingForAction(actionName, project); } if (hasNbm(project)) { return ideDelegate.getMappingForAction(actionName, project); } return null; }
Example #8
Source File: JspRunToCursorActionProvider.java From netbeans with Apache License 2.0 | 6 votes |
private static boolean isDebuggableProject(Project p) { ActionProvider actionProvider = (ActionProvider)p.getLookup ().lookup (ActionProvider.class); if (actionProvider == null) return false; String[] sa = actionProvider.getSupportedActions (); int i, k = sa.length; for (i = 0; i < k; i++) { if (ActionProvider.COMMAND_DEBUG.equals (sa [i])) { break; } } if (i == k) { return false; } // check if this action should be enabled return ((ActionProvider) p.getLookup ().lookup ( ActionProvider.class )).isActionEnabled ( ActionProvider.COMMAND_DEBUG, p.getLookup () ); }
Example #9
Source File: RunSeleniumAction.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void actionPerformed(final ActionEvent e) { RP.post(new Runnable() { @Override public void run() { Project p = FileOwnerQuery.getOwner(activatedFOs[0]); if (p == null) { return; } FileSensitiveActions.fileCommandAction(ActionProvider.COMMAND_TEST_SINGLE, Bundle.SeleniumTestFileAction_name(), null).actionPerformed(e); SeleniumTestingProvider provider = SeleniumTestingProviders.getDefault().getSeleniumTestingProvider(p, true); if (provider != null) { provider.runTests(activatedFOs); } } }); }
Example #10
Source File: AbstractOutputHandler.java From netbeans with Apache License 2.0 | 6 votes |
private boolean isProtectedWait(Project proj, RunConfig config) { String action = config.getActionName(); if(action == null || proj == null || !RunUtils.isCompileOnSaveEnabled(proj)) { return false; } switch(action) { case ActionProvider.COMMAND_RUN: case ActionProvider.COMMAND_RUN_SINGLE: case ActionProvider.COMMAND_DEBUG: case ActionProvider.COMMAND_DEBUG_SINGLE: case ActionProviderImpl.COMMAND_DEBUG_MAIN: case ActionProviderImpl.COMMAND_RUN_MAIN: return true; default: return false; } }
Example #11
Source File: CoverageSideBar.java From netbeans with Apache License 2.0 | 6 votes |
private void runAction(String action) { Project project = getProject(); if (project != null) { Lookup lookup = project.getLookup(); if (fileForDocument != null) { try { DataObject dobj = DataObject.find(fileForDocument); lookup = dobj.getLookup(); } catch (DataObjectNotFoundException ex) { Exceptions.printStackTrace(ex); } } ActionProvider provider = project.getLookup().lookup(ActionProvider.class); if (provider != null) { if (provider.isActionEnabled(action, lookup)) { provider.invokeAction(action, lookup); } } } }
Example #12
Source File: AntActions.java From netbeans with Apache License 2.0 | 6 votes |
@Messages({ "LBL_ProfileProject=Profile" }) @ActionID(category="Profile", id="org.netbeans.modules.profiler.actions.ProfileProjectPopup") @ActionRegistration(displayName="#LBL_ProfileProject", lazy=false, asynchronous=true) @ActionReferences({ @ActionReference(path="Projects/org-netbeans-modules-java-j2seproject/Actions", position=1000), @ActionReference(path="Projects/org-netbeans-modules-java-j2semodule/Actions", position=1000), @ActionReference(path="Projects/org-netbeans-modules-apisupport-project/Actions", position=900), @ActionReference(path="Projects/org-netbeans-modules-apisupport-project-suite/Actions", position=1000), @ActionReference(path="Projects/org-netbeans-modules-web-project/Actions", position=1000) }) public static Action profileProjectPopup() { Action delegate = ProjectSensitiveActions.projectSensitiveAction( ProjectSensitivePerformer.profileProject(ActionProvider.COMMAND_PROFILE), NbBundle.getMessage(AntActions.class, "LBL_ProfileProject"), // NOI18N null ); return delegate; }
Example #13
Source File: FileSensitivePerformer.java From netbeans with Apache License 2.0 | 6 votes |
static boolean supportsProfileFile(String command, FileObject file) { Project p = file == null ? null : FileOwnerQuery.getOwner(file); if (p == null) return false; ActionProvider ap = p.getLookup().lookup(ActionProvider.class); try { if (ap != null && contains(ap.getSupportedActions(), command)) { ProjectProfilingSupport ppp = ProjectProfilingSupport.get(p); return ppp.isProfilingSupported() && ppp.isFileObjectSupported(file) && ap.isActionEnabled(command, getContext(file, p, command)); } } catch (IllegalArgumentException e) { // command not supported } return false; }
Example #14
Source File: JavaActionsTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testGetSupportedActions() throws Exception { assertEquals("initially all context-sensitive actions supported", Arrays.asList(new String[] { ActionProvider.COMMAND_COMPILE_SINGLE, ActionProvider.COMMAND_DEBUG, ActionProvider.COMMAND_PROFILE, ActionProvider.COMMAND_RUN_SINGLE, ActionProvider.COMMAND_DEBUG_SINGLE, ActionProvider.COMMAND_PROFILE_SINGLE }), Arrays.asList(ja.getSupportedActions())); /* Not really necessary; once there is a binding, the main ant/freeform Actions will mask this anyway: ja.addBinding(ActionProvider.COMMAND_COMPILE_SINGLE, "target", "prop", "${dir}", null, "relative-path", null); assertEquals("binding a context-sensitive action makes it not be supported any longer", Collections.EMPTY_LIST, Arrays.asList(ja.getSupportedActions())); */ }
Example #15
Source File: BaseActionProviderTest.java From netbeans with Apache License 2.0 | 6 votes |
@Test public void testOverridenGetTargetNames() throws Exception { assertNotNull(ap); final Logger log = Logger.getLogger(ActionProviderSupport.class.getName()); final Level origLevel = log.getLevel(); final MockHandler handler = new MockHandler(); log.setLevel(Level.FINE); log.addHandler(handler); try { SwingUtilities.invokeAndWait(() -> { ap.invokeAction(ActionProvider.COMMAND_CLEAN, Lookup.EMPTY); }); assertEquals("1", handler.props.get("a")); //NOI18N assertEquals("2", handler.props.get("b")); //NOI18N } finally { log.setLevel(origLevel); log.removeHandler(handler); } }
Example #16
Source File: NbAndroidProjectImpl.java From NBANDROID-V2 with Apache License 2.0 | 6 votes |
@Override public Action[] getActions(boolean arg0) { List<Action> projectActions = new ArrayList<>(32); projectActions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_REBUILD, "Clean and Build", null)); projectActions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_CLEAN, "Clean", null)); projectActions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_BUILD, "Buld", null)); projectActions.add(null); projectActions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_RUN, "Run", null)); projectActions.add(ProjectSensitiveActions.projectCommandAction(ActionProvider.COMMAND_DEBUG, "Debug", null)); projectActions.add(selectDeviceProjectAction); projectActions.add(configurationsProjectAction); projectActions.add(null); List<? extends Action> actionsForPath = Utilities.actionsForPath("Android/Projects/Project"); projectActions.addAll(actionsForPath); projectActions.add(CommonProjectActions.closeProjectAction()); projectActions.add(CommonProjectActions.setAsMainProjectAction()); projectActions.add(null); projectActions.addAll(Utilities.actionsForPath("Projects/Actions")); projectActions.add(null); projectActions.add(CommonProjectActions.customizeProjectAction()); return projectActions.toArray(new Action[projectActions.size()]); }
Example #17
Source File: J2SEModularProject.java From netbeans with Apache License 2.0 | 5 votes |
@NonNull private ActionProvider newActionProvider() { return MultiModuleActionProviderBuilder.newInstance( this, getUpdateHelper(), evaluator(), getSourceRoots(), getTestSourceRoots(), cpProvider) .setCompileOnSaveOperationsProvider(() -> { return J2SEModularProjectUtil.isCompileOnSaveEnabled(this) ? EnumSet.of(JavaActionProvider.CompileOnSaveOperation.UPDATE, JavaActionProvider.CompileOnSaveOperation.EXECUTE) : Collections.emptySet(); }) .build(); }
Example #18
Source File: FixActionProvider.java From netbeans with Apache License 2.0 | 5 votes |
private void invokeAction() { ((ActionProvider) getCurrentProject().getLookup ().lookup ( ActionProvider.class )).invokeAction ( JavaProjectConstants.COMMAND_DEBUG_FIX, getLookup () ); }
Example #19
Source File: REPLAction2.java From netbeans with Apache License 2.0 | 5 votes |
@Override public boolean enable(Project project) { if (ShellProjectUtils.findPlatform(project) == null) { return false; } ActionProvider p = project.getLookup().lookup(ActionProvider.class); if (p == null) { return false; } return p.isActionEnabled(ActionProvider.COMMAND_BUILD, Lookups.singleton(project)); }
Example #20
Source File: GroovyActionsRegistration.java From netbeans with Apache License 2.0 | 5 votes |
@Messages("LBL_RunFile_Action=Run File") @ActionID(id = "org.netbeans.modules.groovy.support.GroovyProjectModule.run", category = "Groovy") @ActionRegistration(lazy = false, displayName = "#LBL_RunFile_Action") @ActionReferences(value = { @ActionReference(path = "Loaders/text/x-groovy/Actions", position = 560), @ActionReference(path = "Editors/text/x-groovy/Popup", position = 810, separatorBefore = 800) }) public static Action run() { return FileSensitiveActions.fileCommandAction( ActionProvider.COMMAND_RUN_SINGLE, LBL_RunFile_Action(), null); }
Example #21
Source File: REPLAction2.java From netbeans with Apache License 2.0 | 5 votes |
@NbBundle.Messages({ "ERR_CannotBuildProject=Could not build the project", "ERR_ProjectBuildFailed=Project build failed, please check Output window", }) @Override public void perform(Project project) { ActionProvider p = project.getLookup().lookup(ActionProvider.class); // check whether the is CoS enabled fo the project if (ShellProjectUtils.isCompileOnSave(project)) { doRunShell(project); return; } if (p == null || !p.isActionEnabled(ActionProvider.COMMAND_BUILD, Lookups.singleton(project))) { StatusDisplayer.getDefault().setStatusText(Bundle.ERR_CannotBuildProject()); return; } p.invokeAction(ActionProvider.COMMAND_BUILD, Lookups.fixed(project, new ActionProgress() { @Override protected void started() { // no op } @Override public void finished(boolean success) { if (success) { doRunShell(project); } else { StatusDisplayer.getDefault().setStatusText(Bundle.ERR_ProjectBuildFailed()); } } })); }
Example #22
Source File: GroovyActionsRegistration.java From netbeans with Apache License 2.0 | 5 votes |
@Messages("LBL_TestProject_Action=Test") @ActionID(id = "org.netbeans.modules.groovy.support.GroovyProjectModule.test.project", category = "Groovy") @ActionRegistration(lazy = false, displayName = "#LBL_TestProject_Action") public static Action testProject() { return ProjectSensitiveActions.projectCommandAction( ActionProvider.COMMAND_TEST, LBL_TestProject_Action(), null); }
Example #23
Source File: ModuleOperationsTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testDelete() throws Exception { NbModuleProject project = generateStandaloneModule("module"); project.open(); ActionProvider ap = project.getLookup().lookup(ActionProvider.class); assertNotNull("have an action provider", ap); assertTrue("delete action is enabled", ap.isActionEnabled(ActionProvider.COMMAND_DELETE, null)); FileObject prjDir = project.getProjectDirectory(); FileObject buildXML = prjDir.getFileObject(GeneratedFilesHelper.BUILD_XML_PATH); // build project ActionUtils.runTarget(buildXML, new String[] { "compile" }, null).waitFinished(); assertNotNull("project was build", prjDir.getFileObject("build")); FileObject[] expectedMetadataFiles = { buildXML, prjDir.getFileObject("manifest.mf"), prjDir.getFileObject("nbproject"), }; assertEquals("correct metadata files", Arrays.asList(expectedMetadataFiles), ProjectOperations.getMetadataFiles(project)); FileObject[] expectedDataFiles = { prjDir.getFileObject("src"), prjDir.getFileObject("test"), }; assertEquals("correct data files", Arrays.asList(expectedDataFiles), ProjectOperations.getDataFiles(project)); // It is hard to simulate exact scenario invoked by user. Let's test at least something. ProjectOperations.notifyDeleting(project); prjDir.getFileSystem().refresh(true); assertNull(prjDir.getFileObject("build")); }
Example #24
Source File: CreateBundleAction.java From netbeans with Apache License 2.0 | 5 votes |
private CreateBundleAction( @NonNull final ActionProvider actionProvider, @NonNull final Lookup context) { Parameters.notNull("actionProvider", actionProvider); //NOI18N Parameters.notNull("context", context); //NOI18N this.actionProvider = actionProvider; this.context = context; init(); }
Example #25
Source File: RunFileActionProvider.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void invokeAction(String command, Lookup context) { boolean debug = ActionProvider.COMMAND_DEBUG_SINGLE.equals(command); for (DataObject dataObject : context.lookupAll(DataObject.class)) { File file = FileUtil.toFile(dataObject.getPrimaryFile()); if (file != null) { FileUtils.saveFile(dataObject); runFile(file, debug); } } }
Example #26
Source File: Actions.java From netbeans with Apache License 2.0 | 5 votes |
public static Action runMainProject() { Action a = new MainProjectActionWithHistory( ActionProvider.COMMAND_RUN, NbBundle.getMessage(Actions.class, "LBL_RunMainProjectAction_Name"),null); //NOI18N a.putValue("iconBase","org/netbeans/modules/project/ui/resources/runProject.png"); //NOI18N return a; }
Example #27
Source File: RunJSAction.java From netbeans with Apache License 2.0 | 5 votes |
@Override public Action createContextAwareInstance(Lookup actionContext) { if (!isEnabled()) { return NO_ACTION; } FileObject fo = actionContext.lookup(FileObject.class); if (fo == null) { return NO_ACTION; } if (isEnabledAction(ActionProvider.COMMAND_RUN_SINGLE, fo, actionContext)) { // There's a project's run action already. return NO_ACTION; } return new RunJSAction(fo); }
Example #28
Source File: CommonUtils.java From netbeans with Apache License 2.0 | 5 votes |
/**Get the ActionProvider associated with the project, if any, which "owns" the given file. * * @param fileObject the selected file * @return the ActionProvider associated with the given file, or {@code null} */ public ActionProvider getActionProvider(FileObject fileObject) { Project owner = FileOwnerQuery.getOwner(fileObject); if (owner == null) { // #183586 return null; } return owner.getLookup().lookup(ActionProvider.class); }
Example #29
Source File: CodelessProject.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void invokeAction(String string, Lookup lookup) throws IllegalArgumentException { if (string.equalsIgnoreCase(ActionProvider.COMMAND_DELETE)) { DefaultProjectOperations.performDefaultDeleteOperation(CodelessProject.this); } if (string.equalsIgnoreCase(ActionProvider.COMMAND_COPY)) { DefaultProjectOperations.performDefaultCopyOperation(CodelessProject.this); } }
Example #30
Source File: TestMethodNodeAction.java From netbeans with Apache License 2.0 | 5 votes |
public TestMethodNodeAction(ActionProvider actionProvider, Lookup context, String command, String name) { this.actionProvider = actionProvider; this.context = context; this.command = command; this.name = name; }