org.openide.actions.FileSystemAction Java Examples

The following examples show how to use org.openide.actions.FileSystemAction. 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: MultiModuleNodeFactory.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NonNull
@Override
public Action[] getActions(final boolean context) {
    if (context) {
        return super.getActions(context);
    } else {
        if (actions == null) {
            actions = new Action[] {
                CommonProjectActions.newFileAction(),
                null,
                SystemAction.get(FindAction.class),
                null,
                SystemAction.get(PasteAction.class ),
                null,
                SystemAction.get(FileSystemAction.class ),
                null,
                SystemAction.get(ToolsAction.class )
            };
        }
        return actions;
    }
}
 
Example #2
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 #3
Source File: LookupNode.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public final Action[] getActions(boolean context) {
    if (isUISettingCategoryNode()) {
        return new Action[0];
    } else {
        return new Action[] {
            SystemAction.get(FileSystemAction.class),
            null,
            SystemAction.get(PasteAction.class),
            null,
            SystemAction.get(MoveUpAction.class),
            SystemAction.get(MoveDownAction.class),
            SystemAction.get(ReorderAction.class),
            null,
            SystemAction.get(NewTemplateAction.class),
            null,
            SystemAction.get(ToolsAction.class),
            SystemAction.get(PropertiesAction.class),
        };
    }
}
 
Example #4
Source File: ClientSideProjectLogicalView.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Action[] getActions(boolean context) {
    List<Action> actions = new ArrayList<Action>();
    actions.add(CommonProjectActions.newFileAction());
    actions.add(null);
    actions.add(SystemAction.get(FindAction.class));
    actions.add(null);
    actions.add(SystemAction.get(FileSystemAction.class));
    actions.add(null);
    actions.add(SystemAction.get(PasteAction.class));
    actions.add(null);
    actions.add(SystemAction.get(ToolsAction.class));
    actions.add(null);
    actions.add(CommonProjectActions.customizeProjectAction());
    return actions.toArray(new Action[actions.size()]);
}
 
Example #5
Source File: DocBaseNodeFactory.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Action[] getActions(boolean context) {
    if (actions == null) {
        actions = new Action[9];
        actions[0] = CommonProjectActions.newFileAction();
        actions[1] = null;
        actions[2] = SystemAction.get(FindAction.class);
        actions[3] = null;
        actions[4] = SystemAction.get(PasteAction.class);
        actions[5] = null;
        actions[6] = SystemAction.get(FileSystemAction.class);
        actions[7] = null;
        actions[8] = ProjectUISupport.createPreselectPropertiesAction(project, "Sources", null); //NOI18N
    }
    return actions;
}
 
Example #6
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 #7
Source File: MVCNode.java    From cakephp3-netbeans with Apache License 2.0 5 votes vote down vote up
@Override
@NbBundle.Messages({
    "LBL_DownloadCommand=Download...",
    "LBL_UploadCommand=Upload...",
    "LBL_SyncCommand=Synchronize..."
})
public Action[] getActions(boolean context) {
    List<Action> actions = new ArrayList<>();
    actions.add(CommonProjectActions.newFileAction());
    actions.add(null);
    actions.add(FileSensitiveActions.fileCommandAction("dowonload", Bundle.LBL_DownloadCommand(), null));
    actions.add(FileSensitiveActions.fileCommandAction("upload", Bundle.LBL_UploadCommand(), null));
    actions.add(FileSensitiveActions.fileCommandAction("synchronize", Bundle.LBL_SyncCommand(), null));
    actions.add(null);
    actions.add(SystemAction.get(FileSystemAction.class));
    actions.add(null);
    actions.add(SystemAction.get(FindAction.class));
    actions.add(null);
    actions.add(SystemAction.get(PasteAction.class));
    actions.add(null);
    actions.add(SystemAction.get(ToolsAction.class));
    actions.add(null);
    // customizer - open sources for source node, phpunit for test node
    Action customizeAction;
    customizeAction = CommonProjectActions.customizeProjectAction();
    actions.add(customizeAction);
    return actions.toArray(new Action[actions.size()]);
}
 
Example #8
Source File: TreeRootNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Action[] getActions( boolean context ) {
    
    if ( !context ) {
        if ( actions == null ) {                
            // Copy actions and leave out the PropertiesAction and FileSystemAction.                
            Action superActions[] = super.getActions( context );            
            List<Action> actionList = new ArrayList<Action>(superActions.length);
            
            for( int i = 0; i < superActions.length; i++ ) {
                if ( superActions[i] instanceof FileSystemAction ) {
                    actionList.add (null); // insert separator and new action
                    actionList.add (testPackageAction);
                    actionList.addAll((List<Action>) org.openide.util.Utilities.actionsForPath("Projects/package/Actions"));
                }
                
                actionList.add( superActions[i] );                                                  
            }

            actions = new Action[ actionList.size() ];
            actionList.toArray( actions );
        }
        return actions;
    }
    else {
        return super.getActions( context );
    }
}
 
