private void addTreeMouseListeners() { EditSourceOnDoubleClickHandler.install(getTree(), new Runnable() { @Override public void run() { TreePath path = getTree().getSelectionPath(); if (path == null) return; DefaultMutableTreeNode selectedElement = (DefaultMutableTreeNode)path.getLastPathComponent(); if (selectedElement == null) return; GlobalConfigsTreeStructure.GlobalConfigNode configNode = (GlobalConfigsTreeStructure.GlobalConfigNode)selectedElement.getUserObject(); if (configNode == null) return; PsiElement element = configNode.getXmlTag(); if (element == null) return; OpenSourceUtil.navigate((Navigatable)element); } }); CustomizationUtil.installPopupHandler(getTree(), IdeActions.GROUP_STRUCTURE_VIEW_POPUP, ActionPlaces.STRUCTURE_VIEW_POPUP); }
private void initTree(final MyTree tree) { tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.setCellRenderer(new MyTreeCellRenderer(tree == myLeftTree)); tree.setRootVisible(false); tree.setShowsRootHandles(true); UIUtil.setLineStyleAngled(tree); TreeUtil.installActions(tree); SmartExpander.installOn(tree); EditSourceOnDoubleClickHandler.install(tree); new TreeSpeedSearch(tree); PopupHandler.installUnknownPopupHandler(tree, createTreePopupActions(), ActionManager.getInstance()); }
@NotNull public CheckBoxListModelEditor<T> editAction(final @NotNull Function<T, T> consumer) { final Runnable action = new Runnable() { @Override public void run() { T item = getSelectedItem(); if (item != null) { T newItem = consumer.fun(item); if (newItem != null) { list.updateItem(item, newItem, StringUtil.notNullize(toNameConverter.fun(newItem))); } list.requestFocus(); } } }; toolbarDecorator.setEditAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { action.run(); } }); EditSourceOnDoubleClickHandler.install(list, action); return this; }
public StatisticsPanel() { super(new BorderLayout(0, 0)); myChildInfo = new StatisticsTable(TestColumnInfo.COLUMN_NAMES); myTable = new TableView(myChildInfo) { @Override public TableCellRenderer getCellRenderer(int row, int column) { return new TestTableRenderer(TestColumnInfo.COLUMN_NAMES); } }; EditSourceOnDoubleClickHandler.install(myTable); PopupHandler.installPopupHandler(myTable, IdeActions.GROUP_TESTSTATISTICS_POPUP, ActionPlaces.TESTSTATISTICS_VIEW_POPUP); // add(myTestCaseInfo, BorderLayout.NORTH); add(ScrollPaneFactory.createScrollPane(myTable), BorderLayout.CENTER); final JPanel eastPanel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, false)); myTotalLabel = new SimpleColoredComponent(); eastPanel.add(myTotalLabel); myTimeLabel = new SimpleColoredComponent(); eastPanel.add(myTimeLabel); add(eastPanel, BorderLayout.SOUTH); }
private void createComponent() { setLayout(new BorderLayout()); myRepositoryTree = new Tree(); myRepositoryTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); myRepositoryTree.setRootVisible(false); myRepositoryTree.setShowsRootHandles(true); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myRepositoryTree, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); add(scrollPane, BorderLayout.CENTER); myRepositoryTree.setCellRenderer(new SvnRepositoryTreeCellRenderer()); TreeSpeedSearch search = new TreeSpeedSearch(myRepositoryTree, new Convertor<TreePath, String>() { @Override public String convert(TreePath o) { Object component = o.getLastPathComponent(); if (component instanceof RepositoryTreeNode) { return ((RepositoryTreeNode)component).getURL().toDecodedString(); } return null; } }); search.setComparator(new SpeedSearchComparator(false, true)); EditSourceOnDoubleClickHandler.install(myRepositoryTree); }
public FilesystemToolwindow(final VirtualFile root, Project project) { myRoot = root; myProject = project; myToolWindow = ToolWindowManager.getInstance(project).registerToolWindow("File System", false, ToolWindowAnchor.LEFT); myContent = new MyContent(); final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, true, false, true, true); descriptor.setRoots(myRoot); myFsTree = new FileSystemTreeImpl(project, descriptor); myContent.add(ScrollPaneFactory.createScrollPane(myFsTree.getTree()), BorderLayout.CENTER); EditSourceOnDoubleClickHandler.install(myFsTree.getTree()); EditSourceOnEnterKeyHandler.install(myFsTree.getTree()); final ContentFactory contentFactory = new ContentFactoryImpl(); final Content content = contentFactory.createContent(myContent, null, false); myToolWindow.getContentManager().addContent(content); }
private void initTree(final Tree tree) { final MigrationRootsTreeCellRenderer rootsTreeCellRenderer = new MigrationRootsTreeCellRenderer(); tree.setCellRenderer(rootsTreeCellRenderer); tree.setRootVisible(false); tree.setShowsRootHandles(true); UIUtil.setLineStyleAngled(tree); TreeUtil.installActions(tree); TreeUtil.expandAll(tree); SmartExpander.installOn(tree); EditSourceOnDoubleClickHandler.install(tree); new TreeSpeedSearch(tree); PopupHandler.installUnknownPopupHandler(tree, createTreePopupActions(), ActionManager.getInstance()); }
protected void installHandlers() { EditSourceOnDoubleClickHandler.install(this); new TreeSpeedSearch(this, new Convertor<TreePath, String>() { public String convert(final TreePath path) { final AbstractTestProxy testProxy = getSelectedTest(path); if (testProxy == null) return null; return testProxy.getName(); } }); TreeUtil.installActions(this); PopupHandler.installPopupHandler(this, IdeActions.GROUP_TESTTREE_POPUP, ActionPlaces.TESTTREE_VIEW_POPUP); }
public UnversionedViewDialog(final Project project) { super(project, true); setTitle("Unversioned Files"); myProject = project; final Runnable closer = new Runnable() { public void run() { UnversionedViewDialog.this.close(0); } }; myView = new ChangesListView(project) { @Override public void calcData(DataKey key, DataSink sink) { super.calcData(key, sink); if (ChangesListView.UNVERSIONED_FILES_DATA_KEY.is(key.getName())) { sink.put(key, Arrays.asList(getSelectedFiles())); } } @Override protected void editSourceRegistration() { EditSourceOnDoubleClickHandler.install(this, closer); EditSourceOnEnterKeyHandler.install(this, closer); } }; myChangeListManager = ChangeListManager.getInstance(project); createPanel(); setOKButtonText("Close"); init(); initData(((ChangeListManagerImpl) myChangeListManager).getUnversionedFiles()); myView.setMinimumSize(new Dimension(100, 100)); }
private void initTree() { myTree.setCellRenderer(new MyTreeCellRenderer()); myTree.setRootVisible(false); myTree.setShowsRootHandles(true); UIUtil.setLineStyleAngled(myTree); TreeUtil.installActions(myTree); EditSourceOnDoubleClickHandler.install(myTree); new TreeSpeedSearch(myTree); myCopyPasteDelegator = new CopyPasteDelegator(myProject, this) { @Override @NotNull protected PsiElement[] getSelectedElements() { return getSelectedPsiElements(); } }; myTreeExpansionMonitor = PackageTreeExpansionMonitor.install(myTree, myProject); final ScopeTreeStructureExpander[] extensions = Extensions.getExtensions(ScopeTreeStructureExpander.EP_NAME, myProject); for (ScopeTreeStructureExpander expander : extensions) { myTree.addTreeWillExpandListener(expander); } if (extensions.length == 0) { myTree.addTreeWillExpandListener(new SortingExpandListener()); } myTree.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (KeyEvent.VK_ENTER == e.getKeyCode()) { final Object component = myTree.getLastSelectedPathComponent(); if (component instanceof DefaultMutableTreeNode) { final DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)component; if (selectedNode.isLeaf()) { OpenSourceUtil.openSourcesFrom(DataManager.getInstance().getDataContext(myTree), false); } } } } }); }
public EditorsPanel(final Project project, List<EditorInfo> editors) { super(new BorderLayout()); myProject = project; myModel.setItems(editors); add(ScrollPaneFactory.createScrollPane(myTable), BorderLayout.CENTER); EditSourceOnDoubleClickHandler.install(myTable); EditSourceOnEnterKeyHandler.install(myTable, null); }
private void initUI() { final DefaultMutableTreeNode root = new DefaultMutableTreeNode(); myJTree = new JTree(root); myJTree.setRootVisible(false); myJTree.setShowsRootHandles(false); myJTree.setCellRenderer(new ChangesBrowserNodeRenderer(myProject, true, false)); TreeModelBuilder builder = new TreeModelBuilder(myProject, true); final DefaultTreeModel treeModel = builder.buildModelFromFilePaths(myFilesToShow); myJTree.setModel(treeModel); myJTree.expandPath(new TreePath(root.getPath())); final JLabel label = new JLabel(myText) { @Override public Dimension getPreferredSize() { final Dimension superValue = super.getPreferredSize(); return new Dimension((int) superValue.getWidth(), (int) (superValue.getHeight() * 1.7)); } }; label.setUI(new MultiLineLabelUI()); label.setBackground(UIUtil.getTextFieldBackground()); label.setVerticalTextPosition(JLabel.TOP); myPanel.setBackground(UIUtil.getTextFieldBackground()); myPanel.add(label, BorderLayout.NORTH); myPanel.add(myJTree, BorderLayout.CENTER); EditSourceOnDoubleClickHandler.install(myJTree); EditSourceOnEnterKeyHandler.install(myJTree); final EditSourceAction editSourceAction = new EditSourceAction(); editSourceAction.registerCustomShortcutSet(CommonShortcuts.getEditSource(), myPanel); }
protected void installHandlers() { EditSourceOnDoubleClickHandler.install(this); new TreeSpeedSearch(this, new Convertor<TreePath, String>() { public String convert(final TreePath path) { final AbstractTestProxy testProxy = getSelectedTest(path); if (testProxy == null) return null; return testProxy.getName(); } }); TreeUtil.installActions(this); PopupHandler.installPopupHandler(this, IdeActions.GROUP_TESTTREE_POPUP, ActionPlaces.TESTTREE_VIEW_POPUP); ViewAssertEqualsDiffAction.registerShortcut(this); }
private void initTree() { myTree.setCellRenderer(new MyTreeCellRenderer()); myTree.setRootVisible(false); myTree.setShowsRootHandles(true); UIUtil.setLineStyleAngled(myTree); TreeUtil.installActions(myTree); EditSourceOnDoubleClickHandler.install(myTree); new TreeSpeedSearch(myTree); myCopyPasteDelegator = new CopyPasteDelegator(myProject, this) { @Override @NotNull protected PsiElement[] getSelectedElements() { return getSelectedPsiElements(); } }; myTreeExpansionMonitor = PackageTreeExpansionMonitor.install(myTree, myProject); final ScopeTreeStructureExpander[] extensions = Extensions.getExtensions(ScopeTreeStructureExpander.EP_NAME, myProject); for (ScopeTreeStructureExpander expander : extensions) { myTree.addTreeWillExpandListener(expander); } if (extensions.length == 0) { myTree.addTreeWillExpandListener(new SortingExpandListener()); } myTree.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (KeyEvent.VK_ENTER == e.getKeyCode()) { final Object component = myTree.getLastSelectedPathComponent(); if (component instanceof DefaultMutableTreeNode) { final DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)component; if (selectedNode.isLeaf()) { OpenSourceUtil.openSourcesFrom(DataManager.getInstance().getDataContext(myTree), false); } } } } }); CustomizationUtil.installPopupHandler(myTree, IdeActions.GROUP_PROJECT_VIEW_POPUP, ActionPlaces.PROJECT_VIEW_POPUP); }
protected SpecificFilesViewDialog(@Nonnull Project project, @Nonnull String title, @Nonnull Key<Stream<VirtualFile>> shownDataKey, @Nonnull List<VirtualFile> initDataFiles) { super(project, true); setTitle(title); myProject = project; final Runnable closer = () -> this.close(0); myView = new ChangesListView(project) { @Override public void calcData(Key<?> key, DataSink sink) { super.calcData(key, sink); if (shownDataKey == key) { sink.put(shownDataKey, getSelectedFiles()); } } @Override protected void editSourceRegistration() { EditSourceOnDoubleClickHandler.install(this, closer); EditSourceOnEnterKeyHandler.install(this, closer); } }; myChangeListManager = ChangeListManager.getInstance(project); createPanel(); setOKButtonText("Close"); init(); initData(initDataFiles); myView.setMinimumSize(new Dimension(100, 100)); }
private void initTree() { myTree.setCellRenderer(new MyTreeCellRenderer()); myTree.setRootVisible(false); myTree.setShowsRootHandles(true); UIUtil.setLineStyleAngled(myTree); TreeUtil.installActions(myTree); EditSourceOnDoubleClickHandler.install(myTree); new TreeSpeedSearch(myTree); myCopyPasteDelegator = new CopyPasteDelegator(myProject, this) { @Override @Nonnull protected PsiElement[] getSelectedElements() { return getSelectedPsiElements(); } }; myTreeExpansionMonitor = PackageTreeExpansionMonitor.install(myTree, myProject); final ScopeTreeStructureExpander[] extensions = Extensions.getExtensions(ScopeTreeStructureExpander.EP_NAME, myProject); for (ScopeTreeStructureExpander expander : extensions) { myTree.addTreeWillExpandListener(expander); } if (extensions.length == 0) { myTree.addTreeWillExpandListener(new SortingExpandListener()); } myTree.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (KeyEvent.VK_ENTER == e.getKeyCode()) { final Object component = myTree.getLastSelectedPathComponent(); if (component instanceof DefaultMutableTreeNode) { final DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)component; if (selectedNode.isLeaf()) { OpenSourceUtil.openSourcesFrom(DataManager.getInstance().getDataContext(myTree), false); } } } } }); CustomizationUtil.installPopupHandler(myTree, IdeActions.GROUP_PROJECT_VIEW_POPUP, ActionPlaces.PROJECT_VIEW_POPUP); }
public void installEditSourceOnDoubleClickHandler() { EditSourceOnDoubleClickHandler.install(myTreeView); EditSourceOnDoubleClickHandler.install(myFlatView); }
public void installEditSourceOnDoubleClick(final JTree tree) { EditSourceOnDoubleClickHandler.install(tree); }
public NewErrorTreeViewPanel(Project project, String helpId, boolean createExitAction, boolean createToolbar, @Nullable Runnable rerunAction) { myProject = project; myHelpId = helpId; myCreateExitAction = createExitAction; myConfiguration = ErrorTreeViewConfiguration.getInstance(project); setLayout(new BorderLayout()); myAutoScrollToSourceHandler = new AutoScrollToSourceHandler() { @Override protected boolean isAutoScrollMode() { return myConfiguration.isAutoscrollToSource(); } @Override protected void setAutoScrollMode(boolean state) { myConfiguration.setAutoscrollToSource(state); } }; myMessagePanel = new JPanel(new BorderLayout()); myErrorViewStructure = new ErrorViewStructure(project, canHideWarnings()); DefaultMutableTreeNode root = new DefaultMutableTreeNode(); root.setUserObject(myErrorViewStructure.createDescriptor(myErrorViewStructure.getRootElement(), null)); final DefaultTreeModel treeModel = new DefaultTreeModel(root); myTree = new Tree(treeModel) { @Override public void setRowHeight(int i) { super.setRowHeight(0); // this is needed in order to make UI calculate the height for each particular row } }; myBuilder = new ErrorViewTreeBuilder(myTree, treeModel, myErrorViewStructure); myExporterToTextFile = new ErrorViewTextExporter(myErrorViewStructure); myOccurrenceNavigatorSupport = new MyOccurrenceNavigatorSupport(myTree); myAutoScrollToSourceHandler.install(myTree); TreeUtil.installActions(myTree); UIUtil.setLineStyleAngled(myTree); myTree.setRootVisible(false); myTree.setShowsRootHandles(true); myTree.setLargeModel(true); JScrollPane scrollPane = NewErrorTreeRenderer.install(myTree); scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT)); myMessagePanel.add(scrollPane, BorderLayout.CENTER); if (createToolbar) { add(createToolbarPanel(rerunAction), BorderLayout.WEST); } add(myMessagePanel, BorderLayout.CENTER); myTree.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { navigateToSource(false); } } }); myTree.addMouseListener(new PopupHandler() { @Override public void invokePopup(Component comp, int x, int y) { popupInvoked(comp, x, y); } }); EditSourceOnDoubleClickHandler.install(myTree); }
private void createTree() { SmartExpander.installOn(myTree); SelectionSaver.installOn(myTree); createTreeModel(); myTree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { AbstractTreeNode treeNode = (AbstractTreeNode)e.getPath().getLastPathComponent(); VirtualFilePointer pointer = null; if (treeNode instanceof FileTreeNode) { pointer = ((FileTreeNode)treeNode).getFilePointer(); } if (pointer != null && pointer.isValid()) { mySelectedUrl = pointer.getUrl(); mySelectedFile = pointer.getFile(); } else { mySelectedUrl = null; mySelectedFile = null; } } }); myTree.setCellRenderer(new UpdateTreeCellRenderer()); TreeUtil.installActions(myTree); new TreeSpeedSearch(myTree, new Convertor<TreePath, String>() { public String convert(TreePath path) { Object last = path.getLastPathComponent(); if (last instanceof AbstractTreeNode) { return ((AbstractTreeNode)last).getText(); } return TreeSpeedSearch.NODE_DESCRIPTOR_TOSTRING.convert(path); } }, true); myTree.addMouseListener(new PopupHandler() { public void invokePopup(Component comp, int x, int y) { final DefaultActionGroup group = (DefaultActionGroup)ActionManager.getInstance().getAction("UpdateActionGroup"); if (group != null) { //if no UpdateActionGroup was configured ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UPDATE_POPUP, group); popupMenu.getComponent().show(comp, x, y); } } }); EditSourceOnDoubleClickHandler.install(myTree); EditSourceOnEnterKeyHandler.install(myTree); myTree.setSelectionRow(0); }
protected void editSourceRegistration() { EditSourceOnDoubleClickHandler.install(this); EditSourceOnEnterKeyHandler.install(this); }
private JPanel createPanel() { createModel(); myTree = new MyTree(); myTree.setLineStyleAngled(); myTree.setRootVisible(false); myTree.setShowsRootHandles(true); myTree.updateUI(); myTree.setLargeModel(true); myTree.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { OpenSourceUtil.openSourcesFrom(DataManager.getInstance().getDataContext(myTree), false); } } }); myTree.addMouseListener(new PopupHandler() { public void invokePopup(Component comp, int x, int y) { popupInvoked(comp, x, y); } }); EditSourceOnDoubleClickHandler.install(myTree); myAutoScrollToSourceHandler.install(myTree); myOccurenceNavigatorSupport = new OccurenceNavigatorSupport(myTree) { protected Navigatable createDescriptorForNode(DefaultMutableTreeNode node) { if (!(node instanceof MessageNode)) { return null; } MessageNode messageNode = (MessageNode)node; AntBuildMessageView.MessageType type = messageNode.getType(); if (type != AntBuildMessageView.MessageType.MESSAGE && type != AntBuildMessageView.MessageType.ERROR) { return null; } if (!isValid(messageNode.getFile())) { return null; } return new OpenFileDescriptor(myProject, messageNode.getFile(), messageNode.getOffset()); } @Nullable public String getNextOccurenceActionName() { return AntBundle.message("ant.execution.next.error.warning.action.name"); } @Nullable public String getPreviousOccurenceActionName() { return AntBundle.message("ant.execution.previous.error.warning.action.name"); } }; return JBUI.Panels.simplePanel(MessageTreeRenderer.install(myTree)); }
public PantsConsoleViewPanel(Project project) { myProject = project; myConfiguration = ErrorTreeViewConfiguration.getInstance(project); setLayout(new BorderLayout()); myAutoScrollToSourceHandler = new AutoScrollToSourceHandler() { @Override protected boolean isAutoScrollMode() { return myConfiguration.isAutoscrollToSource(); } @Override protected void setAutoScrollMode(boolean state) { myConfiguration.setAutoscrollToSource(state); } }; JPanel myMessagePanel = new JPanel(new BorderLayout()); DefaultMutableTreeNode root = new DefaultMutableTreeNode(); final DefaultTreeModel treeModel = new DefaultTreeModel(root); myTree = createTree(treeModel); myTree.getEmptyText().setText(IdeBundle.message("errortree.noMessages")); myAutoScrollToSourceHandler.install(myTree); TreeUtil.installActions(myTree); UIUtil.setLineStyleAngled(myTree); myTree.setRootVisible(false); myTree.setShowsRootHandles(true); myTree.setLargeModel(true); JScrollPane scrollPane = NewErrorTreeRenderer.install(myTree); scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT)); myMessagePanel.add(PantsConsoleManager.getOrMakeNewConsole(myProject).getComponent(), BorderLayout.CENTER); add(createToolbarPanel(), BorderLayout.WEST); add(myMessagePanel, BorderLayout.CENTER); EditSourceOnDoubleClickHandler.install(myTree); }
public NewErrorTreeViewPanel(Project project, String helpId, boolean createExitAction, boolean createToolbar, @Nullable Runnable rerunAction) { myProject = project; myHelpId = helpId; myCreateExitAction = createExitAction; myConfiguration = ErrorTreeViewConfiguration.getInstance(project); setLayout(new BorderLayout()); myAutoScrollToSourceHandler = new AutoScrollToSourceHandler() { protected boolean isAutoScrollMode() { return myConfiguration.isAutoscrollToSource(); } protected void setAutoScrollMode(boolean state) { myConfiguration.setAutoscrollToSource(state); } }; myMessagePanel = new JPanel(new BorderLayout()); myErrorViewStructure = new ErrorViewStructure(project, canHideWarnings()); DefaultMutableTreeNode root = new DefaultMutableTreeNode(); root.setUserObject(myErrorViewStructure.createDescriptor(myErrorViewStructure.getRootElement(), null)); final DefaultTreeModel treeModel = new DefaultTreeModel(root); myTree = new Tree(treeModel) { public void setRowHeight(int i) { super.setRowHeight(0); // this is needed in order to make UI calculate the height for each particular row } }; myBuilder = new ErrorViewTreeBuilder(myTree, treeModel, myErrorViewStructure); myExporterToTextFile = new ErrorViewTextExporter(myErrorViewStructure); myOccurenceNavigatorSupport = new MyOccurenceNavigatorSupport(myTree); myAutoScrollToSourceHandler.install(myTree); TreeUtil.installActions(myTree); UIUtil.setLineStyleAngled(myTree); myTree.setRootVisible(false); myTree.setShowsRootHandles(true); myTree.setLargeModel(true); JScrollPane scrollPane = NewErrorTreeRenderer.install(myTree); scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT)); myMessagePanel.add(scrollPane, BorderLayout.CENTER); if (createToolbar) { add(createToolbarPanel(rerunAction), BorderLayout.WEST); } add(myMessagePanel, BorderLayout.CENTER); myTree.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { navigateToSource(false); } } }); myTree.addMouseListener(new PopupHandler() { public void invokePopup(Component comp, int x, int y) { popupInvoked(comp, x, y); } }); EditSourceOnDoubleClickHandler.install(myTree); }
private void createTree() { SmartExpander.installOn(myTree); SelectionSaver.installOn(myTree); createTreeModel(); myTree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { AbstractTreeNode treeNode = (AbstractTreeNode)e.getPath().getLastPathComponent(); VirtualFilePointer pointer = null; if (treeNode instanceof FileTreeNode) { pointer = ((FileTreeNode)treeNode).getFilePointer(); } if (pointer != null && pointer.isValid()) { mySelectedUrl = pointer.getUrl(); mySelectedFile = pointer.getFile(); } else { mySelectedUrl = null; mySelectedFile = null; } } }); myTree.setCellRenderer(new UpdateTreeCellRenderer()); TreeUtil.installActions(myTree); new TreeSpeedSearch(myTree, new Convertor<TreePath, String>() { public String convert(TreePath path) { Object last = path.getLastPathComponent(); if (last instanceof AbstractTreeNode) { return ((AbstractTreeNode)last).getName(); } return TreeSpeedSearch.NODE_DESCRIPTOR_TOSTRING.convert(path); } }); myTree.addMouseListener(new PopupHandler() { public void invokePopup(Component comp, int x, int y) { final DefaultActionGroup group = (DefaultActionGroup)ActionManager.getInstance().getAction("UpdateActionGroup"); if (group != null) { //if no UpdateActionGroup was configured ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UPDATE_POPUP, group); popupMenu.getComponent().show(comp, x, y); } } }); EditSourceOnDoubleClickHandler.install(myTree); EditSourceOnEnterKeyHandler.install(myTree); myTree.setSelectionRow(0); }
private void addTreeMouseListeners() { EditSourceOnDoubleClickHandler.install(getTree()); CustomizationUtil.installPopupHandler(getTree(), IdeActions.GROUP_STRUCTURE_VIEW_POPUP, ActionPlaces.STRUCTURE_VIEW_POPUP); }
private JPanel createPanel() { createModel(); myTree = new MyTree(); myTree.setLineStyleAngled(); myTree.setRootVisible(false); myTree.setShowsRootHandles(true); myTree.updateUI(); myTree.setLargeModel(true); myTree.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { OpenSourceUtil.openSourcesFrom(DataManager.getInstance().getDataContext(myTree), false); } } }); myTree.addMouseListener(new PopupHandler() { public void invokePopup(Component comp, int x, int y) { popupInvoked(comp, x, y); } }); EditSourceOnDoubleClickHandler.install(myTree); myAutoScrollToSourceHandler.install(myTree); myOccurenceNavigatorSupport = new OccurenceNavigatorSupport(myTree) { protected Navigatable createDescriptorForNode(DefaultMutableTreeNode node) { if (!(node instanceof MessageNode)) { return null; } MessageNode messageNode = (MessageNode)node; AntBuildMessageView.MessageType type = messageNode.getType(); if (type != AntBuildMessageView.MessageType.MESSAGE && type != AntBuildMessageView.MessageType.ERROR) { return null; } if (!isValid(messageNode.getFile())) { return null; } return new OpenFileDescriptor(myProject, messageNode.getFile(), messageNode.getOffset()); } @Nullable public String getNextOccurenceActionName() { return AntBundle.message("ant.execution.next.error.warning.action.name"); } @Nullable public String getPreviousOccurenceActionName() { return AntBundle.message("ant.execution.previous.error.warning.action.name"); } }; JPanel panel = new JPanel(new BorderLayout()); JScrollPane scrollPane = MessageTreeRenderer.install(myTree); panel.add(scrollPane, BorderLayout.CENTER); return panel; }