Java Code Examples for com.intellij.openapi.ui.Splitter#setSecondComponent()

The following examples show how to use com.intellij.openapi.ui.Splitter#setSecondComponent() . 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: ModulesDependenciesPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
public ModulesDependenciesPanel(final Project project, final Module[] modules) {
  super(new BorderLayout());
  myProject = project;
  myModules = modules;

  //noinspection HardCodedStringLiteral
  myRightTreeModel = new DefaultTreeModel(new DefaultMutableTreeNode("Root"));
  myRightTree = new Tree(myRightTreeModel);
  initTree(myRightTree, true);

  initLeftTree();

  mySplitter = new Splitter();
  mySplitter.setFirstComponent(new MyTreePanel(myLeftTree, myProject));
  mySplitter.setSecondComponent(new MyTreePanel(myRightTree, myProject));

  setSplitterProportion();
  add(mySplitter, BorderLayout.CENTER);
  add(createNorthPanel(), BorderLayout.NORTH);

  project.getMessageBus().connect(this).subscribe(ProjectTopics.PROJECT_ROOTS, this);
}
 
Example 2
Source File: DetailsPanel.java    From Crucible4IDEA with MIT License 6 votes vote down vote up
public DetailsPanel(@NotNull final Project project, @NotNull final Review review) {
  super(false);
  myProject = project;
  myReview = review;

  final Splitter splitter = new Splitter(false, 0.7f);
  final JPanel mainTable = createMainTable();
  splitter.setFirstComponent(mainTable);

  final JComponent repoBrowser = createRepositoryBrowserDetails();
  splitter.setSecondComponent(repoBrowser);

  setContent(splitter);

  myChangesBrowser.getDiffAction().registerCustomShortcutSet(CommonShortcuts.getDiff(), myCommitsTable);

  myCommentsPane.setVisible(PropertiesComponent.getInstance().getBoolean(GENERAL_COMMENTS_VISIBILITY_PROPERTY, false));
}
 
Example 3
Source File: CommittedChangesTreeBrowser.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void initSplitters() {
  final Splitter filterSplitter = new Splitter(false, 0.5f);

  filterSplitter.setSecondComponent(ScrollPaneFactory.createScrollPane(myChangesTree));
  myLeftPanel.add(filterSplitter, BorderLayout.CENTER);
  final Splitter mainSplitter = new Splitter(false, 0.7f);
  mainSplitter.setFirstComponent(myLeftPanel);
  mainSplitter.setSecondComponent(myDetailsView);

  add(mainSplitter, BorderLayout.CENTER);

  myInnerSplitter = new WiseSplitter(new Runnable() {
    public void run() {
      filterSplitter.doLayout();
      updateModel();
    }
  }, filterSplitter);
  Disposer.register(this, myInnerSplitter);

  mySplitterProportionsData.externalizeFromDimensionService("CommittedChanges.SplitterProportions");
  mySplitterProportionsData.restoreSplitterProportions(this);
}
 
Example 4
Source File: VcsSelectionHistoryDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
private JComponent createComments(final JComponent addComp) {
  JPanel panel = new JPanel(new BorderLayout(4, 4));
  panel.add(new JLabel("Commit Message:"), BorderLayout.NORTH);
  panel.add(ScrollPaneFactory.createScrollPane(myComments), BorderLayout.CENTER);

  final Splitter splitter = new Splitter(false);
  splitter.setFirstComponent(panel);
  splitter.setSecondComponent(addComp);
  return splitter;
}
 
