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


Java Tree.addKeyListener方法代码示例

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


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

示例1: 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

示例2: 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

示例3: partOpened

import org.eclipse.swt.widgets.Tree; //导入方法依赖的package包/类
public void partOpened(IWorkbenchPart part) {
	if (part instanceof PropertySheet) {
		PropertySheet view = (PropertySheet)part;
		if (view != null) {
			if (view.getCurrentPage().getControl() instanceof Tree) {
				Tree tree = (Tree) view.getCurrentPage().getControl();
				if (tree != null) {
					tree.addKeyListener(new KeyAdapter() {
						
						@Override
						public void keyReleased(KeyEvent event) {
							boolean bCtrl = (((event.stateMask & SWT.CONTROL) != 0) || ((event.stateMask & SWT.CTRL) != 0));
							int keyCode = event.keyCode;
							char c = event.character;
							if (bCtrl) {
								if ((c == 's') || (keyCode == 115)) {
									ProjectExplorerView projectExplorerView = ConvertigoPlugin.getDefault().getProjectExplorerView();
									if (projectExplorerView != null) {
										projectExplorerView.projectExplorerSaveAllAction.run();
									}
								}
							}
						}
						
					});
				}
			}
		}
	}
	if (part instanceof EditorPart) {
		IEditorInput input = ((EditorPart)part).getEditorInput();
		if (input instanceof ApplicationComponentEditorInput) {
			try {
				MobileBuilder mb = ((ApplicationComponentEditorInput)input).getApplication().getProject().getMobileBuilder();
				mb.addMobileEventListener((ApplicationComponentEditor)part);
				mb.setAutoBuild(true);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:43,代码来源:ConvertigoPartListener.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);

      // 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


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