Java 类org.eclipse.swt.widgets.Menu 实例源码

项目:neoscada    文件:ProtocolEditor.java   
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
项目:neoscada    文件:ChartEditor.java   
/**
 * This creates a context menu for the viewer and adds a listener as well
 * registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @generated NOT
 */
protected void createContextMenuFor ( final StructuredViewer viewer )
{
    final MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    final Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    final int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    final Transfer[] transfers = new Transfer[] {
            LocalTransfer.getInstance (),
            LocalSelectionTransfer.getTransfer (),
            FileTransfer.getInstance (),
            ItemTransfer.getInstance ()
    };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new DropAdapterExtension ( this.editingDomain, viewer ) );
}
项目:neoscada    文件:ChartConfiguratorView.java   
/**
 * This creates a context menu for the viewer and adds a listener as well
 * registering the menu for extension. <!-- begin-user-doc --> <!--
 * end-user-doc -->
 */
protected void createContextMenuFor ( final StructuredViewer viewer )
{
    final MenuManager contextMenu = new MenuManager ( "#PopUp" );
    contextMenu.add ( new Separator ( "additions" ) );
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    final Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    final int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    final Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( this.editingDomain, viewer ) );
}
项目:avro-schema-editor    文件:AddElementAction.java   
protected void openPopupMenu(NodeType[] availableTypes, final AvroNode targetNode, final AvroContext context) {

    Shell shell = Display.getCurrent().getActiveShell();
    final Menu menu = new Menu(shell, SWT.POP_UP);
    for (NodeType availableType : availableTypes) {
        final NodeType type = availableType;
        MenuItem item = new MenuItem(menu, SWT.PUSH);
        item.setText(type.getDisplayLabel());
        item.addListener(SWT.Selection, new Listener() {
            public void handleEvent(Event e) {
                menu.dispose();
                IEditCommand cmd = context.getService(IEditCommandFactory.class)
                        .createAddElementCommand(targetNode, type, getNotifications());
                context.getService(ICommandExecutor.class).execute(cmd);
            }
        });
    }

    Point location = MouseInfo.getPointerInfo().getLocation();
    int x = location.x;
    int y = location.y;
       menu.setLocation(x, y);
       menu.setVisible(true);

}
项目:neoscada    文件:ProfileEditor.java   
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
项目:neoscada    文件:OsgiEditor.java   
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
项目:neoscada    文件:WorldEditor.java   
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
项目:neoscada    文件:MemoryEditor.java   
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" );
    contextMenu.add ( new Separator ( "additions" ) );
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
项目:neoscada    文件:RecipeEditor.java   
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
项目:neoscada    文件:InfrastructureEditor.java   
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
项目:neoscada    文件:SecurityEditor.java   
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
项目:neoscada    文件:ComponentEditor.java   
/**
 * This creates a context menu for the viewer and adds a listener as well
 * registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 *
 * @generated NOT
 */
protected void createContextMenuFor ( final StructuredViewer viewer )
{
    final MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    final Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    final int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    final Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance (), ItemTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new DropAdapterExtension ( this.editingDomain, viewer ) );
}
项目:neoscada    文件:ItemEditor.java   
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
项目:neoscada    文件:ConfigurationEditor.java   
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
项目:convertigo-eclipse    文件:TwsDomTree.java   
private void buildContextMenu(MouseEvent e) {
    Point point = new Point(e.x, e.y);
    TreeItem  treeItem = getTree().getItem(point);
    Menu menu = new Menu((Control)e.getSource());
    Iterator<MenuMaker> i = menuMakers.iterator();
    int cpt = 0;
    while(i.hasNext()) {
        i.next().makeMenu(this, treeItem, e, menu);
        if (i.hasNext() && menu.getItemCount() != cpt) {
            new MenuItem(menu, SWT.SEPARATOR);
            cpt = menu.getItemCount();
        }
    }
    if (menu.getItemCount() > 0) {
        menu.setVisible(true);
    } else {
        menu.dispose();
    }
}
项目:BiglyBT    文件:ClipboardCopy.java   
public static void
 addCopyToClipMenu(
final Menu      menu,
final String    text )
 {
  MenuItem   item = new MenuItem( menu,SWT.NONE );

  String    msg_text_id= "label.copy.to.clipboard";

  item.setText( MessageText.getString( msg_text_id ));

  item.addSelectionListener(
      new SelectionAdapter()
      {
          @Override
          public void
          widgetSelected(
                  SelectionEvent arg0)
          {
              new Clipboard(menu.getDisplay()).setContents(new Object[] {text}, new Transfer[] {TextTransfer.getInstance()});
          }
      });
 }
