Java Code Examples for org.openide.util.actions.SystemAction

The following examples show how to use org.openide.util.actions.SystemAction. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: netbeans   Source File: ServerNode.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Action[] getActions(boolean context) {
    if ( context ) {
        return super.getActions(context);
    } else {
        return new SystemAction[] {
            SystemAction.get(CreateDatabaseAction.class),
            SystemAction.get(StartAction.class),
            SystemAction.get(StopAction.class),
            SystemAction.get(ConnectServerAction.class),
            SystemAction.get(DisconnectServerAction.class),
            SystemAction.get(DeleteAction.class),
            SystemAction.get(RefreshServerAction.class),
            SystemAction.get(AdministerAction.class),
            SystemAction.get(PropertiesAction.class)
        };
    }
}
 
Example 2
Source Project: netbeans   Source File: LayoutNode.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public javax.swing.Action[] getActions(boolean context) {
    if (systemActions == null) { // from AbstractNode
        java.util.List<javax.swing.Action> actions = new ArrayList<javax.swing.Action>(10);

        if (!layoutSupport.getMetaContainer().isReadOnly()) {
            actions.add(SystemAction.get(SelectLayoutAction.class));
            actions.add(null);
        }

        javax.swing.Action[] superActions = super.getActions(context);
        for (int i=0; i < superActions.length; i++)
            actions.add(superActions[i]);

        systemActions = new SystemAction[actions.size()];
        actions.toArray(systemActions);
    }

    return systemActions;
}
 
Example 3
Source Project: netbeans   Source File: LocalHistoryVCSAnnotator.java    License: Apache License 2.0 6 votes vote down vote up
public Action[] getActions(VCSContext ctx, VCSAnnotator.ActionDestination destination) {
    Lookup context = ctx.getElements();
    List<Action> actions = new ArrayList<Action>();
    if (destination == VCSAnnotator.ActionDestination.MainMenu) {
        actions.add(SystemAction.get(ShowHistoryAction.class));
        actions.add(SystemAction.get(RevertDeletedAction.class));
    } else {
        actions.add(SystemActionBridge.createAction(
                                        SystemAction.get(ShowHistoryAction.class), 
                                        NbBundle.getMessage(ShowHistoryAction.class, "CTL_ShowHistory"), 
                                        context));
        actions.add(SystemActionBridge.createAction(
                                        SystemAction.get(RevertDeletedAction.class), 
                                        NbBundle.getMessage(RevertDeletedAction.class, "CTL_ShowRevertDeleted"),  
                                        context));           
        
    }
    return actions.toArray(new Action[actions.size()]);
}
 
Example 4
Source Project: netbeans   Source File: BridgingServerInstance.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Action[] getActions(boolean context) {
    // replace the action with correct one
    boolean found = false;
    List<Action> freshActions = new ArrayList<Action>();
    Action[] actions = getOriginal().getActions(context);
    for (int i = 0; i < actions.length; i++) {
        if (actions[i] instanceof CustomizerAction) {
            freshActions.add(SystemAction.get(BridgingCustomizerAction.class));
            found = true;
        } else {
            freshActions.add(actions[i]);
        }
    }
    if (!found) {
        freshActions.add(null);
        freshActions.add(SystemAction.get(BridgingCustomizerAction.class));
    }
    return freshActions.toArray(new Action[freshActions.size()]);
}
 
Example 5
Source Project: netbeans   Source File: WildflyWebModuleNode.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Action[] getActions(boolean context) {
    if (getParentNode() instanceof WildflyEarApplicationNode) {
        if (url != null) {
            return new SystemAction[]{
                SystemAction.get(OpenURLAction.class)
            };
        } else {
            return new SystemAction[0];
        }
    } else {
        if (url != null) {
            return new SystemAction[]{
                SystemAction.get(OpenURLAction.class),
                SystemAction.get(StopModuleAction.class),
                SystemAction.get(UndeployModuleAction.class)
            };
        } else {
            return new SystemAction[]{
                SystemAction.get(StartModuleAction.class),
                SystemAction.get(UndeployModuleAction.class)
            };
        }
    }
}
 
