private void setupCentralPanel() {
    myCentralPanel.removeAll();
    if (myUsagePreviewPanel != null) {
      Disposer.dispose(myUsagePreviewPanel);
      myUsagePreviewPanel = null;
    }
    JScrollPane pane = ScrollPaneFactory.createScrollPane(myTree);

    if (UsageViewSettings.getInstance().IS_PREVIEW_USAGES) {
      Splitter splitter =
          new Splitter(false, UsageViewSettings.getInstance().PREVIEW_USAGES_SPLITTER_PROPORTIONS);
      pane.putClientProperty(UIUtil.KEEP_BORDER_SIDES, SideBorder.RIGHT);

      splitter.setFirstComponent(pane);
      myUsagePreviewPanel = new UsagePreviewPanel(myProject);
      myUsagePreviewPanel.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT));
      Disposer.register(this, myUsagePreviewPanel);
      splitter.setSecondComponent(myUsagePreviewPanel);
      myCentralPanel.add(splitter, BorderLayout.CENTER);
    } else {
      myCentralPanel.add(pane, BorderLayout.CENTER);
    }
    myCentralPanel.add(myButtonPanel, BorderLayout.SOUTH);

    myRootPanel.revalidate();
  }
 @SuppressWarnings({"HardCodedStringLiteral"})
 private Element writePanel(final JPanel panel) {
   final Component comp = panel.getComponent(0);
   if (comp instanceof Splitter) {
     final Splitter splitter = (Splitter) comp;
     final Element res = new Element("splitter");
     res.setAttribute("split-orientation", splitter.getOrientation() ? "vertical" : "horizontal");
     res.setAttribute("split-proportion", Float.toString(splitter.getProportion()));
     final Element first = new Element("split-first");
     first.addContent(writePanel((JPanel) splitter.getFirstComponent()));
     final Element second = new Element("split-second");
     second.addContent(writePanel((JPanel) splitter.getSecondComponent()));
     res.addContent(first);
     res.addContent(second);
     return res;
   } else if (comp instanceof JBTabs) {
     final Element res = new Element("leaf");
     final EditorWindow window = findWindowWith(comp);
     writeWindow(res, window);
     return res;
   } else if (comp instanceof EditorWindow.TCompForTablessMode) {
     final EditorWithProviderComposite composite =
         ((EditorWindow.TCompForTablessMode) comp).myEditor;
     final Element res = new Element("leaf");
     writeComposite(res, composite.getFile(), composite, false, composite);
     return res;
   } else {
     LOG.error(comp != null ? comp.getClass().getName() : null);
     return null;
   }
 }
 @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 ToolWindowManagerImpl)
       || !((ToolWindowManagerImpl) 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);
 }
  public GridImpl(ViewContextEx viewContext, String sessionName) {
    myViewContext = viewContext;
    mySessionName = sessionName;

    Disposer.register(myViewContext, this);
    Disposer.register(this, myTopSplit);

    Placeholder left = new Placeholder();
    myPlaceInGrid2Cell.put(
        PlaceInGrid.left, new GridCellImpl(myViewContext, this, left, PlaceInGrid.left));
    Placeholder center = new Placeholder();
    myPlaceInGrid2Cell.put(
        PlaceInGrid.center, new GridCellImpl(myViewContext, this, center, PlaceInGrid.center));
    Placeholder right = new Placeholder();
    myPlaceInGrid2Cell.put(
        PlaceInGrid.right, new GridCellImpl(myViewContext, this, right, PlaceInGrid.right));
    Placeholder bottom = new Placeholder();
    myPlaceInGrid2Cell.put(
        PlaceInGrid.bottom, new GridCellImpl(myViewContext, this, bottom, PlaceInGrid.bottom));

    setContent(mySplitter);
    setOpaque(false);
    setFocusCycleRoot(true);

    myTopSplit.setFirstComponent(left);
    myTopSplit.setInnerComponent(center);
    myTopSplit.setLastComponent(right);
    myTopSplit.setMinSize(48);
    mySplitter.setFirstComponent(myTopSplit);
    mySplitter.setSecondComponent(bottom);
  }
  private JPanel readSplitter(
      JPanel panel, Element splitterElement, Ref<EditorWindow> currentWindow) {
    final boolean orientation =
        "vertical".equals(splitterElement.getAttributeValue("split-orientation"));
    final float proportion =
        Float.valueOf(splitterElement.getAttributeValue("split-proportion")).floatValue();
    final Element first = splitterElement.getChild("split-first");
    final Element second = splitterElement.getChild("split-second");

    Splitter splitter;
    if (panel == null) {
      panel = new JPanel(new BorderLayout());
      panel.setOpaque(false);
      splitter = new Splitter(orientation, proportion, 0.1f, 0.9f);
      panel.add(splitter, BorderLayout.CENTER);
      splitter.setFirstComponent(readExternalPanel(first, null, currentWindow));
      splitter.setSecondComponent(readExternalPanel(second, null, currentWindow));
    } else if (panel.getComponent(0) instanceof Splitter) {
      splitter = (Splitter) panel.getComponent(0);
      readExternalPanel(first, (JPanel) splitter.getFirstComponent(), currentWindow);
      readExternalPanel(second, (JPanel) splitter.getSecondComponent(), currentWindow);
    } else {
      readExternalPanel(first, panel, currentWindow);
      readExternalPanel(second, panel, currentWindow);
    }
    return panel;
  }
