本文整理汇总了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();
}
}
});
}
示例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();
}
}
});
}
示例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();
}
}
}
}
示例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();
}
}
});
}