项目:AppleCommander    文件:DropDownSelectionListener.java   
/**
 * Construct the DropDownSelectionListener with the specific menu to be used.
 */
public DropDownSelectionListener(Menu menu) {
    this.menu = menu;

    MenuItem[] menuItems = menu.getItems();
    for (int i=0; i<menuItems.length; i++) {
        /*
         * Add a menu selection listener so that the menu is hidden
         * when the user selects an item from the drop down menu.
         */
        menuItems[i].addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                setMenuVisible(false);
            }
        });
    }
}
项目:gw4e.project    文件:GW4EPreferencePage.java   
private SWTBotShell showPreferenceDialogMAC() {
    final IWorkbench workbench = PlatformUI.getWorkbench();
    workbench.getDisplay().asyncExec(new Runnable() {
        public void run() {
            IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
            if (window != null) {
                Menu appMenu = workbench.getDisplay().getSystemMenu();
                for (MenuItem item : appMenu.getItems()) {
                    if (item.getText().startsWith("Preferences")) {
                        Event event = new Event();
                        event.time = (int) System.currentTimeMillis();
                        event.widget = item;
                        event.display = workbench.getDisplay();
                        item.setSelection(true);
                        item.notifyListeners(SWT.Selection, event);
                        break;
                    }
                }
            }
        }
    });
    return  getPreferenceDialog() ;
}
项目:gw4e.project    文件:ConsolePreferencePage.java   
private SWTBotShell showPreferenceDialogMAC() {
    final IWorkbench workbench = PlatformUI.getWorkbench();
    workbench.getDisplay().asyncExec(new Runnable() {
        public void run() {
            IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
            if (window != null) {
                Menu appMenu = workbench.getDisplay().getSystemMenu();
                for (MenuItem item : appMenu.getItems()) {
                    if (item.getText().startsWith("Preferences")) {
                        Event event = new Event();
                        event.time = (int) System.currentTimeMillis();
                        event.widget = item;
                        event.display = workbench.getDisplay();
                        item.setSelection(true);
                        item.notifyListeners(SWT.Selection, event);
                        break;
                    }
                }
            }
        }
    });
    return  getPreferenceDialog() ;
}
项目:applecommander    文件:DropDownSelectionListener.java   
/**
 * Construct the DropDownSelectionListener with the specific menu to be used.
 */