Пример #6
0
  public void initSplitterProportion(
      final Splitter splitter, float defaultProportion, final String id) {
    final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
    String value =
        propertiesComponent.getValue(UnitTestViewComponent.SPLITTER_SIZE_PROPERTY + "." + id);
    float proportion = defaultProportion;
    if ((value != null && value.length() > 0)) {
      try {
        proportion = Float.parseFloat(value);
      } catch (NumberFormatException ignore) {
      }
    }

    splitter.addPropertyChangeListener(
        new PropertyChangeListener() {
          @Override
          public void propertyChange(PropertyChangeEvent event) {
            if (event.getPropertyName().equals(Splitter.PROP_PROPORTION)) {
              propertiesComponent.setValue(
                  UnitTestViewComponent.SPLITTER_SIZE_PROPERTY + "." + id,
                  String.valueOf(splitter.getProportion()));
            }
          }
        });

    splitter.setProportion(proportion);
  }
  private void layoutPanel() {
    if (myUsagePreviewPanel != null) {
      Disposer.dispose(myUsagePreviewPanel);
    }
    removeAll();
    JScrollPane pane = ScrollPaneFactory.createScrollPane(myTree);

    if (isPreview()) {
      pane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT | SideBorder.RIGHT));

      boolean vertical =
          myToolWindow.getAnchor() == ToolWindowAnchor.LEFT
              || myToolWindow.getAnchor() == ToolWindowAnchor.RIGHT;
      Splitter splitter =
          new Splitter(
              vertical, UsageViewSettings.getInstance().PREVIEW_USAGES_SPLITTER_PROPORTIONS);
      splitter.setFirstComponent(pane);
      myUsagePreviewPanel = new UsagePreviewPanel(myProject, new UsageViewPresentation());
      myUsagePreviewPanel.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT));

      Disposer.register(this, myUsagePreviewPanel);
      splitter.setSecondComponent(myUsagePreviewPanel);
      add(splitter, BorderLayout.CENTER);
    } else {
      pane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT));
      add(pane, BorderLayout.CENTER);
    }

    add(createToolbar().getComponent(), BorderLayout.WEST);

    myTree.getParent().setBackground(UIManager.getColor("Tree.background"));

    revalidate();
  }
  @Override
  public JComponent createComponent() {
    if (myMainComponent == null) {
      myMainComponent = new JPanel(new BorderLayout());
      myCbUseSoftWrapsAtConsole =
          new JCheckBox(ApplicationBundle.message("checkbox.use.soft.wraps.at.console"), false);
      myCommandsHistoryLimitField = new JTextField(3);
      myCbOverrideConsoleCycleBufferSize =
          new JCheckBox(
              ApplicationBundle.message(
                  "checkbox.override.console.cycle.buffer.size",
                  String.valueOf(ConsoleBuffer.getLegacyCycleBufferSize() / 1024)),
              false);
      myCbOverrideConsoleCycleBufferSize.addChangeListener(
          new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
              myConsoleCycleBufferSizeField.setEnabled(
                  myCbOverrideConsoleCycleBufferSize.isSelected());
            }
          });
      myConsoleCycleBufferSizeField = new JTextField(3);

      JPanel northPanel = new JPanel(new GridBagLayout());
      GridBag gridBag = new GridBag();
      gridBag.anchor(GridBagConstraints.WEST).setDefaultAnchor(GridBagConstraints.WEST);
      northPanel.add(myCbUseSoftWrapsAtConsole, gridBag.nextLine().next());
      northPanel.add(Box.createHorizontalGlue(), gridBag.next().coverLine());
      northPanel.add(
          new JLabel(ApplicationBundle.message("editbox.console.history.limit")),
          gridBag.nextLine().next());
      northPanel.add(myCommandsHistoryLimitField, gridBag.next());
      if (ConsoleBuffer.useCycleBuffer()) {
        northPanel.add(myCbOverrideConsoleCycleBufferSize, gridBag.nextLine().next());
        northPanel.add(myConsoleCycleBufferSizeField, gridBag.next());
      }
      if (!editFoldingsOnly()) {
        JPanel wrapper = new JPanel(new BorderLayout());
        wrapper.add(northPanel, BorderLayout.WEST);
        myMainComponent.add(wrapper, BorderLayout.NORTH);
      }
      Splitter splitter = new Splitter(true);
      myMainComponent.add(splitter, BorderLayout.CENTER);
      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;
  }
