Пример #1
0
  private void buildGUI() {
    setLayout(new BorderLayout());

    _tree = new PsiViewerTree(_model);
    _tree.getSelectionModel().addTreeSelectionListener(_treeSelectionListener);

    ActionMap actionMap = _tree.getActionMap();
    actionMap.put(
        "EditSource",
        new AbstractAction("EditSource") {
          public void actionPerformed(ActionEvent e) {
            debug("key typed " + e);
            if (getSelectedElement() == null) return;
            Editor editor = _caretMover.openInEditor(getSelectedElement());
            selectElementAtCaret(editor, TREE_SELECTION_CHANGED);
            editor.getContentComponent().requestFocus();
          }
        });
    InputMap inputMap = _tree.getInputMap();
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0, true), "EditSource");

    _propertyPanel = new PropertySheetPanel();

    _splitPane =
        new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JBScrollPane(_tree), _propertyPanel) {
          public void setDividerLocation(int location) {
            debug(
                "Divider location changed to "
                    + location
                    + " component below "
                    + (getRightComponent().isVisible() ? "visible" : "not visible"));
            if (getRightComponent().isVisible())
              _projectComponent.setSplitDividerLocation(location);
            super.setDividerLocation(location);
          }
        };
    _splitPane.setDividerLocation(_projectComponent.getSplitDividerLocation());
    add(_splitPane);
  }
Пример #2
0
  private void resetTree() {
    _tree.getSelectionModel().removeTreeSelectionListener(_treeSelectionListener);

    Enumeration expandedDescendants = null;
    TreePath path = null;
    if (_model.getRoot() != null) {
      expandedDescendants = _tree.getExpandedDescendants(new TreePath(_model.getRoot()));
      path = _tree.getSelectionModel().getSelectionPath();
    }

    _model = new PsiViewerTreeModel(_projectComponent);
    _model.setRoot(getRootElement());
    _tree.setModel(_model);
    if (expandedDescendants != null)
      while (expandedDescendants.hasMoreElements()) {
        TreePath treePath = (TreePath) expandedDescendants.nextElement();
        _tree.expandPath(treePath);
      }
    _tree.setSelectionPath(path);
    _tree.scrollPathToVisible(path);

    _tree.getSelectionModel().addTreeSelectionListener(_treeSelectionListener);
  }
Пример #3
0
 private void changeTreeSelection() {
   TreePath path = getPath(getSelectedElement());
   _tree.expandPath(path);
   _tree.scrollPathToVisible(path);
   _tree.setSelectionPath(path);
 }