com.intellij.ui.AutoScrollToSourceHandler Java Examples

The following examples show how to use com.intellij.ui.AutoScrollToSourceHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BlazeProblemsViewPanel.java    From intellij with Apache License 2.0 6 votes vote down vote up
BlazeProblemsViewPanel(Project project) {
  super(project, "reference.problems.tool.window", false, false, null);
  myTree.getEmptyText().setText("No problems found");
  configuration = ProblemsViewConfiguration.getInstance(project);
  autoScrollToConsoleHandler =
      new AutoScrollToSourceHandler() {
        @Override
        protected boolean isAutoScrollMode() {
          return configuration.getAutoscrollToConsole();
        }

        @Override
        protected void setAutoScrollMode(boolean state) {
          configuration.setAutoscrollToConsole(state);
        }

        @Override
        protected void scrollToSource(Component tree) {
          BlazeProblemsViewPanel.this.scrollToSource(tree);
        }
      };
  autoScrollToConsoleHandler.install(myTree);
  add(createToolbarPanel(), BorderLayout.WEST);
}
 
Example #2
Source File: CommonActionsManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #3
Source File: AnalysisUIOptions.java    From consulo with Apache License 2.0 5 votes vote down vote up
public AnalysisUIOptions() {
  myAutoScrollToSourceHandler = new AutoScrollToSourceHandler() {
    @Override
    protected boolean isAutoScrollMode() {
      return AUTOSCROLL_TO_SOURCE;
    }

    @Override
    protected void setAutoScrollMode(boolean state) {
      AUTOSCROLL_TO_SOURCE = state;
    }
  };

}
 
Example #4
Source File: HierarchyBrowserBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
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;
    }
  };
}
 
Example #5
Source File: PantsConsoleViewPanel.java    From intellij-pants-plugin with Apache License 2.0 4 votes vote down vote up
public PantsConsoleViewPanel(Project project, ConsoleView console) {
  myProject = project;
  myConfiguration = ErrorTreeViewConfiguration.getInstance(project);
  setLayout(new BorderLayout());

  AutoScrollToSourceHandler autoScrollToSourceHandler = 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);
  Tree tree = createTree(treeModel);
  tree.getEmptyText().setText(IdeBundle.message("errortree.noMessages"));

  autoScrollToSourceHandler.install(tree);
  TreeUtil.installActions(tree);

  tree.setRootVisible(false);
  tree.setShowsRootHandles(true);
  tree.setLargeModel(true);

  JScrollPane scrollPane = NewErrorTreeRenderer.install(tree);
  scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT));
  myMessagePanel.add(console.getComponent(), BorderLayout.CENTER);

  add(createToolbarPanel(), BorderLayout.WEST);

  add(myMessagePanel, BorderLayout.CENTER);

  EditSourceOnDoubleClickHandler.install(tree);
}
 
Example #6
Source File: NewErrorTreeViewPanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
public NewErrorTreeViewPanel(Project project, String helpId, boolean createExitAction, boolean createToolbar, @Nullable Runnable rerunAction) {
  myProject = project;
  myHelpId = helpId;
  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);
}
 
Example #7
Source File: AnalysisUIOptions.java    From consulo with Apache License 2.0 4 votes vote down vote up
public AutoScrollToSourceHandler getAutoScrollToSourceHandler() {
  return myAutoScrollToSourceHandler;
}
 
Example #8
Source File: FavoritesAutoScrollToSourceAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
public FavoritesAutoScrollToSourceAction(Project project,
                                         AutoScrollToSourceHandler autoScrollToSourceHandler,
                                         FavoritesViewTreeBuilder builder) {
  super(project, builder, UIBundle.message("autoscroll.to.source.action.name"), AllIcons.General.AutoscrollToSource);
  myAutoScrollToSourceHandler = autoScrollToSourceHandler;
}
 
Example #9
Source File: ProjectViewImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Inject
public ProjectViewImpl(@Nonnull Project project, FileEditorManager fileEditorManager, ToolWindowManager toolWindowManager, @Nonnull ProjectViewSharedSettings projectViewSharedSettings) {
  myProject = project;
  myProjectViewSharedSettings = projectViewSharedSettings;

  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);
    }
  };
  ((ToolWindowManagerEx)toolWindowManager).addToolWindowManagerListener(new ToolWindowManagerListener() {
    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();
    }
  });
}