Пример #9
0
  public 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);
  }
 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;
 }
 private void collect(final JPanel panel) {
   final Component comp = panel.getComponent(0);
   if (comp instanceof Splitter) {
     final Splitter splitter = (Splitter) comp;
     collect((JPanel) splitter.getFirstComponent());
     collect((JPanel) splitter.getSecondComponent());
   } else if (comp instanceof JPanel || comp instanceof JBTabs) {
     final EditorWindow window = findWindowWith(comp);
     if (window != null) {
       res.add(window);
     }
   }
 }
Пример #12
0
  public ServersToolWindowContent(@NotNull 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 Splitter(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.getExtensions()) {
      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);
          return true;
        }
        return false;
      }
    }.installOn(myTree);
  }
    @Override
    protected JComponent createCenterPanel() {
      final JComponent tree = super.createCenterPanel();

      myCommitMessagePanel = new CommitMessage(myProject);
      myCommitMessagePanel.setCommitMessage("Initial commit");

      Splitter splitter = new Splitter(true);
      splitter.setHonorComponentsMinimumSize(true);
      splitter.setFirstComponent(tree);
      splitter.setSecondComponent(myCommitMessagePanel);
      splitter.setProportion(0.7f);

      return splitter;
    }
 @Override
 public void dispose() {
   mySplitter.dispose();
   myBrowser.dispose();
   myInspectionProfile = null;
   myDisposed = true;
 }
  protected JComponent createEditorContent() {
    JPanel result = new JPanel(new BorderLayout());
    Splitter p;

    result.add(BorderLayout.CENTER, p = new Splitter(true, 0.5f));
    p.setFirstComponent(super.createEditorContent());

    replaceCriteriaEdit =
        createEditor(searchContext, mySavedEditorText != null ? mySavedEditorText : "");
    JPanel replace = new JPanel(new BorderLayout());
    replace.add(BorderLayout.NORTH, new JLabel(SSRBundle.message("replacement.template.label")));
    replace.add(BorderLayout.CENTER, replaceCriteriaEdit.getComponent());
    replaceCriteriaEdit.getComponent().setMinimumSize(new Dimension(150, 100));

    p.setSecondComponent(replace);

    return result;
  }
  private JPanel createSignaturePanel() {
    mySignature = new GrMethodSignatureComponent("", myProject);
    myTable =
        new ParameterTablePanel() {
          @Override
          protected void updateSignature() {
            GrIntroduceParameterDialog.this.updateSignature();
          }

          @Override
          protected void doEnterAction() {
            clickDefaultButton();
          }

          @Override
          protected void doCancelAction() {
            GrIntroduceParameterDialog.this.doCancelAction();
          }
        };

    mySignature.setBorder(
        IdeBorderFactory.createTitledBorder(
            GroovyRefactoringBundle.message("signature.preview.border.title"), false));

    Splitter splitter = new Splitter(true);

    splitter.setFirstComponent(myTable);
    splitter.setSecondComponent(mySignature);

    mySignature.setPreferredSize(JBUI.size(500, 100));
    mySignature.setSize(JBUI.size(500, 100));

    splitter.setShowDividerIcon(false);

    final JPanel panel = new JPanel(new BorderLayout());
    panel.add(splitter, BorderLayout.CENTER);
    myForceReturnCheckBox =
        new JCheckBox(UIUtil.replaceMnemonicAmpersand("Use e&xplicit return statement"));
    panel.add(myForceReturnCheckBox, BorderLayout.NORTH);

    return panel;
  }
  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;
  }
