com.intellij.openapi.ui.Splitter Java Examples

The following examples show how to use com.intellij.openapi.ui.Splitter. 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: TemplateListPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
public TemplateListPanel() {
  super(new BorderLayout());

  myDetailsPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
  JLabel label = new JLabel("No live template is selected");
  label.setHorizontalAlignment(SwingConstants.CENTER);
  myDetailsPanel.add(label, NO_SELECTION);
  createTemplateEditor(MOCK_TEMPLATE, "Tab", MOCK_TEMPLATE.createOptions(), MOCK_TEMPLATE.createContext());

  add(createExpandByPanel(), BorderLayout.NORTH);

  Splitter splitter = new Splitter(true, 0.9f);
  splitter.setFirstComponent(createTable());
  splitter.setSecondComponent(myDetailsPanel);
  add(splitter, BorderLayout.CENTER);
}
 
Example #2
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 #3
Source File: SdksConfigurable.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void reset() {
  super.reset();

  mySdksModel.reset();

  myRoot.removeAllChildren();
  final Map<Sdk, Sdk> sdks = mySdksModel.getModifiedSdksMap();
  for (Sdk sdk : sdks.keySet()) {
    final SdkConfigurable configurable = new SdkConfigurable((SdkImpl)sdks.get(sdk), mySdksModel, TREE_UPDATER, myHistory, myProject);
    addNode(new MyNode(configurable), myRoot);
  }

  final String value = PropertiesComponent.getInstance().getValue(SPLITTER_PROPORTION);
  if (value != null) {
    try {
      final Splitter splitter = extractSplitter();
      if (splitter != null) {
        (splitter).setProportion(Float.parseFloat(value));
      }
    }
    catch (NumberFormatException e) {
      //do not set proportion
    }
  }
}
 
Example #4
Source File: DesktopToolWindowPanelImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
  try {
    ToolWindowAnchor anchor = myInfo.getAnchor();
    JComponent c = getComponentAt(anchor);
    if (c instanceof Splitter) {
      Splitter splitter = (Splitter)c;
      final DesktopInternalDecorator component = myInfo.isSplit() ? (DesktopInternalDecorator)splitter.getFirstComponent() : (DesktopInternalDecorator)splitter.getSecondComponent();
      if (myInfo.isSplit() && component != null) {
        myId2SplitProportion.put(component.getWindowInfo().getId(), splitter.getProportion());
      }
      setComponent(component, anchor, component != null ? component.getWindowInfo().getWeight() : 0);
    }
    else {
      setComponent(null, anchor, 0);
    }
    if (!myDirtyMode) {
      myLayeredPane.validate();
      myLayeredPane.repaint();
    }
  }
  finally {
    finish();
  }
}
 
Example #5
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 #6
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 #7
Source File: ConsoleFoldingConfigurable.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public JComponent createComponent() {
  if (myMainComponent == null) {
    myMainComponent = new JPanel(new BorderLayout());
    Splitter splitter = new Splitter(true);
    myMainComponent.add(splitter);
    myPositivePanel =
      new MyAddDeleteListPanel("Fold console lines that contain", "Enter a substring of a console line you'd like to see folded:");
    myNegativePanel = new MyAddDeleteListPanel("Exceptions", "Enter a substring of a console line you don't want to fold:");
    splitter.setFirstComponent(myPositivePanel);
    splitter.setSecondComponent(myNegativePanel);

    myPositivePanel.getEmptyText().setText("Fold nothing");
    myNegativePanel.getEmptyText().setText("No exceptions");
  }
  return myMainComponent;
}
 
Example #8
Source File: SplitterProportionsDataImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private int restoreSplitterProportions(Component root, int index) {
  if (root instanceof Splitter) {
    if (proportions.size() <= index) return index;
    ((Splitter)root).setProportion(proportions.get(index++).floatValue());
  }
  if (root instanceof Container) {
    Component[] children = ((Container)root).getComponents();
    for (Component child : children) {
      index = restoreSplitterProportions(child, index);
    }
  }
  return index;
}
 