Example 5
Source File: CallerChooserBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
private JComponent createCallSitesViewer() {
  Splitter splitter = new Splitter(true);
  myCallerEditor = createEditor();
  myCalleeEditor = createEditor();
  final JComponent callerComponent = myCallerEditor.getComponent();
  callerComponent.setBorder(IdeBorderFactory.createTitledBorder(RefactoringBundle.message("caller.chooser.caller.method"),
                                                                false));
  splitter.setFirstComponent(callerComponent);
  final JComponent calleeComponent = myCalleeEditor.getComponent();
  calleeComponent.setBorder(IdeBorderFactory.createTitledBorder(RefactoringBundle.message("caller.chooser.callee.method"),
                                                                false));
  splitter.setSecondComponent(calleeComponent);
  splitter.setBorder(IdeBorderFactory.createRoundedBorder());
  return splitter;
}
 
Example 6
Source File: IgnoreSettingsPanel.java    From idea-gitignore with MIT License 5 votes vote down vote up
/** Create UI components. */
private void createUIComponents() {
    templatesListPanel = new TemplatesListPanel();
    editorPanel = new EditorPanel();
    editorPanel.setPreferredSize(new Dimension(Integer.MAX_VALUE, 200));

    templatesSplitter = new Splitter(false, 0.3f);
    templatesSplitter.setFirstComponent(templatesListPanel);
    templatesSplitter.setSecondComponent(editorPanel);

    languagesTable = new JBTable();
    languagesTable.setModel(new LanguagesTableModel());
    languagesTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    languagesTable.setColumnSelectionAllowed(false);
    languagesTable.setRowHeight(22);
    languagesTable.getColumnModel().getColumn(2).setCellRenderer(new BooleanTableCellRenderer() {
        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSel, boolean hasFocus,
                                                       int row, int column) {
            boolean editable = table.isCellEditable(row, column);
            Object newValue = editable ? value : null;
            return super.getTableCellRendererComponent(table, newValue, isSel, hasFocus, row, column);
        }
    });
    languagesTable.setPreferredScrollableViewportSize(
            new Dimension(-1, languagesTable.getRowHeight() * IgnoreBundle.LANGUAGES.size() / 2)
    );

    languagesTable.setStriped(true);
    languagesTable.setShowGrid(false);
    languagesTable.setBorder(JBUI.Borders.empty());
    languagesTable.setDragEnabled(false);

    languagesPanel = ScrollPaneFactory.createScrollPane(languagesTable);
}
 
Example 7
Source File: PreviewPanel.java    From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void createGUI() {
	this.setLayout(new BorderLayout());

	// Had to set min size / preferred size in InputPanel.form to get slider to allow left shift of divider
	Splitter splitPane = new Splitter();
	inputPanel = getEditorPanel();
	splitPane.setFirstComponent(inputPanel.getComponent());
	splitPane.setSecondComponent(createParseTreeAndProfileTabbedPanel());

	this.add(splitPane, BorderLayout.CENTER);
	this.buttonBar = createButtonBar();
	this.add(buttonBar.getComponent(), BorderLayout.WEST);
}
 
Example 8
Source File: DesktopEditorWindow.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void removeFromSplitter() {
  if (!inSplitter()) return;

  if (myOwner.getCurrentWindow() == this) {
    DesktopEditorWindow[] siblings = findSiblings();
    myOwner.setCurrentWindow(siblings[0], false);
  }

  Splitter splitter = (Splitter)myPanel.getParent();
  JComponent otherComponent = splitter.getOtherComponent(myPanel);

  Container parent = splitter.getParent().getParent();
  if (parent instanceof Splitter) {
    Splitter parentSplitter = (Splitter)parent;
    if (parentSplitter.getFirstComponent() == splitter.getParent()) {
      parentSplitter.setFirstComponent(otherComponent);
    }
    else {
      parentSplitter.setSecondComponent(otherComponent);
    }
  }
  else if (AWTComponentProviderUtil.getMark(parent) instanceof EditorsSplitters) {
    parent.removeAll();
    parent.add(otherComponent, BorderLayout.CENTER);
    parent.revalidate();
  }
  else {
    throw new IllegalStateException("Unknown container: " + parent);
  }

  dispose();
}
 
