当前位置: 首页>>代码示例>>Java>>正文


Java Tree.setMenu方法代码示例

本文整理汇总了Java中org.eclipse.swt.widgets.Tree.setMenu方法的典型用法代码示例。如果您正苦于以下问题:Java Tree.setMenu方法的具体用法?Java Tree.setMenu怎么用?Java Tree.setMenu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.swt.widgets.Tree的用法示例。


在下文中一共展示了Tree.setMenu方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createContextMenu

import org.eclipse.swt.widgets.Tree; //导入方法依赖的package包/类
/**
	 * create the views context menu
	 */
	private void createContextMenu() {

		final MenuManager menuMgr = new MenuManager();

		menuMgr.setRemoveAllWhenShown(true);

		menuMgr.addMenuListener(new IMenuListener() {
			@Override
			public void menuAboutToShow(final IMenuManager menuMgr2) {
//				fillContextMenu(menuMgr2);
			}
		});

		final Tree tree = _colorProfileViewer.getTree();
		final Menu treeContextMenu = menuMgr.createContextMenu(tree);

		tree.setMenu(treeContextMenu);

		_columnManager.createHeaderContextMenu(tree, treeContextMenu);
	}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:24,代码来源:PrefPageMap3Color.java

示例2: createContextMenu

import org.eclipse.swt.widgets.Tree; //导入方法依赖的package包/类
/**
 * create the views context menu
 */
private void createContextMenu() {

	final MenuManager menuMgr = new MenuManager();
	menuMgr.setRemoveAllWhenShown(true);
	menuMgr.addMenuListener(new IMenuListener() {
		@Override
		public void menuAboutToShow(final IMenuManager manager) {
			fillContextMenu(manager);
		}
	});

	final Tree tree = _folderViewer.getTree();
	final Menu contextMenu = menuMgr.createContextMenu(tree);

	tree.setMenu(contextMenu);

	_picDirView.registerContextMenu(MENU_ID_PIC_DIR_VIEW_IN_FOLDER, menuMgr);
}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:22,代码来源:PicDirFolder.java

示例3: createActionControls

import org.eclipse.swt.widgets.Tree; //导入方法依赖的package包/类
private void createActionControls(Tree tree) {
	String outlineId = FluentMkUI.PLUGIN_ID + ".outline";
	MenuManager menuMgr = new MenuManager(outlineId, outlineId);
	menuMgr.setRemoveAllWhenShown(true);
	menuMgr.addMenuListener(new IMenuListener() {

		@Override
		public void menuAboutToShow(IMenuManager m) {
			contextMenuAboutToShow(m);
		}
	});
	menu = menuMgr.createContextMenu(tree);
	tree.setMenu(menu);

	IPageSite site = getSite();
	site.registerContextMenu(outlineId, menuMgr, viewer); // $NON-NLS-1$
	site.setSelectionProvider(viewer);

	actionGroups = new CompositeActionGroup(new ActionGroup[] { new OpenViewActionGroup(this) });

	setAction(ACTION_EXPAND, new ExpandAllAction(viewer));
	setAction(ACTION_COLLAPSE, new CollapseAllAction(viewer));
	setAction(ACTION_TOGGLE, new ToggleLinkingAction(editor));

	setAction(ACTION_COPY, new OutlineCopyAction(this));
	setAction(ACTION_CUT, new OutlineCutAction(this));
	setAction(ACTION_PASTE, new OutlinePasteAction(this));
	setAction(ACTION_DELETE, new OutlineDeleteAction(this));

	createToolBar();
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:32,代码来源:MkOutlinePage.java

示例4: contributeActions

import org.eclipse.swt.widgets.Tree; //导入方法依赖的package包/类
/**
 * Contributes actions to the tree.
 * @param treeViewer tree viewer
 */
private void contributeActions(final TreeViewer treeViewer) {
    Tree tree = treeViewer.getTree();
    
    // Add menu
    MenuManager menuManager = new MenuManager();
    Menu menu = menuManager.createContextMenu(tree);

    // Add
    final IAction addAction = new AddKeyAction(editor, treeViewer);
    menuManager.add(addAction);
    // Delete
    final IAction deleteAction = new DeleteKeyAction(editor, treeViewer);
    menuManager.add(deleteAction);
    // Rename
    final IAction renameAction = new RenameKeyAction(editor, treeViewer);
    menuManager.add(renameAction);
    
    menuManager.update(true);
    tree.setMenu(menu);
    
    // Bind actions to tree
    tree.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent event) {
            if (event.character == SWT.DEL) {
                deleteAction.run();
            } else if (event.keyCode == SWT.F2) {
                renameAction.run();
            }
        }
    });
}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:36,代码来源:KeyTreeContributor.java

