@Override public void handleEvent(final MessageBoxEvent be) { final Button btn = be.getButtonClicked(); try { if (btn.getText().equals("Yes")) { acceptConnection(r, true); scrollMenu.remove(m); } else if (btn.getText().equals("No")) { scrollMenu.remove(m); acceptConnection(r, false); } } catch (NimbitsException ex) { FeedbackHelper.showError(ex); } }
public static Menu getMultiSelectionMenu(boolean isOnlyLayers) { if (multipleSelectionContextMenu == null) { multipleSelectionContextMenu = new Menu(); DeleteElementsMenuAction deleteElementsMenuAction = new DeleteElementsMenuAction(treePanel); MenuItem deleteElements = new MenuItem(); deleteElements.setText(deleteElementsMenuAction.getTitle()); deleteElements.setIcon(deleteElementsMenuAction.getImage()); deleteElements.addSelectionListener(deleteElementsMenuAction); multipleSelectionContextMenu.add(deleteElements); copyMultiLayers = new MenuItem("Copy Layers"); copyMultiLayers.setIcon(LayerResources.ICONS.copy()); copyMultiLayers.addSelectionListener( new CopyLayerAction(treePanel, pasteAction, pasteMenuItem)); } if (isOnlyLayers) { multipleSelectionContextMenu.add(copyMultiLayers); } else if (multipleSelectionContextMenu.getItems().contains(copyMultiLayers)) { multipleSelectionContextMenu.remove(copyMultiLayers); } return multipleSelectionContextMenu; }
public SVGWindow addWindow(OMSVGSVGElement svg, ILoadRequest request) { String title = request.getTitle(); SVGModel model = SVGModel.newInstance(svg, title); SVGWindow window = new SVGWindow(model); window.setHeading(title); svgWindows.add(window); // To be notified when a window is activated in order to // keep track of the active window window.addListener( Events.Activate, new Listener<WindowEvent>() { @Override public void handleEvent(WindowEvent we) { SVGWindow svgWindow = (SVGWindow) we.getWindow(); GWT.log("VectomaticApp2.Activate(" + svgWindow.getHeading() + ")"); if (activeWindow != svgWindow) { if (activeWindow != null) { activeWindow.deactivate(); fireEvent(new DeactivateWindowEvent(activeWindow)); } activeWindow = svgWindow; activeWindow.activate(); fireEvent(new ActivateWindowEvent(activeWindow)); } } }); window.addListener( Events.BeforeHide, new Listener<WindowEvent>() { @Override public void handleEvent(WindowEvent we) { SVGWindow svgWindow = (SVGWindow) we.getWindow(); svgWindow.getSvgModel().getSelectionModel().deselectAll(); GWT.log("VectomaticApp2.BeforeHide(" + svgWindow.getHeading() + ")"); svgWindow.removeAllListeners(); svgWindow.deactivate(); fireEvent(new DeactivateWindowEvent(svgWindow)); svgWindows.remove(svgWindow); activeWindow = null; update(); } }); // Update the recent docs menu if (!(request instanceof NewDocRequest)) { List<Component> recentDocs = recentDocsMenu.getItems(); boolean alreadyInRecentDocs = false; for (Component item : recentDocs) { RecentDocMenuItem menuItem = (RecentDocMenuItem) item; if (request.equals(menuItem.getRequest())) { alreadyInRecentDocs = true; break; } } if (!alreadyInRecentDocs) { if (recentDocs.size() >= 8) { Component oldestItem = recentDocs.get(0); oldestItem.removeAllListeners(); recentDocsMenu.remove(oldestItem); } RecentDocMenuItem recentDocItem = new RecentDocMenuItem(request); recentDocsMenu.add(recentDocItem); } } int windowBarHeight = getWindowBarHeight(); windowY += windowBarHeight; window.setPagePosition(windowX, windowY); windowX += windowBarHeight; // window.show(); viewport.add(window); window.setVisible(true); update(); return window; }