public DropDownSelectionListener(Menu menu) {
    this.menu = menu;

    MenuItem[] menuItems = menu.getItems();
    for (int i=0; i<menuItems.length; i++) {
        /*
         * Add a menu selection listener so that the menu is hidden
         * when the user selects an item from the drop down menu.
         */
        menuItems[i].addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                setMenuVisible(false);
            }
        });
    }
}
项目:avro-schema-editor    文件:SchemaRegistryView.java   
protected void configurePopupMenu(TreeViewer treeViewer) {
    MenuManager mgr = new MenuManager();
       mgr.setRemoveAllWhenShown(true);
       mgr.addMenuListener(new IMenuListener() {

        @Override
        public void menuAboutToShow(IMenuManager manager) {
            fillPopupMenu(manager);
        }
    });           
       Menu menu = mgr.createContextMenu(treeViewer.getControl());
       treeViewer.getControl().setMenu(menu);
}
项目:BiglyBT    文件:SBC_TorrentDetailsView.java   
@Override
public void menuWillBeShown(MdiEntry entry, Menu menuTree) {
    // todo: This even work?
    TableView<?> tv = SelectedContentManager.getCurrentlySelectedTableView();
    menuTree.setData("TableView", tv);
    DownloadManager manager = DataSourceUtils.getDM(((BaseMdiEntry) entry).getDatasourceCore());
    if (manager != null) {
        menuTree.setData("downloads", new DownloadManager[] {
            manager
        });
    }
    menuTree.setData("is_detailed_view", Boolean.TRUE);

    MenuFactory.buildTorrentMenu(menuTree);
}
项目:n4js    文件:DropDownAction.java   
@Override
public void runWithEvent(final Event event) {
    if (event.widget instanceof ToolItem) {
        final ToolItem toolItem = (ToolItem) event.widget;
        final Control control = toolItem.getParent();
        @SuppressWarnings("hiding")
        final Menu menu = getMenu(control);
        final Rectangle bounds = toolItem.getBounds();
        final Point topLeft = new Point(bounds.x, bounds.y + bounds.height);
        menu.setLocation(control.toDisplay(topLeft));
        menu.setVisible(true);
    }
}
项目:n4js    文件:TestResultsView.java   
private void hookContextMenu() {
    final MenuManager menuMgr = new MenuManager("#PopupMenu");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {
        @Override
        public void menuAboutToShow(IMenuManager manager) {
            TestResultsView.this.fillContextMenu(manager);
        }
    });
    Menu menu = menuMgr.createContextMenu(testTreeViewer.getControl());
    testTreeViewer.getControl().setMenu(menu);
    getSite().registerContextMenu(menuMgr, testTreeViewer);
}
项目:n4js    文件:ShowHistoryAction.java   
@Override
public void runWithEvent(Event event) {
    if (event.widget instanceof ToolItem) {
        final ToolItem toolItem = (ToolItem) event.widget;
        final Control control = toolItem.getParent();
        final Menu menu = getMenuCreator().getMenu(control);

        final Rectangle bounds = toolItem.getBounds();
        final Point topLeft = new Point(bounds.x, bounds.y + bounds.height);
        menu.setLocation(control.toDisplay(topLeft));
        menu.setVisible(true);
    }
}
项目:OCCI-Studio    文件:CrtpEditor.java   
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor(StructuredViewer viewer) {
    MenuManager contextMenu = new MenuManager("#PopUp");
    contextMenu.add(new Separator("additions"));
    contextMenu.setRemoveAllWhenShown(true);
    contextMenu.addMenuListener(this);
    Menu menu= contextMenu.createContextMenu(viewer.getControl());
    viewer.getControl().setMenu(menu);
    getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer));

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance(), LocalSelectionTransfer.getTransfer(), FileTransfer.getInstance() };
    viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer));
    viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer));
}
项目:smarthome-cep-demonstrator    文件:SmarthomeEditor.java   
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
    * <!-- end-user-doc -->
 * @generated
 */
   protected void createContextMenuFor(StructuredViewer viewer) {
    MenuManager contextMenu = new MenuManager("#PopUp");
    contextMenu.add(new Separator("additions"));
    contextMenu.setRemoveAllWhenShown(true);
    contextMenu.addMenuListener(this);
    Menu menu= contextMenu.createContextMenu(viewer.getControl());
    viewer.getControl().setMenu(menu);
    getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer));

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance(), LocalSelectionTransfer.getTransfer(), FileTransfer.getInstance() };
    viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer));
    viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer));
}
项目:SimQRI    文件:MetamodelEditor.java   
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor(StructuredViewer viewer) {
    MenuManager contextMenu = new MenuManager("#PopUp");
    contextMenu.add(new Separator("additions"));
    contextMenu.setRemoveAllWhenShown(true);
    contextMenu.addMenuListener(this);
    Menu menu= contextMenu.createContextMenu(viewer.getControl());
    viewer.getControl().setMenu(menu);
    getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer));

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance(), LocalSelectionTransfer.getTransfer(), FileTransfer.getInstance() };
    viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer));
    viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer));
}
项目:BiglyBT    文件:PiecesView.java   
@Override
public void
addThisColumnSubMenu(
    String  sColumnName,
    Menu    menuThisColumn )
{

}
项目:BiglyBT    文件:PingGraphic.java   
@Override
 protected void
 addMenuItems(
Menu    menu )
 {
  new MenuItem( menu, SWT.SEPARATOR );

  MenuItem mi_reset = new MenuItem( menu, SWT.PUSH );

  mi_reset.setText(  MessageText.getString( "label.clear.history" ));

  mi_reset.addListener(SWT.Selection, new Listener() {
      @Override
      public void handleEvent(Event e) {
          try{
            this_mon.enter();

            nbValues        = 0;
            currentPosition = 0;

            for ( int i=0;i<all_values.length;i++ ){
                all_values[i] = new int[all_values[i].length];
            }
          }finally{

            this_mon.exit();
          }

          refresh( true );
      }
  });
 }
