protected void createContextMenu(final List list) { contextMenu = new Menu(list); copyMenuItem = createCopyMenuItem(list); new MenuItem(contextMenu, SWT.SEPARATOR); selectAllMenuItem = createSelectAllMenuItem(list); new MenuItem(contextMenu, SWT.SEPARATOR); clearMenuItem = createClearMenuItem(); list.addMenuDetectListener(new MenuDetectListener() { @Override public void menuDetected(final MenuDetectEvent mde) { final boolean notEmpty = !isEmpty(); selectAllMenuItem.setEnabled(notEmpty); clearMenuItem.setEnabled(notEmpty); copyMenuItem.setEnabled(list.getSelectionCount() > 0); contextMenu.setVisible(true); } }); list.setMenu(contextMenu); }
protected void createContextMenu(final StyledText styledText) { contextMenu = new Menu(styledText); copyMenuItem = createCopyMenuItem(styledText); new MenuItem(contextMenu, SWT.SEPARATOR); selectAllMenuItem = createSelectAllMenuItem(styledText); new MenuItem(contextMenu, SWT.SEPARATOR); clearMenuItem = createClearMenuItem(); styledText.addMenuDetectListener(new MenuDetectListener() { @Override public void menuDetected(final MenuDetectEvent mde) { final boolean notEmpty = !isEmpty(); selectAllMenuItem.setEnabled(notEmpty); clearMenuItem.setEnabled(notEmpty); copyMenuItem.setEnabled(styledText.getSelectionCount() > 0); } }); styledText.setMenu(contextMenu); }
public MergeTreeViewer(TreeTableComposite treeComposite, final TreeTableColumnConfiguration configuration, IWorkbenchPartSite site) { super(treeComposite, configuration, site); addFilter(new VisabilityFilter()); treeComposite.getTree().addTreeListener(new PlanElementTreeListener()); // will be disposed with the Tree final Tree tree = getTree(); tree.addMenuDetectListener(new MenuDetectListener() { @Override public void menuDetected(MenuDetectEvent e) { Point point = tree.toControl(e.x, e.y); Rectangle clientArea = tree.getClientArea(); if (clientArea.y <= point.y && point.y < (clientArea.y + tree.getHeaderHeight())) { e.doit = false; int columnIndex = getColumnIndex(point.x); fillHeaderContextMenu(e.display, columnIndex, point, configuration.getColumns()); } } }); }
public void makePopupMenu(final TreeViewer viewer) { final Tree tree = viewer.getTree(); tree.addMenuDetectListener(new MenuDetectListener() { @Override public void menuDetected(MenuDetectEvent event) { Point clickedAt = tree.toControl(event.x, event.y); Point displayAt = viewer.getControl().toDisplay(clickedAt); final TreeItem treeItem = tree.getItem(clickedAt); if (treeItem != null) { Object objectInTree = treeItem.getData(); List<ContextualCommandContributor> menuContributors = getMenuContributors(objectInTree); if (!menuContributors.isEmpty()) { Shell shell = viewer.getControl().getShell(); popupMenu(objectInTree, menuContributors, shell, displayAt); event.doit = false; } } } }); }
/** * Initialize quick fix menu for content assist. */ protected void initQuickFixMenu( ) { if ( hasQuickFix( ) ) { controlDecoration.addMenuDetectListener( new MenuDetectListener( ) { public void menuDetected( MenuDetectEvent event ) { // no quick fix if we aren't in error state. if ( isValid( ) ) { return; } if ( quickFixMenu == null ) { quickFixMenu = FieldAssistHelper.getInstance( ) .createQuickFixMenu( AssistField.this ); } quickFixMenu.setLocation( event.x, event.y ); quickFixMenu.setVisible( true ); } } ); } }
/** * @param parent * Composite * @param style * Integer * @param labelText * String * @param regex * String */ public NumericWidget(Composite parent, int style, final String labelText, RegexValidation regex) { super(parent, style, labelText, regex); // Create quickFix menu listener this.controlDecoration.addMenuDetectListener(new MenuDetectListener() { public void menuDetected(MenuDetectEvent event) { // no quick fix if we aren't in error state. if (NumericWidget.this.smartField.isValid()) { return; } if (NumericWidget.this.smartField.quickFixMenu == null) { NumericWidget.this.smartField.quickFixMenu = NumericWidget.this .createQuickFixMenu((SmartNumericField) NumericWidget.this.smartField); } NumericWidget.this.smartField.quickFixMenu.setLocation(event.x, event.y); NumericWidget.this.smartField.quickFixMenu.setVisible(true); } }); }
/** * A context menu has been requested for the selected breadcrumb item. * * @param event the event issued the menu detection */ void fireMenuDetect(MenuDetectEvent event) { Object[] listeners = fMenuListeners.getListeners(); for (int i = 0; i < listeners.length; i++) { ((MenuDetectListener) listeners[i]).menuDetected(event); } }
/** * A context menu has been requested for the selected breadcrumb item. * * @param event the event issued the menu detection */ void fireMenuDetect(MenuDetectEvent event) { Object[] listeners= fMenuListeners.getListeners(); for (int i= 0; i < listeners.length; i++) { ((MenuDetectListener)listeners[i]).menuDetected(event); } }
private void notifyMenuDetectListeners(Event event) { if (getDecorationRectangle(null).contains(event.x, event.y)) { MenuDetectEvent clientEvent = new MenuDetectEvent(event); clientEvent.data = this; Object[] listeners = menuDetectListeners.getListeners(); for (int i = 0; i < listeners.length; i++) { ((MenuDetectListener) listeners[i]).menuDetected(clientEvent); } } }
/** * A context menu has been requested for the selected breadcrumb item. * * @param event * the event issued the menu detection */ void fireMenuDetect( MenuDetectEvent event ) { Object[] listeners = fMenuListeners.getListeners( ); for ( int i = 0; i < listeners.length; i++ ) { ( (MenuDetectListener) listeners[i] ).menuDetected( event ); } }
public TreeSelectionTracker(final TreeViewer treeViewer) { treeViewer.getTree().addMenuDetectListener(new MenuDetectListener() { @Override public void menuDetected(final MenuDetectEvent e) { final Point point = Display.getDefault().map(null, treeViewer.getTree(), new Point(e.x, e.y)); final ViewerCell cell = treeViewer.getCell(point); if(cell != null && cell.getItem() != null) { treeItemData = cell.getItem().getData(); selectedColumnIndex = cell.getColumnIndex(); } else { treeItemData = null; } } }); }
public TableSelectionTracker(final TableViewer tableViewer) { tableViewer.getTable().addMenuDetectListener(new MenuDetectListener() { @Override public void menuDetected(final MenuDetectEvent e) { final Point point = Display.getDefault().map(null, tableViewer.getControl(), new Point(e.x, e.y)); selection = tableViewer.getCell(point); } }); }
public void addMenuDetectListener(MenuDetectListener mdl) { tree.addMenuDetectListener(mdl); }
protected void setMenuDetectListener(final MenuDetectListener menuDetectListener) { getUiReference().removeMenuDetectListener(this.menuDetectListener); this.menuDetectListener = menuDetectListener; getUiReference().addMenuDetectListener(menuDetectListener); }
/** * Hook an SWT listener on the canvas where the chart is drawn. * The purpose of this method is to allow some degree of customization. * * @param listener The SWT listener to attach to the canvas. */ public void addSWTListener(EventListener listener) { if (listener instanceof ControlListener) { this.canvas.addControlListener((ControlListener) listener); } else if (listener instanceof DisposeListener) { this.canvas.addDisposeListener((DisposeListener) listener); } else if (listener instanceof DragDetectListener) { this.canvas.addDragDetectListener((DragDetectListener) listener); } else if (listener instanceof FocusListener) { this.canvas.addFocusListener((FocusListener) listener); } else if (listener instanceof HelpListener) { this.canvas.addHelpListener((HelpListener) listener); } else if (listener instanceof KeyListener) { this.canvas.addKeyListener((KeyListener) listener); } else if (listener instanceof MenuDetectListener) { this.canvas.addMenuDetectListener((MenuDetectListener) listener); } else if (listener instanceof MouseListener) { this.canvas.addMouseListener((MouseListener) listener); } else if (listener instanceof MouseMoveListener) { this.canvas.addMouseMoveListener((MouseMoveListener) listener); } else if (listener instanceof MouseTrackListener) { this.canvas.addMouseTrackListener((MouseTrackListener) listener); } else if (listener instanceof MouseWheelListener) { this.canvas.addMouseWheelListener((MouseWheelListener) listener); } else if (listener instanceof PaintListener) { this.canvas.addPaintListener((PaintListener) listener); } else if (listener instanceof TraverseListener) { this.canvas.addTraverseListener((TraverseListener) listener); } }
public void addMenuDetectListener(MenuDetectListener listener){ this.text.addMenuDetectListener(listener); }
public void removeMenuDetectListener(MenuDetectListener listener){ this.text.removeMenuDetectListener(listener); }
/** * Adds the listener to the collection of listeners who will be notified * when the platform-specific context menu trigger has occurred, by sending * it one of the messages defined in the <code>MenuDetectListener</code> * interface. * * @param listener * the listener which should be notified * * @exception IllegalArgumentException * <ul> * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> * </ul> * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> * * @see MenuDetectListener * @see #removeMenuDetectListener * * @since 3.3 */ public void addMenuDetectListener(MenuDetectListener listener) { checkWidget(); if (listener == null) error(SWT.ERROR_NULL_ARGUMENT); TypedListener typedListener = new TypedListener(listener); addListener(SWT.MenuDetect, typedListener); }
/** * Removes the listener from the collection of listeners who will be * notified when the platform-specific context menu trigger has occurred. * * @param listener * the listener which should no longer be notified * * @exception IllegalArgumentException * <ul> * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> * </ul> * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> * * @see MenuDetectListener * @see #addMenuDetectListener * * @since 3.3 */ public void removeMenuDetectListener(MenuDetectListener listener) { checkWidget(); if (listener == null) error(SWT.ERROR_NULL_ARGUMENT); if (eventTable == null) return; eventTable.unhook(SWT.MenuDetect, listener); }
public void addMenuDetectListener(MenuDetectListener listener) { tree.addMenuDetectListener(listener); }
public void removeMenuDetectListener(MenuDetectListener listener) { tree.removeMenuDetectListener(listener); }
/** * Add the given listener to the set of listeners which will be informed when * a context menu is requested for a breadcrumb item. * * @param listener the listener to add */ public void addMenuDetectListener(MenuDetectListener listener) { fMenuListeners.add(listener); }
/** * Remove the given listener from the set of menu detect listeners. Does * nothing if the listener is not element of the set. * * @param listener the listener to remove */ public void removeMenuDetectListener(MenuDetectListener listener) { fMenuListeners.remove(listener); }
/** * Add the given listener to the set of listeners which will be informed * when a context menu is requested for a breadcrumb item. * * @param listener the listener to add */ public void addMenuDetectListener(MenuDetectListener listener) { fMenuListeners.add(listener); }
/** * Remove the given listener from the set of menu detect listeners. * Does nothing if the listener is not element of the set. * * @param listener the listener to remove */ public void removeMenuDetectListener(MenuDetectListener listener) { fMenuListeners.remove(listener); }
/** * Adds the listener to the collection of listeners who will be notified * when the platform-specific context menu trigger has occurred, by sending * it one of the messages defined in the <code>MenuDetectListener</code> * interface. * <p> * The <code>widget</code> field in the SelectionEvent will contain the * Composite on which the decoration is rendered that received the click. * The <code>x</code> and <code>y</code> fields will be in coordinates * relative to the display. The <code>data</code> field will contain the * decoration that received the event. * </p> * * @param listener * the listener which should be notified * * @see org.eclipse.swt.events.MenuDetectListener * @see org.eclipse.swt.events.MenuDetectEvent * @see #removeMenuDetectListener */ public void addMenuDetectListener(MenuDetectListener listener) { menuDetectListeners.add(listener); }
/** * Removes the listener from the collection of listeners who will be * notified when the platform-specific context menu trigger has occurred. * * @param listener * the listener which should no longer be notified. This message * has no effect if the listener was not previously added to the * receiver. * * @see org.eclipse.swt.events.MenuDetectListener * @see #addMenuDetectListener */ public void removeMenuDetectListener(MenuDetectListener listener) { menuDetectListeners.remove(listener); }
/** * Add the given listener to the set of listeners which will be informed * when a context menu is requested for a breadcrumb item. * * @param listener * the listener to add */ public void addMenuDetectListener( MenuDetectListener listener ) { fMenuListeners.add( listener ); }
/** * Remove the given listener from the set of menu detect listeners. Does * nothing if the listener is not element of the set. * * @param listener * the listener to remove */ public void removeMenuDetectListener( MenuDetectListener listener ) { fMenuListeners.remove( listener ); }