List of usage examples for com.google.gwt.user.client.ui MenuBar setAutoOpen
public void setAutoOpen(boolean autoOpen)
From source file:com.appspot.socialinquirer.client.SocialInquirer.java
License:Apache License
/** * Creates the menu bar./* www . j a va2 s . c o m*/ * * @param constants the constants * @param user the user * @return the menu bar */ private MenuBar createMenuBar(final EverScribeConstants constants, final User user) { final boolean enabled = (user != null); final MenuBar menu = new MenuBar(); GWT.runAsync(new RunAsyncCallback() { public void onFailure(Throwable caught) { UiUtils.showErrorDialog(constants, constants.errorCodeDownloadFailed()); } public void onSuccess() { menu.setAutoOpen(true); menu.setAnimationEnabled(true); MenuItem homeMenuItem = new MenuItem(constants.homeMenuName(), new HistoryCommand(HistoryToken.Home)); homeMenuItem.setEnabled(enabled); menu.addItem(homeMenuItem); MenuBar networkMenuItem = new MenuBar(true); networkMenuItem.setAnimationEnabled(true); menu.addItem(new MenuItem(constants.networkMenuName(), networkMenuItem)); MenuItem nfMenuItem = new MenuItem(constants.followersMenuName(), new HistoryCommand(HistoryToken.Network_Followers)); nfMenuItem.setEnabled(enabled); networkMenuItem.addItem(nfMenuItem); nfMenuItem = new MenuItem(constants.followingMenuName(), new HistoryCommand(HistoryToken.Network_Following)); nfMenuItem.setEnabled(enabled); networkMenuItem.addItem(nfMenuItem); nfMenuItem = new MenuItem(constants.recommendedMenuName(), new HistoryCommand(HistoryToken.Network_Recommended)); nfMenuItem.setEnabled(enabled); networkMenuItem.addItem(nfMenuItem); MenuBar activityMenuItem = new MenuBar(true); activityMenuItem.setAnimationEnabled(true); menu.addItem(new MenuItem(constants.activityMenuName(), activityMenuItem)); MenuItem aMenuItem = new MenuItem(constants.tasksMenuName(), new HistoryCommand(HistoryToken.Activity_Tasks)); aMenuItem.setEnabled(enabled); activityMenuItem.addItem(aMenuItem); aMenuItem = new MenuItem(constants.pollMenuName(), new HistoryCommand(HistoryToken.Activity_Polls)); aMenuItem.setEnabled(enabled); activityMenuItem.addItem(aMenuItem); aMenuItem = new MenuItem(constants.quizMenuName(), new HistoryCommand(HistoryToken.Activity_Quizzes)); aMenuItem.setEnabled(enabled); activityMenuItem.addItem(aMenuItem); aMenuItem = new MenuItem(constants.pagesMenuName(), new HistoryCommand(HistoryToken.Activity_Pages)); aMenuItem.setEnabled(enabled); activityMenuItem.addItem(aMenuItem); aMenuItem = new MenuItem(constants.messagesMenuName(), new HistoryCommand(HistoryToken.Activity_Messages)); aMenuItem.setEnabled(enabled); activityMenuItem.addItem(aMenuItem); aMenuItem = new MenuItem(constants.endorsementsMenuName(), new HistoryCommand(HistoryToken.Activity_Endorsements)); aMenuItem.setEnabled(enabled); activityMenuItem.addItem(aMenuItem); // MenuBar pagesMenuItem = new MenuBar(true); // pagesMenuItem.setAnimationEnabled(true); // menu.addItem(new MenuItem(constants.pagesMenuName(), // pagesMenuItem)); // aMenuItem = new MenuItem(constants // .followingMenuName(), new HistoryCommand(HistoryToken.Pages_Following)); // aMenuItem.setEnabled(enabled); // pagesMenuItem.addItem(aMenuItem); // aMenuItem = new MenuItem(constants // .ownedMenuName(), new HistoryCommand(HistoryToken.Pages_Created)); // aMenuItem.setEnabled(enabled); // pagesMenuItem.addItem(aMenuItem); // aMenuItem = new MenuItem(constants // .recommendedMenuName(), new HistoryCommand(HistoryToken.Pages_Recommended)); // aMenuItem.setEnabled(enabled); // pagesMenuItem.addItem(aMenuItem); MenuBar questionsMenuItem = new MenuBar(true); questionsMenuItem.setAnimationEnabled(true); menu.addItem(new MenuItem(constants.questionsMenuName(), questionsMenuItem)); aMenuItem = new MenuItem(constants.askedMenuName(), new HistoryCommand(HistoryToken.Questions_Asked)); aMenuItem.setEnabled(enabled); questionsMenuItem.addItem(aMenuItem); aMenuItem = new MenuItem(constants.answeredMenuName(), new HistoryCommand(HistoryToken.Questions_Answered)); aMenuItem.setEnabled(enabled); questionsMenuItem.addItem(aMenuItem); aMenuItem = new MenuItem(constants.followingMenuName(), new HistoryCommand(HistoryToken.Questions_Following)); aMenuItem.setEnabled(enabled); questionsMenuItem.addItem(aMenuItem); aMenuItem = new MenuItem(constants.recommendedMenuName(), new HistoryCommand(HistoryToken.Questions_Recommended)); aMenuItem.setEnabled(enabled); questionsMenuItem.addItem(aMenuItem); MenuBar tagsMenuItem = new MenuBar(true); tagsMenuItem.setAnimationEnabled(true); menu.addItem(new MenuItem(constants.tagsMenuName(), tagsMenuItem)); aMenuItem = new MenuItem(constants.ownedMenuName(), new HistoryCommand(HistoryToken.Topics_Active)); aMenuItem.setEnabled(enabled); tagsMenuItem.addItem(aMenuItem); aMenuItem = new MenuItem(constants.followingMenuName(), new HistoryCommand(HistoryToken.Topics_Following)); aMenuItem.setEnabled(enabled); tagsMenuItem.addItem(aMenuItem); aMenuItem = new MenuItem(constants.recommendedMenuName(), new HistoryCommand(HistoryToken.Topics_Recommended)); aMenuItem.setEnabled(enabled); tagsMenuItem.addItem(aMenuItem); MenuBar accountMenu = new MenuBar(true); accountMenu.setAnimationEnabled(true); menu.addItem(new MenuItem(constants.accountMenuName(), accountMenu)); MenuItem loginMenuItem = new MenuItem(constants.loginMenuName(), new LoginCommand(constants)); loginMenuItem.setEnabled(!enabled); accountMenu.addItem(loginMenuItem); MenuItem logoutMenuItem = new MenuItem(constants.logoutMenuName(), new LogoutCommand(constants)); logoutMenuItem.setEnabled(enabled); accountMenu.addItem(logoutMenuItem); MenuItem settingsMenuItem = new MenuItem(constants.settingsMenuName(), new HistoryCommand(HistoryToken.Settings)); settingsMenuItem.setEnabled(enabled); accountMenu.addItem(settingsMenuItem); } }); return menu; }
From source file:com.codenvy.ide.client.elements.widgets.element.ElementViewImpl.java
License:Open Source License
private void preparePopup(@Nonnull Element element) { MenuBar menuBar = new MenuBar(true); menuBar.addStyleName(resources.editorCSS().branchBackground()); menuBar.addStyleName(resources.editorCSS().gwtMenuItemSelected()); MenuItem delete = new MenuItem("Delete", true, new Command() { @Override//from w ww .ja v a 2s .co m public void execute() { delegate.onDeleteActionClicked(); } }); menuBar.addItem(delete); menuBar.setAutoOpen(true); if (element.isPossibleToAddBranches()) { MenuItem amountOfBranches = new MenuItem("Number of branches", true, new Command() { @Override public void execute() { delegate.onChangeNumberBranchesActionClicked(); } }); menuBar.addItem(amountOfBranches); } popup = new PopupPanel(true, true); popup.add(menuBar); }
From source file:com.google.gwt.sample.showcase.client.content.lists.CwMenuBar.java
License:Apache License
/** * Initialize this example.//w w w . ja v a2 s .co m */ @ShowcaseSource @Override public Widget onInitialize() { // Create a command that will execute on menu item selection Command menuCommand = new Command() { private int curPhrase = 0; private final String[] phrases = constants.cwMenuBarPrompts(); public void execute() { Window.alert(phrases[curPhrase]); curPhrase = (curPhrase + 1) % phrases.length; } }; // Create a menu bar MenuBar menu = new MenuBar(); menu.setAutoOpen(true); menu.setWidth("500px"); menu.setAnimationEnabled(true); // Create a sub menu of recent documents MenuBar recentDocsMenu = new MenuBar(true); String[] recentDocs = constants.cwMenuBarFileRecents(); for (int i = 0; i < recentDocs.length; i++) { recentDocsMenu.addItem(recentDocs[i], menuCommand); } // Create the file menu MenuBar fileMenu = new MenuBar(true); fileMenu.setAnimationEnabled(true); menu.addItem(new MenuItem(constants.cwMenuBarFileCategory(), fileMenu)); String[] fileOptions = constants.cwMenuBarFileOptions(); for (int i = 0; i < fileOptions.length; i++) { if (i == 3) { fileMenu.addSeparator(); fileMenu.addItem(fileOptions[i], recentDocsMenu); fileMenu.addSeparator(); } else { fileMenu.addItem(fileOptions[i], menuCommand); } } // Create the edit menu MenuBar editMenu = new MenuBar(true); menu.addItem(new MenuItem(constants.cwMenuBarEditCategory(), editMenu)); String[] editOptions = constants.cwMenuBarEditOptions(); for (int i = 0; i < editOptions.length; i++) { editMenu.addItem(editOptions[i], menuCommand); } // Create the GWT menu MenuBar gwtMenu = new MenuBar(true); menu.addItem(new MenuItem("GWT", true, gwtMenu)); String[] gwtOptions = constants.cwMenuBarGWTOptions(); for (int i = 0; i < gwtOptions.length; i++) { gwtMenu.addItem(gwtOptions[i], menuCommand); } // Create the help menu MenuBar helpMenu = new MenuBar(true); menu.addSeparator(); menu.addItem(new MenuItem(constants.cwMenuBarHelpCategory(), helpMenu)); String[] helpOptions = constants.cwMenuBarHelpOptions(); for (int i = 0; i < helpOptions.length; i++) { helpMenu.addItem(helpOptions[i], menuCommand); } // Return the menu menu.ensureDebugId("cwMenuBar"); return menu; }
From source file:com.lushprojects.circuitjs1.client.CirSim.java
License:Open Source License
public void init() { boolean printable = false; boolean convention = true; boolean euroRes = false; boolean usRes = false; MenuBar m;// ww w.j av a 2s. c o m CircuitElm.initClass(this); QueryParameters qp = new QueryParameters(); try { //baseURL = applet.getDocumentBase().getFile(); // look for circuit embedded in URL // String doc = applet.getDocumentBase().toString(); String cct = qp.getValue("cct"); if (cct != null) startCircuitText = cct.replace("%24", "$"); startCircuit = qp.getValue("startCircuit"); startLabel = qp.getValue("startLabel"); startCircuitLink = qp.getValue("startCircuitLink"); euroRes = qp.getBooleanValue("euroResistors", false); usRes = qp.getBooleanValue("usResistors", false); printable = qp.getBooleanValue("whiteBackground", getOptionFromStorage("whiteBackground", false)); convention = qp.getBooleanValue("conventionalCurrent", getOptionFromStorage("conventionalCurrent", true)); } catch (Exception e) { } boolean euroSetting = false; if (euroRes) euroSetting = true; else if (usRes) euroSetting = false; else euroSetting = getOptionFromStorage("euroResistors", !weAreInUS()); transform = new double[6]; String os = Navigator.getPlatform(); isMac = (os.toLowerCase().contains("mac")); ctrlMetaKey = (isMac) ? "Cmd" : "Ctrl"; shortcuts = new String[127]; layoutPanel = new DockLayoutPanel(Unit.PX); fileMenuBar = new MenuBar(true); importFromLocalFileItem = new MenuItem(LS("Import From Local File"), new MyCommand("file", "importfromlocalfile")); importFromLocalFileItem.setEnabled(LoadFile.isSupported()); fileMenuBar.addItem(importFromLocalFileItem); importFromTextItem = new MenuItem(LS("Import From Text"), new MyCommand("file", "importfromtext")); fileMenuBar.addItem(importFromTextItem); importFromDropboxItem = new MenuItem(LS("Import From Dropbox"), new MyCommand("file", "importfromdropbox")); fileMenuBar.addItem(importFromDropboxItem); exportAsUrlItem = new MenuItem(LS("Export As Link"), new MyCommand("file", "exportasurl")); fileMenuBar.addItem(exportAsUrlItem); exportAsLocalFileItem = new MenuItem(LS("Export As Local File"), new MyCommand("file", "exportaslocalfile")); exportAsLocalFileItem.setEnabled(ExportAsLocalFileDialog.downloadIsSupported()); fileMenuBar.addItem(exportAsLocalFileItem); exportAsTextItem = new MenuItem(LS("Export As Text"), new MyCommand("file", "exportastext")); fileMenuBar.addItem(exportAsTextItem); exportToDropboxItem = new MenuItem(LS("Export To Dropbox"), new MyCommand("file", "exporttodropbox")); exportToDropboxItem.setEnabled(ExportToDropbox.isSupported()); fileMenuBar.addItem(exportToDropboxItem); fileMenuBar.addSeparator(); aboutItem = new MenuItem(LS("About"), (Command) null); fileMenuBar.addItem(aboutItem); aboutItem.setScheduledCommand(new MyCommand("file", "about")); int width = (int) RootLayoutPanel.get().getOffsetWidth(); VERTICALPANELWIDTH = width / 5; if (VERTICALPANELWIDTH > 166) VERTICALPANELWIDTH = 166; if (VERTICALPANELWIDTH < 128) VERTICALPANELWIDTH = 128; menuBar = new MenuBar(); menuBar.addItem(LS("File"), fileMenuBar); verticalPanel = new VerticalPanel(); // make buttons side by side if there's room buttonPanel = (VERTICALPANELWIDTH == 166) ? new HorizontalPanel() : new VerticalPanel(); m = new MenuBar(true); m.addItem(undoItem = menuItemWithShortcut(LS("Undo"), LS("Ctrl-Z"), new MyCommand("edit", "undo"))); m.addItem(redoItem = menuItemWithShortcut(LS("Redo"), LS("Ctrl-Y"), new MyCommand("edit", "redo"))); m.addSeparator(); m.addItem(cutItem = menuItemWithShortcut(LS("Cut"), LS("Ctrl-X"), new MyCommand("edit", "cut"))); m.addItem(copyItem = menuItemWithShortcut(LS("Copy"), LS("Ctrl-C"), new MyCommand("edit", "copy"))); m.addItem(pasteItem = menuItemWithShortcut(LS("Paste"), LS("Ctrl-V"), new MyCommand("edit", "paste"))); pasteItem.setEnabled(false); m.addItem(menuItemWithShortcut(LS("Duplicate"), LS("Ctrl-D"), new MyCommand("edit", "duplicate"))); m.addSeparator(); m.addItem(selectAllItem = menuItemWithShortcut(LS("Select All"), LS("Ctrl-A"), new MyCommand("edit", "selectAll"))); m.addSeparator(); m.addItem(new MenuItem(weAreInUS() ? LS("Center Circuit") : LS("Centre Circuit"), new MyCommand("edit", "centrecircuit"))); m.addItem(menuItemWithShortcut(LS("Zoom 100%"), "0", new MyCommand("edit", "zoom100"))); m.addItem(menuItemWithShortcut(LS("Zoom In"), "+", new MyCommand("edit", "zoomin"))); m.addItem(menuItemWithShortcut(LS("Zoom Out"), "-", new MyCommand("edit", "zoomout"))); menuBar.addItem(LS("Edit"), m); MenuBar drawMenuBar = new MenuBar(true); drawMenuBar.setAutoOpen(true); menuBar.addItem(LS("Draw"), drawMenuBar); m = new MenuBar(true); m.addItem(new MenuItem(LS("Stack All"), new MyCommand("scopes", "stackAll"))); m.addItem(new MenuItem(LS("Unstack All"), new MyCommand("scopes", "unstackAll"))); m.addItem(new MenuItem(LS("Combine All"), new MyCommand("scopes", "combineAll"))); menuBar.addItem(LS("Scopes"), m); optionsMenuBar = m = new MenuBar(true); menuBar.addItem(LS("Options"), optionsMenuBar); m.addItem(dotsCheckItem = new CheckboxMenuItem(LS("Show Current"))); dotsCheckItem.setState(true); m.addItem(voltsCheckItem = new CheckboxMenuItem(LS("Show Voltage"), new Command() { public void execute() { if (voltsCheckItem.getState()) powerCheckItem.setState(false); setPowerBarEnable(); } })); voltsCheckItem.setState(true); m.addItem(powerCheckItem = new CheckboxMenuItem(LS("Show Power"), new Command() { public void execute() { if (powerCheckItem.getState()) voltsCheckItem.setState(false); setPowerBarEnable(); } })); m.addItem(showValuesCheckItem = new CheckboxMenuItem(LS("Show Values"))); showValuesCheckItem.setState(true); //m.add(conductanceCheckItem = getCheckItem(LS("Show Conductance"))); m.addItem(smallGridCheckItem = new CheckboxMenuItem(LS("Small Grid"), new Command() { public void execute() { setGrid(); } })); m.addItem(crossHairCheckItem = new CheckboxMenuItem(LS("Show Cursor Cross Hairs"), new Command() { public void execute() { setOptionInStorage("crossHair", crossHairCheckItem.getState()); } })); crossHairCheckItem.setState(getOptionFromStorage("crossHair", false)); m.addItem(euroResistorCheckItem = new CheckboxMenuItem(LS("European Resistors"), new Command() { public void execute() { setOptionInStorage("euroResistors", euroResistorCheckItem.getState()); } })); euroResistorCheckItem.setState(euroSetting); m.addItem(printableCheckItem = new CheckboxMenuItem(LS("White Background"), new Command() { public void execute() { int i; for (i = 0; i < scopeCount; i++) scopes[i].setRect(scopes[i].rect); setOptionInStorage("whiteBackground", printableCheckItem.getState()); } })); printableCheckItem.setState(printable); m.addItem(conventionCheckItem = new CheckboxMenuItem(LS("Conventional Current Motion"), new Command() { public void execute() { setOptionInStorage("conventionalCurrent", conventionCheckItem.getState()); } })); conventionCheckItem.setState(convention); m.addItem(optionsItem = new CheckboxAlignedMenuItem(LS("Other Options..."), new MyCommand("options", "other"))); mainMenuBar = new MenuBar(true); mainMenuBar.setAutoOpen(true); composeMainMenu(mainMenuBar); composeMainMenu(drawMenuBar); layoutPanel.addNorth(menuBar, MENUBARHEIGHT); layoutPanel.addEast(verticalPanel, VERTICALPANELWIDTH); RootLayoutPanel.get().add(layoutPanel); cv = Canvas.createIfSupported(); if (cv == null) { RootPanel.get().add(new Label("Not working. You need a browser that supports the CANVAS element.")); return; } cvcontext = cv.getContext2d(); backcv = Canvas.createIfSupported(); backcontext = backcv.getContext2d(); setCanvasSize(); layoutPanel.add(cv); verticalPanel.add(buttonPanel); buttonPanel.add(resetButton = new Button(LS("Reset"))); resetButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { resetAction(); } }); resetButton.setStylePrimaryName("topButton"); buttonPanel.add(runStopButton = new Button(LSHTML("<Strong>RUN</Strong> / Stop"))); runStopButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { setSimRunning(!simIsRunning()); } }); /* dumpMatrixButton = new Button("Dump Matrix"); dumpMatrixButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { dumpMatrix = true; }}); verticalPanel.add(dumpMatrixButton);// IES for debugging */ if (LoadFile.isSupported()) verticalPanel.add(loadFileInput = new LoadFile(this)); Label l; verticalPanel.add(l = new Label(LS("Simulation Speed"))); l.addStyleName("topSpace"); // was max of 140 verticalPanel.add(speedBar = new Scrollbar(Scrollbar.HORIZONTAL, 3, 1, 0, 260)); verticalPanel.add(l = new Label(LS("Current Speed"))); l.addStyleName("topSpace"); currentBar = new Scrollbar(Scrollbar.HORIZONTAL, 50, 1, 1, 100); verticalPanel.add(currentBar); verticalPanel.add(powerLabel = new Label(LS("Power Brightness"))); powerLabel.addStyleName("topSpace"); verticalPanel.add(powerBar = new Scrollbar(Scrollbar.HORIZONTAL, 50, 1, 1, 100)); setPowerBarEnable(); // verticalPanel.add(new Label("")); // Font f = new Font("SansSerif", 0, 10); l = new Label(LS("Current Circuit:")); l.addStyleName("topSpace"); // l.setFont(f); titleLabel = new Label("Label"); // titleLabel.setFont(f); verticalPanel.add(l); verticalPanel.add(titleLabel); verticalPanel.add(iFrame = new Frame("iframe.html")); iFrame.setWidth(VERTICALPANELWIDTH + "px"); iFrame.setHeight("100 px"); iFrame.getElement().setAttribute("scrolling", "no"); setGrid(); elmList = new Vector<CircuitElm>(); // setupList = new Vector(); undoStack = new Vector<String>(); redoStack = new Vector<String>(); scopes = new Scope[20]; scopeColCount = new int[20]; scopeCount = 0; random = new Random(); // cv.setBackground(Color.black); // cv.setForeground(Color.lightGray); elmMenuBar = new MenuBar(true); elmMenuBar.addItem(elmEditMenuItem = new MenuItem(LS("Edit"), new MyCommand("elm", "edit"))); elmMenuBar .addItem(elmScopeMenuItem = new MenuItem(LS("View in Scope"), new MyCommand("elm", "viewInScope"))); elmMenuBar.addItem(elmCutMenuItem = new MenuItem(LS("Cut"), new MyCommand("elm", "cut"))); elmMenuBar.addItem(elmCopyMenuItem = new MenuItem(LS("Copy"), new MyCommand("elm", "copy"))); elmMenuBar.addItem(elmDeleteMenuItem = new MenuItem(LS("Delete"), new MyCommand("elm", "delete"))); elmMenuBar.addItem(new MenuItem(LS("Duplicate"), new MyCommand("elm", "duplicate"))); elmMenuBar.addItem(elmFlipMenuItem = new MenuItem(LS("Swap Terminals"), new MyCommand("elm", "flip"))); scopeMenuBar = buildScopeMenu(false); transScopeMenuBar = buildScopeMenu(true); if (startCircuitText != null) { getSetupList(false); readSetup(startCircuitText, true); } else { if (stopMessage == null && startCircuitLink != null) { readSetup(null, 0, false, true); getSetupList(false); ImportFromDropboxDialog.setSim(this); ImportFromDropboxDialog.doImportDropboxLink(startCircuitLink, false); } else { readSetup(null, 0, false, true); if (stopMessage == null && startCircuit != null) { getSetupList(false); readSetupFile(startCircuit, startLabel, true); } else getSetupList(true); } } enableUndoRedo(); enablePaste(); setiFrameHeight(); cv.addMouseDownHandler(this); cv.addMouseMoveHandler(this); cv.addMouseOutHandler(this); cv.addMouseUpHandler(this); cv.addClickHandler(this); cv.addDoubleClickHandler(this); doTouchHandlers(cv.getCanvasElement()); cv.addDomHandler(this, ContextMenuEvent.getType()); menuBar.addDomHandler(new ClickHandler() { public void onClick(ClickEvent event) { doMainMenuChecks(); } }, ClickEvent.getType()); Event.addNativePreviewHandler(this); cv.addMouseWheelHandler(this); setSimRunning(true); // setup timer timer.scheduleRepeating(FASTTIMER); }
From source file:com.lushprojects.circuitjs1.client.CirSim.java
License:Open Source License
void processSetupList(byte b[], int len, final boolean openDefault) { MenuBar currentMenuBar; MenuBar stack[] = new MenuBar[6]; int stackptr = 0; currentMenuBar = new MenuBar(true); currentMenuBar.setAutoOpen(true); menuBar.addItem(LS("Circuits"), currentMenuBar); stack[stackptr++] = currentMenuBar;/*from ww w.j av a 2s .c om*/ int p; for (p = 0; p < len;) { int l; for (l = 0; l != len - p; l++) if (b[l + p] == '\n') { l++; break; } String line = new String(b, p, l - 1); if (line.charAt(0) == '#') ; else if (line.charAt(0) == '+') { // MenuBar n = new Menu(line.substring(1)); MenuBar n = new MenuBar(true); n.setAutoOpen(true); currentMenuBar.addItem(LS(line.substring(1)), n); currentMenuBar = stack[stackptr++] = n; } else if (line.charAt(0) == '-') { currentMenuBar = stack[--stackptr - 1]; } else { int i = line.indexOf(' '); if (i > 0) { String title = LS(line.substring(i + 1)); boolean first = false; if (line.charAt(0) == '>') first = true; String file = line.substring(first ? 1 : 0, i); currentMenuBar .addItem(new MenuItem(title, new MyCommand("circuits", "setup " + file + " " + title))); if (file.equals(startCircuit) && startLabel == null) { startLabel = title; titleLabel.setText(title); } if (first && startCircuit == null) { startCircuit = file; startLabel = title; if (openDefault && stopMessage == null) readSetupFile(startCircuit, startLabel, true); } } } p += l; } }
From source file:com.qualogy.qafe.gwt.client.factory.WindowFactory.java
License:Apache License
private static void processMenu(MenuItemGVO root, MenuBar menuBar, final String uuid) { MenuBar subMenuBar = null;//from ww w .j a v a2 s . c o m if (QAFEKeywordsGVO.SYSTEM_MENU_APPLICATIONS.equals(root.getId())) { MenuBar applicationsMenu = new MenuBar(true); applicationsMenu.setAutoOpen(true); ClientApplicationContext.getInstance().setApplicationsMenu(applicationsMenu); subMenuBar = ClientApplicationContext.getInstance().getApplicationsMenu(); subMenuBar.setAnimationEnabled(true); subMenuBar.setAutoOpen(true); MenuItem menuItem = GWTUIGenerator.createMenuItem(root.getId(), root.getDisplayname(), uuid, root.getContext(), subMenuBar); menuBar.addItem(menuItem); } if (root.getSubMenus() != null) { if (subMenuBar == null) { subMenuBar = new MenuBar(true); subMenuBar.setAnimationEnabled(true); subMenuBar.setAutoOpen(true); MenuItem menuItem = GWTUIGenerator.createMenuItem(root.getId(), root.getDisplayname(), uuid, root.getContext(), subMenuBar); menuBar.addItem(menuItem); } for (int i = 0; i < root.getSubMenus().length; i++) { processMenu(root.getSubMenus()[i], subMenuBar, uuid); } ClientApplicationContext.getInstance().addMenu(root.getId(), subMenuBar); } else { if (!QAFEKeywordsGVO.SYSTEM_MENU_APPLICATIONS.equals(root.getId()) && root.getDisplayname() != null && !root.getDisplayname().equals(menuBar.getTitle())) { MenuItem menuItem = new MenuItem(root.getDisplayname(), (Command) null); RendererHelper.fillIn(root, menuItem, uuid, null, root.getContext()); // DOM.setElementAttribute(menuItem.getElement(), "id", // root.getId()); Command cmd = null; if (QAFEKeywordsGVO.SYSTEM_MENUITEM_LOGGING.equals(root.getId())) { cmd = new Command() { public void execute() { } }; } else if (QAFEKeywordsGVO.SYSTEM_MENUITEM_RELOAD.equals(root.getId())) { cmd = new Command() { public void execute() { if (ClientApplicationContext.getInstance().getReloadable()) { MainFactoryActions.processReloadUIFromApplicationContext(); } else { ClientApplicationContext.getInstance().log("Not available", "Reloading of application is only available in debug mode", true); } } }; } else if (QAFEKeywordsGVO.SYSTEM_MENUITEM_TRYME.equals(root.getId())) { cmd = new Command() { public void execute() { if (ClientApplicationContext.getInstance().isDebugMode()) { MainFactory.createTryMeWindow(QAFEKeywordsGVO.SYSTEM_MENUITEM_TRYME); } else { ClientApplicationContext.getInstance().log("Not available", "Try me feature is only available in debug mode", true); } } }; } else if (QAFEKeywordsGVO.SYSTEM_MENUITEM_TRYME_FORMS.equals(root.getId())) { cmd = new Command() { public void execute() { if (ClientApplicationContext.getInstance().isDebugMode()) { MainFactory.createTryMeWindow(QAFEKeywordsGVO.SYSTEM_MENUITEM_TRYME_FORMS); } else { ClientApplicationContext.getInstance().log("Not available", "Try me feature is only available in debug mode", true); } } }; } else { if ((root.getEvents() != null) && (root.getEvents().length > 0)) { EventListenerGVO eventListenerGVO = root.getEvents()[0]; cmd = EventFactory.createCommandListener(menuItem, eventListenerGVO, null); } } menuItem.setCommand(cmd); menuBar.addItem(menuItem); } else if (root instanceof MenuItemSeparatorGVO) { MenuItemSeparator menuItemSeparator = new MenuItemSeparator(); menuBar.addSeparator(menuItemSeparator); //menuBar.addItem((MenuItem)menuItemSeparator); } } }
From source file:com.qualogy.qafe.gwt.client.ui.renderer.RendererHelper.java
License:Apache License
public static void addMenu(ComponentGVO vo, UIObject ui, String uuid, String parent) { if (vo != null && ui != null) { if (vo.getMenu() != null) { MenuBar menu = new MenuBar(); menu.setAutoOpen(true); menu.setWidth("100%"); UIObject renderedComponent = new MenuItemRenderer().render(vo.getMenu(), uuid, parent, vo.getContext());// w w w .j a v a2s .c om if (renderedComponent instanceof MenuBar) { menu.addItem(vo.getMenu().getDisplayname(), (MenuBar) renderedComponent); } else if (renderedComponent instanceof MenuItem) { menu.addItem((MenuItem) renderedComponent); } if (ui instanceof DockPanel) { ((DockPanel) ui).add(menu, DockPanel.NORTH); } else if (ui instanceof Grid || ui instanceof VerticalPanel || ui instanceof HorizontalPanel) ((Panel) ui).add(menu); } } }
From source file:com.qualogy.qafe.gwt.client.ui.renderer.WindowRenderer.java
License:Apache License
private MenuBar createMenu(ComponentGVO component, String uuid, String parent) { Command cmd = new Command() { public void execute() { }/* w ww . j ava2s . c om*/ }; MenuBar mainMenu = null; MenuItemGVO rootMenu = component.getMenu(); if (rootMenu != null) { if (rootMenu.getSubMenus() != null) { mainMenu = new MenuBar(); RendererHelper.fillIn(rootMenu, mainMenu, uuid, parent, component.getContext()); for (int i = 0; i < rootMenu.getSubMenus().length; i++) { if (rootMenu.getSubMenus()[i].getSubMenus() != null && rootMenu.getSubMenus()[i].getSubMenus().length > 0) { processMenu(mainMenu, rootMenu.getSubMenus()[i], rootMenu.getSubMenus()[i].getDisplayname(), uuid, parent); } else { MenuItem menuItem = new MenuItem(rootMenu.getSubMenus()[i].getDisplayname(), cmd); RendererHelper.fillIn(rootMenu.getSubMenus()[i], menuItem, uuid, parent, component.getContext()); mainMenu.addItem(menuItem); } } } if (rootMenu.getStyleClass() != null) { mainMenu.setStylePrimaryName(rootMenu.getStyleClass()); } } if (mainMenu != null) { mainMenu.setAutoOpen(true); mainMenu.setAnimationEnabled(true); } return mainMenu; }
From source file:com.qualogy.qafe.mgwt.client.ui.renderer.RendererHelper.java
License:Apache License
public static void addMenu(ComponentGVO vo, UIObject ui, String uuid, String parent) { if (vo != null && ui != null) { if (vo.getMenu() != null) { MenuBar menu = new MenuBar(); menu.setAutoOpen(true); menu.setWidth("100%"); UIObject renderedComponent = new MenuItemRenderer().render(vo.getMenu(), null, uuid, parent, vo.getContext(), null); if (renderedComponent instanceof MenuBar) { menu.addItem(vo.getMenu().getDisplayname(), (MenuBar) renderedComponent); } else if (renderedComponent instanceof MenuItem) { menu.addItem((MenuItem) renderedComponent); }/*from www . j a va 2s . co m*/ if (ui instanceof DockPanel) { ((DockPanel) ui).add(menu, DockPanel.NORTH); } else if (ui instanceof Grid || ui instanceof VerticalPanel || ui instanceof HorizontalPanel) ((Panel) ui).add(menu); } } }
From source file:edu.iastate.airl.semtus.client.SEMTUSWEBAPP.java
License:Open Source License
public Widget createMenu() { Command menuCommandNws = new Command() { public void execute() { tabPanel.selectTab(0);//from w w w .j a v a2 s . com inputField.selectAll(); resultField.selectAll(); panelHoldingTabPanel.setVisible(true); } }; Command menuCommandLom = new Command() { public void execute() { uploadBox.center(); } }; Command menuCommandEx = new Command() { public void execute() { tabPanel.selectTab(0); inputField.setText( "Input some text based on the uploaded ontology for analysis.\n\n [PS: Remember to upload an ontology model for your domain to get relevant results."); resultField.setText("Send some text for processing before trying to view the results in this tab."); level = LEVEL_ONE; panelHoldingTabPanel.setVisible(false); } }; Command menuCommandPod = new Command() { public void execute() { announcementLabel.setHTML( "<p align=\"center\"><b>SEMANTIXS Analysis Level has been set to 1 (default).</b><br/><br/>" + "In this setting, SEMANTIXS expects an rdf/owl file as input (via upload option under File menu), containing the domain ontology (TBOX: class concepts + relationships) as well as instance assertions (A-BOX) that you expect in text.</p>"); announcementBox.center(); level = LEVEL_ONE; } }; Command menuCommandUone = new Command() { public void execute() { announcementLabel .setHTML("<p align=\"center\"><b>SEMANTIXS Analysis Level has been set to 2.</b><br/><br/>" + "In this setting, SEMANTIXS still expects an rdf/owl file as input (via upload option under File menu), however it doesn't assume that it's complete in the sense of covering all the instances expected in text. " + "It thus utilizes some pre-generated instance data (for eg., FOAF, DBPedia) in addition " + "to the given ontology for acquiring knowledge, however in the current version, it won't attempt to automatically map those instances to the input ontology and instead, retain their original references.</center>"); announcementBox.center(); level = LEVEL_TWO; } }; Command menuCommandUowe = new Command() { public void execute() { announcementLabel .setHTML("<p align=\"center\"><b>SEMANTIXS Analysis Level has been set to 3.</b><br/><br/>" + "In this setting, SEMANTIXS still expects an rdf/owl file as input (via upload option under File menu), however it doesn't assume that it's complete in the sense of covering all the relationships expected in text, or the instance data. " + "Thus, it sacrifices some correctness for exploring wilderness in trying to enrich the given ontology by learning new relationships and possible classes / instances as it reads text.</center>"); announcementBox.center(); level = LEVEL_THREE; } }; Command menuCommandVsg = new Command() { public void execute() { Window.open( "http://" + SEMTUS_HOSTING_SERVER_NAME + ":" + SEMTUS_HOSTING_PORT_NAME + "/" + SEMTUS_APP_NAME + "/visualize?lang=visual&model=output.rdf&search=&submit=search", "_blank", "menubar=no,location=no,resizable=yes,scrollbars=yes,status=no"); } }; Command menuCommandVcg = new Command() { public void execute() { tabPanel.selectTab(0); dialogBox.setHTML( "<p align=\"center\"><font color=\"#000000\" face=\"verdana\" size=\"2\">Visualize Complete RDF Graph</font></p>"); serverResponseLabel.removeStyleName("serverResponseLabelError"); serverResponseLabel.setHTML("<p align=\"center\">" + "In order to visualize the entire RDF graph, please click on the following button to go to the W3 Visualization servlet." + " On the servlet page, please copy-paste the RDF structure generated by SEMANTIXS into the textarea titled - <b>Check by Direct Input</b>." + " Set the <b>Display Result Options</b> to <b>Graph only</b> and click on <b>Parse RDF</b> to generate the graph.</p>"); w3Button = new Button("Go to W3 Validator Servlet"); w3Button.getElement().setId("closeButton"); dialogVPanel.remove(closeButton); dialogVPanel.add(w3Button); dialogBox.center(); // Add a handler to invoke W3 Servlet w3Button.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Window.open("http://www.w3.org/RDF/Validator/", "_blank", "menubar=no,location=no,resizable=yes,scrollbars=yes,status=no"); dialogBox.hide(); dialogVPanel.remove(w3Button); dialogVPanel.add(closeButton); } }); } }; Command menuCommandSo = new Command() { public void execute() { } }; Command menuCommandUg = new Command() { public void execute() { panelHoldingTabPanel.setVisible(true); } }; Command menuCommandAs = new Command() { public void execute() { tabPanel.selectTab(0); dialogBox.setHTML( "<p align=\"center\"><font color=\"#000000\" face=\"verdana\" size=\"2\">About SEMANTIXS</font></p>"); serverResponseLabel.removeStyleName("serverResponseLabelError"); serverResponseLabel.setHTML("<p align=\"center\"><font color=\"#a29364\" face=\"Times\" size=\"6\">" + "<b>SEMANTIXS</b></font>" + "<br/><font color=\"#a29364\" face=\"Times\" size=\"3\">version 1.0.0</font><br/><br/></br></br>" + "Copyright (c) <a href=\"http://sushain.com\" target=\"_blank\">Sushain Pandit</a>. All rights reserved." + "<br/>" + "<a href=\"http://www.cs.iastate.edu/~honavar/aigroup.html\" target=\"_blank\">Artificial Intelligence Research Lab</a>, Iowa State University.</p>"); dialogBox.center(); } }; // Create a menu bar MenuBar menu = new MenuBar(); menu.setAutoOpen(true); menu.setWidth("400px"); menu.setAnimationEnabled(true); // menu.setStylePrimaryName("menu"); // Create the file menu MenuBar fileMenu = new MenuBar(true); fileMenu.setAnimationEnabled(true); menu.addItem(new MenuItem("File", fileMenu)); String[] fileOptions = new String[] { "New Workspace", "Load Ontology Model", "Exit" }; fileMenu.addItem(fileOptions[0], menuCommandNws); fileMenu.addSeparator(); fileMenu.addItem(fileOptions[1], menuCommandLom); fileMenu.addSeparator(); fileMenu.addItem(fileOptions[2], menuCommandEx); menu.addSeparator(); // Create the edit menu MenuBar editMenu = new MenuBar(true); menu.addItem(new MenuItem("Analysis Complexity", editMenu)); String[] editOptions = new String[] { "Level 1 (default) - Purely Ontology Dependent [No Enrichment]", "Level 2 - Utilizes Ontology + other sources [No Enrichment]", "Level 3 - Utilizes Ontology + other sources [With Enrichment]" }; editMenu.addItem(editOptions[0], menuCommandPod); editMenu.addSeparator(); editMenu.addItem(editOptions[1], menuCommandUone); editMenu.addSeparator(); editMenu.addItem(editOptions[2], menuCommandUowe); menu.addSeparator(); // Create the GWT menu MenuBar gwtMenu = new MenuBar(true); menu.addItem(new MenuItem("User Options", true, gwtMenu)); String[] gwtOptions = new String[] { "Analyze RDF sub-graphs", "Visualize complete RDF graph", "Output file in .rdf Format" }; gwtMenu.addItem(gwtOptions[0], menuCommandVsg); gwtMenu.addSeparator(); gwtMenu.addItem(gwtOptions[1], menuCommandVcg); gwtMenu.addSeparator(); gwtMenu.addItem(gwtOptions[2], menuCommandSo); // Create the help menu MenuBar helpMenu = new MenuBar(true); menu.addSeparator(); menu.addItem(new MenuItem("Help", helpMenu)); String[] helpOptions = new String[] { "User Guide", "About SEMANTIXS" }; helpMenu.addItem(helpOptions[0], menuCommandUg); helpMenu.addSeparator(); helpMenu.addItem(helpOptions[1], menuCommandAs); // Return the menu menu.ensureDebugId("cwMenuBar"); return menu; }