use of com.intellij.ide.PsiCopyPasteManager in project intellij-community by JetBrains.
the class StructureViewComponent method addTreeKeyListener.
private void addTreeKeyListener() {
getTree().addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (KeyEvent.VK_ENTER == e.getKeyCode()) {
DataContext dataContext = DataManager.getInstance().getDataContext(getTree());
OpenSourceUtil.openSourcesFrom(dataContext, false);
} else if (KeyEvent.VK_ESCAPE == e.getKeyCode()) {
if (e.isConsumed()) {
return;
}
PsiCopyPasteManager copyPasteManager = PsiCopyPasteManager.getInstance();
boolean[] isCopied = new boolean[1];
if (copyPasteManager.getElements(isCopied) != null && !isCopied[0]) {
copyPasteManager.clear();
e.consume();
}
}
}
});
}
use of com.intellij.ide.PsiCopyPasteManager in project intellij-community by JetBrains.
the class AbstractProjectViewPSIPane method initTree.
private void initTree() {
myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
UIUtil.setLineStyleAngled(myTree);
myTree.setRootVisible(false);
myTree.setShowsRootHandles(true);
myTree.expandPath(new TreePath(myTree.getModel().getRoot()));
myTree.setSelectionPath(new TreePath(myTree.getModel().getRoot()));
EditSourceOnDoubleClickHandler.install(myTree);
ToolTipManager.sharedInstance().registerComponent(myTree);
TreeUtil.installActions(myTree);
myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
fireTreeChangeListener();
}
});
myTree.getModel().addTreeModelListener(new TreeModelListener() {
@Override
public void treeNodesChanged(TreeModelEvent e) {
fireTreeChangeListener();
}
@Override
public void treeNodesInserted(TreeModelEvent e) {
fireTreeChangeListener();
}
@Override
public void treeNodesRemoved(TreeModelEvent e) {
fireTreeChangeListener();
}
@Override
public void treeStructureChanged(TreeModelEvent e) {
fireTreeChangeListener();
}
});
new MySpeedSearch(myTree);
myTree.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (KeyEvent.VK_ENTER == e.getKeyCode()) {
final DefaultMutableTreeNode selectedNode = ((ProjectViewTree) myTree).getSelectedNode();
if (selectedNode != null && !selectedNode.isLeaf()) {
return;
}
DataContext dataContext = DataManager.getInstance().getDataContext(myTree);
OpenSourceUtil.openSourcesFrom(dataContext, ScreenReader.isActive());
} else if (KeyEvent.VK_ESCAPE == e.getKeyCode()) {
if (e.isConsumed())
return;
PsiCopyPasteManager copyPasteManager = PsiCopyPasteManager.getInstance();
boolean[] isCopied = new boolean[1];
if (copyPasteManager.getElements(isCopied) != null && !isCopied[0]) {
copyPasteManager.clear();
e.consume();
}
}
}
});
CustomizationUtil.installPopupHandler(myTree, IdeActions.GROUP_PROJECT_VIEW_POPUP, ActionPlaces.PROJECT_VIEW_POPUP);
}
use of com.intellij.ide.PsiCopyPasteManager in project netbeans-mmd-plugin by raydac.
the class KnowledgeViewPane method initTree.
private void initTree() {
myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
UIUtil.setLineStyleAngled(myTree);
myTree.setRootVisible(false);
myTree.setShowsRootHandles(true);
myTree.expandPath(new TreePath(myTree.getModel().getRoot()));
myTree.setSelectionPath(new TreePath(myTree.getModel().getRoot()));
EditSourceOnDoubleClickHandler.install(myTree);
ToolTipManager.sharedInstance().registerComponent(myTree);
TreeUtil.installActions(myTree);
myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
fireTreeChangeListener();
}
});
myTree.getModel().addTreeModelListener(new TreeModelListener() {
@Override
public void treeNodesChanged(TreeModelEvent e) {
fireTreeChangeListener();
}
@Override
public void treeNodesInserted(TreeModelEvent e) {
fireTreeChangeListener();
}
@Override
public void treeNodesRemoved(TreeModelEvent e) {
fireTreeChangeListener();
}
@Override
public void treeStructureChanged(TreeModelEvent e) {
fireTreeChangeListener();
}
});
new SpeedSearch(myTree);
myTree.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (KeyEvent.VK_ENTER == e.getKeyCode()) {
final DefaultMutableTreeNode selectedNode = ((ProjectViewTree) myTree).getSelectedNode();
if (selectedNode != null && !selectedNode.isLeaf()) {
return;
}
DataContext dataContext = DataManager.getInstance().getDataContext(myTree);
OpenSourceUtil.openSourcesFrom(dataContext, false);
} else if (KeyEvent.VK_ESCAPE == e.getKeyCode()) {
if (e.isConsumed())
return;
PsiCopyPasteManager copyPasteManager = PsiCopyPasteManager.getInstance();
boolean[] isCopied = new boolean[1];
if (copyPasteManager.getElements(isCopied) != null && !isCopied[0]) {
copyPasteManager.clear();
e.consume();
}
}
}
});
CustomizationUtil.installPopupHandler(myTree, IdeActions.GROUP_PROJECT_VIEW_POPUP, ActionPlaces.PROJECT_VIEW_POPUP);
}
use of com.intellij.ide.PsiCopyPasteManager in project intellij-community by JetBrains.
the class Commander method createPanel.
private CommanderPanel createPanel() {
final CommanderPanel panel = new CommanderPanel(myProject, true, false);
panel.getList().addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(final KeyEvent e) {
if (KeyEvent.VK_ESCAPE == e.getKeyCode()) {
if (e.isConsumed())
return;
final PsiCopyPasteManager copyPasteManager = PsiCopyPasteManager.getInstance();
final boolean[] isCopied = new boolean[1];
if (copyPasteManager.getElements(isCopied) != null && !isCopied[0]) {
copyPasteManager.clear();
e.consume();
}
}
}
});
final ProjectAbstractTreeStructureBase treeStructure = createProjectTreeStructure();
panel.setBuilder(new ProjectListBuilder(myProject, panel, treeStructure, AlphaComparator.INSTANCE, true));
panel.setProjectTreeStructure(treeStructure);
final FocusAdapter focusListener = new FocusAdapter() {
@Override
public void focusGained(final FocusEvent e) {
updateToolWindowTitle(panel);
}
};
final JList list = panel.getList();
list.addFocusListener(focusListener);
list.getSelectionModel().addListSelectionListener(mySelectionListener);
list.getModel().addListDataListener(myListDataListener);
Disposer.register(this, new Disposable() {
@Override
public void dispose() {
list.removeFocusListener(focusListener);
list.getSelectionModel().removeListSelectionListener(mySelectionListener);
list.getModel().removeListDataListener(myListDataListener);
}
});
return panel;
}
Aggregations