Пример #18
0
  public UnitTestViewComponent(
      Project project,
      ConsoleView console,
      TestRunState testRunState,
      _FunctionTypes._void_P0_E0 closeListener) {
    myProject = project;
    myTestState = testRunState;
    StatisticsTableModel statisticsModel = new StatisticsTableModel(myTestState);

    myTreeComponent = new TestTree(myTestState, ProjectHelper.toMPSProject(project), this);
    myTestNavigator = new FailedTestOccurrenceNavigator(myTreeComponent);
    myActionToolComponent = new TestToolbarPanel(myTreeComponent, myTestNavigator);

    JComponent leftPanel = createTreeComponent(myActionToolComponent, myTreeComponent);

    myProgressLineComponent = new ProgressLine(myTestState);
    myProgressLineComponent.setMinimumSize(
        new Dimension(0, myProgressLineComponent.getMinimumSize().height));
    myOutputComponent = new TestOutputComponent(myProject, this, console, myTestState);
    myTreeComponent.addTreeSelectionListener(
        new TestTreeSelectionListener(myTreeComponent, statisticsModel, myOutputComponent));
    myTreeComponent.addMouseListener(
        new TestTreeRootMouseListener(myTreeComponent, statisticsModel, myOutputComponent));

    JPanel rightPanel =
        createOutputComponent(
            console, myProgressLineComponent, myOutputComponent.getComponent(), statisticsModel);

    Splitter splitter = new Splitter(false);
    initSplitterProportion(splitter, 0.2f, "tree");
    splitter.setFirstComponent(leftPanel);
    splitter.setSecondComponent(rightPanel);
    setLayout(new BorderLayout());

    add(splitter, BorderLayout.CENTER);

    myTestState.addView(myTreeComponent);
    myTestState.addView(myProgressLineComponent);
    myTestState.addView(myOutputComponent);
    addCloseListener(closeListener);
  }
 private void adjustTo(final int idx) {
   final Splitter target = mySplitters.get(idx);
   for (int i = 0; i < mySplitters.size(); i++) {
     final Splitter splitter = mySplitters.get(i);
     splitter.setProportion(target.getProportion());
   }
   for (Splitter splitter : myListening) {
     splitter.setProportion(target.getProportion());
   }
 }
Пример #20
0
  public void editSelectedMongoDocument() {

    DBObject mongoDocument = getSelectedMongoDocument();

    if (mongoDocument == null) {
      return;
    }

    mongoEditionPanel.updateEditionTree(mongoDocument);

    splitter.setSecondComponent(mongoEditionPanel);
  }