Example 9
Source File: QuickListsPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public QuickListsPanel() {
  super(new BorderLayout());
  myKeymapListener = ApplicationManager.getApplication().getMessageBus().syncPublisher(KeymapListener.CHANGE_TOPIC);
  Splitter splitter = new OnePixelSplitter(false, 0.3f);
  splitter.setFirstComponent(createQuickListsPanel());
  splitter.setSecondComponent(myRightPanel);
  add(splitter, BorderLayout.CENTER);
}
 
Example 10
Source File: GuiUtils.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static void replaceJSplitPaneWithIDEASplitter(JComponent root) {
    final Container parent = root.getParent();
    if (root instanceof JSplitPane) {
      // we can painlessly replace only splitter which is the only child in container
      if (parent.getComponents().length != 1 && !(parent instanceof Splitter)) {
        return;
      }
      final JSplitPane pane = (JSplitPane)root;
      final Component component1 = pane.getTopComponent();
      final Component component2 = pane.getBottomComponent();
      final int orientation = pane.getOrientation();
      final Splitter splitter = new JBSplitter(orientation == JSplitPane.VERTICAL_SPLIT);
      splitter.setFirstComponent((JComponent) component1);
      splitter.setSecondComponent((JComponent) component2);
      splitter.setShowDividerControls(pane.isOneTouchExpandable());
      splitter.setHonorComponentsMinimumSize(true);

      if (pane.getDividerLocation() > 0) {
// let the component chance to resize itself
        SwingUtilities.invokeLater(() -> {
          double proportion;
          if (pane.getOrientation() == JSplitPane.VERTICAL_SPLIT) {
            proportion = pane.getDividerLocation() / (double)(parent.getHeight() - pane.getDividerSize());
          }
          else {
            proportion = pane.getDividerLocation() / (double)(parent.getWidth() - pane.getDividerSize());
          }
          if (proportion > 0 && proportion < 1) {
            splitter.setProportion((float)proportion);
          }
        });
      }

      if (parent instanceof Splitter) {
        final Splitter psplitter = (Splitter) parent;
        if (psplitter.getFirstComponent() == root)
          psplitter.setFirstComponent(splitter);
        else
          psplitter.setSecondComponent(splitter);
      }
      else {
        parent.remove(0);
        parent.setLayout(new BorderLayout());
        parent.add(splitter, BorderLayout.CENTER);
      }
      replaceJSplitPaneWithIDEASplitter((JComponent) component1);
      replaceJSplitPaneWithIDEASplitter((JComponent) component2);
    }
    else {
      final Component[] components = root.getComponents();
      for (Component component : components) {
        if (component instanceof JComponent) {
          replaceJSplitPaneWithIDEASplitter((JComponent)component);
        }
      }
    }
  }
 
