org.openide.util.actions.CallableSystemAction Java Examples

The following examples show how to use org.openide.util.actions.CallableSystemAction. 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: gui.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/**
 * Generic method to invoke commands available from the menu bar. The actionName passed in is usually
 * the concatentaion of the words making the menu items:
 * e.g. performAction("FileOpen") is equivalent to picking the cascade menu File->Open Model
 * 
 * @param actionName
 */
static public void performAction(String actionName) {
    FileObject myActionsFolder = FileUtil.getConfigFile("Actions/Edit");
    FileObject[] myActionsFolderKids = myActionsFolder.getChildren();
    for (FileObject fileObject : myActionsFolderKids) {
        //Probably want to make this more robust,
        //but the point is that here we find a particular Action:
        if (fileObject.getName().contains(actionName)) {
            try {
                DataObject dob = DataObject.find(fileObject);
                InstanceCookie ic = dob.getLookup().lookup(InstanceCookie.class);
                if (ic != null) {
                    Object instance = ic.instanceCreate();
                    if (instance instanceof CallableSystemAction) {
                        CallableSystemAction a = (CallableSystemAction) instance;
                        a.performAction();
                    }
                }
                break;
            } catch (Exception e) {
                ErrorManager.getDefault().notify(ErrorManager.WARNING, e);
             }
        }
    }

}
 
Example #2
Source File: JavaRefactoringGlobalAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private boolean isMethodOverridden(NodeAction d, String name) {
    try {
        Method m = d.getClass().getMethod(name, new Class[0]);

        return m.getDeclaringClass() != CallableSystemAction.class;
    } catch (java.lang.NoSuchMethodException ex) {
        ex.printStackTrace();
        throw new IllegalStateException("Error searching for method " + name + " in " + d); // NOI18N
    }
}
 
Example #3
Source File: JavaRefactoringGlobalAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private boolean isMethodOverridden(NodeAction d, String name) {
    try {
        Method m = d.getClass().getMethod(name, new Class[0]);

        return m.getDeclaringClass() != CallableSystemAction.class;
    } catch (java.lang.NoSuchMethodException ex) {
        ex.printStackTrace();
        throw new IllegalStateException("Error searching for method " + name + " in " + d); // NOI18N
    }
}
 
Example #4
Source File: RefactoringGlobalAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private boolean isMethodOverridden(NodeAction d, String name) {
    try {
        Method m = d.getClass().getMethod(name, new Class[0]);

        return m.getDeclaringClass() != CallableSystemAction.class;
    } catch (java.lang.NoSuchMethodException ex) {
        ex.printStackTrace();
        throw new IllegalStateException("Error searching for method " + name + " in " + d); // NOI18N
    }
}
 
Example #5
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 #6
Source File: HtmlRefactoringGlobalAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private boolean isMethodOverridden(NodeAction d, String name) {
    try {
        Method m = d.getClass().getMethod(name, new Class[0]);

        return m.getDeclaringClass() != CallableSystemAction.class;
    } catch (java.lang.NoSuchMethodException ex) {
        ex.printStackTrace();
        throw new IllegalStateException("Error searching for method " + name + " in " + d); // NOI18N
    }
}