Java Code Examples for org.openide.awt.Actions#MenuItem

The following examples show how to use org.openide.awt.Actions#MenuItem . 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: RefactoringContextAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public JComponent[] synchMenuPresenters(JComponent[] items) {
    JComponent[] comps = new JComponent[1];
    for (JComponent item : items) {
        if (item instanceof Actions.MenuItem) {
            comps[0] = item;
            // update menu items to reflect Action.isEnabled
            ((Actions.MenuItem) item).synchMenuPresenters(comps);
        } else if(item instanceof JMenu) {
            JMenu jMenu = (JMenu) item;
            for (Component subItem : jMenu.getMenuComponents()) {
                if (subItem instanceof Actions.MenuItem) {
                    comps[0] = (JComponent) subItem;
                    // update menu items to reflect Action.isEnabled
                    ((Actions.MenuItem) subItem).synchMenuPresenters(comps);
                }
            }
        }
    }
    // returns most up-to date items
    return createMenuItems();
}
 
Example 2
Source File: HtmlRefactoringGlobalAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public JMenuItem getPopupPresenter() {
    if (isMethodOverridden(HtmlRefactoringGlobalAction.this, "getPopupPresenter")) { // NOI18N

        return HtmlRefactoringGlobalAction.this.getPopupPresenter();
    } else {
        return new Actions.MenuItem(this, false);
    }
}
 
Example 3
Source File: RefactoringContextActionsProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static void resolveInstance(Object instance, List<JComponent> result) throws IOException {
   if (instance instanceof Presenter.Popup) {
       JMenuItem temp = ((Presenter.Popup) instance).getPopupPresenter();
       result.add(temp);
   } else if (instance instanceof JSeparator) {
       result.add(null);
   } else if (instance instanceof JComponent) {
       result.add((JComponent) instance);
   } else if (instance instanceof Action) {
       Actions.MenuItem mi = new Actions.MenuItem((Action) instance, true);
       result.add(mi);
   } else {
       throw new IOException(String.format("Unsupported instance: %s, class: %s", instance, instance.getClass())); // NOI18N
   }
}
 
Example 4
Source File: RunPhingTargetAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public JMenuItem getPopupPresenter() {
    if (project == null) {
        return new Actions.MenuItem(this, false);
    }
    return BuildTools.getDefault().createTasksMenu(new TasksMenuSupportImpl(project, buildXml));
}
 
Example 5
Source File: RunGulpTaskAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public JMenuItem getPopupPresenter() {
    if (project == null) {
        return new Actions.MenuItem(this, false);
    }
    return BuildTools.getDefault().createTasksMenu(new TasksMenuSupportImpl(project, gulpfile));
}
 
Example 6
Source File: RefactoringGlobalAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public JMenuItem getPopupPresenter() {
    if (isMethodOverridden(RefactoringGlobalAction.this, "getPopupPresenter")) { // NOI18N

        return RefactoringGlobalAction.this.getPopupPresenter();
    } else {
        return new Actions.MenuItem(this, false);
    }
}
 
Example 7
Source File: RunGruntTaskAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public JMenuItem getPopupPresenter() {
    if (project == null) {
        return new Actions.MenuItem(this, false);
    }
    return BuildTools.getDefault().createTasksMenu(new TasksMenuSupportImpl(project, gruntfile));
}
 
Example 8
Source File: PropertiesAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public JMenuItem getPopupPresenter() {
    JMenuItem prop = new Actions.MenuItem(this, false);

    Action customizeAction = SystemAction.get(CustomizeAction.class);

    // Retrieve context sensitive action instance if possible.
    if (lookup != null) {
        customizeAction = ((ContextAwareAction) customizeAction).createContextAwareInstance(lookup);
    }

    if (customizeAction.isEnabled()) {
        JInlineMenu mi = new JInlineMenu();
        mi.setMenuItems(new JMenuItem[] { new Actions.MenuItem(customizeAction, false), prop });

        return mi;
    } else {
        for (Node n : nodes()) {
            for (Node.PropertySet ps : n.getPropertySets()) {
                if (ps.getProperties().length > 0) {
                    // OK, we have something to show!
                    return prop;
                }
            }
        }
        // else nothing to show, so show nothing
        return new JInlineMenu();
    }
}
 