项目:eZooKeeper    文件:ZooKeeperExplorerView.java   
private void hookContextMenu() {
    MenuManager menuMgr = new MenuManager("#PopupMenu");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            fillContextMenu(manager);
        }
    });

    Menu menu = menuMgr.createContextMenu(_TreeViewer.getControl());
    _TreeViewer.getControl().setMenu(menu);
    getSite().registerContextMenu(menuMgr, _TreeViewer);
}
项目:eZooKeeper    文件:ZnodeModelChildrenFormPage.java   
private void hookTableContextMenu() {
    MenuManager menuMgr = new MenuManager("#PopupMenu");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            fillContextMenu(manager);
        }
    });

    Menu menu = menuMgr.createContextMenu(_TableViewer.getControl());
    _TableViewer.getControl().setMenu(menu);
    getSite().registerContextMenu(menuMgr, _TableViewer);
}
项目:eZooKeeper    文件:JmxExplorerView.java   
private void hookContextMenu() {
    MenuManager menuMgr = new MenuManager("#PopupMenu");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            fillContextMenu(manager);
        }
    });

    Menu menu = menuMgr.createContextMenu(_TreeViewer.getControl());
    _TreeViewer.getControl().setMenu(menu);
    getSite().registerContextMenu(menuMgr, _TreeViewer);
}
项目:pmTrans    文件:BarManager.java   
private MenuItem addMenuItem(Menu menu, String text, int accelerator,
        Object data, SelectionListener listener) {
    MenuItem item = new MenuItem(menu, SWT.NONE);
    item.setText(text);
    item.addSelectionListener(listener);
    if (accelerator != SWT.NONE)
        item.setAccelerator(accelerator);
    item.setData(data);
    return item;
}
项目:pmTrans    文件:MenuManager.java   
public void createMenu() {
    menuBar = new Menu(shell, SWT.BAR);
    createFileMenu();
    createEditMenu();
    createPlaybackMenu();
    createViewMenu();
    createHelpMenu();

    shell.setMenuBar(menuBar);
}
项目:pmTrans    文件:MenuManager.java   
private MenuItem addConfigurableMenuItem(Menu menu, final String orgText,
        final String acceleratorKey, SelectionListener listener) {
    char accelerator = Config.getInstance().getString(acceleratorKey)
            .toUpperCase().charAt(0);
    int acc = SWT.MOD1 + (accelerator == ' ' ? SWT.SPACE : accelerator);
    String text = orgText + " \t Ctrl+"
            + (accelerator == ' ' ? "[space]" : accelerator);

    final MenuItem item = addMenuItem(menu, text, acc, listener);

    Config.getInstance().addPropertyChangeListener(
            new IPropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent arg0) {
                    if (arg0.getProperty().equals(acceleratorKey))
                        updateAccelerator(item, orgText, Config
                                .getInstance().getString(acceleratorKey)
                                .toUpperCase().charAt(0));
                }
            });

    return item;
}
项目:pmTrans    文件:MenuManager.java   
private MenuItem addMenuItem(Menu menu, String text,
        SelectionListener listener) {
    MenuItem item = new MenuItem(menu, SWT.NONE);
    item.setText(text);
    item.addSelectionListener(listener);
    return item;
}
项目:pmTrans    文件:MenuManager.java   
private MenuItem addMenuItem(Menu menu, String text, int accelerator,
        SelectionListener listener) {
    MenuItem item = addMenuItem(menu, text, listener);
    if (accelerator != SWT.NONE)
        item.setAccelerator(accelerator);
    return item;
}
项目:neoscada    文件:InformationViewPart.java   
private void hookContextMenu ( final IViewSite viewSite )
{
    final MenuManager menuMgr = new MenuManager ( "#PopupMenu" ); //$NON-NLS-1$
    menuMgr.setRemoveAllWhenShown ( true );
    menuMgr.addMenuListener ( new IMenuListener () {
        @Override
        public void menuAboutToShow ( final IMenuManager manager )
        {
            fillContextMenu ( manager );
        }
    } );
    final Menu menu = menuMgr.createContextMenu ( this.viewer.getControl () );
    this.viewer.getControl ().setMenu ( menu );
    viewSite.registerContextMenu ( menuMgr, this.viewer );
}
项目:neoscada    文件:ChartControllerView.java   
private void hookContextMenu ( final IViewSite viewSite )
{
    final MenuManager menuMgr = new MenuManager ( "#PopupMenu" ); //$NON-NLS-1$
    menuMgr.setRemoveAllWhenShown ( true );
    menuMgr.addMenuListener ( new IMenuListener () {
        @Override
        public void menuAboutToShow ( final IMenuManager manager )
        {
            fillContextMenu ( manager );
        }
    } );
    final Menu menu = menuMgr.createContextMenu ( this.viewer.getControl () );
    this.viewer.getControl ().setMenu ( menu );
    viewSite.registerContextMenu ( menuMgr, this.viewer );
}