Example #9
Source File: AbstractMMFilter.java    From netbeans-mmd-plugin with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
@MayContainNull
public Action[] getActions(final boolean context) {
  if (!context) {
    if (actions == null) {
      // Copy actions and leave out the PropertiesAction and FileSystemAction.                
      Action superActions[] = super.getActions(context);
      List<Action> actionList = new ArrayList<Action>(superActions.length);

      for (int i = 0; i < superActions.length; i++) {
        if ((i <= superActions.length - 2) && superActions[i] == null && (superActions[i + 1] instanceof PropertiesAction)) {
          i++;
          continue;
        }
        else if (superActions[i] instanceof PropertiesAction) {
          continue;
        }
        else if (superActions[i] instanceof FileSystemAction) {
          actionList.add(null); // insert separator and new action
          actionList.addAll((List<Action>) org.openide.util.Utilities.actionsForPath("Projects/package/Actions"));
        }

        actionList.add(superActions[i]);
      }

      actions = new Action[actionList.size()];
      actionList.toArray(actions);
    }
    return actions;
  }
  else {
    return super.getActions(context);
  }
}
 
Example #10
Source File: MergeDialogComponent.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static JPopupMenu createPopupMenu(MergePanel panel) {
    JPopupMenu popup = new JPopupMenuPlus();
    SystemAction[] actions = panel.getSystemActions();
    for (int i = 0; i < actions.length; i++) {
        if (actions[i] == null) {
            popup.addSeparator();
        } else if (actions[i] instanceof CallableSystemAction) {
            popup.add(((CallableSystemAction)actions[i]).getPopupPresenter());
            //add FileSystemAction to pop-up menu
        } else if (actions[i] instanceof FileSystemAction) {
            popup.add(((FileSystemAction)actions[i]).getPopupPresenter());
        }
    }
    return popup;
}
 
Example #11
Source File: AbstractMultiViewElement.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public javax.swing.Action[] getActions() {
    Action[] actions = callback.createDefaultActions();
    SystemAction fsAction = SystemAction.get(FileSystemAction.class);
    if (!Arrays.asList(actions).contains(fsAction)) {
        Action[] newActions = new Action[actions.length+1];
        System.arraycopy(actions, 0, newActions, 0, actions.length);
        newActions[actions.length] = fsAction;
        actions = newActions;
    }
    return actions;
}
 
Example #12
Source File: SrcNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Action[] getActions(boolean context) {
    List<Action> actions = new ArrayList<>();
    actions.add(CommonProjectActions.newFileAction());
    actions.add(null);
    if (!isTest) {
        actions.add(FileSensitiveActions.fileCommandAction(DownloadCommand.ID, DownloadCommand.DISPLAY_NAME, null));
        actions.add(FileSensitiveActions.fileCommandAction(UploadCommand.ID, UploadCommand.DISPLAY_NAME, null));
        actions.add(FileSensitiveActions.fileCommandAction(SyncCommand.ID, SyncCommand.DISPLAY_NAME, null));
        actions.add(null);
    } else {
        // #252010
        if (project.getTestRoots().getRoots().length > 1) {
            actions.add(ProjectSensitiveActions.projectCommandAction(RunTestsCommand.ID, RunTestsCommand.DISPLAY_NAME, null));
            actions.add(null);
        }
    }
    actions.add(SystemAction.get(FileSystemAction.class));
    actions.add(null);
    actions.add(SystemAction.get(FindAction.class));
    actions.add(null);
    actions.add(SystemAction.get(PasteAction.class));
    actions.add(null);
    actions.add(SystemAction.get(ToolsAction.class));
    actions.add(null);
    // customizer - open sources for source node, testing for test node
    Action customizeAction = null;
    if (isTest) {
        customizeAction = new PhpLogicalViewProvider.CustomizeProjectAction(project, CompositePanelProviderImpl.TESTING);
    } else {
        customizeAction = CommonProjectActions.customizeProjectAction();
    }
    if (customizeAction != null) {
        actions.add(customizeAction);
    }
    return actions.toArray(new Action[actions.size()]);
}
 
Example #13
Source File: ServerResourceNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Action[] getActions( boolean context ) {
    return new Action[] {
        CommonProjectActions.newFileAction(),
        null,
        SystemAction.get(FileSystemAction.class),
        null,
        SystemAction.get(FindAction.class),
        null,
        SystemAction.get(PasteAction.class),
    };
}
 
Example #14
Source File: FormDesignerTC.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Action[] getActions() {
    Action[] actions = super.getActions();
    SystemAction fsAction = SystemAction.get(FileSystemAction.class);
    if (!Arrays.asList(actions).contains(fsAction)) {
        Action[] newActions = new Action[actions.length+1];
        System.arraycopy(actions, 0, newActions, 0, actions.length);
        newActions[actions.length] = fsAction;
        actions = newActions;
    }
    return actions;
}
 