Example #9
Source File: SplitterProportionsDataImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void doSaveSplitterProportions(Component root) {
  if (root instanceof Splitter) {
    Float prop = ((Splitter)root).getProportion();
    proportions.add(prop);
  }
  if (root instanceof Container) {
    Component[] children = ((Container)root).getComponents();
    for (Component child : children) {
      doSaveSplitterProportions(child);
    }
  }
}
 
Example #10
Source File: DesktopEditorsSplitters.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static int getSplitCount(JComponent component) {
  if (component.getComponentCount() > 0) {
    final JComponent firstChild = (JComponent)component.getComponent(0);
    if (firstChild instanceof Splitter) {
      final Splitter splitter = (Splitter)firstChild;
      return getSplitCount(splitter.getFirstComponent()) + getSplitCount(splitter.getSecondComponent());
    }
    return 1;
  }
  return 0;
}
 
Example #11
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 #12
Source File: DesktopEditorWindow.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public DesktopEditorWindow[] findSiblings() {
  checkConsistency();
  final ArrayList<DesktopEditorWindow> res = new ArrayList<>();
  if (myPanel.getParent() instanceof Splitter) {
    final Splitter splitter = (Splitter)myPanel.getParent();
    for (final DesktopEditorWindow win : myOwner.getWindows()) {
      if (win != this && SwingUtilities.isDescendingFrom(win.myPanel, splitter)) {
        res.add(win);
      }
    }
  }
  return res.toArray(new DesktopEditorWindow[res.size()]);
}
 
Example #13
Source File: DesktopEditorWindow.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void changeOrientation() {
  checkConsistency();
  final Container parent = myPanel.getParent();
  if (parent instanceof Splitter) {
    final Splitter splitter = (Splitter)parent;
    splitter.setOrientation(!splitter.getOrientation());
  }
}
 
Example #14
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 #15
Source File: SdksConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void disposeUIResources() {
  final Splitter splitter = extractSplitter();
  if (splitter != null) {
    PropertiesComponent.getInstance().setValue(SPLITTER_PROPORTION, String.valueOf(splitter.getProportion()));
  }
  mySdksModel.disposeUIResources();
  super.disposeUIResources();
}
 
Example #16
Source File: SdksConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
private Splitter extractSplitter() {
  final Component[] components = myWholePanel.getComponents();
  if (components.length == 1 && components[0] instanceof Splitter) {
    return (Splitter)components[0];
  }
  return null;
}
 
Example #17
Source File: WiseSplitter.java    From consulo with Apache License 2.0 5 votes vote down vote up
public WiseSplitter(final Runnable refresher, final Splitter parentSplitter) {
  myRefresher = refresher;
  myParentSplitter = parentSplitter;

  myInnerSplitter = new ThreeComponentsSplitter(false);
  Disposer.register(this, myInnerSplitter);
  myInnerSplitter.setHonorComponentsMinimumSize(true);
  myInnerSplitterContents = new HashMap<CommittedChangesFilterKey, Integer>();
  updateBorders();
}
 
Example #18
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 #19
Source File: EditConfigurationsDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Nonnull
@Override
public Couple<JComponent> createSplitterComponents(JPanel rootPanel) {
  RunConfigurable configurable = getConfigurable();
  configurable.createComponent();
  configurable.setWholePanel(rootPanel);
  Splitter splitter = configurable.getSplitter();
  return Couple.of(splitter.getFirstComponent(), splitter.getSecondComponent());
}
 
Example #20
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 #21
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 #22
Source File: DataSourcesSettingsForm.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
private Splitter prepareSplitter(DataSourceListPanel dataSourceListPanel,
                                 JPanel dataSourcesConfigurationPanel) {
    Splitter splitter = new Splitter(false, 0.3f);
    splitter.setFirstComponent(dataSourceListPanel);
    splitter.setSecondComponent(dataSourcesConfigurationPanel);
    dataSourcesConfigurationPanel.setMinimumSize(new Dimension(300, 400));
    return splitter;
}
 
