org.openide.actions.OpenAction Java Examples

The following examples show how to use org.openide.actions.OpenAction. 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: XMLViewActions.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
protected Collection getPossibleActions () {
    Collection actions = new Vector(2);
    
    // XXX #48712 heuristics: enable open action only if tree editor installed
    boolean visualEditorInstalled = false;
    Lookup lookup = Lookup.getDefault();
    Lookup.Template t = new Lookup.Template(ModuleInfo.class);
    Iterator it = lookup.lookup(t).allInstances().iterator();
    while (it.hasNext()) {
        ModuleInfo next = (ModuleInfo) it.next();
        if (next.getCodeNameBase().equals("org.netbeans.modules.xml.tree") && next.isEnabled()) {  // NOI18N
            visualEditorInstalled = true;
            break;
        }
    }
    if (visualEditorInstalled) {                
        actions.add (SystemAction.get (OpenAction.class));
    }
    actions.add (SystemAction.get (ViewAction.class));
    return actions;
}
 
Example #2
Source File: JaxWsNode.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
    public Action[] getActions(boolean context) {
        ArrayList<Action> actions = new ArrayList<Action>(Arrays.asList(
                SystemAction.get(OpenAction.class),
//                SystemAction.get(JaxWsRefreshAction.class),
//                null,
                SystemAction.get(AddOperationAction.class),
                null,
                SystemAction.get(WsTesterPageAction.class),
//                null,
                SystemAction.get(WSEditAttributesAction.class),
                SystemAction.get(ConfigureHandlerAction.class),
//                null,
//                SystemAction.get(JaxWsGenWSDLAction.class),
//                null,
//                SystemAction.get(ConvertToRestAction.class),
                null,
                SystemAction.get(DeleteAction.class),
                null,
                SystemAction.get(PropertiesAction.class)));
        addFromLayers(actions, "WebServices/Services/Actions");
        return actions.toArray(new Action[actions.size()]);
    }
 
Example #3
Source File: AnnotationProviderTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Gets default system actions. Overrides superclass method. */
protected SystemAction[] defaultActions() {
    return new SystemAction[] {
        SystemAction.get(OpenAction.class),
        SystemAction.get (FileSystemAction.class),
        null,
        SystemAction.get(CutAction.class),
        SystemAction.get(CopyAction.class),
        SystemAction.get(PasteAction.class),
        null,
        SystemAction.get(DeleteAction.class),
        SystemAction.get(RenameAction.class),
        null,
        SystemAction.get(SaveAsTemplateAction.class),
        null,
        SystemAction.get(ToolsAction.class),
        SystemAction.get(PropertiesAction.class),
    };
}
 
Example #4
Source File: JaxWsClientNode.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Action[] getActions(boolean context) {
    ArrayList<Action> actions = new ArrayList<Action>(Arrays.asList(
        SystemAction.get(OpenAction.class),
        SystemAction.get(JaxWsRefreshAction.class),
        null,
        SystemAction.get(WSEditAttributesAction.class),
        null,
        SystemAction.get(ConfigureHandlerAction.class),
        null,
        SystemAction.get(DeleteAction.class),
        null,
        SystemAction.get(PropertiesAction.class)));
    addFromLayers(actions, "WebServices/Clients/Actions");
    return actions.toArray(new Action[actions.size()]);
}
 
Example #5
Source File: JaxWsNode.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Action[] getActions(boolean context) {
    //DataObject dobj = getCookie(DataObject.class);
    ArrayList<Action> actions = new ArrayList<Action>(Arrays.asList(
            SystemAction.get(OpenAction.class),
            SystemAction.get(JaxWsRefreshAction.class),
            null,
            SystemAction.get(AddOperationAction.class),
            null,
            SystemAction.get(WsTesterPageAction.class),
            null,
            SystemAction.get(WSEditAttributesAction.class),
            null,
            SystemAction.get(ConfigureHandlerAction.class),
            null,
            SystemAction.get(JaxWsGenWSDLAction.class),
            null,
            SystemAction.get(ConvertToRestAction.class),
            null,
            SystemAction.get(DeleteAction.class),
            null,
            SystemAction.get(PropertiesAction.class)));
    addFromLayers(actions, "WebServices/Services/Actions");
    return actions.toArray(new Action[actions.size()]);
}
 