Example 6
Source Project: netbeans   Source File: MultiModuleNodeFactory.java    License: 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 7
Source Project: netbeans   Source File: JaxWsNode.java    License: 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 8
Source Project: netbeans   Source File: CreateViewAction.java    License: Apache License 2.0 6 votes vote down vote up
private void perform(final BaseNode node) {
   DatabaseConnection connection = node.getLookup().lookup(DatabaseConnection.class);

   String schemaName = findSchemaWorkingName(node.getLookup());

   try {
       boolean viewsSupported = connection.getConnector().getDriverSpecification(schemaName).areViewsSupported();
       if (!viewsSupported) {
           String message = NbBundle.getMessage (CreateViewAction.class, "MSG_ViewsAreNotSupported", // NOI18N
                   connection.getJDBCConnection().getMetaData().getDatabaseProductName().trim());
           DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(message, NotifyDescriptor.INFORMATION_MESSAGE));
           return;
       }

       Specification spec = connection.getConnector().getDatabaseSpecification();

       boolean viewAdded = AddViewDialog.showDialogAndCreate(spec, schemaName);
       if (viewAdded) {
           SystemAction.get(RefreshAction.class).performAction(new Node[]{node});
       }
   } catch(Exception exc) {
       Logger.getLogger(CreateViewAction.class.getName()).log(Level.INFO, exc.getLocalizedMessage(), exc);
       DbUtilities.reportError(NbBundle.getMessage (CreateViewAction.class, "ERR_UnableToCreateView"), exc.getMessage()); // NOI18N
   }
}
 
Example 9
Source Project: netbeans   Source File: Page.java    License: Apache License 2.0 6 votes vote down vote up
public Action[] getActions(boolean context) {
    if (pageContentModel != null) {
        return pageContentModel.getActions();
    }
    return new SystemAction[]{};
    //        if( pageContentModel != null ){
    //            SystemAction[] pageModelActions = pageContentModel.getActions();
    //            SystemAction[] nodeActions = super.getActions();
    //
    //            if( pageModelActions == null || pageModelActions.length == 0 ){
    //                return nodeActions;
    //            } else if ( nodeActions == null || nodeActions.length == 0 ){
    //                return pageModelActions;
    //            } else {
    //                int size = pageModelActions.length + nodeActions.length;
    //                SystemAction[] sysActions = new SystemAction[size];
    //                System.arraycopy(nodeActions, 0, sysActions, 0, nodeActions.length);
    //                System.arraycopy(pageModelActions, 0, sysActions, nodeActions.length, pageModelActions.length);
    //                return sysActions;
    //            }
    //        } else {
    //            return super.getActions();
    //        }
}
 
Example 10
Source Project: netbeans   Source File: QPopAllAction.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void performContextAction (Node[] nodes) {
    VCSContext ctx = HgUtils.getCurrentContext(nodes);
    final File roots[] = HgUtils.getActionRoots(ctx);
    if (roots == null || roots.length == 0) return;
    final File root = Mercurial.getInstance().getRepositoryRoot(roots[0]);
    
    Utils.post(new Runnable() {
        @Override
        public void run () {
            if (QUtils.isMQEnabledExtension(root)) {
                SystemAction.get(QGoToPatchAction.class).goToPatch(root, null, null);
            }
        }
    });
}
 
Example 11
Source Project: netbeans   Source File: FindSupport.java    License: Apache License 2.0 6 votes vote down vote up
private FindSupport(TopComponent tc) {
    this.tc = tc;
    bar = new FindBar(this);
    ActionMap actionMap = tc.getActionMap();
    CallbackSystemAction a = SystemAction.get(org.openide.actions.FindAction.class);
    actionMap.put(a.getActionMapKey(), new FindAction(true));
    actionMap.put(FIND_NEXT_ACTION, new FindAction(true));
    actionMap.put(FIND_PREVIOUS_ACTION, new FindAction(false));
    // Hack ensuring the same shortcuts as editor
    JEditorPane pane = new JEditorPane();
    for (Action action : pane.getEditorKitForContentType("text/x-java").getActions()) { // NOI18N
        Object name = action.getValue(Action.NAME);
        if (FIND_NEXT_ACTION.equals(name) || FIND_PREVIOUS_ACTION.equals(name)) {
            reuseShortcut(action);
        }
    }
    // PENDING the colors below should not be hardcoded
    highlighterAll = new DefaultHighlighter.DefaultHighlightPainter(new Color(255,180,66));
    highlighterCurrent = new DefaultHighlighter.DefaultHighlightPainter(new Color(176,197,227));
    pattern = Pattern.compile("$^"); // NOI18N
}
 
Example 12
Source Project: netbeans   Source File: InstanceNodeDecorator.java    License: Apache License 2.0 6 votes vote down vote up
public Action[] getActions(boolean context) {
    List actions = new ArrayList();
    actions.addAll(Arrays.asList(new Action[] {
                                    SystemAction.get(StartAction.class),
                                    SystemAction.get(DebugAction.class)
    }));
    if (si.isProfileSupported()) {
        actions.add(
                                    SystemAction.get(ProfileAction.class)
        );
    }
    actions.addAll(Arrays.asList(new Action[] {
                                    SystemAction.get(RestartAction.class),
                                    SystemAction.get(StopAction.class),
                                    SystemAction.get(RefreshAction.class),
                                    null,
                                    SystemAction.get(RenameAction.class),
                                    SystemAction.get(RemoveAction.class)
    }));
    actions.addAll(Arrays.asList(getOriginal().getActions(context)));
    actions.add(null);
    actions.add(SystemAction.get(CustomizerAction.class));
    return (Action[])actions.toArray(new Action[actions.size()]);
}
 
