Java Code Examples for com.intellij.ui.AutoScrollToSourceHandler#install()

The following examples show how to use com.intellij.ui.AutoScrollToSourceHandler#install() . 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: 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 4
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);
}