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:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccSwing.CFAccSwingTenantListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;/*from  w ww .j  a va 2s.c  om*/
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFAccTenantObj selectedObj = getSwingFocusAsTenant();
    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 (actionAddTenant != null) {
        actionAddTenant.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_0.CFAstSwing.CFAstSwingSecAppListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;/*from w  w  w  .  j  a  v a 2s  .c  o m*/
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFAstSecAppObj selectedObj = getSwingFocusAsSecApp();
    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 (actionAddSecApp != null) {
        actionAddSecApp.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_0.CFAstSwing.CFAstSwingTenantListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;/*from   w w  w.ja va  2s.  co m*/
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFAstTenantObj selectedObj = getSwingFocusAsTenant();
    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 (actionAddTenant != null) {
        actionAddTenant.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.CFAsteriskSwingTSecGroupListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;/*  w  w w .  j a v  a 2  s .c  om*/
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFSecurityTSecGroupObj selectedObj = getSwingFocusAsTSecGroup();
    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 (actionAddTSecGroup != null) {
        actionAddTSecGroup.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.cffreeswitch.v2_1.CFFswSwing.CFFswSwingSecAppListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;//from  w w  w  .j av  a2 s  .  c  o m
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFFswSecAppObj selectedObj = getSwingFocusAsSecApp();
    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 (actionAddSecApp != null) {
        actionAddSecApp.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.CFAsteriskSwingISOCountryCurrencyListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;//from  w  w w . j  a  v a2  s . c o  m
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFSecurityISOCountryCurrencyObj selectedObj = getSwingFocusAsISOCountryCurrency();
    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 (actionAddISOCountryCurrency != null) {
        actionAddISOCountryCurrency.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.CFAsteriskSwingISOCountryLanguageListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;//w  w  w. j a  v a  2 s  .c om
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFSecurityISOCountryLanguageObj selectedObj = getSwingFocusAsISOCountryLanguage();
    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 (actionAddISOCountryLanguage != null) {
        actionAddISOCountryLanguage.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.CFAsteriskSwingSecDeviceListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;// w  ww. j a  va2s .  co  m
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFSecuritySecDeviceObj selectedObj = getSwingFocusAsSecDevice();
    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 (actionAddSecDevice != null) {
        actionAddSecDevice.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.CFAsteriskSwingAuditActionListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;//  w  w  w.j  av  a 2  s . c  o  m
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFSecurityAuditActionObj selectedObj = getSwingFocusAsAuditAction();
    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 (actionAddAuditAction != null) {
        actionAddAuditAction.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.CFAsteriskSwingServiceTypeListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;/*  w w w.ja  v a 2 s.  c om*/
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFSecurityServiceTypeObj selectedObj = getSwingFocusAsServiceType();
    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 (actionAddServiceType != null) {
        actionAddServiceType.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);
                }
            }
        }
    }
}