Пример #21
0
  private JPanel createOutputComponent(
      ConsoleView console,
      JComponent progressLine,
      JComponent testOutput,
      StatisticsTableModel statisticsModel) {
    JPanel rightPanel = new JPanel(new GridBagLayout());

    JComponent stackTraceActions = createActionsToolbar(console);
    stackTraceActions.setMaximumSize(
        new Dimension(rightPanel.getWidth(), stackTraceActions.getMaximumSize().height));

    Splitter outputStatisticSplitter = new Splitter(false);
    initSplitterProportion(outputStatisticSplitter, 0.5f, "statistic");
    outputStatisticSplitter.setFirstComponent(testOutput);
    JComponent statistics = createStatisticsComponent(statisticsModel);
    outputStatisticSplitter.setSecondComponent(statistics);

    GridBagConstraints c = new GridBagConstraints();
    rightPanel.setBorder(null);
    c.fill = GridBagConstraints.VERTICAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.gridx = 0;
    c.gridy = 1;
    c.weighty = 1;
    c.weightx = 0;
    rightPanel.add(stackTraceActions, c);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 1;
    c.gridy = 0;
    c.weighty = 0;
    c.weightx = 1;
    rightPanel.add(progressLine, c);
    c.fill = GridBagConstraints.BOTH;
    c.gridx = 1;
    c.gridy = 1;
    c.weighty = 1;
    c.weightx = 1;
    rightPanel.add(outputStatisticSplitter, c);
    return rightPanel;
  }
 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;
 }
  @SuppressWarnings("HardCodedStringLiteral")
  private Element writePanel(final JPanel panel) {
    final Component comp = panel.getComponent(0);
    if (comp instanceof Splitter) {
      final Splitter splitter = (Splitter) comp;
      final Element res = new Element("splitter");
      res.setAttribute("split-orientation", splitter.getOrientation() ? "vertical" : "horizontal");
      res.setAttribute("split-proportion", Float.toString(splitter.getProportion()));
      final Element first = new Element("split-first");
      first.addContent(writePanel((JPanel) splitter.getFirstComponent()));
      final Element second = new Element("split-second");
      second.addContent(writePanel((JPanel) splitter.getSecondComponent()));
      res.addContent(first);
      res.addContent(second);
      return res;
    } else if (comp instanceof JBTabs) {
      final Element res = new Element("leaf");
      Integer limit =
          UIUtil.getClientProperty(
              ((JBTabs) comp).getComponent(), JBTabsImpl.SIDE_TABS_SIZE_LIMIT_KEY);
      if (limit != null) {
        res.setAttribute(JBTabsImpl.SIDE_TABS_SIZE_LIMIT_KEY.toString(), String.valueOf(limit));
      }

      writeWindow(res, findWindowWith(comp));
      return res;
    } else if (comp instanceof EditorWindow.TCompForTablessMode) {
      EditorWithProviderComposite composite = ((EditorWindow.TCompForTablessMode) comp).myEditor;
      Element res = new Element("leaf");
      res.addContent(writeComposite(composite.getFile(), composite, false, composite));
      return res;
    } else {
      LOG.error(comp != null ? comp.getClass().getName() : null);
      return null;
    }
  }
  float getBottomPropertion() {
    final float totalSize =
        mySplitter.getOrientation() ? mySplitter.getHeight() : mySplitter.getWidth();
    final float componentSize =
        mySplitter.getOrientation()
            ? mySplitter.getFirstComponent().getHeight()
            : mySplitter.getFirstComponent().getWidth();

    return componentSize / (totalSize - mySplitter.getDividerWidth());
  }
Пример #25
0
  public MongoResultPanel(
      Project project, MongoPanel.MongoDocumentOperations mongoDocumentOperations) {
    this.mongoDocumentOperations = mongoDocumentOperations;
    setLayout(new BorderLayout());
    add(mainPanel, BorderLayout.CENTER);

    splitter = new Splitter(true, 0.6f);

    resultTreePanel = new JPanel(new BorderLayout());

    splitter.setFirstComponent(resultTreePanel);

    mongoEditionPanel = createMongoEditionPanel();

    containerPanel.setLayout(new BorderLayout());
    containerPanel.add(splitter);

    Disposer.register(project, this);
  }
