Example usage for javax.swing JMenuItem setEnabled

List of usage examples for javax.swing JMenuItem setEnabled

Introduction

In this page you can find the example usage for javax.swing JMenuItem setEnabled.

Prototype

@BeanProperty(preferred = true, description = "The enabled state of the component.")
public void setEnabled(boolean b) 

Source Link

Document

Enables or disables the menu item.

Usage

From source file:corelyzer.ui.CorelyzerApp.java

public void createPluginMenuItems(final Vector pluginNames) {
    JMenuItem pluginMenuItem;
    for (int k = 0; k < pluginNames.size(); k++) {
        pluginMenuItem = new JMenuItem((String) pluginNames.elementAt(k));
        pluginMenuItem.addActionListener(controller);
        pluginMenu.add(pluginMenuItem);//  w  ww .j a  va2 s.c  om
        pluginMenuItemVec.add(pluginMenuItem);

        if (k == getPluginUIIndex()) {
            pluginMenuItem.setEnabled(false);
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccSwing.CFAccSwingAttachmentListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;/* w  w  w  .j  ava2s  .  co m*/
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFAccAttachmentObj selectedObj = getSwingFocusAsAttachment();
    CFJPanel.PanelMode mode = getPanelMode();
    if (mode == CFJPanel.PanelMode.Edit) {
        inEditState = true;
        if (getSwingContainer() != null) {
            allowAdds = true;
        } else {
            allowAdds = false;
        }
    } else {
        inEditState = false;
        allowAdds = false;
    }
    if (selectedObj == null) {
        enableState = false;
    } else {
        enableState = true;
    }

    if (actionViewSelected != null) {
        actionViewSelected.setEnabled(enableState);
    }
    if (actionEditSelected != null) {
        actionEditSelected.setEnabled(inEditState && enableState);
    }
    if (actionDeleteSelected != null) {
        actionDeleteSelected.setEnabled(inEditState && enableState);
    }
    if (actionAddAttachment != null) {
        actionAddAttachment.setEnabled(allowAdds);
    }

    if (menuAdd != null) {
        menuAdd.setEnabled(allowAdds);
    }
    if (menuSelected != null) {
        menuSelected.setEnabled(enableState);
        int itemCount = menuSelected.getItemCount();
        for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) {
            menuItem = menuSelected.getItem(itemIdx);
            act = menuItem.getAction();
            if (act != null) {
                if (act == actionViewSelected) {
                    menuItem.setEnabled(enableState);
                } else if (act == actionEditSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                } else if (act == actionDeleteSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                }
            }
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccSwing.CFAccSwingContactURLListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;/*from   www.j  av  a2s  .c o m*/
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFAccContactURLObj selectedObj = getSwingFocusAsContactURL();
    CFJPanel.PanelMode mode = getPanelMode();
    if (mode == CFJPanel.PanelMode.Edit) {
        inEditState = true;
        if (getSwingContainer() != null) {
            allowAdds = true;
        } else {
            allowAdds = false;
        }
    } else {
        inEditState = false;
        allowAdds = false;
    }
    if (selectedObj == null) {
        enableState = false;
    } else {
        enableState = true;
    }

    if (actionViewSelected != null) {
        actionViewSelected.setEnabled(enableState);
    }
    if (actionEditSelected != null) {
        actionEditSelected.setEnabled(inEditState && enableState);
    }
    if (actionDeleteSelected != null) {
        actionDeleteSelected.setEnabled(inEditState && enableState);
    }
    if (actionAddContactURL != null) {
        actionAddContactURL.setEnabled(allowAdds);
    }

    if (menuAdd != null) {
        menuAdd.setEnabled(allowAdds);
    }
    if (menuSelected != null) {
        menuSelected.setEnabled(enableState);
        int itemCount = menuSelected.getItemCount();
        for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) {
            menuItem = menuSelected.getItem(itemIdx);
            act = menuItem.getAction();
            if (act != null) {
                if (act == actionViewSelected) {
                    menuItem.setEnabled(enableState);
                } else if (act == actionEditSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                } else if (act == actionDeleteSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                }
            }
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccSwing.CFAccSwingAccountConfigListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;/*from   www  .j a v  a  2 s  .c om*/
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFAccAccountConfigObj selectedObj = getSwingFocusAsAccountConfig();
    CFJPanel.PanelMode mode = getPanelMode();
    if (mode == CFJPanel.PanelMode.Edit) {
        inEditState = true;
        if (getSwingContainer() != null) {
            allowAdds = true;
        } else {
            allowAdds = false;
        }
    } else {
        inEditState = false;
        allowAdds = false;
    }
    if (selectedObj == null) {
        enableState = false;
    } else {
        enableState = true;
    }

    if (actionViewSelected != null) {
        actionViewSelected.setEnabled(enableState);
    }
    if (actionEditSelected != null) {
        actionEditSelected.setEnabled(inEditState && enableState);
    }
    if (actionDeleteSelected != null) {
        actionDeleteSelected.setEnabled(inEditState && enableState);
    }
    if (actionAddAccountConfig != null) {
        actionAddAccountConfig.setEnabled(allowAdds);
    }

    if (menuAdd != null) {
        menuAdd.setEnabled(allowAdds);
    }
    if (menuSelected != null) {
        menuSelected.setEnabled(enableState);
        int itemCount = menuSelected.getItemCount();
        for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) {
            menuItem = menuSelected.getItem(itemIdx);
            act = menuItem.getAction();
            if (act != null) {
                if (act == actionViewSelected) {
                    menuItem.setEnabled(enableState);
                } else if (act == actionEditSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                } else if (act == actionDeleteSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                }
            }
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSwing.CFAsteriskSwingRealProjectListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;//w  w w . j  ava  2  s  . c  o  m
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFInternetRealProjectObj selectedObj = getSwingFocusAsRealProject();
    CFJPanel.PanelMode mode = getPanelMode();
    if (mode == CFJPanel.PanelMode.Edit) {
        inEditState = true;
        if (getSwingContainer() != null) {
            allowAdds = true;
        } else {
            allowAdds = false;
        }
    } else {
        inEditState = false;
        allowAdds = false;
    }
    if (selectedObj == null) {
        enableState = false;
    } else {
        enableState = true;
    }

    if (actionViewSelected != null) {
        actionViewSelected.setEnabled(enableState);
    }
    if (actionEditSelected != null) {
        actionEditSelected.setEnabled(inEditState && enableState);
    }
    if (actionDeleteSelected != null) {
        actionDeleteSelected.setEnabled(inEditState && enableState);
    }

    if (menuAdd != null) {
        menuAdd.setEnabled(allowAdds);
    }
    if (menuSelected != null) {
        menuSelected.setEnabled(enableState);
        int itemCount = menuSelected.getItemCount();
        for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) {
            menuItem = menuSelected.getItem(itemIdx);
            act = menuItem.getAction();
            if (act != null) {
                if (act == actionViewSelected) {
                    menuItem.setEnabled(enableState);
                } else if (act == actionEditSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                } else if (act == actionDeleteSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                }
            }
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccSwing.CFAccSwingVersionListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;//w  w w  .j  a v a 2  s  . c  o  m
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFAccVersionObj selectedObj = getSwingFocusAsVersion();
    CFJPanel.PanelMode mode = getPanelMode();
    if (mode == CFJPanel.PanelMode.Edit) {
        inEditState = true;
        if (getSwingContainer() != null) {
            allowAdds = true;
        } else {
            allowAdds = false;
        }
    } else {
        inEditState = false;
        allowAdds = false;
    }
    if (selectedObj == null) {
        enableState = false;
    } else {
        enableState = true;
    }

    if (actionViewSelected != null) {
        actionViewSelected.setEnabled(enableState);
    }
    if (actionEditSelected != null) {
        actionEditSelected.setEnabled(inEditState && enableState);
    }
    if (actionDeleteSelected != null) {
        actionDeleteSelected.setEnabled(inEditState && enableState);
    }

    if (menuAdd != null) {
        menuAdd.setEnabled(allowAdds);
    }
    if (menuSelected != null) {
        menuSelected.setEnabled(enableState);
        int itemCount = menuSelected.getItemCount();
        for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) {
            menuItem = menuSelected.getItem(itemIdx);
            act = menuItem.getAction();
            if (act != null) {
                if (act == actionViewSelected) {
                    menuItem.setEnabled(enableState);
                } else if (act == actionEditSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                } else if (act == actionDeleteSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                }
            }
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstSwing.CFAstSwingVersionListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;/*from   w ww.  j  a v a  2  s . c  o  m*/
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFAstVersionObj selectedObj = getSwingFocusAsVersion();
    CFJPanel.PanelMode mode = getPanelMode();
    if (mode == CFJPanel.PanelMode.Edit) {
        inEditState = true;
        if (getSwingContainer() != null) {
            allowAdds = true;
        } else {
            allowAdds = false;
        }
    } else {
        inEditState = false;
        allowAdds = false;
    }
    if (selectedObj == null) {
        enableState = false;
    } else {
        enableState = true;
    }

    if (actionViewSelected != null) {
        actionViewSelected.setEnabled(enableState);
    }
    if (actionEditSelected != null) {
        actionEditSelected.setEnabled(inEditState && enableState);
    }
    if (actionDeleteSelected != null) {
        actionDeleteSelected.setEnabled(inEditState && enableState);
    }

    if (menuAdd != null) {
        menuAdd.setEnabled(allowAdds);
    }
    if (menuSelected != null) {
        menuSelected.setEnabled(enableState);
        int itemCount = menuSelected.getItemCount();
        for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) {
            menuItem = menuSelected.getItem(itemIdx);
            act = menuItem.getAction();
            if (act != null) {
                if (act == actionViewSelected) {
                    menuItem.setEnabled(enableState);
                } else if (act == actionEditSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                } else if (act == actionDeleteSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                }
            }
        }
    }
}

From source file:net.sourceforge.msscodefactory.cffreeswitch.v2_1.CFFswSwing.CFFswSwingVersionListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;/*w  w w.j  a  v  a  2 s .co  m*/
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFFswVersionObj selectedObj = getSwingFocusAsVersion();
    CFJPanel.PanelMode mode = getPanelMode();
    if (mode == CFJPanel.PanelMode.Edit) {
        inEditState = true;
        if (getSwingContainer() != null) {
            allowAdds = true;
        } else {
            allowAdds = false;
        }
    } else {
        inEditState = false;
        allowAdds = false;
    }
    if (selectedObj == null) {
        enableState = false;
    } else {
        enableState = true;
    }

    if (actionViewSelected != null) {
        actionViewSelected.setEnabled(enableState);
    }
    if (actionEditSelected != null) {
        actionEditSelected.setEnabled(inEditState && enableState);
    }
    if (actionDeleteSelected != null) {
        actionDeleteSelected.setEnabled(inEditState && enableState);
    }

    if (menuAdd != null) {
        menuAdd.setEnabled(allowAdds);
    }
    if (menuSelected != null) {
        menuSelected.setEnabled(enableState);
        int itemCount = menuSelected.getItemCount();
        for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) {
            menuItem = menuSelected.getItem(itemIdx);
            act = menuItem.getAction();
            if (act != null) {
                if (act == actionViewSelected) {
                    menuItem.setEnabled(enableState);
                } else if (act == actionEditSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                } else if (act == actionDeleteSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                }
            }
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccSwing.CFAccSwingRealProjectListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;/*w  w w. ja  v a2s .com*/
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFAccRealProjectObj selectedObj = getSwingFocusAsRealProject();
    CFJPanel.PanelMode mode = getPanelMode();
    if (mode == CFJPanel.PanelMode.Edit) {
        inEditState = true;
        if (getSwingContainer() != null) {
            allowAdds = true;
        } else {
            allowAdds = false;
        }
    } else {
        inEditState = false;
        allowAdds = false;
    }
    if (selectedObj == null) {
        enableState = false;
    } else {
        enableState = true;
    }

    if (actionViewSelected != null) {
        actionViewSelected.setEnabled(enableState);
    }
    if (actionEditSelected != null) {
        actionEditSelected.setEnabled(inEditState && enableState);
    }
    if (actionDeleteSelected != null) {
        actionDeleteSelected.setEnabled(inEditState && enableState);
    }

    if (menuAdd != null) {
        menuAdd.setEnabled(allowAdds);
    }
    if (menuSelected != null) {
        menuSelected.setEnabled(enableState);
        int itemCount = menuSelected.getItemCount();
        for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) {
            menuItem = menuSelected.getItem(itemIdx);
            act = menuItem.getAction();
            if (act != null) {
                if (act == actionViewSelected) {
                    menuItem.setEnabled(enableState);
                } else if (act == actionEditSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                } else if (act == actionDeleteSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                }
            }
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstSwing.CFAstSwingRealProjectListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;//w w w  .j a  v a 2 s  .c o m
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFAstRealProjectObj selectedObj = getSwingFocusAsRealProject();
    CFJPanel.PanelMode mode = getPanelMode();
    if (mode == CFJPanel.PanelMode.Edit) {
        inEditState = true;
        if (getSwingContainer() != null) {
            allowAdds = true;
        } else {
            allowAdds = false;
        }
    } else {
        inEditState = false;
        allowAdds = false;
    }
    if (selectedObj == null) {
        enableState = false;
    } else {
        enableState = true;
    }

    if (actionViewSelected != null) {
        actionViewSelected.setEnabled(enableState);
    }
    if (actionEditSelected != null) {
        actionEditSelected.setEnabled(inEditState && enableState);
    }
    if (actionDeleteSelected != null) {
        actionDeleteSelected.setEnabled(inEditState && enableState);
    }

    if (menuAdd != null) {
        menuAdd.setEnabled(allowAdds);
    }
    if (menuSelected != null) {
        menuSelected.setEnabled(enableState);
        int itemCount = menuSelected.getItemCount();
        for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) {
            menuItem = menuSelected.getItem(itemIdx);
            act = menuItem.getAction();
            if (act != null) {
                if (act == actionViewSelected) {
                    menuItem.setEnabled(enableState);
                } else if (act == actionEditSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                } else if (act == actionDeleteSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                }
            }
        }
    }
}