Java Code Examples for com.intellij.openapi.ui.Splitter#getFirstComponent()
The following examples show how to use
com.intellij.openapi.ui.Splitter#getFirstComponent() .
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: DesktopToolWindowPanelImpl.java From consulo with Apache License 2.0 | 6 votes |
@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 2
Source File: DesktopEditorWindow.java From consulo with Apache License 2.0 | 5 votes |
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 3
Source File: DesktopInternalDecorator.java From consulo with Apache License 2.0 | 5 votes |
@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 4
Source File: GuiUtils.java From consulo with Apache License 2.0 | 4 votes |
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 5
Source File: DesktopToolWindowManagerImpl.java From consulo with Apache License 2.0 | 4 votes |
/** * Handles event from decorator and modify weight/floating bounds of the * tool window depending on decoration type. */ @Override public void resized(@Nonnull final ToolWindowInternalDecorator s) { DesktopInternalDecorator source = (DesktopInternalDecorator)s; if (!source.isShowing()) { return; // do not recalculate the tool window size if it is not yet shown (and, therefore, has 0,0,0,0 bounds) } final WindowInfoImpl info = getInfo(source.getToolWindow().getId()); if (info.isFloating()) { final Window owner = SwingUtilities.getWindowAncestor(source); if (owner != null) { info.setFloatingBounds(TargetAWT.from(owner.getBounds())); } } else if (info.isWindowed()) { DesktopWindowedDecorator decorator = getWindowedDecorator(info.getId()); Window frame = decorator != null ? decorator.getFrame() : null; if (frame == null || !frame.isShowing()) return; info.setFloatingBounds(getRootBounds((JFrame)frame)); } else { // docked and sliding windows ToolWindowAnchor anchor = info.getAnchor(); DesktopInternalDecorator another = null; if (source.getParent() instanceof Splitter) { float sizeInSplit = anchor.isSplitVertically() ? source.getHeight() : source.getWidth(); Splitter splitter = (Splitter)source.getParent(); if (splitter.getSecondComponent() == source) { sizeInSplit += splitter.getDividerWidth(); another = (DesktopInternalDecorator)splitter.getFirstComponent(); } else { another = (DesktopInternalDecorator)splitter.getSecondComponent(); } if (anchor.isSplitVertically()) { info.setSideWeight(sizeInSplit / (float)splitter.getHeight()); } else { info.setSideWeight(sizeInSplit / (float)splitter.getWidth()); } } float paneWeight = anchor.isHorizontal() ? (float)source.getHeight() / (float)getToolWindowPanel().getMyLayeredPane().getHeight() : (float)source.getWidth() / (float)getToolWindowPanel().getMyLayeredPane().getWidth(); info.setWeight(paneWeight); if (another != null && anchor.isSplitVertically()) { paneWeight = anchor.isHorizontal() ? (float)another.getHeight() / (float)getToolWindowPanel().getMyLayeredPane().getHeight() : (float)another.getWidth() / (float)getToolWindowPanel().getMyLayeredPane().getWidth(); another.getWindowInfo().setWeight(paneWeight); } } }