Example usage for javax.swing JMenuItem getAction

List of usage examples for javax.swing JMenuItem getAction

Introduction

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

Prototype

public Action getAction() 

Source Link

Document

Returns the currently set Action for this ActionEvent source, or null if no Action is set.

Usage

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

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;//from   w  w w .ja v a2s.  c om
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFAccURLProtocolObj selectedObj = getSwingFocusAsURLProtocol();
    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 (actionAddURLProtocol != null) {
        actionAddURLProtocol.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.CFAstSwingISOLanguageListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;/*  w  w  w.  ja v  a2 s  . com*/
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFAstISOLanguageObj selectedObj = getSwingFocusAsISOLanguage();
    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 (actionAddISOLanguage != null) {
        actionAddISOLanguage.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.CFAstSwingURLProtocolListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;/*from  w w w. j  a v a  2 s .  com*/
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFAstURLProtocolObj selectedObj = getSwingFocusAsURLProtocol();
    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 (actionAddURLProtocol != null) {
        actionAddURLProtocol.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.CFAsteriskSwingVersionListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;/*from   w ww.j  a  v  a 2  s . co m*/
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFInternetVersionObj 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.CFAccSwingAttachmentListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;/*from w  w  w . j  a v  a  2  s. com*/
    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;/*  w  w  w  .ja  va 2s. c  om*/
    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   w  w w.  j a  v  a  2 s  .  c o m*/
    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;/*from   ww w  .j av  a  2s . 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;/*from w w w .j  a  va  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  w  w.j av a  2 s  .  co 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);
                }
            }
        }
    }
}