Example 11
Source File: SingleInspectionProfilePanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
private JPanel createInspectionProfileSettingsPanel() {

    myBrowser = new JEditorPane(UIUtil.HTML_MIME, EMPTY_HTML);
    myBrowser.setEditable(false);
    myBrowser.setBorder(IdeBorderFactory.createEmptyBorder(5, 5, 5, 5));
    myBrowser.addHyperlinkListener(BrowserHyperlinkListener.INSTANCE);

    initToolStates();
    fillTreeData(myProfileFilter != null ? myProfileFilter.getFilter() : null, true);

    JPanel descriptionPanel = new JPanel(new BorderLayout());
    descriptionPanel.setBorder(IdeBorderFactory.createTitledBorder(InspectionsBundle.message("inspection.description.title"), false,
                                                                   new Insets(2, 0, 0, 0)));
    descriptionPanel.add(ScrollPaneFactory.createScrollPane(myBrowser), BorderLayout.CENTER);

    myRightSplitter = new Splitter(true);
    myRightSplitter.setFirstComponent(descriptionPanel);
    myRightSplitter.setProportion(myProperties.getFloat(HORIZONTAL_DIVIDER_PROPORTION, 0.5f));

    myOptionsPanel = new JPanel(new GridBagLayout());
    initOptionsAndDescriptionPanel();
    myRightSplitter.setSecondComponent(myOptionsPanel);
    myRightSplitter.setHonorComponentsMinimumSize(true);

    final JScrollPane tree = initTreeScrollPane();

    final JPanel northPanel = new JPanel(new GridBagLayout());
    northPanel.setBorder(IdeBorderFactory.createEmptyBorder(2, 0, 2, 0));
    myProfileFilter.setPreferredSize(new Dimension(20, myProfileFilter.getPreferredSize().height));
    northPanel.add(myProfileFilter, new GridBagConstraints(0, 0, 1, 1, 0.5, 1, GridBagConstraints.BASELINE_TRAILING, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    northPanel.add(createTreeToolbarPanel().getComponent(), new GridBagConstraints(1, 0, 1, 1, 1, 1, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    myMainSplitter = new Splitter(false, myProperties.getFloat(VERTICAL_DIVIDER_PROPORTION, 0.5f), 0.01f, 0.99f);
    myMainSplitter.setFirstComponent(tree);
    myMainSplitter.setSecondComponent(myRightSplitter);
    myMainSplitter.setHonorComponentsMinimumSize(false);

    final JPanel panel = new JPanel(new BorderLayout());
    panel.add(northPanel, BorderLayout.NORTH);
    panel.add(myMainSplitter, BorderLayout.CENTER);
    return panel;
  }
 
Example 12
Source File: ChangeListViewerDialog.java    From consulo with Apache License 2.0 4 votes vote down vote up
public JComponent createCenterPanel() {
  final JPanel mainPanel = new JPanel();
  mainPanel.setLayout(new BorderLayout());
  final Splitter splitter = new Splitter(true, 0.8f);
  myChangesBrowser = new RepositoryChangesBrowser(myProject, Collections.singletonList(myChangeList),
                                                  new ArrayList<Change>(myChangeList.getChanges()),
                                                  myChangeList, myToSelect) {

    @Override
    protected void buildToolBar(DefaultActionGroup toolBarGroup) {
      super.buildToolBar(toolBarGroup);
      toolBarGroup.add(ActionManager.getInstance().getAction("Vcs.CopyRevisionNumberAction"));
    }

    @Override
    public Object getData(@Nonnull @NonNls Key dataId) {
      Object data = super.getData(dataId);
      if (data != null) {
        return data;
      }
      return ChangeListViewerDialog.this.getData(dataId);
    }

    @Override
    protected void showDiffForChanges(final Change[] changesArray, final int indexInSelection) {
      if (myInAir && (myConvertor != null)) {
        final Change[] convertedChanges = new Change[changesArray.length];
        for (int i = 0; i < changesArray.length; i++) {
          Change change = changesArray[i];
          convertedChanges[i] = myConvertor.fun(change);
        }
        super.showDiffForChanges(convertedChanges, indexInSelection);
      } else {
        super.showDiffForChanges(changesArray, indexInSelection);
      }
    }
  };
  myChangesBrowser.setUseCase(myInAir ? CommittedChangesBrowserUseCase.IN_AIR : null);
  splitter.setFirstComponent(myChangesBrowser);

  if (myCommitMessageArea != null) {
    JPanel commitPanel = new JPanel(new BorderLayout());
    JComponent separator = SeparatorFactory.createSeparator(VcsBundle.message("label.commit.comment"), myCommitMessageArea);
    commitPanel.add(separator, BorderLayout.NORTH);
    commitPanel.add(commitMessageScroll, BorderLayout.CENTER);

    splitter.setSecondComponent(commitPanel);
  }
  mainPanel.add(splitter, BorderLayout.CENTER);

  final String description = getDescription();
  if (description != null) {
    JPanel descPanel = new JPanel();
    descPanel.add(new JLabel(XmlStringUtil.wrapInHtml(description)));
    descPanel.setBorder(BorderFactory.createEtchedBorder());
    mainPanel.add(descPanel, BorderLayout.NORTH);
  }
  return mainPanel;
}
 
Example 13
Source File: TodoPanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected JComponent createCenterComponent() {
  Splitter splitter = new OnePixelSplitter(false);
  splitter.setSecondComponent(myUsagePreviewPanel);
  splitter.setFirstComponent(ScrollPaneFactory.createScrollPane(myTree));
  return splitter;
}
 
Example 14
Source File: BaseItemSelectPanel.java    From EasyCode with MIT License 4 votes vote down vote up
/**
 * 获取面板
 */
public JComponent getComponent() {
    // 创建主面板
    JPanel mainPanel = new JPanel(new BorderLayout());
    // 左边的选择列表
    this.leftPanel = new JPanel(new BorderLayout());

    // 头部操作按钮
    JPanel headToolbar = new JPanel(new FlowLayout(FlowLayout.LEFT));

    // 添加事件按钮
    DefaultActionGroup actionGroup = createActionGroup();

    ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar("Item Toolbar", actionGroup, true);

    headToolbar.add(actionToolbar.getComponent());
    // 添加边框
    actionToolbar.getComponent().setBorder(new CustomLineBorder(1, 1, 1, 1));

    // 工具栏添加至左边面板的北边(上面)
    leftPanel.add(actionToolbar.getComponent(), BorderLayout.NORTH);

    // 元素列表
    listPanel = new JBList<>(dataConvert());
    // 只能单选
    listPanel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    // 添加元素选中事件
    listPanel.addListSelectionListener(e -> {
        T item = getSelectedItem();
        if (item == null) {
            return;
        }
        selectedItem(item);
    });
    // 添加边框
    listPanel.setBorder(new CustomLineBorder(0, 1, 1, 1));

    // 将列表添加至左边面板的中间
    leftPanel.add(listPanel, BorderLayout.CENTER);

    // 右边面板
    this.rightPanel = new JPanel(new BorderLayout());

    // 左右分割面板并添加至主面板
    Splitter splitter = new Splitter(false, 0.2F);

    splitter.setFirstComponent(leftPanel);
    splitter.setSecondComponent(rightPanel);

    mainPanel.add(splitter, BorderLayout.CENTER);

    mainPanel.setPreferredSize(JBUI.size(400, 300));

    // 存在元素时,默认选中第一个元素
    if (!itemList.isEmpty()) {
        listPanel.setSelectedIndex(0);
    }

    return mainPanel;
}
 
Example 15
Source File: ServersToolWindowContent.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ServersToolWindowContent(@Nonnull Project project) {
  super(new BorderLayout());
  myProject = project;

  myTreeModel = new DefaultTreeModel(new DefaultMutableTreeNode());
  myTree = new Tree(myTreeModel);
  myTree.setRootVisible(false);

  myTree.setShowsRootHandles(true);
  myTree.setCellRenderer(new NodeRenderer());
  myTree.setLineStyleAngled();

  getMainPanel().add(createToolbar(), BorderLayout.WEST);
  Splitter splitter = new OnePixelSplitter(false, 0.3f);
  splitter.setFirstComponent(ScrollPaneFactory.createScrollPane(myTree, SideBorder.LEFT));
  myPropertiesPanelLayout = new CardLayout();
  myPropertiesPanel = new JPanel(myPropertiesPanelLayout);
  myMessageLabel = new JLabel(EMPTY_SELECTION_MESSAGE, SwingConstants.CENTER);
  myPropertiesPanel.add(MESSAGE_CARD, new Wrapper(myMessageLabel));
  splitter.setSecondComponent(myPropertiesPanel);
  getMainPanel().add(splitter, BorderLayout.CENTER);

  setupBuilder(project);

  for (RemoteServersViewContributor contributor : RemoteServersViewContributor.EP_NAME.getExtensionList()) {
    contributor.setupTree(myProject, myTree, myBuilder);
  }

  myTree.addTreeSelectionListener(new TreeSelectionListener() {
    @Override
    public void valueChanged(TreeSelectionEvent e) {
      onSelectionChanged();
    }
  });
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent event) {
      Set<ServersTreeStructure.RemoteServerNode> nodes = getSelectedRemoteServerNodes();
      if (nodes.size() == 1) {
        RemoteServer<?> server = nodes.iterator().next().getValue();
        ServerConnectionManager.getInstance().getOrCreateConnection(server).computeDeployments(EmptyRunnable.INSTANCE);
        return true;
      }
      return false;
    }
  }.installOn(myTree);
}
 
Example 16
Source File: DesktopToolWindowPanelImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void run() {
  try {
    final ToolWindowAnchor anchor = myInfo.getAnchor();
    class MySplitter extends Splitter implements UISettingsListener {
      @Override
      public void uiSettingsChanged(UISettings uiSettings) {
        if (anchor == ToolWindowAnchor.LEFT) {
          setOrientation(!uiSettings.getLeftHorizontalSplit());
        }
        else if (anchor == ToolWindowAnchor.RIGHT) {
          setOrientation(!uiSettings.getRightHorizontalSplit());
        }
      }
    }
    Splitter splitter = new MySplitter();
    splitter.setOrientation(anchor.isSplitVertically());
    if (!anchor.isHorizontal()) {
      splitter.setAllowSwitchOrientationByMouseClick(true);
      splitter.addPropertyChangeListener(evt -> {
        if (!Splitter.PROP_ORIENTATION.equals(evt.getPropertyName())) return;
        boolean isSplitterHorizontalNow = !splitter.isVertical();
        UISettings settings = UISettings.getInstance();
        if (anchor == ToolWindowAnchor.LEFT) {
          if (settings.getLeftHorizontalSplit() != isSplitterHorizontalNow) {
            settings.setLeftHorizontalSplit(isSplitterHorizontalNow);
            settings.fireUISettingsChanged();
          }
        }
        if (anchor == ToolWindowAnchor.RIGHT) {
          if (settings.getRightHorizontalSplit() != isSplitterHorizontalNow) {
            settings.setRightHorizontalSplit(isSplitterHorizontalNow);
            settings.fireUISettingsChanged();
          }
        }
      });
    }
    JComponent c = getComponentAt(anchor);
    float newWeight;
    if (c instanceof DesktopInternalDecorator) {
      DesktopInternalDecorator oldComponent = (DesktopInternalDecorator)c;
      if (myInfo.isSplit()) {
        splitter.setFirstComponent(oldComponent);
        splitter.setSecondComponent(myNewComponent);
        float proportion = getPreferredSplitProportion(oldComponent.getWindowInfo().getId(), WindowInfoImpl
                .normalizeWeigh(oldComponent.getWindowInfo().getSideWeight() / (oldComponent.getWindowInfo().getSideWeight() + myInfo.getSideWeight())));
        splitter.setProportion(proportion);
        if (!anchor.isHorizontal() && !anchor.isSplitVertically()) {
          newWeight = WindowInfoImpl.normalizeWeigh(oldComponent.getWindowInfo().getWeight() + myInfo.getWeight());
        }
        else {
          newWeight = WindowInfoImpl.normalizeWeigh(oldComponent.getWindowInfo().getWeight());
        }
      }
      else {
        splitter.setFirstComponent(myNewComponent);
        splitter.setSecondComponent(oldComponent);
        splitter.setProportion(WindowInfoImpl.normalizeWeigh(myInfo.getSideWeight()));
        if (!anchor.isHorizontal() && !anchor.isSplitVertically()) {
          newWeight = WindowInfoImpl.normalizeWeigh(oldComponent.getWindowInfo().getWeight() + myInfo.getWeight());
        }
        else {
          newWeight = WindowInfoImpl.normalizeWeigh(myInfo.getWeight());
        }
      }
    }
    else {
      newWeight = WindowInfoImpl.normalizeWeigh(myInfo.getWeight());
    }
    setComponent(splitter, anchor, newWeight);

    if (!myDirtyMode) {
      myLayeredPane.validate();
      myLayeredPane.repaint();
    }
  }
  finally {
    finish();
  }
}
 
Example 17
Source File: FlutterLogView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void setupLogTreeScrollPane() {
  final JScrollPane treePane = ScrollPaneFactory.createScrollPane(
    logTree,
    ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  treePane.getVerticalScrollBar().getModel().addChangeListener(new LogVerticalScrollChangeListener() {
    @Override
    protected void onScrollUp() {
      scrollToEndAction.disableIfNeeded();
    }

    @Override
    protected void onScrollToEnd() {
      scrollToEndAction.enableIfNeeded();
    }
  });
  logModel.setScrollPane(treePane);

  dataPane = ScrollPaneFactory.createScrollPane(
    dataPanel,
    ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

  treeSplitter = new Splitter(false);
  treeSplitter.setProportion(DATA_PANEL_SPLITTER_PROPORTION_DEFAULT);
  // Data and splitter revealed on demand.
  dataPane.setVisible(false);
  treeSplitter.setVisible(false);

  treeSplitter.setFirstComponent(treePane);
  treeSplitter.setSecondComponent(dataPane);
  toolWindowPanel.setContent(treeSplitter);

  dataPanel.onUpdate(hasContent -> {
    dataPane.setVisible(hasContent);

    if (hasContent) {
      if (treeSplitter.getProportion() != lastSplitProportion) {
        treeSplitter.setProportion(lastSplitProportion);
        treeSplitter.revalidate();
        treeSplitter.repaint();
      }
    }
    else {
      final float proportion = treeSplitter.getProportion();
      if (proportion != 1.0f) {
        lastSplitProportion = proportion;
      }
      treeSplitter.setProportion(1.0f);
    }
  });
}
 
Example 18
Source File: PreviewView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void updateOutline(@NotNull FlutterOutline outline) {
  currentOutline = outline;

  final DefaultMutableTreeNode rootNode = getRootNode();
  rootNode.removeAllChildren();

  outlinesWithWidgets.clear();
  outlineToNodeMap.clear();
  if (outline.getChildren() != null) {
    computeOutlinesWithWidgets(outline);
    updateOutlineImpl(rootNode, outline.getChildren());
  }

  getTreeModel().reload(rootNode);
  tree.expandAll();

  if (currentEditor != null) {
    final Caret caret = currentEditor.getCaretModel().getPrimaryCaret();
    applyEditorSelectionToTree(caret);
  }

  if (FlutterSettings.getInstance().isEnableHotUi() && propertyEditPanel == null) {
    propertyEditSplitter = new Splitter(false, 0.75f);
    propertyEditPanel = new PropertyEditorPanel(inspectorGroupManagerService, project, flutterAnalysisServer, false, false, project);
    propertyEditPanel.initalize(null, activeOutlines, currentFile);
    propertyEditToolbarGroup = new DefaultActionGroup();
    final ActionToolbar windowToolbar = ActionManager.getInstance().createActionToolbar("PropertyArea", propertyEditToolbarGroup, true);

    final SimpleToolWindowPanel window = new SimpleToolWindowPanel(true, true);
    window.setToolbar(windowToolbar.getComponent());
    final JScrollPane propertyScrollPane = ScrollPaneFactory.createScrollPane(propertyEditPanel);
    window.setContent(propertyScrollPane);
    propertyEditSplitter.setFirstComponent(window.getComponent());
    final InspectorGroupManagerService.Client inspectorStateServiceClient = new InspectorGroupManagerService.Client(project) {
      @Override
      public void onInspectorAvailabilityChanged() {
        super.onInspectorAvailabilityChanged();
        // Only show the screen mirror if there is a running device and
        // the inspector supports the neccessary apis.
        if (getInspectorService() != null && getInspectorService().isHotUiScreenMirrorSupported()) {
          // Wait to create the preview area until it is needed.
          if (previewArea == null) {
            previewArea = new PreviewArea(project, outlinesWithWidgets, project);
          }
          propertyEditSplitter.setSecondComponent(previewArea.getComponent());
        }
        else {
          propertyEditSplitter.setSecondComponent(null);
        }
      }
    };
    inspectorGroupManagerService.addListener(inspectorStateServiceClient, project);

    splitter.setSecondComponent(propertyEditSplitter);
  }

  // TODO(jacobr): this is the wrong spot.
  if (propertyEditToolbarGroup != null) {
    final TitleAction propertyTitleAction = new TitleAction("Properties");
    propertyEditToolbarGroup.removeAll();
    propertyEditToolbarGroup.add(propertyTitleAction);
  }
}
 
Example 19
Source File: FlutterLogView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void setupLogTreeScrollPane() {
  final JScrollPane treePane = ScrollPaneFactory.createScrollPane(
    logTree,
    ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  treePane.getVerticalScrollBar().getModel().addChangeListener(new LogVerticalScrollChangeListener() {
    @Override
    protected void onScrollUp() {
      scrollToEndAction.disableIfNeeded();
    }

    @Override
    protected void onScrollToEnd() {
      scrollToEndAction.enableIfNeeded();
    }
  });
  logModel.setScrollPane(treePane);

  dataPane = ScrollPaneFactory.createScrollPane(
    dataPanel,
    ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

  treeSplitter = new Splitter(false);
  treeSplitter.setProportion(DATA_PANEL_SPLITTER_PROPORTION_DEFAULT);
  // Data and splitter revealed on demand.
  dataPane.setVisible(false);
  treeSplitter.setVisible(false);

  treeSplitter.setFirstComponent(treePane);
  treeSplitter.setSecondComponent(dataPane);
  toolWindowPanel.setContent(treeSplitter);

  dataPanel.onUpdate(hasContent -> {
    dataPane.setVisible(hasContent);

    if (hasContent) {
      if (treeSplitter.getProportion() != lastSplitProportion) {
        treeSplitter.setProportion(lastSplitProportion);
        treeSplitter.revalidate();
        treeSplitter.repaint();
      }
    }
    else {
      final float proportion = treeSplitter.getProportion();
      if (proportion != 1.0f) {
        lastSplitProportion = proportion;
      }
      treeSplitter.setProportion(1.0f);
    }
  });
}
 
Example 20
Source File: FocusDebugger.java    From consulo with Apache License 2.0 3 votes vote down vote up
private JComponent init() {
  final JPanel result = new JPanel(new BorderLayout());

  myLogModel = new DefaultListModel();
  myLog = new JBList(myLogModel);
  myLog.setCellRenderer(new FocusElementRenderer());


  myAllocation = new JEditorPane();
  final DefaultCaret caret = new DefaultCaret();
  myAllocation.setCaret(caret);
  caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
  myAllocation.setEditable(false);


  final Splitter splitter = new Splitter(true);
  splitter.setFirstComponent(ScrollPaneFactory.createScrollPane(myLog));
  splitter.setSecondComponent(ScrollPaneFactory.createScrollPane(myAllocation));

  myLog.addListSelectionListener(this);

  KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener(this);

  result.add(splitter, BorderLayout.CENTER);


  final DefaultActionGroup group = new DefaultActionGroup();
  group.add(new ClearAction());

  result.add(ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true).getComponent(), BorderLayout.NORTH);

  return result;
}