Example #23
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 #24
Source File: DesktopInternalDecorator.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Insets getBorderInsets(final Component c) {
  if (myProject == null) return new Insets(0, 0, 0, 0);
  ToolWindowManager toolWindowManager =  ToolWindowManager.getInstance(myProject);
  if (!(toolWindowManager instanceof ToolWindowManagerBase)
      || !((ToolWindowManagerBase)toolWindowManager).isToolWindowRegistered(myInfo.getId())
      || myWindow.getType() == ToolWindowType.FLOATING) {
    return new Insets(0, 0, 0, 0);
  }
  ToolWindowAnchor anchor = myWindow.getAnchor();
  Component component = myWindow.getComponent();
  Container parent = component.getParent();
  while(parent != null) {
    if (parent instanceof Splitter) {
      Splitter splitter = (Splitter)parent;
      boolean isFirst = splitter.getFirstComponent() == component;
      boolean isVertical = splitter.isVertical();
      return new Insets(0,
                        anchor == ToolWindowAnchor.RIGHT || (!isVertical && !isFirst) ? 1 : 0,
                        (isVertical && isFirst) ? 1 : 0,
                        anchor == ToolWindowAnchor.LEFT || (!isVertical && isFirst) ? 1 : 0);
    }
    component = parent;
    parent = component.getParent();
  }
  return new Insets(0, anchor == ToolWindowAnchor.RIGHT ? 1 : 0, anchor == ToolWindowAnchor.TOP ? 1 : 0, anchor == ToolWindowAnchor.LEFT ? 1 : 0);
}
 
Example #25
Source File: RestServicesNavigatorPanel.java    From NutzCodeInsight with Apache License 2.0 5 votes vote down vote up
public RestServicesNavigatorPanel(SimpleTree tree) {
    super(true, true);
    this.apiTree = tree;
    JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(this.apiTree);
    scrollPane.setBorder(BorderFactory.createLineBorder(Color.RED));
    servicesContentPaneSplitter = new Splitter(true, .5f);
    servicesContentPaneSplitter.setShowDividerControls(true);
    servicesContentPaneSplitter.setDividerWidth(10);
    servicesContentPaneSplitter.setBorder(BorderFactory.createLineBorder(Color.RED));
    servicesContentPaneSplitter.setFirstComponent(scrollPane);
    setContent(servicesContentPaneSplitter);
}
 
