/** * The constructor should first call super() to initialize the component and * then handle any initialization relevant to Vaadin. */ public VOpenLayersMap() { setWidth("500px"); setHeight("500px"); add(map); add(fakePaintables); fakePaintables.setVisible(false); // This method call of the Paintable interface sets the component // style name in DOM tree setStyleName(CLASSNAME); sinkEvents(Event.ONCONTEXTMENU); addDomHandler(new ContextMenuHandler() { public void onContextMenu(ContextMenuEvent event) { handleBodyContextMenu(event); } }, ContextMenuEvent.getType()); }
/** * Default constructor */ public MonthItemLabel() { setStylePrimaryName(STYLENAME); addDomHandler(contextMenuEvent -> { calendar.getMouseEventListener().contextMenu(contextMenuEvent, MonthItemLabel.this); contextMenuEvent.stopPropagation(); contextMenuEvent.preventDefault(); }, ContextMenuEvent.getType()); }
@Override protected void handleBodyContextMenu(ContextMenuEvent event) { if (customContextMenu == null) { super.handleBodyContextMenu(event); } else if (!selectedIds.isEmpty()) { int left = event.getNativeEvent().getClientX(); int top = event.getNativeEvent().getClientY(); top += Window.getScrollTop(); left += Window.getScrollLeft(); showContextMenuPopup(left, top); event.stopPropagation(); event.preventDefault(); } }
@Override protected void init() { super.init(); getWidget().tabContextMenuHandler = new CubaTabSheetWidget.TabContextMenuHandler() { @Override public void onContextMenu(int tabIndex, ContextMenuEvent event) { lastContextMenuX = WidgetUtil.getTouchOrMouseClientX(event.getNativeEvent()); lastContextMenuY = WidgetUtil.getTouchOrMouseClientY(event.getNativeEvent()); if (getState().hasActionsHandlers) { rpc.onTabContextMenu(tabIndex); event.stopPropagation(); event.preventDefault(); } } }; }
@Override public void setPlatypusPopupMenu(PlatypusPopupMenu aMenu) { if (menu != aMenu) { if (menuTriggerReg != null) menuTriggerReg.removeHandler(); menu = aMenu; if (menu != null) { menuTriggerReg = super.addDomHandler(new ContextMenuHandler() { @Override public void onContextMenu(ContextMenuEvent event) { event.preventDefault(); event.stopPropagation(); menu.setPopupPosition(event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY()); menu.show(); } }, ContextMenuEvent.getType()); } } }
@Override public void setPlatypusPopupMenu(PlatypusPopupMenu aMenu) { if (contextMenu != aMenu) { if (menuTriggerReg != null) menuTriggerReg.removeHandler(); contextMenu = aMenu; if (contextMenu != null) { menuTriggerReg = super.addDomHandler(new ContextMenuHandler() { @Override public void onContextMenu(ContextMenuEvent event) { event.preventDefault(); event.stopPropagation(); contextMenu.setPopupPosition(event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY()); contextMenu.show(); } }, ContextMenuEvent.getType()); } } }
/** * Update event caches to keep track of the latest event of each instance. * @param the event to cache */ private void updateEventCaches(Event<?> event){ if(event == null){ return; } if(event instanceof DoubleClickEvent){ doubleClickEvent = new org.gz.gwt.mousemanager.client.event.DoubleClickEvent((DoubleClickEvent)event, target); } if(event instanceof ClickEvent){ clickEvent = new org.gz.gwt.mousemanager.client.event.ClickEvent((ClickEvent)event, target); } if(event instanceof MouseUpEvent){ mouseUpEvent = new org.gz.gwt.mousemanager.client.event.MouseUpEvent((MouseUpEvent)event, target); } if(event instanceof MouseDownEvent){ mouseDownEvent = new org.gz.gwt.mousemanager.client.event.MouseDownEvent((MouseDownEvent)event, target); } if(event instanceof MouseMoveEvent){ mouseMoveEvent = new org.gz.gwt.mousemanager.client.event.MouseMoveEvent((MouseMoveEvent)event, target); } if(event instanceof MouseOverEvent){ mouseOverEvent = new org.gz.gwt.mousemanager.client.event.MouseOverEvent((MouseOverEvent)event, target); } if(event instanceof MouseOutEvent){ mouseOutEvent = new org.gz.gwt.mousemanager.client.event.MouseOutEvent((MouseOutEvent)event, target); } if(event instanceof MouseWheelEvent){ mouseWheelEvent = new org.gz.gwt.mousemanager.client.event.MouseWheelEvent((MouseWheelEvent)event, target); } if(event instanceof ContextMenuEvent){ contextMenuEvent = new org.gz.gwt.mousemanager.client.event.ContextMenuEvent(); } }
@PostConstruct public void init() { settings.setShowProgressbar(false); settings.setPauseOnMouseOver(true); settings.setAllowDismiss(true); settings.setDelay(DELAY); settings.setTimer(TIMER); addDomHandler((e) -> { e.preventDefault(); e.stopPropagation(); }, ContextMenuEvent.getType()); showLoading(false); //getting initial palette position paletteInitialTop = palettePanel.getAbsoluteTop(); paletteInitialLeft = palettePanel.getAbsoluteLeft(); }
@Override public void onModuleLoad() { // Rest client configuration RestClient.setJacksonMarshallingActive(true); RestClient.setApplicationRoot("rs"); // Disable right click RootLayoutPanel.get().addDomHandler(new ContextMenuHandler() { @Override public void onContextMenu(ContextMenuEvent event) { event.preventDefault(); event.stopPropagation(); } }, ContextMenuEvent.getType()); // Create main content mainLayout = new MainLayout(); RootLayoutPanel.get().add(mainLayout); // init mainLayout.init(); }
@Override public boolean onContextMenu(ContextMenuEvent event, Element context) { // Ignore quasi-deleted or disabled blip. if (DomUtil.isQuasiDeleted(context) || !isEnabled()) { return false; } menuContextElement = context; menuContextEvent = event.getNativeEvent(); hideAndScheduleShowPopupMenu(); event.stopPropagation(); event.preventDefault(); return true; }
@Inject public PartStackViewImpl( PartStackUIResources resources, CoreLocalizationConstant localizationConstant) { this.resources = resources; this.localizationConstant = localizationConstant; initWidget(UI_BINDER.createAndBindUi(this)); partStackContent.getElement().getStyle().setPosition(Style.Position.ABSOLUTE); tabs = new HashMap<>(); partViewContainer = new AcceptsOneWidget() { @Override public void setWidget(IsWidget widget) { partStackContent.add(widget); } }; addDomHandler(this, MouseDownEvent.getType()); addDomHandler(this, ContextMenuEvent.getType()); setMaximized(false); addMaximizeButton(); addHideButton(); addMenuButton(); }
@Inject public EditorTabWidget( @Assisted final EditorPartPresenter relatedEditorPart, @Assisted EditorPartStack relatedEditorPartStack, PartStackUIResources resources, EditorTabContextMenuFactory editorTabContextMenu, final EventBus eventBus, final EditorAgent editorAgent) { this.resources = resources; this.relatedEditorPart = relatedEditorPart; this.relatedEditorPartStack = relatedEditorPartStack; this.editorAgent = editorAgent; initWidget(UI_BINDER.createAndBindUi(this)); this.editorTabContextMenu = editorTabContextMenu; this.file = relatedEditorPart.getEditorInput().getFile(); this.icon = relatedEditorPart.getTitleImage(); this.title.setText(file.getDisplayName()); // add "path" attribute describing the full path of opened file, will be used full for testing this.title.getElement().setAttribute("path", file.getLocation().toString()); this.id = title + UUID.uuid(4); iconPanel.add(getIcon()); addDomHandler(this, ClickEvent.getType()); addDomHandler(this, DoubleClickEvent.getType()); addDomHandler(this, ContextMenuEvent.getType()); eventBus.addHandler(ResourceChangedEvent.getType(), this); eventBus.addHandler(FileEvent.TYPE, this); sinkEvents(Event.ONMOUSEDOWN); closeButton.addDomHandler( event -> editorAgent.closeEditor(relatedEditorPart), ClickEvent.getType()); relatedEditorPart.addPropertyListener( (source, propId) -> { if (propId == EditorPartPresenter.PROP_INPUT) { file = relatedEditorPart.getEditorInput().getFile(); title.setText(file.getDisplayName()); } }); }
/** {@inheritDoc} */ @Override public void onContextMenu(ContextMenuEvent event) { // construct for each editor tab own context menu, // that will have store information about selected virtual file and pin state at first step // in future maybe we should create another mechanism to associate context menu with initial // dto's editorTabContextMenu .newContextMenu(this, relatedEditorPart, relatedEditorPartStack) .show(event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY()); }