Java 类org.eclipse.swt.events.MenuDetectListener 实例源码

项目:JFaceUtils    文件:ListConsole.java   
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);
}
项目:JFaceUtils    文件:StyledTextConsole.java   
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);
}
项目:OpenSPIFe    文件:MergeTreeViewer.java   
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());
            }
        }
    });
}
项目:OpenSPIFe    文件:TreeContextMenuFactory.java   
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;
                }
            }
        }
    });
}
项目:birt    文件:AssistField.java   
/**
 * 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 );
            }
        } );
    }
}
项目:elexis-3-base    文件:NumericWidget.java   
/**
 * @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);
        }
    });
}
项目:gwt-eclipse-plugin    文件:BreadcrumbViewer.java   
/**
 * 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);
  }
}
项目:Eclipse-Postfix-Code-Completion    文件:BreadcrumbViewer.java   
/**
 * 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);
    }
}
项目:gef-gwt    文件:ControlDecoration.java   
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);

        }
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:BreadcrumbViewer.java   
/**
 * 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);
    }
}
项目:birt    文件:BreadcrumbViewer.java   
/**
 * 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 );
    }
}
项目:smaccm    文件:VariablesView.java   
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;
            }
        }
    });
}
项目:smaccm    文件:PropertiesStateViewer.java   
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);
        }
    });
}
项目:ldparteditor    文件:Tree.java   
public void addMenuDetectListener(MenuDetectListener mdl) {
    tree.addMenuDetectListener(mdl);
}
项目:jo-widgets    文件:SwtComponent.java   
protected void setMenuDetectListener(final MenuDetectListener menuDetectListener) {
    getUiReference().removeMenuDetectListener(this.menuDetectListener);
    this.menuDetectListener = menuDetectListener;
    getUiReference().addMenuDetectListener(menuDetectListener);
}
项目:astor    文件:ChartComposite.java   
/**
 * 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);
    }
}
项目:elexis-3-base    文件:AbstractBrowseText.java   
public void addMenuDetectListener(MenuDetectListener listener){
    this.text.addMenuDetectListener(listener);
}
项目:elexis-3-base    文件:AbstractBrowseText.java   
public void removeMenuDetectListener(MenuDetectListener listener){
    this.text.removeMenuDetectListener(listener);
}
项目:gef-gwt    文件:TrayItem.java   
/**
 * 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);
}
项目:gef-gwt    文件:TrayItem.java   
/**
 * 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);
}
项目:gef-gwt    文件:Control.java   
/**
 * 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);
}
项目:gef-gwt    文件:Control.java   
/**
 * 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);
}
项目:convertigo-eclipse    文件:TreeWrapper.java   
public void addMenuDetectListener(MenuDetectListener listener) {

    tree.addMenuDetectListener(listener);
}
项目:convertigo-eclipse    文件:TreeWrapper.java   
public void removeMenuDetectListener(MenuDetectListener listener) {

    tree.removeMenuDetectListener(listener);
}
项目:gwt-eclipse-plugin    文件:BreadcrumbViewer.java   
/**
 * 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);
}
项目:gwt-eclipse-plugin    文件:BreadcrumbViewer.java   
/**
 * 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);
}
项目:Eclipse-Postfix-Code-Completion    文件:BreadcrumbViewer.java   
/**
 * 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);
}
项目:Eclipse-Postfix-Code-Completion    文件:BreadcrumbViewer.java   
/**
 * 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);
}
项目:gef-gwt    文件:ControlDecoration.java   
/**
 * 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);
}
项目:gef-gwt    文件:ControlDecoration.java   
/**
 * 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);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:BreadcrumbViewer.java   
/**
 * 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);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:BreadcrumbViewer.java   
/**
 * 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);
}
项目:birt    文件:BreadcrumbViewer.java   
/**
 * 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 );
}
项目:birt    文件:BreadcrumbViewer.java   
/**
 * 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 );
}