Example 13
Source Project: netbeans   Source File: GitUtils.java    License: Apache License 2.0 6 votes vote down vote up
public static void openInVersioningView (Collection<File> files, File repository, ProgressMonitor pm) {
    List<Node> nodes = new LinkedList<Node>();
    for (File file : files) {
        Node node = new AbstractNode(Children.LEAF, Lookups.fixed(file));
        nodes.add(node);
        // this will refresh seen roots
    }
    Git.getInstance().getFileStatusCache().refreshAllRoots(Collections.<File, Collection<File>>singletonMap(repository, files), pm);
    if (!pm.isCanceled()) {
        final VCSContext context = VCSContext.forNodes(nodes.toArray(new Node[nodes.size()]));
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                SystemAction.get(StatusAction.class).performContextAction(context);
            }
        });
    }
}
 
Example 14
Source Project: netbeans   Source File: HudsonJobNode.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Action[] getActions(boolean context) {
    if (job.getColor() == Color.secured) {
        return new Action[] {new LogInAction(job.getInstance())};
    }
    List<Action> actions = new ArrayList<Action>();
    actions.add(SystemAction.get(StartJobAction.class));
    actions.add(new ProjectAssociationAction(job));
    actions.add(null);
    if (job instanceof OpenableInBrowser) {
        actions.add(OpenUrlAction.forOpenable((OpenableInBrowser) job));
    }
    actions.add(new ViewConfigAction(job));
    actions.add(SystemAction.get(PropertiesAction.class));
    return actions.toArray(new Action[actions.size()]);
}
 
Example 15
Source Project: netbeans   Source File: JaxWsClientNode.java    License: 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 16
Source Project: netbeans   Source File: QueryBuilder.java    License: Apache License 2.0 5 votes vote down vote up
/** Called when the selection is removed: disable delete */
void disableDelete() {
    if (!isActivated()) {
        return;
    }
    deleteActionPerformer.setEnabled(false);
    DeleteAction da = SystemAction.get(DeleteAction.class);
    da.setEnabled(false);
}
 
Example 17
Source Project: netbeans   Source File: PullAction.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Void call () throws HgException {
    OutputLogger logger = supp.getLogger();
    topPatch = FetchAction.selectPatch(root);
    if (topPatch != null) {
        supp.setDisplayName(Bundle.MSG_PullAction_popingPatches());
        SystemAction.get(QGoToPatchAction.class).popAllPatches(root, logger);
        supp.setDisplayName(Bundle.MSG_PullAction_pulling());
        logger.output(""); // NOI18N
    }
    if (supp.isCanceled()) {
        return null;
    }
    List<String> list;
    if(type == PullType.LOCAL){
        supp.setDisplayName(Bundle.MSG_PullAction_progress_pullingFromLocal());
        list = HgCommand.doPull(root, revision, branch, logger);
    }else{
        supp.setDisplayName(Bundle.MSG_PullAction_progress_unbundling());
        list = HgCommand.doUnbundle(root, fileToUnbundle, false, logger);
    }
    if (list != null && !list.isEmpty()) {
        annotateChangeSets(HgUtils.replaceHttpPassword(listIncoming), PullAction.class, "MSG_CHANGESETS_TO_PULL", logger); // NOI18N
        handlePulledChangesets(list);
    }

    return null;
}
 
Example 18
Source Project: netbeans   Source File: FormEditor.java    License: Apache License 2.0 5 votes vote down vote up
private void createDefaultComponentActionsList() {
    defaultActions = new LinkedList<Action>();
    defaultActions.add(SystemAction.get(CustomizeEmptySpaceAction.EditSingleGapAction.class));
    defaultActions.add(SystemAction.get(EditContainerAction.class));
    defaultActions.add(SystemAction.get(EditFormAction.class));
    defaultActions.add(SystemAction.get(DefaultRADAction.class));
}
 
Example 19
Source Project: netbeans   Source File: RADComponentNode.java    License: Apache License 2.0 5 votes vote down vote up
private void addLayoutActions(List<Action> actions) {
    if (component.getParentComponent() instanceof RADVisualContainer) {
        actions.add(SystemAction.get(AlignAction.class));
        actions.add(SystemAction.get(SetAnchoringAction.class));
        actions.add(SystemAction.get(SetResizabilityAction.class));
        actions.add(SystemAction.get(ChooseSameSizeAction.class));
        actions.add(SystemAction.get(DefaultSizeAction.class));
        actions.add(SystemAction.get(EncloseAction.class));
        actions.add(SystemAction.get(CustomizeEmptySpaceAction.class));
        actions.add(null);
    }
}
 