示例5: contributeActions

import org.eclipse.swt.widgets.Tree; //导入方法依赖的package包/类
/**
  * Contributes actions to the tree.
  * @param treeViewer tree viewer
  */
 private void contributeActions(final TreeViewer treeViewer) {
     final Tree tree = treeViewer.getTree();
     
     // Add menu
     final MenuManager menuManager = new MenuManager();
     final Menu menu = menuManager.createContextMenu(tree);

     // Add
     final IAction addAction = new AddKeyAction(editor, treeViewer);
     menuManager.add(addAction);
     // Delete
     final IAction deleteAction = new DeleteKeyAction(editor, treeViewer);
     menuManager.add(deleteAction);
     // Rename
     final IAction renameAction = new RenameKeyAction(editor, treeViewer);
     menuManager.add(renameAction);
     
     menuManager.update(true);
     tree.setMenu(menu);
     
     // Bind actions to tree
     tree.addKeyListener(new KeyAdapter() {
         @Override
public void keyReleased(final KeyEvent event) {
             if (event.character == SWT.DEL) {
                 deleteAction.run();
             } else if (event.keyCode == SWT.F2) {
                 renameAction.run();
             }
         }
     });
 }
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:37,代码来源:KeyTreeContributor-modified.java

示例6: createControl

import org.eclipse.swt.widgets.Tree; //导入方法依赖的package包/类
public void createControl(Composite parent) {
	Composite outerContainer = new Composite(parent,SWT.NONE);
	GridLayout layout = new GridLayout();
	layout.numColumns = 1;
	outerContainer.setLayout(layout);
	outerContainer.setLayoutData(
	new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));

	treeViewer = new TreeViewer(outerContainer, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER);
	RepositoryContentProvider contentProvider = new RepositoryContentProvider();
       treeViewer.setContentProvider(contentProvider);
       treeViewer.addFilter(RepositoryFilters.FOLDERS_ONLY);
       treeViewer.setLabelProvider(new WorkbenchLabelProvider());
       treeViewer.setInput(repositoryLocation);

	GridData data = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL);
	data.heightHint = LIST_HEIGHT_HINT;
	data.widthHint = LIST_WIDTH_HINT;
	treeViewer.getControl().setLayoutData(data);

	treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
		public void selectionChanged(SelectionChangedEvent event) {
			CheckoutWizard wizard = (CheckoutWizard)getWizard();
			ArrayList folderArray = new ArrayList();
			IStructuredSelection selection = (IStructuredSelection)treeViewer.getSelection();
			Iterator iter = selection.iterator();
			while (iter.hasNext()) {
				Object object = iter.next();
				if (object instanceof ISVNRemoteFolder || object instanceof ISVNRepositoryLocation) {
					if (object instanceof ISVNRepositoryLocation) folderArray.add(((ISVNRepositoryLocation)object).getRootFolder());
					else folderArray.add(object);
				}
			}
			ISVNRemoteFolder[] remoteFolders = new ISVNRemoteFolder[folderArray.size()];
			folderArray.toArray(remoteFolders);
			wizard.setRemoteFolders(remoteFolders);
			setPageComplete(!treeViewer.getSelection().isEmpty());
		}
	});
	
       final Action refreshAction = new Action(Policy.bind("RepositoriesView.refreshPopup"), SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_REFRESH)) { //$NON-NLS-1$
           public void run() {
           	refreshViewerNode();
           }
       };
       MenuManager menuMgr = new MenuManager();
       Tree tree = treeViewer.getTree();
       Menu menu = menuMgr.createContextMenu(tree);
       menuMgr.addMenuListener(new IMenuListener() {
           public void menuAboutToShow(IMenuManager manager) {
               manager.add(refreshAction);
           }

       });
       menuMgr.setRemoveAllWhenShown(true);
       tree.setMenu(menu);

	setMessage(Policy.bind("CheckoutWizardSelectionPage.text")); //$NON-NLS-1$

	setControl(outerContainer);
}
 
