org.openide.util.actions.SystemAction Java Examples

The following examples show how to use org.openide.util.actions.SystemAction. 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: GitUtils.java    From netbeans with 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 #2
Source File: InstanceNodeDecorator.java    From netbeans with 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 #3
Source File: BridgingServerInstance.java    From netbeans with 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 #4
Source File: HudsonJobNode.java    From netbeans with 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 #5
Source File: LocalHistoryVCSAnnotator.java    From netbeans with 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 #6
Source File: CreateViewAction.java    From netbeans with 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 #7
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 #8
Source File: FindSupport.java    From netbeans with 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 #9
Source File: LayoutNode.java    From netbeans with 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 #10
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 #11
Source File: ServerNode.java    From netbeans with 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 #12
Source File: Page.java    From netbeans with 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 #13
Source File: WildflyWebModuleNode.java    From netbeans with 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 #14
Source File: QPopAllAction.java    From netbeans with 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 #15
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 #16
Source File: UnusedBindingNode.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(GoToBindingSourceAction.class),
        SystemAction.get(ShowInDOMAction.class)
    };
}
 
Example #17
Source File: ConfVioGenQueryCNode.java    From BART with MIT License 5 votes vote down vote up
@Override
public Action[] getActions(boolean context) {
        Action[] result = new Action[]{
        Actions.forID("ConfVioGenQueryCNode", "it.unibas.bartgui.controlegt.actions.node.ConfVioGenQ.Edit"),
        null,
        SystemAction.get(PropertiesAction.class),
        };
        return result;
}
 
Example #18
Source File: DerbyDatabaseTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testConnect() throws Exception{
     SystemAction.get(StartAction.class).performAction();
     sleep(2000);

     String url="jdbc:derby://localhost:1527/testdbtest;create=true";
     Connection con=DbUtil.createDerbyConnection(url);
     con.close();
}
 
Example #19
Source File: BasicOpenFileTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void undo() throws Exception {
    final UndoAction ua = SystemAction.get(UndoAction.class);
    assertNotNull("Cannot obtain UndoAction", ua);
    while (ua.isEnabled()) {
        SwingUtilities.invokeAndWait(new Runnable() {

            public void run() {
                ua.performAction();
            }
        });
    }
}
 
Example #20
Source File: NbEditorUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Action getSystemAction(JTextComponent c) {
    if (systemAction == null) {
        Action ea = getEditorAction(c);
        if (ea != null) {
            String saClassName = (String)ea.getValue(NbEditorKit.SYSTEM_ACTION_CLASS_NAME_PROPERTY);
            if (saClassName != null) {
                Class saClass;
                try {
                    saClass = Class.forName(saClassName);
                } catch (Throwable t) {
                    saClass = null;
                }

                if (saClass != null) {
                    systemAction = SystemAction.get(saClass);
                    if (systemAction instanceof ContextAwareAction){
                        Lookup lookup = getContextLookup(c);
                        if (lookup!=null){
                            systemAction = ((ContextAwareAction)systemAction).createContextAwareInstance(lookup);
                        }
                    }
                    
                }
            }
        }
    }
    return systemAction;
}
 
Example #21
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 #22
Source File: JaxWsRootNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Action[] getActions(boolean context) {
    return new Action[]{
        CommonProjectActions.newFileAction(),
        null,
        SystemAction.get(FindAction.class),
        null,
        SystemAction.get(PasteAction.class),
        null,
        SystemAction.get(PropertiesAction.class)
    };
}
 
Example #23
Source File: CollectSystemAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private JMenuItem[] createMenu (Collection coll) {
    if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug (
        "\n--> CollectSystemAction.createMenu: ( " + coll + " )");

    ArrayList items = new ArrayList ();

    Iterator it = coll.iterator();
    while (it.hasNext ()) {
        SystemAction a = (SystemAction) it.next();
        
        if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug (
            "-*- CollectSystemAction.createMenu: next action " + a +
                         " -- " + ( a.isEnabled() ? "<enabled>" : "[disabled]" ) );
        
        if ( a.isEnabled() ) {
            JMenuItem item = null;
            if (a instanceof Presenter.Popup) {
                item = ((Presenter.Popup)a).getPopupPresenter ();
            }

            if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug
                ("-*- CollectSystemAction.createMenu: menu item = " + item);

            // test if we obtained the item
            if (item != null) {
                items.add (item);
            }
        }
    }

    if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug
        ("<-- CollectSystemAction.createMenu: all items = " + items + "\n");

    JMenuItem[] array = new JMenuItem [items.size ()];
    items.toArray (array);
    return array;
}
 
Example #24
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 #25
Source File: PageFlowScene.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private WidgetAction createActionMap() {

        ActionMap actionMap = refPageFlowView.get().getActionMap();
        CallbackSystemAction a = (CallbackSystemAction) SystemAction.get(DeleteAction.class);
        actionMap.put(a.getActionMapKey(), new PageFlowDeleteAction(this));

        //Temporary workaround  ISSUE# 107506
        return new MyActionMapAction(MapActionUtility.initInputMap(), MapActionUtility.initActionMap());
        //return ActionFactory.createActionMapAction(MapActionUtility.initInputMap(), MapActionUtility.initActionMap());
    }
 
Example #26
Source File: WildflyDestinationNode.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(PropertiesAction.class),
        SystemAction.get(UndeployModuleAction.class)
    };
}
 
Example #27
Source File: NodeOp.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Get the default actions for all nodes.
* @return array of default actions
 * @deprecated Do not use this method. It is useless now.
*/
@Deprecated
public static SystemAction[] getDefaultActions() {
    if (defaultActions == null) {
        defaultActions = createFromNames(new String[] {"Tools", "Properties"}); // NOI18N 
    }

    return defaultActions;
}
 
Example #28
Source File: WsdlSaasNode.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<Action>(Arrays.asList(super.getActions(context)));
    actions.add(SystemAction.get(ViewWSDLAction.class));

    return actions.toArray(new Action[actions.size()]);
}
 
Example #29
Source File: JBEjbModuleNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Action[] getActions(boolean context){
    if(getParentNode() instanceof JBEarApplicationNode)
        return new SystemAction[] {};
    else
        return new SystemAction[] {
            SystemAction.get(UndeployModuleAction.class)
        };
}
 
Example #30
Source File: NbEditorKit.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected void initActionByName(String actionName) {
    if (actionName != null) { // try if it's an action class name
        // Check for the TopComponent actions
        if (TopComponent.class.getName().equals(actionName)) {
            Action[] actions = outerTopComponent.getActions();
            addInitedObject(actions, ACTIONS_TOPCOMPONENT);
            return;
        } else { // not cloneable-editor actions

            // Try to load the action class
            Class saClass = null;
            try {
                ClassLoader loader = (ClassLoader)Lookup.getDefault().lookup(ClassLoader.class);
                saClass = Class.forName(actionName, false, loader);
            } catch (Throwable t) {
            }

            if (saClass != null && SystemAction.class.isAssignableFrom(saClass)) {
                Action action = SystemAction.get(saClass);
                action = translateContextLookupAction(contextLookup, action);
                if (action != null) {
                    addInitedObject(action, ACTION_SYSTEM);
                }
                return;
            }
        }

    }

    // implementation taken from ExtKit
    Action a = editorKit == null ? null : editorKit.getActionByName(actionName);
    addInitedObject(actionName, ACTION_EXTKIT_BYNAME);
}