package Express.windows;
import java.awt.Component;
import java.io.Serializable;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.MenuElement;
import DisplayProject.Array_Of_MenuElement;
import DisplayProject.Constants;
import DisplayProject.GridField;
import DisplayProject.actions.IntegerValue;
import DisplayProject.actions.Parent;
import DisplayProject.actions.WidgetState;
import DisplayProject.binding.beans.Observable;
import DisplayProject.controls.MenuList;
import DisplayProject.controls.MenuSeparator;
import Framework.RuntimeProperties;
/**
* The MenuSetDesc class defines the common features of the menu commands for generated windows that use the menu command interface. The MenuSetDesc class is always used in the context of a CommandMgr. The window calls the CommandMgr to request actions on commands. The CommandMgr uses the MenuSetDesc to carry out the requests if the window uses the menu command interface.
* <p>
* @author ITerative Consulting
* @since 26-Feb-2008
*/
@RuntimeProperties(isDistributed=false, isAnchored=false, isShared=false, isTransactional=false)
@SuppressWarnings("serial")
public class MenuSetDesc
extends CommandSetDesc
implements Serializable, Observable
{
// ----------
// Attributes
// ----------
private JMenuItem cancelCMD;
private JMenuItem clearCMD;
private MenuSeparator clearSP;
private JMenuItem closeCMD;
private MenuSeparator closeSP;
private JMenuItem deleteCMD;
private JMenuItem editCopyCMD;
private JMenuItem editCutCMD;
private JMenuItem editDeleteCMD;
private JMenu editMenu;
private JMenuItem editPasteCMD;
private JMenuItem editSelectAllCMD;
private JMenuItem exitAllCMD;
private JMenu fileMenu;
private JMenuItem firstCMD;
private JMenuItem insertCMD;
private JMenuItem lastCMD;
private MenuList modeCMD;
private MenuSeparator modeSP;
private JMenuItem nextCMD;
private JMenuItem preferencesCMD;
private MenuSeparator preferencesSP;
private JMenuItem prevCMD;
private JMenuItem printCMD;
private JMenuItem printSetupCMD;
private MenuSeparator printSP;
private JMenu resultSetMenu;
private JMenuItem revertCMD;
private MenuSeparator revertSP;
private JMenuItem saveCMD;
private MenuSeparator saveSP;
private JMenu scrollMenu;
private MenuSeparator scrollSP;
private MenuSeparator scrollToSP;
private JMenuItem searchCMD;
private JFrame window;
// ------------
// Constructors
// ------------
public MenuSetDesc() {
// Explicitly call the superclass constructor to prevent the implicit call
super();
this.cancelCMD = null;
this.clearCMD = null;
this.clearSP = null;
this.closeCMD = null;
this.closeSP = null;
this.deleteCMD = null;
this.editCopyCMD = null;
this.editCutCMD = null;
this.editDeleteCMD = null;
this.editMenu = null;
this.editPasteCMD = null;
this.editSelectAllCMD = null;
this.exitAllCMD = null;
this.fileMenu = null;
this.firstCMD = null;
this.insertCMD = null;
this.lastCMD = null;
this.modeCMD = null;
this.modeSP = null;
this.nextCMD = null;
this.preferencesCMD = null;
this.preferencesSP = null;
this.prevCMD = null;
this.printCMD = null;
this.printSetupCMD = null;
this.printSP = null;
this.resultSetMenu = null;
this.revertCMD = null;
this.revertSP = null;
this.saveCMD = null;
this.saveSP = null;
this.scrollMenu = null;
this.scrollSP = null;
this.scrollToSP = null;
this.searchCMD = null;
this.window = null;
}
// ----------------------
// Accessors and Mutators
// ----------------------
public void setCancelCMD(JMenuItem cancelCMD) {
JMenuItem oldValue = this.cancelCMD;
this.cancelCMD = cancelCMD;
this.qq_Listeners.firePropertyChange("cancelCMD", oldValue, this.cancelCMD);
}
public JMenuItem getCancelCMD() {
return this.cancelCMD;
}
public void setClearCMD(JMenuItem clearCMD) {
JMenuItem oldValue = this.clearCMD;
this.clearCMD = clearCMD;
this.qq_Listeners.firePropertyChange("clearCMD", oldValue, this.clearCMD);
}
public JMenuItem getClearCMD() {
return this.clearCMD;
}
public void setClearSP(MenuSeparator clearSP) {
MenuSeparator oldValue = this.clearSP;
this.clearSP = clearSP;
this.qq_Listeners.firePropertyChange("clearSP", oldValue, this.clearSP);
}
public MenuSeparator getClearSP() {
return this.clearSP;
}
public void setCloseCMD(JMenuItem closeCMD) {
JMenuItem oldValue = this.closeCMD;
this.closeCMD = closeCMD;
this.qq_Listeners.firePropertyChange("closeCMD", oldValue, this.closeCMD);
}
public JMenuItem getCloseCMD() {
return this.closeCMD;
}
public void setCloseSP(MenuSeparator closeSP) {
MenuSeparator oldValue = this.closeSP;
this.closeSP = closeSP;
this.qq_Listeners.firePropertyChange("closeSP", oldValue, this.closeSP);
}
public MenuSeparator getCloseSP() {
return this.closeSP;
}
public void setDeleteCMD(JMenuItem deleteCMD) {
JMenuItem oldValue = this.deleteCMD;
this.deleteCMD = deleteCMD;
this.qq_Listeners.firePropertyChange("deleteCMD", oldValue, this.deleteCMD);
}
public JMenuItem getDeleteCMD() {
return this.deleteCMD;
}
public void setEditCopyCMD(JMenuItem editCopyCMD) {
JMenuItem oldValue = this.editCopyCMD;
this.editCopyCMD = editCopyCMD;
this.qq_Listeners.firePropertyChange("editCopyCMD", oldValue, this.editCopyCMD);
}
public JMenuItem getEditCopyCMD() {
return this.editCopyCMD;
}
public void setEditCutCMD(JMenuItem editCutCMD) {
JMenuItem oldValue = this.editCutCMD;
this.editCutCMD = editCutCMD;
this.qq_Listeners.firePropertyChange("editCutCMD", oldValue, this.editCutCMD);
}
public JMenuItem getEditCutCMD() {
return this.editCutCMD;
}
public void setEditDeleteCMD(JMenuItem editDeleteCMD) {
JMenuItem oldValue = this.editDeleteCMD;
this.editDeleteCMD = editDeleteCMD;
this.qq_Listeners.firePropertyChange("editDeleteCMD", oldValue, this.editDeleteCMD);
}
public JMenuItem getEditDeleteCMD() {
return this.editDeleteCMD;
}
public void setEditMenu(JMenu editMenu) {
JMenu oldValue = this.editMenu;
this.editMenu = editMenu;
this.qq_Listeners.firePropertyChange("editMenu", oldValue, this.editMenu);
}
public JMenu getEditMenu() {
return this.editMenu;
}
public void setEditPasteCMD(JMenuItem editPasteCMD) {
JMenuItem oldValue = this.editPasteCMD;
this.editPasteCMD = editPasteCMD;
this.qq_Listeners.firePropertyChange("editPasteCMD", oldValue, this.editPasteCMD);
}
public JMenuItem getEditPasteCMD() {
return this.editPasteCMD;
}
public void setEditSelectAllCMD(JMenuItem editSelectAllCMD) {
JMenuItem oldValue = this.editSelectAllCMD;
this.editSelectAllCMD = editSelectAllCMD;
this.qq_Listeners.firePropertyChange("editSelectAllCMD", oldValue, this.editSelectAllCMD);
}
public JMenuItem getEditSelectAllCMD() {
return this.editSelectAllCMD;
}
public void setExitAllCMD(JMenuItem exitAllCMD) {
JMenuItem oldValue = this.exitAllCMD;
this.exitAllCMD = exitAllCMD;
this.qq_Listeners.firePropertyChange("exitAllCMD", oldValue, this.exitAllCMD);
}
public JMenuItem getExitAllCMD() {
return this.exitAllCMD;
}
public void setFileMenu(JMenu fileMenu) {
JMenu oldValue = this.fileMenu;
this.fileMenu = fileMenu;
this.qq_Listeners.firePropertyChange("fileMenu", oldValue, this.fileMenu);
}
public JMenu getFileMenu() {
return this.fileMenu;
}
public void setFirstCMD(JMenuItem firstCMD) {
JMenuItem oldValue = this.firstCMD;
this.firstCMD = firstCMD;
this.qq_Listeners.firePropertyChange("firstCMD", oldValue, this.firstCMD);
}
public JMenuItem getFirstCMD() {
return this.firstCMD;
}
public void setInsertCMD(JMenuItem insertCMD) {
JMenuItem oldValue = this.insertCMD;
this.insertCMD = insertCMD;
this.qq_Listeners.firePropertyChange("insertCMD", oldValue, this.insertCMD);
}
public JMenuItem getInsertCMD() {
return this.insertCMD;
}
public void setLastCMD(JMenuItem lastCMD) {
JMenuItem oldValue = this.lastCMD;
this.lastCMD = lastCMD;
this.qq_Listeners.firePropertyChange("lastCMD", oldValue, this.lastCMD);
}
public JMenuItem getLastCMD() {
return this.lastCMD;
}
public void setModeCMD(MenuList modeCMD) {
MenuList oldValue = this.modeCMD;
this.modeCMD = modeCMD;
this.qq_Listeners.firePropertyChange("modeCMD", oldValue, this.modeCMD);
}
public MenuList getModeCMD() {
return this.modeCMD;
}
public void setModeSP(MenuSeparator modeSP) {
MenuSeparator oldValue = this.modeSP;
this.modeSP = modeSP;
this.qq_Listeners.firePropertyChange("modeSP", oldValue, this.modeSP);
}
public MenuSeparator getModeSP() {
return this.modeSP;
}
public void setNextCMD(JMenuItem nextCMD) {
JMenuItem oldValue = this.nextCMD;
this.nextCMD = nextCMD;
this.qq_Listeners.firePropertyChange("nextCMD", oldValue, this.nextCMD);
}
public JMenuItem getNextCMD() {
return this.nextCMD;
}
public void setPreferencesCMD(JMenuItem preferencesCMD) {
JMenuItem oldValue = this.preferencesCMD;
this.preferencesCMD = preferencesCMD;
this.qq_Listeners.firePropertyChange("preferencesCMD", oldValue, this.preferencesCMD);
}
public JMenuItem getPreferencesCMD() {
return this.preferencesCMD;
}
public void setPreferencesSP(MenuSeparator preferencesSP) {
MenuSeparator oldValue = this.preferencesSP;
this.preferencesSP = preferencesSP;
this.qq_Listeners.firePropertyChange("preferencesSP", oldValue, this.preferencesSP);
}
public MenuSeparator getPreferencesSP() {
return this.preferencesSP;
}
public void setPrevCMD(JMenuItem prevCMD) {
JMenuItem oldValue = this.prevCMD;
this.prevCMD = prevCMD;
this.qq_Listeners.firePropertyChange("prevCMD", oldValue, this.prevCMD);
}
public JMenuItem getPrevCMD() {
return this.prevCMD;
}
public void setPrintCMD(JMenuItem printCMD) {
JMenuItem oldValue = this.printCMD;
this.printCMD = printCMD;
this.qq_Listeners.firePropertyChange("printCMD", oldValue, this.printCMD);
}
public JMenuItem getPrintCMD() {
return this.printCMD;
}
public void setPrintSetupCMD(JMenuItem printSetupCMD) {
JMenuItem oldValue = this.printSetupCMD;
this.printSetupCMD = printSetupCMD;
this.qq_Listeners.firePropertyChange("printSetupCMD", oldValue, this.printSetupCMD);
}
public JMenuItem getPrintSetupCMD() {
return this.printSetupCMD;
}
public void setPrintSP(MenuSeparator printSP) {
MenuSeparator oldValue = this.printSP;
this.printSP = printSP;
this.qq_Listeners.firePropertyChange("printSP", oldValue, this.printSP);
}
public MenuSeparator getPrintSP() {
return this.printSP;
}
public void setResultSetMenu(JMenu resultSetMenu) {
JMenu oldValue = this.resultSetMenu;
this.resultSetMenu = resultSetMenu;
this.qq_Listeners.firePropertyChange("resultSetMenu", oldValue, this.resultSetMenu);
}
public JMenu getResultSetMenu() {
return this.resultSetMenu;
}
public void setRevertCMD(JMenuItem revertCMD) {
JMenuItem oldValue = this.revertCMD;
this.revertCMD = revertCMD;
this.qq_Listeners.firePropertyChange("revertCMD", oldValue, this.revertCMD);
}
public JMenuItem getRevertCMD() {
return this.revertCMD;
}
public void setRevertSP(MenuSeparator revertSP) {
MenuSeparator oldValue = this.revertSP;
this.revertSP = revertSP;
this.qq_Listeners.firePropertyChange("revertSP", oldValue, this.revertSP);
}
public MenuSeparator getRevertSP() {
return this.revertSP;
}
public void setSaveCMD(JMenuItem saveCMD) {
JMenuItem oldValue = this.saveCMD;
this.saveCMD = saveCMD;
this.qq_Listeners.firePropertyChange("saveCMD", oldValue, this.saveCMD);
}
public JMenuItem getSaveCMD() {
return this.saveCMD;
}
public void setSaveSP(MenuSeparator saveSP) {
MenuSeparator oldValue = this.saveSP;
this.saveSP = saveSP;
this.qq_Listeners.firePropertyChange("saveSP", oldValue, this.saveSP);
}
public MenuSeparator getSaveSP() {
return this.saveSP;
}
public void setScrollMenu(JMenu scrollMenu) {
JMenu oldValue = this.scrollMenu;
this.scrollMenu = scrollMenu;
this.qq_Listeners.firePropertyChange("scrollMenu", oldValue, this.scrollMenu);
}
public JMenu getScrollMenu() {
return this.scrollMenu;
}
public void setScrollSP(MenuSeparator scrollSP) {
MenuSeparator oldValue = this.scrollSP;
this.scrollSP = scrollSP;
this.qq_Listeners.firePropertyChange("scrollSP", oldValue, this.scrollSP);
}
public MenuSeparator getScrollSP() {
return this.scrollSP;
}
public void setScrollToSP(MenuSeparator scrollToSP) {
MenuSeparator oldValue = this.scrollToSP;
this.scrollToSP = scrollToSP;
this.qq_Listeners.firePropertyChange("scrollToSP", oldValue, this.scrollToSP);
}
public MenuSeparator getScrollToSP() {
return this.scrollToSP;
}
public void setSearchCMD(JMenuItem searchCMD) {
JMenuItem oldValue = this.searchCMD;
this.searchCMD = searchCMD;
this.qq_Listeners.firePropertyChange("searchCMD", oldValue, this.searchCMD);
}
public JMenuItem getSearchCMD() {
return this.searchCMD;
}
public void setWindow(JFrame window) {
JFrame oldValue = this.window;
this.window = window;
this.qq_Listeners.firePropertyChange("window", oldValue, this.window);
}
public JFrame getWindow() {
return this.window;
}
// -------
// Methods
// -------
/**
* getState<p>
* GetState<br>
* GetState returns the state of the given command.<br>
* <p>
* Returns TRUE if the command is enabled, FALSE otherwise.<br>
* <p>
* @param command Type: int
* @return boolean
*/
public boolean getState(int command) {
switch (command) {
case CommandMgr.C_WC_CANCEL: {
if (this.getCancelCMD() != null && (WidgetState.get(this.getCancelCMD()) == Constants.MS_ENABLED || WidgetState.get(this.getCancelCMD()) == Constants.FS_USAGESTATE)) {
return true;
}
else {
return false;
}
}
case CommandMgr.C_RS_CLEAR: {
if (this.getClearCMD() != null && (WidgetState.get(this.getClearCMD()) == Constants.MS_ENABLED || WidgetState.get(this.getClearCMD()) == Constants.FS_USAGESTATE)) {
return true;
}
else {
return false;
}
}
case CommandMgr.C_WC_CLOSE: {
if (this.getCloseCMD() != null && (WidgetState.get(this.getCloseCMD()) == Constants.MS_ENABLED || WidgetState.get(this.getCloseCMD()) == Constants.FS_USAGESTATE)) {
return true;
}
else {
return false;
}
}
case CommandMgr.C_RS_SAVE: {
if (this.getSaveCMD() != null && WidgetState.get(this.getSaveCMD()) == Constants.MS_ENABLED) {
return true;
}
else {
return false;
}
}
case CommandMgr.C_RS_INSERT: {
if (this.getInsertCMD() != null && (WidgetState.get(this.getInsertCMD()) == Constants.MS_ENABLED || WidgetState.get(this.getInsertCMD()) == Constants.FS_USAGESTATE)) {
return true;
}
else {
return false;
}
}
case CommandMgr.C_RS_DELETE: {
if (this.getDeleteCMD() != null && WidgetState.get(this.getDeleteCMD()) == Constants.MS_ENABLED) {
return true;
}
else {
return false;
}
}
case CommandMgr.C_RS_FIRST: {
if (this.getFirstCMD() != null && WidgetState.get(this.getFirstCMD()) == Constants.MS_ENABLED) {
return true;
}
else {
return false;
}
}
case CommandMgr.C_RS_LAST: {
if (this.getLastCMD() != null && WidgetState.get(this.getLastCMD()) == Constants.MS_ENABLED) {
return true;
}
else {
return false;
}
}
case CommandMgr.C_RS_NEXT: {
if (this.getNextCMD() != null && WidgetState.get(this.getNextCMD()) == Constants.MS_ENABLED) {
return true;
}
else {
return false;
}
}
case CommandMgr.C_WC_PREFERENCES: {
if (this.getPreferencesCMD() != null && WidgetState.get(this.getPreferencesCMD()) == Constants.MS_ENABLED) {
return true;
}
else {
return false;
}
}
case CommandMgr.C_WC_PRINT: {
if (this.getPrintCMD() != null && WidgetState.get(this.getPrintCMD()) == Constants.MS_ENABLED) {
return true;
}
else {
return false;
}
}
case CommandMgr.C_WC_PRINTSETUP: {
if (this.getPrintSetupCMD() != null && WidgetState.get(this.getPrintSetupCMD()) == Constants.MS_ENABLED) {
return true;
}
else {
return false;
}
}
case CommandMgr.C_RS_PREV: {
if (this.getPrevCMD() != null && WidgetState.get(this.getPrevCMD()) == Constants.MS_ENABLED) {
return true;
}
else {
return false;
}
}
case CommandMgr.C_RS_SEARCH: {
if (this.getSearchCMD() != null && WidgetState.get(this.getSearchCMD()) == Constants.MS_ENABLED) {
return true;
}
else {
return false;
}
}
case CommandMgr.C_WC_MODE: {
if (this.getModeCMD() != null) {
if (IntegerValue.get(this.getModeCMD()) == 1) {
return false;
}
else {
return true;
}
}
break;
}
case CommandMgr.C_RS_REVERT: {
if (this.getRevertCMD() != null && WidgetState.get(this.getRevertCMD()) == Constants.MS_ENABLED) {
return true;
}
else {
return false;
}
}
}
//
// Should never get here, but if we do, return FALSE
//
return false;
}
/**
* hideCommand<p>
* HideCommand<br>
* HideCommand makes the command invisible to the user.<br>
* <p>
* @param command Type: int
*/
public void hideCommand(int command) {
switch (command) {
case CommandMgr.C_WC_CANCEL: {
if (this.getCancelCMD() != null) {
this.hideCommand(this.getCancelCMD());
}
break;
}
case CommandMgr.C_RS_CLEAR: {
if (this.getClearCMD() != null) {
this.hideCommand(this.getClearCMD());
this.hideCommand(this.getClearSP());
}
break;
}
case CommandMgr.C_WC_CLOSE: {
if (this.getCloseCMD() != null) {
this.hideCommand(this.getCloseCMD());
}
break;
}
case CommandMgr.C_RS_SAVE: {
if (this.getSaveCMD() != null) {
this.hideCommand(this.getSaveCMD());
this.hideCommand(this.getSaveSP());
}
break;
}
case CommandMgr.C_RS_INSERT: {
if (this.getInsertCMD() != null) {
this.hideCommand(this.getInsertCMD());
}
break;
}
case CommandMgr.C_RS_DELETE: {
if (this.getDeleteCMD() != null) {
this.hideCommand(this.getDeleteCMD());
}
break;
}
case CommandMgr.C_WC_EXITALL: {
if (this.getExitAllCMD() != null) {
this.hideCommand(this.getExitAllCMD());
this.hideCommand(this.getCloseSP());
}
break;
}
case CommandMgr.C_RS_FIRST: {
if (this.getFirstCMD() != null) {
this.hideCommand(this.getFirstCMD());
}
break;
}
case CommandMgr.C_RS_LAST: {
if (this.getLastCMD() != null) {
this.hideCommand(this.getLastCMD());
}
break;
}
case CommandMgr.C_RS_NEXT: {
if (this.getNextCMD() != null) {
this.hideCommand(this.getNextCMD());
}
break;
}
case CommandMgr.C_WC_PREFERENCES: {
if (this.getPreferencesCMD() != null) {
this.hideCommand(this.getPreferencesCMD());
this.hideCommand(this.getPreferencesSP());
}
break;
}
case CommandMgr.C_WC_PRINT: {
if (this.getPrintCMD() != null) {
this.hideCommand(this.getPrintCMD());
}
break;
}
case CommandMgr.C_WC_PRINTSETUP: {
if (this.getPrintSetupCMD() != null) {
this.hideCommand(this.getPrintSetupCMD());
}
break;
}
case CommandMgr.C_RS_PREV: {
if (this.getPrevCMD() != null) {
this.hideCommand(this.getPrevCMD());
this.hideCommand(this.getScrollSP());
this.hideCommand(this.getScrollToSP());
}
break;
}
case CommandMgr.C_RS_SEARCH: {
if (this.getSearchCMD() != null) {
this.hideCommand(this.getSearchCMD());
}
break;
}
case CommandMgr.C_WC_MODE: {
if (this.getModeCMD() != null) {
this.hideCommand(this.getModeCMD());
this.hideCommand(this.getModeSP());
}
break;
}
case CommandMgr.C_RS_REVERT: {
if (this.getRevertCMD() != null) {
this.hideCommand(this.getRevertCMD());
this.hideCommand(this.getRevertSP());
}
break;
}
}
}
/**
* hideCommand<p>
* HideCommand<br>
* HideCommand makes a command invisible and<br>
* makes it's parent CompoundMenus invisible if<br>
* they have no visible children.<br>
* <p>
* @param command Type: MenuElement
*/
@SuppressWarnings("unchecked")
public void hideCommand(MenuElement command) {
boolean foundVisible = false;
JMenu parent = null;
//
// make this command invisible
//
if (command != null) {
WidgetState.set(command, Constants.MS_INVISIBLE);
}
//
// if the command is in a grid field, we may want to
// make the parent invisible too (if it has no visible
// children. Get a pointer to the parent.
//
if (command != null && Parent.get(command) != null && Parent.get(command) instanceof JMenu) {
parent = (JMenu)Parent.get(command);
}
//
// loop through successive parents, making each invisible
// until we find a visible child.
//
//
// look for a visible child in this parent.
//
while (foundVisible == false && parent != null) {
Array_Of_MenuElement<MenuElement> qq_localVector = new Array_Of_MenuElement(MenuElement.class, parent.getComponents());
if (qq_localVector != null) {
for (MenuElement c : qq_localVector) {
if (WidgetState.get(c) != Constants.MS_INVISIBLE) {
foundVisible = true;
break;
}
}
}
//
// if we find none visible, make this parent invisible
// and look at it's parent (but only if it's a CompoundMenu).
//
if (foundVisible == false) {
WidgetState.set(parent, Constants.MS_INVISIBLE);
if (Parent.get((MenuElement)parent) != null && Parent.get((MenuElement)parent) instanceof JMenu) {
parent = (JMenu)Parent.get((MenuElement)parent);
}
else {
parent = null;
}
}
}
}
/**
* removeCommand<p>
* RemoveCommand<br>
* RemoveCommand makes the command invisible to the user.<br>
* <p>
* @param command Type: int
*/
public void removeCommand(int command) {
switch (command) {
case CommandMgr.C_WC_CANCEL: {
if (this.getCancelCMD() != null) {
this.removeCommand(this.getCancelCMD());
}
break;
}
case CommandMgr.C_RS_CLEAR: {
if (this.getClearCMD() != null) {
this.removeCommand(this.getClearCMD());
this.removeCommand(this.getClearSP());
}
break;
}
case CommandMgr.C_WC_CLOSE: {
if (this.getCloseCMD() != null) {
this.removeCommand(this.getCloseCMD());
}
break;
}
case CommandMgr.C_RS_SAVE: {
if (this.getSaveCMD() != null) {
this.removeCommand(this.getSaveCMD());
this.removeCommand(this.getSaveSP());
}
break;
}
case CommandMgr.C_RS_INSERT: {
if (this.getInsertCMD() != null) {
this.removeCommand(this.getInsertCMD());
}
break;
}
case CommandMgr.C_RS_DELETE: {
if (this.getDeleteCMD() != null) {
this.removeCommand(this.getDeleteCMD());
}
break;
}
case CommandMgr.C_WC_EDITMENU: {
if (this.getEditMenu() != null) {
Parent.set(this.getEditMenu(), (Component)null);
}
break;
}
case CommandMgr.C_WC_EXITALL: {
if (this.getExitAllCMD() != null) {
this.removeCommand(this.getExitAllCMD());
this.removeCommand(this.getCloseSP());
}
break;
}
case CommandMgr.C_RS_FIRST: {
if (this.getFirstCMD() != null) {
this.removeCommand(this.getFirstCMD());
}
break;
}
case CommandMgr.C_RS_LAST: {
if (this.getLastCMD() != null) {
this.removeCommand(this.getLastCMD());
}
break;
}
case CommandMgr.C_RS_NEXT: {
if (this.getNextCMD() != null) {
this.removeCommand(this.getNextCMD());
}
break;
}
case CommandMgr.C_WC_PREFERENCES: {
if (this.getPreferencesCMD() != null) {
this.removeCommand(this.getPreferencesCMD());
this.removeCommand(this.getPreferencesSP());
}
break;
}
case CommandMgr.C_WC_PRINT: {
if (this.getPrintCMD() != null) {
this.removeCommand(this.getPrintCMD());
}
break;
}
case CommandMgr.C_WC_PRINTSETUP: {
if (this.getPrintSetupCMD() != null) {
this.removeCommand(this.getPrintSetupCMD());
}
break;
}
case CommandMgr.C_RS_PREV: {
if (this.getPrevCMD() != null) {
this.removeCommand(this.getPrevCMD());
this.removeCommand(this.getScrollSP());
this.removeCommand(this.getScrollToSP());
}
break;
}
case CommandMgr.C_RS_SEARCH: {
if (this.getSearchCMD() != null) {
this.removeCommand(this.getSearchCMD());
}
break;
}
case CommandMgr.C_WC_MODE: {
if (this.getModeCMD() != null) {
this.removeCommand(this.getModeCMD());
this.removeCommand(this.getModeSP());
}
break;
}
case CommandMgr.C_RS_REVERT: {
if (this.getRevertCMD() != null) {
this.removeCommand(this.getRevertCMD());
this.removeCommand(this.getRevertSP());
}
break;
}
case CommandMgr.C_RS_SCROLL: {
if (this.getScrollMenu() != null) {
Parent.set(this.getScrollMenu(), (Component)null);
}
break;
}
}
}
/**
* removeCommand<p>
* RemoveCommand<br>
* RemoveCommand removes a command from the menu which<br>
* contains it and removes its parent CompoundMenu(s)<br>
* if it has no visible children.<br>
* <p>
* @param command Type: MenuElement
*/
public void removeCommand(MenuElement command) {
JMenu parent = null;
//
// if the command is in a sub menu, we may want to
// make the parent invisible too (if it has no visible
// children). Get a pointer to the parent.
//
if (command != null && Parent.get(command) != null && Parent.get(command) instanceof GridField) {
parent = (JMenu)Parent.get(command);
}
//
// deparent this command
//
if (command != null) {
Parent.set(command, null);
}
//
// loop through successive parents, removing each
// until we find one with children.
//
//
// if the parent has any children, then exit the loop
//
while (parent != null) {
if (parent.getItemCount() > 0) {
parent = null;
break;
}
else {
//
// keep a temporary pointer to the current parent
//
JMenu temp = parent;
//
// find a pointer to the parent's parent
//
if (Parent.get((MenuElement)parent) != null && Parent.get((MenuElement)parent) instanceof JMenu) {
parent = (JMenu)Parent.get((MenuElement)parent);
}
else {
parent = null;
}
//
// deparent the current parent
//
Parent.set(temp, (Component)null);
}
}
}
/**
* removeExtraSeparators<p>
* RemoveExtraSeparators<br>
* RemoveExtraSeparators traverses the menu tree and<br>
* removes separators at the start of a menu, when there<br>
* are two separators in a row, and at the end of a menu<br>
* <p>
*/
@SuppressWarnings("unchecked")
public void removeExtraSeparators() {
Array_Of_MenuElement<MenuElement> qq_localVector = new Array_Of_MenuElement(MenuElement.class, this.getWindow().getJMenuBar().getComponents());
if (qq_localVector != null) {
for (MenuElement m : qq_localVector) {
this.removeExtraSeparators((JMenu)m);
}
}
}
/**
* removeExtraSeparators<p>
* RemoveExtraSeparators<br>
* RemoveExtraSeparators traverses the given menu tree and<br>
* removes separators at the start of a menu, when there<br>
* are two separators in a row, and at the end of a menu.<br>
* Also, remove empty menus and submenus.<br>
* <p>
* @param menu Type: JMenu
*/
public void removeExtraSeparators(JMenu menu) {
for (int i = menu.getItemCount(); i >= 1; i--) {
//
// if this is a separator and it is the first item,
// the last item, or a separator that follows another
// separator, remove it.
//
if (menu.getMenuComponent(i-1) instanceof MenuSeparator && (i == 1 || i == menu.getItemCount() || (i > 1 && menu.getMenuComponent(i-1-1) instanceof MenuSeparator))) {
Parent.set((JComponent)menu.getMenuComponent(i-1), (Component)null);
//
// if this is a menu itself, remove it's extra separators
//
}
else if (menu.getMenuComponent(i-1) instanceof JMenu) {
this.removeExtraSeparators((JMenu)(menu.getMenuComponent(i-1)));
}
}
if (menu.getItemCount() == 0) {
Parent.set(menu, (Component)null);
}
}
/**
* removeSet<p>
* RemoveSet<br>
* RemoveSet makes the entire command set invisible<br>
* to the user.<br>
* <p>
*/
public void removeSet() {
this.getWindow().setJMenuBar(null);
}
/**
* setState<p>
* SetState<br>
* SetState enables or disables the given command.<br>
* <p>
* @param command Type: int
* @param state Type: boolean
*/
public void setState(int command, boolean state) {
switch (command) {
case CommandMgr.C_WC_CANCEL: {
if (this.getCancelCMD() != null) {
if (state == true) {
WidgetState.set(this.getCancelCMD(), Constants.MS_ENABLE);
}
else {
WidgetState.set(this.getCancelCMD(), Constants.MS_DISABLED);
}
}
break;
}
case CommandMgr.C_RS_CLEAR: {
if (this.getClearCMD() != null) {
if (state == true) {
WidgetState.set(this.getClearCMD(), Constants.MS_ENABLE);
}
else {
WidgetState.set(this.getClearCMD(), Constants.MS_DISABLED);
}
if (this.getClearSP() != null) {
WidgetState.set((JComponent)this.getClearSP(), Constants.MS_ENABLE);
}
}
break;
}
case CommandMgr.C_WC_CLOSE: {
if (this.getCloseCMD() != null) {
if (state == true) {
WidgetState.set(this.getCloseCMD(), Constants.MS_ENABLE);
}
else {
WidgetState.set(this.getCloseCMD(), Constants.MS_DISABLED);
}
}
break;
}
case CommandMgr.C_RS_SAVE: {
if (this.getSaveCMD() != null) {
if (state == true) {
WidgetState.set(this.getSaveCMD(), Constants.MS_ENABLE);
}
else {
WidgetState.set(this.getSaveCMD(), Constants.MS_DISABLED);
}
if (this.getSaveSP() != null) {
WidgetState.set((JComponent)this.getSaveSP(), Constants.MS_ENABLE);
}
}
break;
}
case CommandMgr.C_RS_INSERT: {
if (this.getInsertCMD() != null) {
if (state == true) {
WidgetState.set(this.getInsertCMD(), Constants.MS_ENABLE);
}
else {
WidgetState.set(this.getInsertCMD(), Constants.MS_DISABLED);
}
}
break;
}
case CommandMgr.C_RS_DELETE: {
if (this.getDeleteCMD() != null) {
if (state == true) {
WidgetState.set(this.getDeleteCMD(), Constants.MS_ENABLE);
}
else {
WidgetState.set(this.getDeleteCMD(), Constants.MS_DISABLED);
}
}
break;
}
case CommandMgr.C_RS_FIRST: {
if (this.getFirstCMD() != null) {
if (state == true) {
WidgetState.set(this.getFirstCMD(), Constants.MS_ENABLE);
}
else {
WidgetState.set(this.getFirstCMD(), Constants.MS_DISABLED);
}
}
break;
}
case CommandMgr.C_RS_LAST: {
if (this.getLastCMD() != null) {
if (state == true) {
WidgetState.set(this.getLastCMD(), Constants.MS_ENABLE);
}
else {
WidgetState.set(this.getLastCMD(), Constants.MS_DISABLED);
}
}
break;
}
case CommandMgr.C_RS_NEXT: {
if (this.getNextCMD() != null) {
if (state == true) {
WidgetState.set(this.getNextCMD(), Constants.MS_ENABLE);
}
else {
WidgetState.set(this.getNextCMD(), Constants.MS_DISABLED);
}
}
break;
}
case CommandMgr.C_WC_PREFERENCES: {
if (this.getPreferencesCMD() != null) {
if (state == true) {
WidgetState.set(this.getPreferencesCMD(), Constants.MS_ENABLE);
}
else {
WidgetState.set(this.getPreferencesCMD(), Constants.MS_DISABLED);
}
if (this.getPreferencesSP() != null) {
WidgetState.set((JComponent)this.getPreferencesSP(), Constants.MS_ENABLE);
}
}
break;
}
case CommandMgr.C_WC_PRINT: {
if (this.getPrintCMD() != null) {
if (state == true) {
WidgetState.set(this.getPrintCMD(), Constants.MS_ENABLE);
}
else {
WidgetState.set(this.getPrintCMD(), Constants.MS_DISABLED);
}
}
break;
}
case CommandMgr.C_WC_PRINTSETUP: {
if (this.getPrintSetupCMD() != null) {
if (state == true) {
WidgetState.set(this.getPrintSetupCMD(), Constants.MS_ENABLE);
}
else {
WidgetState.set(this.getPrintSetupCMD(), Constants.MS_DISABLED);
}
}
break;
}
case CommandMgr.C_RS_PREV: {
if (this.getPrevCMD() != null) {
if (state == true) {
WidgetState.set(this.getPrevCMD(), Constants.MS_ENABLE);
}
else {
WidgetState.set(this.getPrevCMD(), Constants.MS_DISABLED);
}
if (this.getScrollSP() != null) {
WidgetState.set((JComponent)this.getScrollSP(), Constants.MS_ENABLE);
}
if (this.getScrollToSP() != null) {
WidgetState.set((JComponent)this.getScrollToSP(), Constants.MS_ENABLE);
}
if (this.getScrollMenu() != null) {
WidgetState.set(this.getScrollMenu(), Constants.MS_ENABLE);
}
}
break;
}
case CommandMgr.C_RS_SEARCH: {
if (this.getSearchCMD() != null) {
if (state == true) {
WidgetState.set(this.getSearchCMD(), Constants.MS_ENABLE);
}
else {
WidgetState.set(this.getSearchCMD(), Constants.MS_DISABLED);
}
}
break;
}
case CommandMgr.C_WC_MODE: {
if (this.getModeCMD() != null) {
if (state == true) {
IntegerValue.set(this.getModeCMD(), 2);
}
else {
IntegerValue.set(this.getModeCMD(), 1);
}
if (this.getModeSP() != null) {
WidgetState.set((JComponent)this.getModeSP(), Constants.MS_ENABLE);
}
}
break;
}
case CommandMgr.C_RS_REVERT: {
if (this.getRevertCMD() != null) {
if (state == true) {
WidgetState.set(this.getRevertCMD(), Constants.MS_ENABLE);
}
else {
WidgetState.set(this.getRevertCMD(), Constants.MS_DISABLED);
}
if (this.getRevertSP() != null) {
WidgetState.set((JComponent)this.getRevertSP(), Constants.MS_ENABLE);
}
}
break;
}
}
}
/**
* showCommand<p>
* ShowCommand<br>
* ShowCommand makes the command visible to the user.<br>
* <p>
* @param command Type: int
*/
public void showCommand(int command) {
switch (command) {
case CommandMgr.C_WC_CANCEL: {
if (this.getCancelCMD() != null) {
WidgetState.set(this.getCancelCMD(), Constants.MS_ENABLED);
}
break;
}
case CommandMgr.C_RS_CLEAR: {
if (this.getClearCMD() != null) {
WidgetState.set(this.getClearCMD(), Constants.MS_ENABLED);
}
break;
}
case CommandMgr.C_WC_CLOSE: {
if (this.getCloseCMD() != null) {
WidgetState.set(this.getCloseCMD(), Constants.MS_ENABLED);
}
break;
}
case CommandMgr.C_RS_SAVE: {
if (this.getSaveCMD() != null) {
WidgetState.set(this.getSaveCMD(), Constants.MS_ENABLED);
}
break;
}
case CommandMgr.C_RS_INSERT: {
if (this.getInsertCMD() != null) {
WidgetState.set(this.getInsertCMD(), Constants.MS_ENABLED);
}
break;
}
case CommandMgr.C_RS_DELETE: {
if (this.getDeleteCMD() != null) {
WidgetState.set(this.getDeleteCMD(), Constants.MS_ENABLED);
}
break;
}
case CommandMgr.C_WC_EXITALL: {
if (this.getCloseCMD() != null) {
WidgetState.set(this.getExitAllCMD(), Constants.MS_ENABLED);
if (this.getState(CommandMgr.C_WC_CLOSE) == true || this.getState(CommandMgr.C_WC_CANCEL) == true) {
WidgetState.set((JComponent)this.getCloseSP(), Constants.MS_ENABLED);
}
else {
WidgetState.set((JComponent)this.getCloseSP(), Constants.MS_INVISIBLE);
}
}
break;
}
case CommandMgr.C_RS_FIRST: {
if (this.getFirstCMD() != null) {
WidgetState.set(this.getFirstCMD(), Constants.MS_ENABLED);
}
break;
}
case CommandMgr.C_RS_LAST: {
if (this.getLastCMD() != null) {
WidgetState.set(this.getLastCMD(), Constants.MS_ENABLED);
}
break;
}
case CommandMgr.C_RS_NEXT: {
if (this.getNextCMD() != null) {
WidgetState.set(this.getNextCMD(), Constants.MS_ENABLED);
}
break;
}
case CommandMgr.C_WC_PREFERENCES: {
if (this.getPreferencesCMD() != null) {
WidgetState.set(this.getPreferencesCMD(), Constants.MS_ENABLED);
}
break;
}
case CommandMgr.C_WC_PRINT: {
if (this.getPrintCMD() != null) {
WidgetState.set(this.getPrintCMD(), Constants.MS_ENABLED);
}
break;
}
case CommandMgr.C_WC_PRINTSETUP: {
if (this.getPrintSetupCMD() != null) {
WidgetState.set(this.getPrintSetupCMD(), Constants.MS_ENABLED);
}
break;
}
case CommandMgr.C_RS_PREV: {
if (this.getPrevCMD() != null) {
WidgetState.set(this.getPrevCMD(), Constants.MS_ENABLED);
}
break;
}
case CommandMgr.C_RS_SEARCH: {
if (this.getSearchCMD() != null) {
WidgetState.set(this.getSearchCMD(), Constants.MS_ENABLED);
}
break;
}
case CommandMgr.C_WC_MODE: {
if (this.getModeCMD() != null) {
WidgetState.set(this.getModeCMD(), Constants.MS_ENABLED);
}
break;
}
case CommandMgr.C_RS_REVERT: {
if (this.getRevertCMD() != null) {
WidgetState.set(this.getRevertCMD(), Constants.MS_ENABLED);
}
break;
}
}
}
} // end class MenuSetDesc
// c Pass 2 Conversion Time: 3250 milliseconds