Example #6
Source File: EarDataNodeTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testGetActions() throws Exception {
    File ddFile = new File(getWorkDir(), "application.xml");
    String ddContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
            "<application version=\"1.4\" xmlns=\"http://java.sun.com/xml/ns/j2ee\" " +
            "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
            "xsi:schemaLocation=\"http://java.sun.com/xml/ns/j2ee " +
            "http://java.sun.com/xml/ns/j2ee/application_1_4.xsd\">" +
            "</application>";
    EarDataNodeTest.dump(ddFile, ddContent);
    FileObject fo = FileUtil.toFileObject(ddFile);
    EarDataObject edo = (EarDataObject) DataObject.find(fo);
    Action[] action = edo.getNodeDelegate().getActions(false);
    for (int i = 0; i < action.length; i++) {
        assertFalse("OpenAction is not present yet", action[i] instanceof OpenAction);
    }
}
 
Example #7
Source File: FolderInstanceTaskOrderTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testRunImmediatelly() throws Exception {
    String[] names = {
        "folder/"
    };
    FileSystem lfs = TestUtilHid.createLocalFileSystem(getWorkDir(), names);
    FileObject folder = lfs.findResource("folder");
    DataFolder f = DataFolder.findFolder(folder);

    InstanceDataObject.create(f, null, SaveAction.class);

    err.info("Creating InvCheckFolderInstance");
    RunImmediatelly instances = new RunImmediatelly(f);
    err.info("Computing result");
    List computed = (List)instances.instanceCreate();
    assertEquals("One action", 1, computed.size());

    InstanceDataObject.create(f, null, OpenAction.class);
    computed = (List)instances.instanceCreate();
    err.info("Result is here: " + computed);
    assertEquals("Two actions", 2, computed.size());
}
 
Example #8
Source File: PropertiesLocaleNode.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Lazily initialize set of node's actions.
 * Overrides superclass method.
 *
 * @return array of actions for this node
 */
@Override
protected SystemAction[] createActions () {
    return new SystemAction[] {
        SystemAction.get(EditAction.class),
        SystemAction.get(OpenAction.class),
        null,
        SystemAction.get(CutAction.class),
        SystemAction.get(CopyAction.class),
        SystemAction.get(PasteAction.class),
        null,
        SystemAction.get(DeleteAction.class),
        SystemAction.get(LangRenameAction.class),
        null,
        SystemAction.get(NewAction.class),
        SystemAction.get(SaveAsTemplateAction.class),
        null,
        SystemAction.get(FileSystemAction.class),
        null,
        SystemAction.get(ToolsAction.class),
        SystemAction.get(PropertiesAction.class)
    };
}
 
Example #9
Source File: EntityNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Action[] getActions(boolean context) {
    Collection<? extends Node> nodes = Utilities.actionsGlobalContext().lookup(new Lookup.Template<Node>(Node.class)).allInstances();
    List<SystemAction> list = new ArrayList<SystemAction>();
    list.add(SystemAction.get(OpenAction.class));
    if (nodes.size() == 1) {
        list.add(null);
        list.add(SystemAction.get(AddActionGroup.class));
        list.add(null);
        list.add(SystemAction.get(GoToSourceActionGroup.class));
    }
    return list.toArray(new SystemAction[0]);
}
 
Example #10
Source File: CMPFieldNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Action[] getActions(boolean context) {
        return new Action[] {
            SystemAction.get(OpenAction.class),
            null,
        //TODO: RETOUCHE
//            RefactoringActionsFactory.safeDeleteAction().createContextAwareInstance(Utilities.actionsGlobalContext())
        };
    }
 
Example #11
Source File: CMRFieldNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Action[] getActions(boolean context) {
    return new SystemAction[] {
        SystemAction.get(OpenAction.class),
                null,
                SystemAction.get(DeleteAction.class),
    };
}
 
Example #12
Source File: FormDataNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Action[] getActions(boolean context) {
    Action[] javaActions = super.getActions(context);
    Action[] formActions = new Action[javaActions.length+2];
    formActions[0] = SystemAction.get(OpenAction.class);
    formActions[1] = SystemAction.get(EditAction.class);
    formActions[2] = null;
    // Skipping the first (e.g. Open) action
    System.arraycopy(javaActions, 1, formActions, 3, javaActions.length-1);
    return formActions;
}
 