Пример #26
0
 public DependenciesPanel(BaseTool tool, Project project) {
   super(new BorderLayout());
   myTool = tool;
   myIsMeta = false;
   myInitTree = new DependencyTree(this);
   myProject = project;
   myTargetsView = new TargetsView(myProject, this);
   myReferencesView = new ReferencesView(myProject, this);
   myReferencesView.setRunOptions(
       null, null, new UsagesView.ButtonConfiguration(false, false, false));
   JBScrollPane leftPane = new JBScrollPane(myInitTree);
   Splitter treeSplitter = new Splitter(false);
   treeSplitter.setFirstComponent(leftPane);
   treeSplitter.setSecondComponent(myTargetsView.getTreeComponent());
   Splitter splitter = new Splitter(true);
   splitter.setFirstComponent(treeSplitter);
   splitter.setSecondComponent(myReferencesView.getComponent());
   splitter.setDividerWidth(5);
   treeSplitter.setDividerWidth(5);
   add(splitter, BorderLayout.CENTER);
   add(createToolbar(), BorderLayout.NORTH);
 }
  void restoreLastSplitterProportions(PlaceInGrid placeInGrid) {
    if (getRootPane() == null) return;
    if (!RunnerContentUi.ensureValid(this)) return;

    final TabImpl tab = (TabImpl) getTab();
    if (tab != null) {
      switch (placeInGrid) {
        case left:
          setLeftProportion(tab.getLeftProportion());
          break;
        case right:
          setRightProportion(tab.getRightProportion());
          break;
        case bottom:
          mySplitter.setProportion(tab.getBottomProportion());
          break;
        case center:
          break;
      }
    }
  }
  private Editor createEditor() {
    EditorFactory editorFactory = EditorFactory.getInstance();
    Document doc =
        myFile == null
            ? editorFactory.createDocument(myTemplate == null ? "" : myTemplate.getText())
            : PsiDocumentManager.getInstance(myFile.getProject()).getDocument(myFile);
    Editor editor =
        myProject == null
            ? editorFactory.createEditor(doc)
            : editorFactory.createEditor(doc, myProject);

    EditorSettings editorSettings = editor.getSettings();
    editorSettings.setVirtualSpace(false);
    editorSettings.setLineMarkerAreaShown(false);
    editorSettings.setIndentGuidesShown(false);
    editorSettings.setLineNumbersShown(false);
    editorSettings.setFoldingOutlineShown(false);
    editorSettings.setAdditionalColumnsCount(3);
    editorSettings.setAdditionalLinesCount(3);

    EditorColorsScheme scheme = editor.getColorsScheme();
    scheme.setColor(EditorColors.CARET_ROW_COLOR, null);

    editor
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              @Override
              public void documentChanged(DocumentEvent e) {
                onTextChanged();
              }
            });

    ((EditorEx) editor).setHighlighter(createHighlighter());
    mySplitter.setFirstComponent(editor.getComponent());
    return editor;
  }
  @Override
  public void createToolWindowContent(final Project project, ToolWindow toolWindow) {
    Component component = toolWindow.getComponent();

    changeListPanel = new GerritChangeListPanel(Lists.<ChangeInfo>newArrayList(), null);

    SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true);

    ActionToolbar toolbar = createToolbar();
    toolbar.setTargetComponent(changeListPanel);
    panel.setToolbar(toolbar.getComponent());

    myRepositoryChangesBrowser = createRepositoryChangesBrowser(project);

    myDetailsSplitter = new Splitter(true, 0.6f);
    myDetailsSplitter.setShowDividerControls(true);

    changeListPanel.setBorder(
        IdeBorderFactory.createBorder(SideBorder.TOP | SideBorder.RIGHT | SideBorder.BOTTOM));
    myDetailsSplitter.setFirstComponent(changeListPanel);

    myDetailsPanel = new GerritChangeDetailsPanel(project);
    JPanel details = myDetailsPanel.getComponent();
    details.setBorder(IdeBorderFactory.createBorder(SideBorder.TOP | SideBorder.RIGHT));
    myDetailsSplitter.setSecondComponent(details);

    Splitter myHorizontalSplitter = new Splitter(false, 0.7f);
    myHorizontalSplitter.setShowDividerControls(true);
    myHorizontalSplitter.setFirstComponent(myDetailsSplitter);
    myHorizontalSplitter.setSecondComponent(myRepositoryChangesBrowser);

    panel.setContent(myHorizontalSplitter);

    component.getParent().add(panel);

    reloadChanges(project, false);

    setupRefreshTask(project);
  }
  @Override
  public JComponent createComponent() {
    myMainPanel = new JPanel(new GridBagLayout());
    myNameField = new JTextField();
    myExtensionField = new JTextField();
    mySplitter = new Splitter(true, 0.4f);

    myTemplateEditor = createEditor();

    myDescriptionComponent = new JEditorPane(UIUtil.HTML_MIME, EMPTY_HTML);
    myDescriptionComponent.setEditable(false);

    myAdjustBox = new JCheckBox(IdeBundle.message("checkbox.reformat.according.to.style"));
    myTopPanel = new JPanel(new GridBagLayout());

    myDescriptionPanel = new JPanel(new GridBagLayout());
    myDescriptionPanel.add(
        SeparatorFactory.createSeparator(IdeBundle.message("label.description"), null),
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 2, 0),
            0,
            0));
    myDescriptionPanel.add(
        ScrollPaneFactory.createScrollPane(myDescriptionComponent),
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(2, 0, 0, 0),
            0,
            0));

    myMainPanel.add(
        myTopPanel,
        new GridBagConstraints(
            0,
            0,
            4,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 2, 0),
            0,
            0));
    myMainPanel.add(
        myAdjustBox,
        new GridBagConstraints(
            0,
            1,
            4,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 0, 2, 0),
            0,
            0));
    myMainPanel.add(
        mySplitter,
        new GridBagConstraints(
            0,
            2,
            4,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(2, 0, 0, 0),
            0,
            0));

    mySplitter.setSecondComponent(myDescriptionPanel);
    setShowInternalMessage(null);

    myNameField.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusLost(FocusEvent e) {
            onNameChanged();
          }
        });
    myExtensionField.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusLost(FocusEvent e) {
            onNameChanged();
          }
        });
    myMainPanel.setPreferredSize(new Dimension(400, 300));
    return myMainPanel;
  }