public AnAction installAutoscrollToSourceHandler(Project project, JTree tree, final AutoScrollToSourceOptionProvider optionProvider) { AutoScrollToSourceHandler handler = new AutoScrollToSourceHandler() { public boolean isAutoScrollMode() { return optionProvider.isAutoScrollMode(); } public void setAutoScrollMode(boolean state) { optionProvider.setAutoScrollMode(state); } }; handler.install(tree); return handler.createToggleAction(); }
public AnalysisUIOptions() { myAutoScrollToSourceHandler = new AutoScrollToSourceHandler() { @Override protected boolean isAutoScrollMode() { return AUTOSCROLL_TO_SOURCE; } @Override protected void setAutoScrollMode(boolean state) { AUTOSCROLL_TO_SOURCE = state; } }; }
protected HierarchyBrowserBase(@NotNull Project project) { super(true, true); myProject = project; myAutoScrollToSourceHandler = new AutoScrollToSourceHandler() { @Override protected boolean isAutoScrollMode() { return HierarchyBrowserManager.getInstance(myProject).getState().IS_AUTOSCROLL_TO_SOURCE; } @Override protected void setAutoScrollMode(final boolean state) { HierarchyBrowserManager.getInstance(myProject).getState().IS_AUTOSCROLL_TO_SOURCE = state; } }; }
public TreeView(final Project project, final AntBuildFile buildFile) { myProject = project; myBuildFile = buildFile; myAutoScrollToSourceHandler = new AutoScrollToSourceHandler() { protected boolean isAutoScrollMode() { return AntConfigurationBase.getInstance(myProject).isAutoScrollToSource(); } protected void setAutoScrollMode(boolean state) { AntConfigurationBase.getInstance(myProject).setAutoScrollToSource(state); } }; myPanel = createPanel(); }
protected HierarchyBrowserBase(@Nonnull Project project) { super(true, true); myProject = project; myAutoScrollToSourceHandler = new AutoScrollToSourceHandler() { @Override protected boolean isAutoScrollMode() { return HierarchyBrowserManager.getInstance(myProject).getState().IS_AUTOSCROLL_TO_SOURCE; } @Override protected void setAutoScrollMode(final boolean state) { HierarchyBrowserManager.getInstance(myProject).getState().IS_AUTOSCROLL_TO_SOURCE = state; } }; }
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); }
public AutoScrollToSourceHandler getAutoScrollToSourceHandler() { return myAutoScrollToSourceHandler; }
public FavoritesAutoScrollToSourceAction(Project project, AutoScrollToSourceHandler autoScrollToSourceHandler, FavoritesViewTreeBuilder builder) { super(project, builder, UIBundle.message("autoscroll.to.source.action.name"), AllIcons.General.AutoscrollToSource); myAutoScrollToSourceHandler = autoScrollToSourceHandler; }
public ProjectViewImpl(@NotNull Project project, final FileEditorManager fileEditorManager, final ToolWindowManagerEx toolWindowManager) { myProject = project; constructUi(); Disposer.register(myProject, this); myFileEditorManager = fileEditorManager; myConnection = project.getMessageBus().connect(); myConnection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() { @Override public void rootsChanged(ModuleRootEvent event) { refresh(); } }); myAutoScrollFromSourceHandler = new MyAutoScrollFromSourceHandler(); myDataProvider = new MyPanel(); myDataProvider.add(myPanel, BorderLayout.CENTER); myCopyPasteDelegator = new CopyPasteDelegator(myProject, myPanel) { @Override @NotNull protected PsiElement[] getSelectedElements() { final AbstractProjectViewPane viewPane = getCurrentProjectViewPane(); return viewPane == null ? PsiElement.EMPTY_ARRAY : viewPane.getSelectedPSIElements(); } }; myAutoScrollToSourceHandler = new AutoScrollToSourceHandler() { @Override protected boolean isAutoScrollMode() { return isAutoscrollToSource(myCurrentViewId); } @Override protected void setAutoScrollMode(boolean state) { setAutoscrollToSource(state, myCurrentViewId); } }; toolWindowManager.addToolWindowManagerListener(new ToolWindowManagerAdapter(){ private boolean toolWindowVisible; @Override public void stateChanged() { ToolWindow window = toolWindowManager.getToolWindow(ToolWindowId.PROJECT_VIEW); if (window == null) return; if (window.isVisible() && !toolWindowVisible) { String id = getCurrentViewId(); if (isAutoscrollToSource(id)) { AbstractProjectViewPane currentProjectViewPane = getCurrentProjectViewPane(); if (currentProjectViewPane != null) { myAutoScrollToSourceHandler.onMouseClicked(currentProjectViewPane.getTree()); } } if (isAutoscrollFromSource(id)) { myAutoScrollFromSourceHandler.setAutoScrollEnabled(true); } } toolWindowVisible = window.isVisible(); } }); }
public MvcProjectViewPane(final Project project, MvcToolWindowDescriptor descriptor) { super(project); myDescriptor = descriptor; myId = descriptor.getToolWindowId(); myViewState = descriptor.getProjectViewState(project); class TreeUpdater implements Runnable, PsiModificationTracker.Listener { private volatile boolean myInQueue; @Override public void run() { if (getTree() != null && getTreeBuilder() != null) { updateFromRoot(true); } myInQueue = false; } @Override public void modificationCountChanged() { if (!myInQueue) { myInQueue = true; ApplicationManager.getApplication().invokeLater(this); } } } project.getMessageBus().connect(this).subscribe(PsiModificationTracker.TOPIC, new TreeUpdater()); myComponent = createComponent(); DataManager.registerDataProvider(myComponent, this); myAutoScrollFromSourceHandler = new MyAutoScrollFromSourceHandler(); myAutoScrollToSourceHandler = new AutoScrollToSourceHandler() { @Override protected boolean isAutoScrollMode() { return myViewState.autoScrollToSource; } @Override protected void setAutoScrollMode(boolean state) { myViewState.autoScrollToSource = state; } }; myAutoScrollFromSourceHandler.install(); myAutoScrollToSourceHandler.install(getTree()); myAutoScrollToSourceHandler.onMouseClicked(getTree()); myCopyPasteDelegator = new CopyPasteDelegator(project, myComponent) { @NotNull @Override protected PsiElement[] getSelectedElements() { return MvcProjectViewPane.this.getSelectedPSIElements(); } }; myDeletePSIElementProvider = new DeleteHandler.DefaultDeleteProvider(); }
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); }
public ProjectViewImpl(Project project, final FileEditorManager fileEditorManager, final ToolWindowManagerEx toolWindowManager) { myProject = project; constructUi(); Disposer.register(myProject, this); myFileEditorManager = fileEditorManager; myConnection = project.getMessageBus().connect(); myConnection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() { @Override public void rootsChanged(ModuleRootEvent event) { refresh(); } }); myAutoScrollFromSourceHandler = new MyAutoScrollFromSourceHandler(); myDataProvider = new MyPanel(); myDataProvider.add(myPanel, BorderLayout.CENTER); myCopyPasteDelegator = new CopyPasteDelegator(myProject, myPanel) { @Override @NotNull protected PsiElement[] getSelectedElements() { final AbstractProjectViewPane viewPane = getCurrentProjectViewPane(); return viewPane == null ? PsiElement.EMPTY_ARRAY : viewPane.getSelectedPSIElements(); } }; myAutoScrollToSourceHandler = new AutoScrollToSourceHandler() { @Override protected boolean isAutoScrollMode() { return isAutoscrollToSource(myCurrentViewId); } @Override protected void setAutoScrollMode(boolean state) { setAutoscrollToSource(state, myCurrentViewId); } }; toolWindowManager.addToolWindowManagerListener(new ToolWindowManagerAdapter(){ private boolean toolWindowVisible; @Override public void stateChanged() { ToolWindow window = toolWindowManager.getToolWindow(ToolWindowId.PROJECT_VIEW); if (window == null) return; if (window.isVisible() && !toolWindowVisible) { String id = getCurrentViewId(); if (isAutoscrollToSource(id)) { AbstractProjectViewPane currentProjectViewPane = getCurrentProjectViewPane(); if (currentProjectViewPane != null) { myAutoScrollToSourceHandler.onMouseClicked(currentProjectViewPane.getTree()); } } if (isAutoscrollFromSource(id)) { myAutoScrollFromSourceHandler.setAutoScrollEnabled(true); } } toolWindowVisible = window.isVisible(); } }); }
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, canHideWarningsOrInfos()); 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); 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() { @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); }
public ProjectViewImpl(@Nonnull Project project, final FileEditorManager fileEditorManager, final ToolWindowManagerEx toolWindowManager) { myProject = project; constructUi(); myFileEditorManager = fileEditorManager; myConnection = project.getMessageBus().connect(); myConnection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() { @Override public void rootsChanged(ModuleRootEvent event) { refresh(); } }); myAutoScrollFromSourceHandler = new MyAutoScrollFromSourceHandler(); myDataProvider = new MyPanel(); myDataProvider.add(myPanel, BorderLayout.CENTER); myCopyPasteDelegator = new CopyPasteDelegator(myProject, myPanel) { @Override @Nonnull protected PsiElement[] getSelectedElements() { final AbstractProjectViewPane viewPane = getCurrentProjectViewPane(); return viewPane == null ? PsiElement.EMPTY_ARRAY : viewPane.getSelectedPSIElements(); } }; myAutoScrollToSourceHandler = new AutoScrollToSourceHandler() { @Override protected boolean isAutoScrollMode() { return isAutoscrollToSource(myCurrentViewId); } @Override protected void setAutoScrollMode(boolean state) { setAutoscrollToSource(state, myCurrentViewId); } }; toolWindowManager.addToolWindowManagerListener(new ToolWindowManagerAdapter() { private boolean toolWindowVisible; @Override public void stateChanged() { ToolWindow window = toolWindowManager.getToolWindow(ToolWindowId.PROJECT_VIEW); if (window == null) return; if (window.isVisible() && !toolWindowVisible) { String id = getCurrentViewId(); if (isAutoscrollToSource(id)) { AbstractProjectViewPane currentProjectViewPane = getCurrentProjectViewPane(); if (currentProjectViewPane != null) { myAutoScrollToSourceHandler.onMouseClicked(currentProjectViewPane.getTree()); } } if (isAutoscrollFromSource(id)) { myAutoScrollFromSourceHandler.setAutoScrollEnabled(true); } } toolWindowVisible = window.isVisible(); } }); }