Example #15
Source File: PackageView.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Creates actions for package root.
 * @return the array of {@link Action}s
 */
@NonNull
static Action[] createRootNodeActions() {
    return new Action[] {
        CommonProjectActions.newFileAction(),
        null,
        SystemAction.get( FindAction.class ),
        null,
        SystemAction.get( PasteAction.class ),
        null,
        SystemAction.get( FileSystemAction.class ),
        null,
        SystemAction.get( ToolsAction.class ),
    };
}
 
Example #16
Source File: PackageViewChildren.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Messages("LBL_CompilePackage_Action=Compile Package")
@Override
public Action[] getActions( boolean context ) {
    
    if ( !context ) {
        if ( actions == null ) {                
            // Copy actions and leave out the PropertiesAction and FileSystemAction.                
            Action superActions[] = super.getActions( context );            
            List<Action> actionList = new ArrayList<Action>(superActions.length);
            
            for( int i = 0; i < superActions.length; i++ ) {

                if ( (i <= superActions.length - 2) && superActions[ i ] == null && superActions[i + 1] instanceof PropertiesAction ) {
                    i ++;
                    continue;
                }
                else if ( superActions[i] instanceof PropertiesAction ) {
                    continue;
                }
                else if ( superActions[i] instanceof FileSystemAction ) {
                    actionList.add (null); // insert separator and new action
                    actionList.add (FileSensitiveActions.fileCommandAction(ActionProvider.COMMAND_COMPILE_SINGLE, LBL_CompilePackage_Action(), null));                           
                    actionList.add (testPackageAction);
                    actionList.addAll((List<Action>) org.openide.util.Utilities.actionsForPath("Projects/package/Actions"));
                }
                
                actionList.add( superActions[i] );                                                  
            }

            actions = new Action[ actionList.size() ];
            actionList.toArray( actions );
        }
        return actions;
    }
    else {
        return super.getActions( context );
    }
}
 
Example #17
Source File: DefaultOpenFileImpl.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void openInEDT(FileObject fileObject, DataObject dataObject, int line) {
    Class<? extends Node.Cookie> cookieClass;        
    Node.Cookie cookie;
    
    if ((line != -1)
        && (   ((cookie = dataObject.getCookie(cookieClass = EditorCookie.Observable.class)) != null)
            || ((cookie = dataObject.getCookie(cookieClass = EditorCookie.class)) != null) )) {
        boolean ret = openByCookie(cookie, cookieClass, line);
        if (!ret) {
            showNotPlainFileWarning(fileObject);
        }
        return;
    } 
                        
    /* try to open the object using the default action */
    Node dataNode = dataObject.getNodeDelegate();        
    Action action = dataNode.getPreferredAction();
    if ((action != null)
            && !(action instanceof FileSystemAction)
            && !(action instanceof ToolsAction)) {
        if (log.isLoggable(FINEST)) {
            log.log(FINEST, " - using preferred action "            //NOI18N
                    + "(\"{0}\" - {1}) for opening the file",       //NOI18N
                    new Object[]{action.getValue(Action.NAME),
                        action.getClass().getName()});
        }

        if (action instanceof ContextAwareAction) {
            action = ((ContextAwareAction) action)
              .createContextAwareInstance(dataNode.getLookup());
            if (log.isLoggable(FINEST)) {
                log.finest("    - it is a ContextAwareAction");     //NOI18N
                log.log(FINEST, "    - using a context-aware "      //NOI18N
                        + "instance instead (\"{0}\" - {1})",       //NOI18N
                        new Object[]{action.getValue(Action.NAME),
                            action.getClass().getName()});
            }
        }

        log.finest("   - will call action.actionPerformed(...)");   //NOI18N
        final Action a = action;
        final Node n = dataNode;
        WindowManager.getDefault().invokeWhenUIReady(new Runnable() {

            @Override
            public void run() {
                a.actionPerformed(new ActionEvent(n, 0, ""));
            }
        });
        return;
    }             
    String fileName = fileObject.getNameExt();
    /* Try to grab an editor/open/edit/view cookie and open the object: */
    StatusDisplayer.getDefault().setStatusText(
            NbBundle.getMessage(DefaultOpenFileImpl.class,
                                "MSG_opening",                      //NOI18N
                                fileName));
    boolean success = openDataObjectByCookie(dataObject, line);
    if (success) {
        return;
    }        
    if (fileObject.isFolder() || FileUtil.isArchiveFile(fileObject)) {
        // select it in explorer:
        final Node node = dataObject.getNodeDelegate();
        if (node != null) {
            WindowManager.getDefault().invokeWhenUIReady(new Runnable() {

                @Override
                public void run() {
                    NodeOperation.getDefault().explore(node);
                }
            });
            return;
        }
    }
    showNotPlainFileWarning(fileObject);
}