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

项目: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);
        }
    });
}
项目:JavaFX-FrameRateMeter    文件:OldFXCanvas.java   
private void sendMenuEventToFX(MenuDetectEvent me) {
    if (scenePeer == null /*|| !isFxEnabled()*/) {
        return;
    }
    Point pt = toControl(me.x, me.y);
    scenePeer.menuEvent(pt.x, pt.y, me.x, me.y, false);
}
项目:EarthquakeBulletin    文件:ResultsTableContextMenuDetectListener.java   
@Override
public void menuDetected(final MenuDetectEvent mde) {
    final Earthquake selection = (Earthquake) resultsTable.getTableViewer().getStructuredSelection().getFirstElement();
    resultsTable.getContextMenu().getShowMapMenuItem().setEnabled(selection != null && selection.getEnclosure() != null);
    resultsTable.getContextMenu().getCopyLinkMenuItem().setEnabled(selection != null && selection.getLink() != null);
    resultsTable.getContextMenu().getOpenBrowserMenuItem().setEnabled(selection != null && selection.getLink() != null);
    resultsTable.getContextMenu().getGoogleMapsBrowserMenuItem().setEnabled(selection != null);
    resultsTable.getContextMenu().getGoogleMapsPopupMenuItem().setEnabled(selection != null);
    resultsTable.getContextMenu().getExportCsvMenuItem().setEnabled(resultsTable.getTableViewer().getTable() != null && resultsTable.getTableViewer().getTable().getItemCount() > 0);
    resultsTable.getContextMenu().getMenu().setVisible(true);
}
项目:RouterLogger    文件:DataTableContextMenuDetectListener.java   
@Override
public void menuDetected(final MenuDetectEvent mde) {
    final DataTable dataTable = gui.getDataTable();
    dataTable.getCopyMenuItem().setEnabled(dataTable.canCopy());
    dataTable.getDeleteMenuItem().setEnabled(dataTable.canDelete());
    dataTable.getSelectAllMenuItem().setEnabled(dataTable.canSelectAll());
    dataTable.getClearMenuItem().setEnabled(dataTable.canClear());
    dataTable.getContextMenu().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);
  }
}
项目:jo-widgets    文件:NatTableImplSpi.java   
@Override
public void menuDetected(final MenuDetectEvent e) {

    //if a drag source is installed, selection event fires after menu detect but selection
    //should always change before menu detection
    //Not sure if this is necessary for nattable but it does not harm anyway
    setSelectionChangedIfNeccessary();

    //stop editing before popup opens
    stopEditing();

    Point point = new Point(e.x, e.y);
    point = table.toControl(point);

    final Position position = new Position(point.x, point.y);

    final int rowPositionByY = table.getRowPositionByY(point.y);
    final int columnPositionByX = table.getColumnPositionByX(point.x);

    final int rowIndex = table.getRowIndexByPosition(rowPositionByY);
    final int columnIndex = table.getColumnIndexByPosition(columnPositionByX);

    if (rowPositionByY == 0 && columnIndex != -1) {
        tableColumnPopupDetectionObservable.firePopupDetected(new TableColumnPopupEvent(columnIndex, position));
    }
    else if (rowIndex != -1 && columnIndex != -1) {
        tableCellPopupDetectionObservable.firePopupDetected(new TableCellPopupEvent(rowIndex, columnIndex, position));
    }
    else {
        getPopupDetectionObservable().firePopupDetected(position);
    }
}
项目: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);
    }
}
项目:JXTN    文件:FXCanvas.java   
private void sendMenuEventToFX(MenuDetectEvent me) {
    if (this.scenePeer == null /*|| !isFxEnabled()*/) {
        return;
    }
    Point pt = this.toControl(me.x, me.y);
    this.scenePeer.menuEvent(pt.x, pt.y, me.x, me.y, false);
}
项目: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);
        }
    });
}
项目:xowa_android    文件:Swt_lnr__menu_detect.java   
@Override public void menuDetected(MenuDetectEvent arg0) {
    try {Gfo_evt_mgr_.Pub(elem, GfuiElemKeys.Evt_menu_detected);}
    catch (Exception e) {
        kit.Ask_ok("", "", "error during right-click; err=~{0}", Err_.Message_gplx_full(e));
    }
}
项目:jo-widgets    文件:TableImpl.java   
@Override
public void menuDetected(final MenuDetectEvent e) {

    //if a drag source is installed, selection event fires after menu detect but selection
    //should always change before menu detection
    fireSelectionChangedIfNeccessary();

    //stop editing before popup opens
    stopEditing();

    // calculate position manually due to different behavior of Windows and Linux
    final Rectangle tableBounds = table.getBounds();
    final Point tableOrigin = table.getParent().toDisplay(new Point(tableBounds.x, tableBounds.y));
    final Point tableEventPoint = new Point(e.x - tableOrigin.x, e.y - tableOrigin.y);

    Point point = new Point(e.x, e.y);
    point = table.toControl(point);
    final Position position = new Position(point.x, point.y);
    TableItem item = table.getItem(point);

    //Menu detect on table cell
    if (item != null && tableEventPoint.y > table.getHeaderHeight()) {
        for (int colIndex = 0; colIndex < getColumnCount(); colIndex++) {
            final int internalColIndex = colIndex + 1;
            final Rectangle rect = item.getBounds(internalColIndex);
            if (rect.contains(point)) {
                final int rowIndex = table.indexOf(item);

                if (rowIndex != -1) {
                    tableCellPopupDetectionObservable
                            .firePopupDetected(new TableCellPopupEvent(rowIndex, colIndex, position));
                }
            }
        }
    }
    //Menu detect on header. Table has some item(s)
    else if (table.getItemCount() > 0 && tableEventPoint.y < table.getHeaderHeight()) {
        item = table.getItem(0);
        fireColumnPopupDetected(item, point, position);
    }
    //Menu detect on header but table has no item.
    //Just temporarily add an item to the table an remove it, after
    //position was calculated.
    else if (tableEventPoint.y < table.getHeaderHeight()) {
        table.setRedraw(false);
        table.removeListener(SWT.SetData, dataListener);
        final TableItem dummyItem = new TableItem(table, SWT.NONE);
        fireColumnPopupDetected(dummyItem, point, position);
        dummyItem.dispose();
        table.addListener(SWT.SetData, dataListener);
        table.setRedraw(true);
    }
    else {
        getPopupDetectionObservable().firePopupDetected(position);
    }
}
项目:jo-widgets    文件:SwtTableImplSpi.java   
@Override
public void menuDetected(final MenuDetectEvent e) {

    //if a drag source is installed, selection event fires after menu detect but selection
    //should always change before menu detection
    fireSelectionChangedIfNeccessary();

    //stop editing before popup opens
    stopEditing();

    // calculate position manually due to different behavior of Windows and Linux
    final Rectangle tableBounds = table.getBounds();
    final Point tableOrigin = table.getParent().toDisplay(new Point(tableBounds.x, tableBounds.y));
    final Point tableEventPoint = new Point(e.x - tableOrigin.x, e.y - tableOrigin.y);

    Point point = new Point(e.x, e.y);
    point = table.toControl(point);
    final Position position = new Position(point.x, point.y);
    TableItem item = table.getItem(point);

    //Menu detect on table cell
    if (item != null && tableEventPoint.y > table.getHeaderHeight()) {
        for (int colIndex = 0; colIndex < getColumnCount(); colIndex++) {
            final int internalColIndex = colIndex + 1;
            final Rectangle rect = item.getBounds(internalColIndex);
            if (rect.contains(point)) {
                final int rowIndex = table.indexOf(item);

                if (rowIndex != -1) {
                    tableCellPopupDetectionObservable
                            .firePopupDetected(new TableCellPopupEvent(rowIndex, colIndex, position));
                }
            }
        }
    }
    //Menu detect on header. Table has some item(s)
    else if (table.getItemCount() > 0 && tableEventPoint.y < table.getHeaderHeight()) {
        item = table.getItem(0);
        fireColumnPopupDetected(item, point, position);
    }
    //Menu detect on header but table has no item.
    //Just temporarily add an item to the table an remove it, after
    //position was calculated.
    else if (tableEventPoint.y < table.getHeaderHeight()) {
        table.setRedraw(false);
        table.removeListener(SWT.SetData, dataListener);
        final TableItem dummyItem = new TableItem(table, SWT.NONE);
        fireColumnPopupDetected(dummyItem, point, position);
        dummyItem.dispose();
        table.addListener(SWT.SetData, dataListener);
        table.setRedraw(true);
    }
    else {
        getPopupDetectionObservable().firePopupDetected(position);
    }
}
项目:TeamSubb    文件:GadgetController.java   
@Override
public void menuDetected(MenuDetectEvent arg0) {
    gadget.showMenu();

}
项目:TeamSubb    文件:JobController.java   
@Override
public void menuDetected(MenuDetectEvent arg0) {
    view.morphActionsMenu();

}
项目:Sammelbox    文件:BrowserListener.java   
@Override
/** Don't show the usual browser menu */
public void menuDetected(MenuDetectEvent e) {
    e.doit = false;
}
项目:cuina    文件:TerrainEditor.java   
@Override
public void menuDetected(MenuDetectEvent ev)
{
    menuPoint = panel.toControl(ev.x, ev.y);
}
项目:mytourbook    文件:GalleryMT20.java   
private void onMouseContextMenu(final MenuDetectEvent menuEvent) {

    }