在实际应用中,可能有些菜单项对于用户来说用不上,又或许是希望有些客户不能对某些菜单项进行操作,那么就可以对设计器的某些菜单栏和工具栏进行是否可见控制。
菜单栏和工具栏的自动控制功能由程序员自己编程实现,所有的菜单项都通过GCMenu获取对应的菜单项。
代码例子:
FrameMain mainFram = FrameMain.main0(args);
//设置菜单的可视
MenuMain menu = (MenuMain)GVIde.appMenu;
JMenuItem menuiNEW= menu.getMenuItem(GCMenu.iNEW);
menuiNEW.setVisible(false);
………
//设置工具栏的可视
ToolBarProperty topBar = (ToolBarProperty)GVIde.toolBarProperty;
JComponent comp = topBar.getButtonComponent(GCMenu.iNEW);
comp.setVisible(false);
comp = topBar.getButtonComponent(GCToolBar.iBOLD);
comp.setVisible(false);
……….
mainFram.setVisible(true);
mainFram.startAutoRecent();
FrameMain.startAutoLogin();
从上面的代码例子可以看出来,我们可以通过GCMenu类里i开头的项,获取相应的菜单项,比如:GCMenu.iNEW。 com.runqian.report4.ide.base.GCMenu
public class GCMenu {
//文件
public static final String FILE = "file";
public static final String NEW = "file.new";
public static final String OPEN = "file.open";
public static final String QUICKOPEN = "file.quickopen";
public static final String SAVE = "file.save";
public static final String SAVEAS = "file.saveas";
public static final String CLOSE = "file.close";
public static final String CLOSE_ALL = "file.closeall";
public static final String PRINT = "file.print";
public static final String PREVIEW = "file.preview";
public static final String QUIT = "file.quit";
// public static final short iFILE = 0;
public static final short iNEW = 5;
public static final short iOPEN = 10;
public static final short iQUICKOPEN = 15;
public static final short iSAVE = 20;
public static final short iSAVEAS = 25;
public static final short iCLOSE = 30;
public static final short iCLOSE_ALL = 35;
public static final short iPRINT = 50;
public static final short iPREVIEW = 55;
public static final short iQUIT = 60;
//导出
public static final String EXPORT = "file.export";
public static final String EXPORT_EXCEL = "file.export.excel";
public static final String EXPORT_EXCEL_PAGE = "file.export.excelPage";
public static final String EXPORT_EXCEL_FORMULA = "file.export.excelFormula";
public static final String EXPORT_WORD = "file.export.word";
public static final String EXPORT_WORD_PAGE = "file.export.wordPage";
public static final String EXPORT_PDF = "file.export.pdf";
public static final String EXPORT_PDF_PAGE = "file.export.pdfPage";
public static final String EXPORT_TEXT = "file.export.text";
public static final String EXPORT_XML = "file.export.xml";
public static final String RECENT_FILES = "file.recentFiles";
public static final String RECENT_CONNS = "file.recentConns";
public static final String EXPORT_HTML = "file.export.html";
public static final short iEXPORT = 100;
public static final short iEXPORT_EXCEL = iEXPORT + ReportExporter.EXPORT_EXCEL;
public static final short iEXPORT_EXCEL_PAGE = iEXPORT + ReportExporter.EXPORT_EXCEL_PAGE;
public static final short iEXPORT_EXCEL_FORMULA = iEXPORT + ReportExporter.EXPORT_EXCEL_FORMULA;
public static final short iEXPORT_WORD = iEXPORT + ReportExporter.EXPORT_WORD;
public static final short iEXPORT_WORD_PAGE = iEXPORT + ReportExporter.EXPORT_WORD_PAGE;
public static final short iEXPORT_PDF = iEXPORT + ReportExporter.EXPORT_PDF;
public static final short iEXPORT_PDF_PAGE = iEXPORT + ReportExporter.EXPORT_PDF_PAGE;
public static final short iEXPORT_TEXT = iEXPORT + ReportExporter.EXPORT_TEXT;
public static final short iEXPORT_XML = iEXPORT + ReportExporter.EXPORT_XML;
public static final short iEXPORT_HTML = iEXPORT + ReportExporter.EXPORT_HTML;
// public static final short iRECENT_FILES = 150;
// public static final short iRECENT_CONNS = 155;
//编辑
public static final String EDIT = "edit";
public static final String UNDO = "edit.undo";
public static final String REDO = "edit.redo";
public static final String CUT = "edit.cut";
public static final String COPY = "edit.copy";
public static final String PASTE = "edit.paste";
public static final String DELETE = "edit.delete";
public static final String CLEAR_ALL = "edit.clearAll";
public static final String CLEAR_FORMAT = "edit.clearFormat";
public static final String CLEAR_CONTENT = "edit.clearContent";
public static final String CLEAR_INPUT = "edit.clearInput";
public static final String SEARCH = "edit.search";
public static final String REPLACE = "edit.replace";
public static final String CHECKLINEREPORT = "edit.checkLineReport";
public static final String CHECKWHOLEREPORT = "edit.checkWholeReport";
// public static final short iEDIT = 200;
public static final short iUNDO = 205;
public static final short iREDO = 210;
public static final short iCUT = 215;
public static final short iCOPY = 220;
public static final short iPASTE = 225;
//粘贴格子
public static final short iDELETE = 230;
public static final short iCLEAR_ALL = 235;
public static final short iCLEAR_FORMAT = 240;
public static final short iCLEAR_CONTENT = 245;
public static final short iCLEAR_INPUT = 246;
public static final short iSEARCH = 250;
public static final short iREPLACE = 255;
public static final short iCHECKLINEREPORT = 275;
public static final short iCHECKWHOLEREPORT = 280;
//属性
public static final String PROPERTY = "property";
public static final String PROPERTY_ROW = "property.row";
public static final String PROPERTY_COL = "property.col";
public static final String PROPERTY_CEL_BORDER = "property.celBorder";
public static final String PROPERTY_CEL_DATATYPE = "property.celDatatype";
public static final String PROPERTY_CEL_GRAPH = "property.celGraph";
public static final String PROPERTY_CEL_SUBREPORT = "property.celSubreport";
public static final String PROPERTY_CEL_BARCODE = "property.celBarcode";
// public static final String PROPERTY_CEL_FMTSTRING = "property.celFmtString";
public static final String PROPERTY_CEL_EXPRESSION = "property.celExpression";
public static final String PROPERTY_REPORT = "property.report";
public static final String PROPERTY_EXPORT = "property.export";
public static final String PROPERTY_PRINT = "property.print";
public static final String ATTACHED_DATASETS = "property.attacheddatasets";
public static final String REPORTINPUT = "property.reportInput";
// public static final short iPROPERTY = 300;
public static final short iPROPERTY_ROW = 305;
public static final short iPROPERTY_COL = 310;
public static final short iPROPERTY_CEL_BORDER = 325;
public static final short iPROPERTY_CEL_DATATYPE = 330;
public static final short iPROPERTY_CEL_GRAPH = 335;
public static final short iPROPERTY_CEL_SUBREPORT = 340;
public static final short iPROPERTY_CEL_BARCODE = 345;
// public static final short iPROPERTY_CEL_FMTSTRING = 346;
public static final short iPROPERTY_CEL_EXPRESSION = 346;
public static final short iPROPERTY_REPORT = 350;
public static final short iPROPERTY_EXPORT = 355;
public static final short iPROPERTY_PRINT = 358;
public static final short iATTACHED_DATASETS = 360;
public static final short iREPORTINPUT = 365;
//插入
public static final String INSERT = "insert";
public static final String INSERT_BEFOREROW = "insert.insertBeforeRow";
// public static final String INSERT_AFTERROW = "insert.insertAfterRow";
public static final String INSERT_BEFORECOL = "insert.insertBeforeCol";
// public static final String INSERT_AFTERCOL = "insert.insertAfterCol";
public static final String ADDROW = "insert.addRow";
public static final String ADDCOL = "insert.AddCol";
public static final String BACKGROUND = "insert.backGround";
public static final String INSERT_DATASET = "insert.dataset";
// public static final String INSERTDATASET_GRID = "insert.dataset.grid";
// public static final String INSERTDATASET_CROSS = "insert.dataset.cross";
// public static final String INSERTDATASET_GROUP = "insert.dataset.group";
public static final String INSERT_ROWTYPE = "insert.RowType";
public static final String INSERT_COLTYPE = "insert.ColType";
// public static final short iINSERT = 400;
public static final short iINSERT_BEFOREROW = 405;
// public static final short iINSERT_AFTERROW = 406;
public static final short iINSERT_BEFORECOL = 410;
// public static final short iINSERT_AFTERCOL = 411;
public static final short iADDROW = 415;
public static final short iADDCOL = 420;
public static final short iBACKGROUND = 425;
public static final short iINSERT_DATASET = 430;
// public static final short iINSERTDATASET_GRID = 440;
// public static final short iINSERTDATASET_CROSS = 445;
// public static final short iINSERTDATASET_GROUP = 450;
public static final short iINSERT_ROWTYPE = 455;
public static final short iINSERT_COLTYPE = 456;
//配置
public static final String CONFIGURE = "configure";
public static final String ARGUMENT = "configure.argument";
public static final String MACRO = "configure.macro";
public static final String DATASET = "configure.dataset";
// public static final short iCONFIGURE = 500;
public static final short iARGUMENT = 505;
public static final short iMACRO = 510;
public static final short iDATASET = 515;
//系统
public static final String SYSTEM = "system";
public static final String DATASOURCE = "system.dataSource";
public static final String ADDTO_CSSMANAGER = "system.addtocssmanager";
public static final String ADDTO_STYLE_CELL = "system.addtostylecell";
public static final String IMPORTEXCEL = "system.importExcel";
public static final String XMLEDITOR = "system.xmlEditor";
public static final String JSPEDITOR = "system.jspEditor";
public static final String FUNCEDITOR = "system.funcEditor";
public static final String PALETTEEDITOR = "system.paletteEditor";
public static final String RAQTRANSFER = "system.raqTransfer";
// public static final String RAQGROUP = "system.raqGroup";
public static final String OPTION = "system.options";
public static final String CONSOLE = "system.console";
// public static final short iSYSTEM = 600;
public static final short iDATASOURCE = 605;
public static final short iADDTO_CSSMANAGER = 610;
public static final short iADDTO_STYLE_CELL = 611;
public static final short iIMPORTEXCEL = 612;
public static final short iXMLEDITOR = 614;
public static final short iJSPEDITOR = 615;
public static final short iFUNCEDITOR = 616;
public static final short iPALETTEEDITOR = 618;
public static final short iRAQTRANSFER = 620;
// public static final short iRAQGROUP = 621;
public static final short iOPTION = 625;
public static final short iCONSOLE = 630;
//模板
public static final String TEMPLATE = "template";
public static final String SAVETO_TEMPLATE = "template.saveAsTemplate";
public static final String TIDY_TEMPLATE = "template.tidyTemplate";
// public static final short iTEMPLATE = 700;
public static final short iSAVETO_TEMPLATE = 705;
public static final short iTIDY_TEMPLATE = 710;
//语义层
public static final String SEMANTICS = "semantics";
public static final String SEMANTICSOPEN = "semantics.open";
public static final String SEMANTICSCLOSE = "semantics.close";
public static final String SEMANTICSRECENT = "semantics.recent";
public static final String SEMANTICSEDITOR = "semantics.editor";
public static final String SEMANTICSTRANSLATOR = "semantics.translator";
public static final String SEMANTICSREFRESH = "semantics.refresh";
public static final String EDITENUMGROUP = "semantics.editenumgroup";
public static final String SEMANTICSEXPAND = "semantics.expand";
public static final String SEMANTICSSESSION = "semantics.sessionvariable";
// public static final short iTOOLS = 800;
public static final short iSEMANTICSOPEN = 805;
public static final short iSEMANTICSCLOSE = 806;
public static final short iSEMANTICSRECENT = 807;
public static final short iSEMANTICSEDITOR = 815;
public static final short iSEMANTICSTRANSLATOR = 816;
public static final short iSEMANTICSREFRESH = 817;
public static final short iEDITENUMGROUP = 821;
public static final short iSEMANTICSEXPAND = 823;
public static final short iSEMANTICSSESSION = 825;
//远程设计
public static final String REMOTE = "remote";
public static final String REMOTE_LOGIN = "remote.login";
public static final String REMOTE_LOGOUT = "remote.logout";
public static final String REMOTE_OPEN = "remote.open";
public static final String REMOTE_SAVE = "remote.save";
public static final String REMOTE_SAVEAS = "remote.saveas";
public static final String REMOTE_GETSEMANTICS = "remote.getsemantics";
public static final String REMOTE_SESSIONVARIABLE = "remote.sessionvariable";
public static final short iREMOTE_LOGIN = 850;
public static final short iREMOTE_LOGOUT = 851;
public static final short iREMOTE_OPEN = 852;
public static final short iREMOTE_SAVE = 853;
public static final short iREMOTE_SAVEAS = 854;
public static final short iREMOTE_GETSEMANTICS = 855;
public static final short iREMOTE_SESSIONVARIABLE = 856;
//窗口
public static final String WINDOW = "window";
public static final String CASCADE = "window.cascade";
//层叠(C)
public static final String TILEHORIZONTAL = "window.tileHorizontal";
//水平平铺(H)
public static final String TILEVERTICAL = "window.tileVertical";
//垂直平铺(V)
public static final String LAYER = "window.layer";
//填充(L)
// public static final short iWINDOW = 900;
public static final short iCASCADE = 905;
public static final short iTILEHORIZONTAL = 910;
//水平平铺(H)
public static final short iTILEVERTICAL = 915;
//垂直平铺(V)
public static final short iLAYER = 920;
//填充(L)
//帮助
public static final String HELP = "help";
public static final String ABOUT = "help.about";
public static final String MEMORYTIDY = "help.memoryTidy";
// public static final short iHELP = 1000;
public static final short iABOUT = 1005;
public static final short iMEMORYTIDY = 1010;
public static javax.swing.ImageIcon getImageIcon(String menuId) {
String iconText; int dot = menuId.indexOf("."); if (dot > 0) {
iconText = menuId.substring(dot + 1);
} else { iconText = menuId; }
String iconPath = GC.IMAGES_PATH + "m_" + iconText.toLowerCase() + ".gif"; return GM.getImageIcon(iconPath);
}
}