Example 20
Source Project: netbeans   Source File: StopBuildingAction.java    License: Apache License 2.0 5 votes vote down vote up
public @Override void stateChanged(ChangeEvent e) {
    final List<BuildExecutionSupport.Item> items = BuildExecutionSupportImpl.getInstance().getRunningItems();

    SwingUtilities.invokeLater(new Runnable() {
        public @Override void run() {
            SystemAction.get(StopBuildingAction.class).setEnabled(items.size() > 0);
        }
    });
}
 
Example 21
Source Project: MikuMikuStudio   Source File: JmeMesh.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public Action[] getActions(boolean context) {
    return new SystemAction[]{
                //                    SystemAction.get(CopyAction.class),
                //                    SystemAction.get(CutAction.class),
                //                    SystemAction.get(PasteAction.class),
                SystemAction.get(DeleteAction.class)
            };
}
 
Example 22
Source Project: netbeans   Source File: ServerResourceNode.java    License: 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 23
Source Project: netbeans   Source File: WildflyManagerNode.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Action[] getActions(boolean context) {
    Action[] newActions = new Action[5];
    newActions[0] = null;
    newActions[1] = (SystemAction.get(ShowAdminToolAction.class));
    newActions[2] = (SystemAction.get(WildflyEditConfigAction.class));
    newActions[3] = (SystemAction.get(OpenServerLogAction.class));
    newActions[4] = (SystemAction.get(KillServerAction.class));
    return newActions;
}
 
Example 24
Source Project: netbeans   Source File: EntityNode.java    License: 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 25
Source Project: netbeans   Source File: JAXBWizardSchemaNode.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void destroy() throws IOException {
    super.destroy();
    // Delete schema
    JAXBDeleteSchemaAction delAction = SystemAction.get(
                                            JAXBDeleteSchemaAction.class);
    delAction.performAction(new Node[] {this});
}
 
Example 26
Source Project: netbeans   Source File: JAXBBindingSupportFileNode.java    License: Apache License 2.0 5 votes vote down vote up
private void initActions() {
    if ( actions == null ) {
        actions = new Action[] {
            SystemAction.get(JAXBWizardOpenXSDIntoEditorAction.class),
            SystemAction.get(JAXBRefreshAction.class)
        };
    }
}
 
Example 27
Source Project: netbeans   Source File: DataLoaderGetActionsTest.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected SystemAction[] defaultActions() {
    return new SystemAction[] {
        SystemAction.get(CutAction.class),
        null,
        SystemAction.get(CopyAction.class),
        null,
        SystemAction.get(DeleteAction.class),
    };
}
 
Example 28
Source Project: BART   Source File: ConfigurationNode.java    License: MIT License 5 votes vote down vote up
@Override
public Action[] getActions(boolean context) {
    Action[] result = new Action[]{
        SystemAction.get(OpenLocalExplorerAction.class),
    };
    return result;
}
 
Example 29
Source Project: netbeans   Source File: ProjectMenuItem.java    License: Apache License 2.0 5 votes vote down vote up
private void addNoVCSMenu (Action[] actions) throws MissingResourceException {
    if (actions != null && actions.length > 0) {
        addSeparator();
        add(createmenuItem(SystemAction.get(PatchAction.class)));
    } else {
        JMenuItem item = new JMenuItem();
        Mnemonics.setLocalizedText(item, NbBundle.getMessage(VersioningMainMenu.class, "LBL_NoneAvailable"));  // NOI18N
        item.setEnabled(false);
        add(item);
    }
}
 
Example 30
Source Project: netbeans   Source File: ContextMenuWarmUpTask.java    License: Apache License 2.0 5 votes vote down vote up
/** Warms up tools action popup menu item. */
private static void warmUpToolsPopupMenuItem() {
    SystemAction toolsAction = SystemAction.get(ToolsAction.class);
    if(toolsAction instanceof ContextAwareAction) {
        // Here is important to create proper lookup
        // to warm up Tools sub actions.
        Lookup lookup = new org.openide.util.lookup.ProxyLookup(
            new Lookup[] {
                // This part of lookup causes warm up of Node (cookie) actions.
                new AbstractNode(Children.LEAF).getLookup(),
                // This part of lookup causes warm up of Callback actions.
                new TopComponent().getLookup()
            }
        );
        
        Action action = ((ContextAwareAction)toolsAction)
                            .createContextAwareInstance(lookup);
        if(action instanceof Presenter.Popup) {
            JMenuItem toolsMenuItem = ((Presenter.Popup)action)
                                            .getPopupPresenter();
            if(toolsMenuItem instanceof Runnable) {
                // This actually makes the warm up.
                // See ToolsAction.Popup impl.
                ((Runnable)toolsMenuItem).run();
            }
        }
    }
}