开发者ID:subclipse,项目名称:subclipse,代码行数:62,代码来源:CheckoutWizardSelectionPage.java

示例7: contributeActions

import org.eclipse.swt.widgets.Tree; //导入方法依赖的package包/类
/**
   * Contributes actions to the tree.
   *
   * @param treeViewer
   *            tree viewer
   */
  private void contributeActions(final TreeViewer treeViewer) {
      Tree tree = treeViewer.getTree();

      // Add menu
      MenuManager menuManager = new MenuManager();
      Menu menu = menuManager.createContextMenu(tree);

      // Add
      final IAction addAction = new AddKeyAction(editor, treeViewer);
      menuManager.add(addAction);
      // Delete
      final IAction deleteAction = new DeleteKeyAction(editor, treeViewer);
      menuManager.add(deleteAction);

      // Refactor
      final IAction refactorAction = new RefactorKeyAction(editor, treeViewer);
      menuManager.add(refactorAction);

      menuManager.update(true);
      menuManager.addMenuListener(new IMenuListener() {
	
	@Override
	public void menuAboutToShow(IMenuManager manager) {
		IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
        KeyTreeNode node = (KeyTreeNode) selection.getFirstElement();
		refactorAction.setEnabled(node != null && node.getChildren().length == 0);
		deleteAction.setEnabled(node != null);
	}
});
      tree.setMenu(menu);

      // Bind actions to tree
      tree.addKeyListener(new KeyAdapter() {
          public void keyReleased(KeyEvent event) {
              if (event.character == SWT.DEL) {
                  deleteAction.run();
              }
          }
      });
  }
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:47,代码来源:KeyTreeContributor.java

示例8: createPartControl

import org.eclipse.swt.widgets.Tree; //导入方法依赖的package包/类
@Override
public void createPartControl(Composite parent){
	parent.setLayout(new GridLayout(1, false));
	Composite composite = new Composite(parent, SWT.NONE);
	composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	TreeColumnLayout tcl_composite = new TreeColumnLayout();
	composite.setLayout(tcl_composite);
	
	treeViewer = new TreeViewer(composite, SWT.BORDER);
	Tree tree = treeViewer.getTree();
	
	TreeViewerColumn treeViewerColumn = new TreeViewerColumn(treeViewer, SWT.NONE);
	TreeColumn trclmnNewColumn = treeViewerColumn.getColumn();
	tcl_composite.setColumnData(trclmnNewColumn, new ColumnWeightData(100));
	trclmnNewColumn.setText("New Column");
	
	treeViewer.setLabelProvider(new KonsultationenTreeLabelProvider());
	treeViewer.setContentProvider(new KonsultationenTreeContentProvider(treeViewer));

	treeViewer.setInput("0");
	treeViewer.addDoubleClickListener(new KonsultationsbelegAnzeigen());
	
	MenuManager menuManager = new MenuManager();
	menuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
	tree.setMenu(menuManager.createContextMenu(tree));
	
	getSite().registerContextMenu(menuManager, treeViewer);
	getSite().setSelectionProvider(treeViewer);
	
	Composite composite_1 = new Composite(parent, SWT.NONE);
	composite_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	composite_1.setLayout(new GridLayout(4, false));
	
	Label lblOfflineNachsignaturen = new Label(composite_1, SWT.NONE);
	lblOfflineNachsignaturen.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1));
	lblOfflineNachsignaturen.setText("Gespeicherte Offline-Nachsignaturen: ");
	
	lblOFFLINENACHSIGNATUREN = new Label(composite_1, SWT.NONE);
	GridData gd_lblOFFLINENACHSIGNATUREN = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
	gd_lblOFFLINENACHSIGNATUREN.widthHint = 25;
	lblOFFLINENACHSIGNATUREN.setLayoutData(gd_lblOFFLINENACHSIGNATUREN);
	lblOFFLINENACHSIGNATUREN.setText("n/a");
	
	Label lblGespeicherteOfflineKonsultationen = new Label(composite_1, SWT.NONE);
	lblGespeicherteOfflineKonsultationen.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1));
	lblGespeicherteOfflineKonsultationen.setText("Gespeicherte Offline Konsultationen:");
	
	lblGESPEICHERTEKONSULTATIONEN = new Label(composite_1, SWT.NONE);
	GridData gd_lblGESPEICHERTEKONSULTATIONEN = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
	gd_lblGESPEICHERTEKONSULTATIONEN.widthHint = 25;
	lblGESPEICHERTEKONSULTATIONEN.setLayoutData(gd_lblGESPEICHERTEKONSULTATIONEN);
	lblGESPEICHERTEKONSULTATIONEN.setText("n/a");
	m_bindingContext = initDataBindings();
}
 