Example #26
Source File: DependencyViewer.java    From gradle-view with Apache License 2.0 4 votes vote down vote up
public DependencyViewer(Project p, ToolWindow t) {
    super(true, true);
    this.project = p;
    this.toolWindow = t;
    this.splitter = new Splitter(false, 0.75f);
    this.information = new JTextArea();
    this.toolingLogger = initToolingLogger();

    this.dependencyCellRenderer = new DependencyCellRenderer();
    this.dependencyCellRenderer.omittedSelected = JBColor.MAGENTA;
    this.dependencyCellRenderer.omittedUnselected = JBColor.GRAY;
    this.dependencyCellRenderer.normalSelected = JBColor.foreground();
    this.dependencyCellRenderer.normalUnselected = JBColor.BLACK;
    this.information.setEditable(false);

    this.shouldPromptForCurrentProject = true;

    // TODO clean all of this up
    GradleService gradleService = ServiceManager.getService(project, GradleService.class);
    gradleService.addListener(new ViewActionListener() {
        @Override
        public void refresh() {
            // prompt only on first use of tool panel
            if (shouldPromptForCurrentProject) {
                // ask to initialize view for this project to the current project
                if (useCurrentProjectBuild()) {
                    gradleBaseDir = project.getBasePath();
                }
                shouldPromptForCurrentProject = false;
            }

            // there's nothing to do when there is no gradleBaseDir set, instead issue a prompt
            if(gradleBaseDir == null) {
                promptForGradleBaseDir();
            }

            // initialize an empty view even if the gradleBaseDir is set while we load everything in the background
            updateView(null, null);

            new SwingWorker<GradleNode, Void>() {
                protected GradleNode doInBackground() throws Exception {
                    try {
                        Map<String, GradleNode> dependencyMap = loadProjectDependenciesFromModel(gradleBaseDir, toolingLogger);
                        GradleNode rootDependency = dependencyMap.get("root");

                        GradleNode target = dependencyCellRenderer.selectedGradleNode;
                        GradleNode selectedDependency;
                        if(target != null && target.group != null) {
                            selectedDependency = target;
                        } else {
                            selectedDependency = new GradleNode("No dependency selected");
                        }

                        updateView(rootDependency, selectedDependency);
                        return rootDependency;
                    } catch(Exception e) {
                        e.printStackTrace();
                        toolingLogger.log(ExceptionUtils.getFullStackTrace(e));
                        throw new RuntimeException(e);
                    }
                }
            }.execute();
        }

        @Override
        public void toggleShowReplaced() {
            dependencyCellRenderer.showReplaced = !dependencyCellRenderer.showReplaced;
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    splitter.repaint();
                    splitter.validate();
                }
            });
        }

        @Override
        public void reset() {
            gradleBaseDir = null;
            refresh();
        }
    });
    gradleService.refresh();

    setContent(splitter);
    final ActionManager actionManager = ActionManager.getInstance();
    ActionToolbar actionToolbar = actionManager.createActionToolbar("Gradle View Toolbar",
            (DefaultActionGroup)actionManager.getAction("GradleView.NavigatorActionsToolbar"), true);

    actionToolbar.setTargetComponent(splitter);
    setToolbar(actionToolbar.getComponent());
}
 
Example #27
Source File: RunConfigurable.java    From consulo with Apache License 2.0 4 votes vote down vote up
public Splitter getSplitter() {
  return mySplitter;
}
 
Example #28
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 #29
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 #30
Source File: DesktopToolWindowPanelImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
private Pair<Resizer, Component> findResizerAndComponent(@Nonnull ToolWindow wnd) {
  if (!wnd.isVisible()) return null;

  Resizer resizer = null;
  Component cmp = null;

  if (wnd.getType() == ToolWindowType.DOCKED) {
    cmp = getComponentAt(wnd.getAnchor());

    if (cmp != null) {
      if (wnd.getAnchor().isHorizontal()) {
        resizer = myVerticalSplitter.getFirstComponent() == cmp ? new Resizer.Splitter.FirstComponent(myVerticalSplitter) : new Resizer.Splitter.LastComponent(myVerticalSplitter);
      }
      else {
        resizer = myHorizontalSplitter.getFirstComponent() == cmp ? new Resizer.Splitter.FirstComponent(myHorizontalSplitter) : new Resizer.Splitter.LastComponent(myHorizontalSplitter);
      }
    }
  }
  else if (wnd.getType() == ToolWindowType.SLIDING) {
    cmp = wnd.getComponent();
    while (cmp != null) {
      if (cmp.getParent() == myLayeredPane) break;
      cmp = cmp.getParent();
    }

    if (cmp != null) {
      if (wnd.getAnchor() == ToolWindowAnchor.TOP) {
        resizer = new Resizer.LayeredPane.Top(cmp);
      }
      else if (wnd.getAnchor() == ToolWindowAnchor.BOTTOM) {
        resizer = new Resizer.LayeredPane.Bottom(cmp);
      }
      else if (wnd.getAnchor() == ToolWindowAnchor.LEFT) {
        resizer = new Resizer.LayeredPane.Left(cmp);
      }
      else if (wnd.getAnchor() == ToolWindowAnchor.RIGHT) {
        resizer = new Resizer.LayeredPane.Right(cmp);
      }
    }
  }

  return resizer != null ? Pair.create(resizer, cmp) : null;
}