Example 9
Source File: PropertiesAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public JMenuItem getPopupPresenter() {
    JMenuItem prop = new Actions.MenuItem(this, false);

    CustomizeAction customizeAction = SystemAction.get(CustomizeAction.class);

    if (customizeAction.isEnabled()) {
        JInlineMenu mi = new JInlineMenu();
        mi.setMenuItems(new JMenuItem[] { new Actions.MenuItem(customizeAction, false), prop });

        return mi;
    } else {
        return prop;
    }
}
 
Example 10
Source File: DefaultAWTBridge.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public JMenuItem createMenuPresenter (Action action) {
    if (action instanceof BooleanStateAction) {
        BooleanStateAction b = (BooleanStateAction)action;
        return new Actions.CheckboxMenuItem (b, true);
    }
    if (action.getValue(Actions.ACTION_VALUE_TOGGLE) != null) {
        return new Actions.CheckboxMenuItem(action, true);
    }
    if (action instanceof SystemAction) {
        SystemAction s = (SystemAction)action;
        return new Actions.MenuItem (s, true);
    }
        
    return new Actions.MenuItem (action, true);
}
 
Example 11
Source File: NodeAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public JMenuItem getPopupPresenter() {
    if (isMethodOverridden(delegate, "getPopupPresenter")) { // NOI18N

        return delegate.getPopupPresenter();
    } else {
        return new Actions.MenuItem(this, false);
    }
}
 
Example 12
Source File: NodeAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public JMenuItem getMenuPresenter() {
    if (isMethodOverridden(delegate, "getMenuPresenter")) { // NOI18N

        return delegate.getMenuPresenter();
    } else {
        return new Actions.MenuItem(this, true);
    }
}
 
Example 13
Source File: RunTargetsAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public JMenuItem getPopupPresenter() {
    if (project != null) {
        return createMenu(project);
    } else {
        return new Actions.MenuItem(this, false);
    }
}
 
Example 14
Source File: RunTargetsAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public JMenuItem getPopupPresenter() {
    if (project != null) {
        return createMenu(project);
    } else {
        return new Actions.MenuItem(this, false);
    }
}
 
Example 15
Source File: JavaRefactoringGlobalAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public JMenuItem getPopupPresenter() {
    if (isMethodOverridden(JavaRefactoringGlobalAction.this, "getPopupPresenter")) { // NOI18N

        return JavaRefactoringGlobalAction.this.getPopupPresenter();
    } else {
        return new Actions.MenuItem(this, false);
    }
}
 
Example 16
Source File: JavaRefactoringGlobalAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public JMenuItem getMenuPresenter() {
    if (isMethodOverridden(JavaRefactoringGlobalAction.this, "getMenuPresenter")) { // NOI18N

        return JavaRefactoringGlobalAction.this.getMenuPresenter();
    } else {
        return new Actions.MenuItem(this, true);
    }
}
 
Example 17
Source File: JavaRefactoringGlobalAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public JMenuItem getPopupPresenter() {
    if (isMethodOverridden(JavaRefactoringGlobalAction.this, "getPopupPresenter")) { // NOI18N

        return JavaRefactoringGlobalAction.this.getPopupPresenter();
    } else {
        return new Actions.MenuItem(this, false);
    }
}
 
Example 18
Source File: JavaRefactoringGlobalAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public JMenuItem getMenuPresenter() {
    if (isMethodOverridden(JavaRefactoringGlobalAction.this, "getMenuPresenter")) { // NOI18N

        return JavaRefactoringGlobalAction.this.getMenuPresenter();
    } else {
        return new Actions.MenuItem(this, true);
    }
}
 
Example 19
Source File: BreakpointCustomizeAction.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public JMenuItem getPopupPresenter() {
    return new Actions.MenuItem (this, false);
}
 
Example 20
Source File: PropertiesAction.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public JMenuItem getMenuPresenter() {
    return new Actions.MenuItem(this, true);
}