Пример #1
0
 public void disposeUIResources() {
   myState.getProportions().saveSplitterProportions(myWholePanel);
   myAutoScrollHandler.cancelAllRequests();
   myDetails.disposeUIResources();
   myInitializedConfigurables.clear();
   clearChildren();
   final String key = getComponentStateKey();
   final MasterDetailsStateService stateService = getStateService();
   if (key != null && stateService != null) {
     stateService.setComponentState(key, getState());
   }
   myCurrentConfigurable = null;
 }
Пример #2
0
  private void installAutoScroll() {
    myAutoScrollHandler =
        new AutoScrollToSourceHandler() {
          protected boolean isAutoScrollMode() {
            return isAutoScrollEnabled();
          }

          protected void setAutoScrollMode(boolean state) {
            // do nothing
          }

          protected void scrollToSource(Component tree) {
            updateSelectionFromTree();
          }

          protected boolean needToCheckFocus() {
            return false;
          }
        };
    myAutoScrollHandler.install(myTree);
  }
  @NotNull
  private ActionToolbar createToolbar() {
    final DefaultActionGroup actionGroup = new DefaultActionGroup();
    actionGroup.add(new MyRefreshAction(myTree));
    if (isToShowAutoScrollButton()) {
      actionGroup.add(myAutoScrollToSourceHandler.createToggleAction());
    }
    if (isToShowCloseButton()) {
      actionGroup.add(new CloseAction());
    }
    if (isToShowPreviewButton()) {
      actionGroup.add(
          new ToggleAction(
              UsageViewBundle.message("preview.usages.action.text"),
              "preview",
              AllIcons.Actions.PreviewDetails) {
            @Override
            public boolean isSelected(AnActionEvent e) {
              return isPreview();
            }

            @Override
            public void setSelected(AnActionEvent e, boolean state) {
              setPreview(state);
              layoutPanel();
            }
          });
    }

    if (myBuilder.dataFlowToThis) {
      actionGroup.add(new GroupByLeavesAction(myBuilder));
      actionGroup.add(new CanItBeNullAction(myBuilder));
    }

    // actionGroup.add(new ContextHelpAction(HELP_ID));

    return ActionManager.getInstance()
        .createActionToolbar(ActionPlaces.TYPE_HIERARCHY_VIEW_TOOLBAR, actionGroup, false);
  }
  @NotNull
  private JTree createTree() {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode();
    final Tree tree = new Tree(new DefaultTreeModel(root)) /* {
      @Override
      protected void paintComponent(Graphics g) {
        DuplicateNodeRenderer.paintDuplicateNodesBackground(g, this);
        super.paintComponent(g);
      }
    }*/;
    tree.setOpaque(false);

    tree.setToggleClickCount(-1);
    SliceUsageCellRenderer renderer = new SliceUsageCellRenderer();
    renderer.setOpaque(false);
    tree.setCellRenderer(renderer);
    UIUtil.setLineStyleAngled(tree);
    tree.setRootVisible(false);

    tree.setShowsRootHandles(true);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setSelectionPath(new TreePath(root.getPath()));
    // ActionGroup group =
    // (ActionGroup)ActionManager.getInstance().getAction(IdeActions.GROUP_METHOD_HIERARCHY_POPUP);
    // PopupHandler.installPopupHandler(tree, group, ActionPlaces.METHOD_HIERARCHY_VIEW_POPUP,
    // ActionManager.getInstance());
    EditSourceOnDoubleClickHandler.install(tree);

    new TreeSpeedSearch(tree);
    TreeUtil.installActions(tree);
    ToolTipManager.sharedInstance().registerComponent(tree);

    myAutoScrollToSourceHandler.install(tree);

    tree.getSelectionModel()
        .addTreeSelectionListener(
            new TreeSelectionListener() {
              @Override
              public void valueChanged(final TreeSelectionEvent e) {
                treeSelectionChanged();
              }
            });

    tree.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (KeyEvent.VK_ENTER == e.getKeyCode()) {
              List<Navigatable> navigatables = getNavigatables();
              if (navigatables.isEmpty()) return;
              for (Navigatable navigatable : navigatables) {
                if (navigatable instanceof AbstractTreeNode
                    && ((AbstractTreeNode) navigatable).getValue() instanceof Usage) {
                  navigatable = (Usage) ((AbstractTreeNode) navigatable).getValue();
                }
                if (navigatable.canNavigateToSource()) {
                  navigatable.navigate(false);
                  if (navigatable instanceof Usage) {
                    ((Usage) navigatable).highlightInEditor();
                  }
                }
              }
              e.consume();
            }
          }
        });

    tree.addTreeWillExpandListener(
        new TreeWillExpandListener() {
          @Override
          public void treeWillCollapse(TreeExpansionEvent event) {}

          @Override
          public void treeWillExpand(TreeExpansionEvent event) {
            TreePath path = event.getPath();
            SliceNode node = fromPath(path);
            node.calculateDupNode();
          }
        });

    return tree;
  }
Пример #5
0
  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;
  }
Пример #6
0
 ToggleAction createToggleAutoscrollAction() {
   return myAutoScrollToSourceHandler.createToggleAction();
 }