开发者ID:MEDEVIT,项目名称:ecard,代码行数:55,代码来源:KonsultationenView.java

示例9: createHeaderContextMenu

import org.eclipse.swt.widgets.Tree; //导入方法依赖的package包/类
/**
 * set context menu depending on the position of the mouse
 * 
 * @param tree
 * @param defaultContextMenu
 *            can be <code>null</code>
 */
public void createHeaderContextMenu(final Tree tree, final Menu defaultContextMenu) {

	// remove old listener
	if (_treeMenuDetectListener != null) {
		tree.removeListener(SWT.MenuDetect, _treeMenuDetectListener);
	}

	final Menu headerContextMenu = createHCM_0_Menu(tree, defaultContextMenu);

	// add the context menu to the tree viewer
	_treeMenuDetectListener = new Listener() {
		@Override
		public void handleEvent(final Event event) {

			final Decorations shell = tree.getShell();
			final Display display = shell.getDisplay();

			final Point mousePosition = display.map(null, tree, new Point(event.x, event.y));

			final Rectangle clientArea = tree.getClientArea();

			final int headerHeight = tree.getHeaderHeight();
			final int headerBottom = clientArea.y + headerHeight;

			final boolean isTreeHeaderHit = clientArea.y <= mousePosition.y && mousePosition.y < headerBottom;

			_headerColumn = getHeaderColumn(tree, mousePosition, isTreeHeaderHit);

			final Menu contextMenu = getContextMenu(isTreeHeaderHit, headerContextMenu, defaultContextMenu);

			tree.setMenu(contextMenu);

			/*
			 * Set context menu position to the right border of the column
			 */
			if (_headerColumn != null) {

				int posX = _headerColumn.columnRightBorder;
				int xOffset = 0;

				final ScrollBar hBar = tree.getHorizontalBar();

				if (hBar != null) {
					xOffset = hBar.getSelection();
				}

				/*
				 * It is possible that the context menu is outside of the tree, this occures
				 * when the column is very wide and horizonal scrolled.
				 */
				if (posX - xOffset > clientArea.width) {
					posX = xOffset + clientArea.width;
				}

				final Point displayPosition = tree.toDisplay(posX, headerBottom);

				event.x = displayPosition.x - 1;
				event.y = displayPosition.y - 2;
			}
		}
	};

	tree.addListener(SWT.MenuDetect, _treeMenuDetectListener);
}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:72,代码来源:ColumnManager.java


注:本文中的org.eclipse.swt.widgets.Tree.setMenu方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。