Example #13
Source File: HttpMethodNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Action[] getActions(boolean context) {
    return new SystemAction[] {
        SystemAction.get(OpenAction.class),
        SystemAction.get(TestResourceUriAction.class),
        null,
        //SystemAction.get(DeleteAction.class),
        //null,
        SystemAction.get(PropertiesAction.class),
    };
}
 
Example #14
Source File: PhadhailNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Action[] getActions(boolean context) {
    return new Action[] {
        SystemAction.get(OpenAction.class),
        SystemAction.get(SaveAction.class),
        null,
        SystemAction.get(NewAction.class),
        null,
        SystemAction.get(DeleteAction.class),
        SystemAction.get(RenameAction.class),
        SystemAction.get(ToolsAction.class),
    };
}
 
Example #15
Source File: SessionNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Action[] getActions(boolean context) {
    int nodesCount = Utilities.actionsGlobalContext().lookup(new Lookup.Template<Node>(Node.class)).allInstances().size();
    List<SystemAction> list = new ArrayList<SystemAction>();
    list.add(SystemAction.get(OpenAction.class));
    if (nodesCount == 1) {
        list.add(null);
        list.add(SystemAction.get(AddActionGroup.class));
        list.add(null);
        list.add(SystemAction.get(GoToSourceActionGroup.class));
    }
    return list.toArray(new SystemAction[list.size()]);
}
 
Example #16
Source File: VersionNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Action[] getActions(boolean context) {
    Artifact artifact = RepositoryUtil.createArtifact(record);
    List<Action> actions = new ArrayList<Action>();
    actions.add(new ShowArtifactAction(record));
    actions.add(new AddAsDependencyAction(artifact));
    actions.add(CommonArtifactActions.createFindUsages(artifact));
    actions.add(CommonArtifactActions.createViewJavadocAction(artifact));
    actions.add(OpenAction.get(OpenAction.class));
    actions.add(new DownloadAction(artifact));
    actions.add(new DownloadAction(artifact, false));
    actions.add(new DownloadAction(artifact, true));
    actions.add(CopyAction.get(CopyAction.class));
    return actions.toArray(new Action[actions.size()]);
}
 
Example #17
Source File: ActionFilterNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static boolean isOpenAction(final Action action) {
    if (action == null) {
        return false;
    }
    if (action instanceof OpenAction || action instanceof EditAction) {
        return true;
    }
    if ("org.netbeans.api.actions.Openable".equals(action.getValue("type"))) { //NOI18N
        return true;
    }
    return false;
}
 
Example #18
Source File: PhadhailLook.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Action[] getActions(Phadhail ph, Lookup e) {
    return new Action[] {
        SystemAction.get(OpenAction.class),
        SystemAction.get(SaveAction.class),
        null,
        SystemAction.get(NewAction.class),
        null,
        SystemAction.get(DeleteAction.class),
        SystemAction.get(RenameAction.class),
        //SystemAction.get(ToolsAction.class),
    };
}
 
Example #19
Source File: JaxWsClientNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
    public Action[] getActions(boolean context) {
        ArrayList<Action> actions = new ArrayList<Action>(Arrays.asList(
            SystemAction.get(OpenAction.class),
            SystemAction.get(JaxWsRefreshAction.class),
//            null,
            SystemAction.get(WSEditAttributesAction.class),
            SystemAction.get(ConfigureHandlerAction.class),
            null,
            SystemAction.get(DeleteAction.class),
            null,
            SystemAction.get(PropertiesAction.class)));
        addFromLayers(actions, "WebServices/Clients/Actions");
        return actions.toArray(new Action[actions.size()]);
    }
 
Example #20
Source File: MenuBarFastFromAWTTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected void setUp() throws Exception {
    FileObject fo = FileUtil.createFolder(
        FileUtil.getConfigRoot(),
        "Folder" + getName()
    );
    df = DataFolder.findFolder(fo);
    
    FileObject fileMenu = df.getPrimaryFile().createFolder("File");
    DataFolder fileM = DataFolder.findFolder(fileMenu);
    InstanceDataObject.create(fileM, null, OpenAction.class);
    
    mb = new MenuBar(df);
    mb.waitFinished();
}
 
Example #21
Source File: JspNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void initialize () {
    setIconBaseWithExtension(getIconBase());
    setDefaultAction (SystemAction.get (OpenAction.class));

    if (isTagFile())
            setShortDescription (NbBundle.getMessage(JspNode.class, "LBL_tagNodeShortDesc")); //NOI18N
    else
            setShortDescription (NbBundle.getMessage(JspNode.class, "LBL_jspNodeShortDesc")); //NOI18N
}
 
Example #22
Source File: FolderInstanceTaskOrderTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@RandomlyFails // NB-Core-Build #3078
public void testReorderingOfExecutionTasksIsOK() throws Exception {
    String[] names = {
        "folder/"
    };
    FileSystem lfs = TestUtilHid.createLocalFileSystem(getWorkDir(), names);
    FileObject folder = lfs.findResource("folder");
    DataFolder f = DataFolder.findFolder(folder);

    InstanceDataObject.create(f, null, SaveAction.class);

    err.info("Creating InvCheckFolderInstance");
    ReorderTasksCheck instances = new ReorderTasksCheck(f);
    err.info("Computing result");
    instances.waitFinished(500);
    assertEquals("One task scheduled", 1, instances.tasks.size());

    InstanceDataObject.create(f, null, OpenAction.class);

    instances.waitFinished(500);
    assertEquals("Two tasks scheduled", 2, instances.tasks.size());

    // run in reverse order
    instances.tasks.get(1).run();
    instances.tasks.get(0).run();

    List computed = (List)instances.instanceCreate();
    err.info("Result is here: " + computed);
    assertEquals("Two actions", 2, computed.size());
}
 
Example #23
Source File: ActionFilterNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static boolean isOpenAction(final Action action) {
    if (action == null) {
        return false;
    }
    if (action instanceof OpenAction || action instanceof EditAction) {
        return true;
    }
    if ("org.netbeans.api.actions.Openable".equals(action.getValue("type"))) { //NOI18N
        return true;
    }
    return false;
}
 
Example #24
Source File: BookmarkNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Action[] getActions(boolean context) {
    return new Action[] {
        SystemAction.get(OpenAction.class),
        SystemAction.get(RenameAction.class),
        SystemAction.get(DeleteAction.class)
    };
}
 
Example #25
Source File: RestServiceNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Action[] getActions(boolean context) {
    return new SystemAction[] {
        SystemAction.get(OpenAction.class),
        SystemAction.get(TestResourceUriAction.class),
        null,
        //SystemAction.get(DeleteAction.class),
        //null,
        SystemAction.get(PropertiesAction.class),
    };
}
 
Example #26
Source File: SubResourceLocatorNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Action[] getActions(boolean context) {
    return new SystemAction[] {
        SystemAction.get(OpenAction.class),
        null,
        //SystemAction.get(DeleteAction.class),
        //null,
        SystemAction.get(PropertiesAction.class),
    };
}
 
Example #27
Source File: ImageDataObject.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Constructs image node. */
public ImageNode(ImageDataObject obj) {
    super(obj, Children.LEAF);
    //setIconBase(IMAGE_ICON_BASE);
    setIconBaseWithExtension(IMAGE_ICON_BASE);
    setDefaultAction (SystemAction.get (OpenAction.class));
}
 
Example #28
Source File: FolderNodeFactory.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Action createContextAwareInstance(Lookup selection) {
    final Project[] projects = selection.lookupAll(Project.class).toArray(new Project[0]);
    return new AbstractAction(SystemAction.get(OpenAction.class).getName()) {
        public void actionPerformed(ActionEvent ev) {
            OpenProjects.getDefault().open(projects, false);
        }
        @Override
        public boolean isEnabled() {
            return !Arrays.asList(OpenProjects.getDefault().getOpenProjects()).containsAll(Arrays.asList(projects));
        }
    };
}
 
Example #29
Source File: BreadCrumbsNodeImpl.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public Action getPreferredAction() {
    return OpenAction.get(OpenAction.class);
}
 
Example #30
Source File: MessageNode.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public Action getPreferredAction() {
    return SystemAction.get(OpenAction.class);
}