com.intellij.ui.components.JBScrollPane Java Examples

The following examples show how to use com.intellij.ui.components.JBScrollPane. 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: SubmissionsPanel.java    From leetcode-editor with Apache License 2.0 7 votes vote down vote up
public SubmissionsPanel(@Nullable Project project, TableModel tableModel) {
    super(project, true);
    jpanel = new JBPanel(new BorderLayout());
    jpanel.setMinimumSize(new Dimension(400, 400));
    jpanel.setPreferredSize(new Dimension(400, 400));
    table = new JBTable(tableModel);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.getTableHeader().setReorderingAllowed(false);
    table.setRowSelectionAllowed(true);
    table.setRowSelectionInterval(0, 0);
    table.getColumnModel().getColumn(0).setPreferredWidth(350);
    table.getColumnModel().getColumn(1).setPreferredWidth(200);
    table.getColumnModel().getColumn(2).setPreferredWidth(100);
    table.getColumnModel().getColumn(3).setPreferredWidth(200);
    table.getColumnModel().getColumn(4).setPreferredWidth(100);
    jpanel.add(new JBScrollPane(table, JBScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JBScrollPane.HORIZONTAL_SCROLLBAR_NEVER),  BorderLayout.CENTER);

    setModal(true);
    init();
}
 
Example #2
Source File: NoSqlExplorerPanel.java    From nosql4idea with Apache License 2.0 6 votes vote down vote up
public NoSqlExplorerPanel(Project project, DatabaseVendorClientManager databaseVendorClientManager) {
    this.project = project;
    this.databaseVendorClientManager = databaseVendorClientManager;

    treePanel.setLayout(new BorderLayout());

    databaseTree = createTree();
    databaseTree.setCellRenderer(new NoSqlTreeRenderer());
    databaseTree.setName("databaseTree");

    JBScrollPane mongoTreeScrollPane = new JBScrollPane(databaseTree);

    setLayout(new BorderLayout());
    treePanel.add(mongoTreeScrollPane, BorderLayout.CENTER);
    add(rootPanel, BorderLayout.CENTER);

    toolBarPanel.setLayout(new BorderLayout());

    ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
            reloadAllServerConfigurations();
        }
    });
}
 
Example #3
Source File: EditTestsDialog.java    From JHelper with GNU Lesser General Public License v3.0 6 votes vote down vote up
private JPanel generateTestPanel() {
	JPanel testPanel = new JPanel(new GridLayout(2, 1, GRID_LAYOUT_GAP, GRID_LAYOUT_GAP));

	input = generateSavingTextArea();
	JPanel inputPanel = LabeledComponent.create(new JBScrollPane(input), "Input");

	output = generateSavingTextArea();
	outputPanel = LabeledComponent.create(new JBScrollPane(output), "Output");

	knowAnswer = new JCheckBox("Know answer?");
	knowAnswer.addActionListener(e -> saveCurrentTest());
	JPanel outputAndCheckBoxPanel = new JPanel(new BorderLayout());
	outputAndCheckBoxPanel.add(knowAnswer, BorderLayout.NORTH);
	outputAndCheckBoxPanel.add(outputPanel, BorderLayout.CENTER);
	testPanel.add(inputPanel);
	testPanel.add(outputAndCheckBoxPanel);
	return testPanel;
}
 
Example #4
Source File: OrganizationListWindowMock.java    From tmc-intellij with MIT License 6 votes vote down vote up
public OrganizationListWindowMock(List<Organization> organizations) {
    Organization[] orgArray = organizations.toArray(new Organization[organizations.size()]);
    this.organizations = new JList<Organization>(orgArray);

    this.button = new JButton("Select");
    button.addActionListener(new SelectOrganizationListenerMock(this));

    JScrollPane pane = new JBScrollPane(this.organizations);

    this.organizations.addMouseListener(
            new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent event) {
                    if (event.getClickCount() >= 2) {
                        button.doClick();
                    }
                }
            });

    add(pane);
    add(button);
}
 
Example #5
Source File: GtRepoChooser.java    From GitToolBox with Apache License 2.0 6 votes vote down vote up
GtRepoChooser(@NotNull Project project, @Nullable Component parentComponent) {
  super(project, parentComponent, false, IdeModalityType.PROJECT);
  this.project = project;
  repoList = new JBList<>();
  repoList.setCellRenderer(new ColoredListCellRenderer<GitRepository>() {
    @Override
    protected void customizeCellRenderer(@NotNull JList<? extends GitRepository> list, GitRepository value, int index,
                                         boolean selected, boolean hasFocus) {
      append(GtUtil.name(value));
      StringBand url = new StringBand(" (");
      url.append(value.getRoot().getPresentableUrl());
      url.append(")");
      append(url.toString(), SimpleTextAttributes.GRAYED_ATTRIBUTES);
    }
  });
  JBScrollPane scrollPane = new JBScrollPane(repoList);
  centerPanel = JBUI.Panels.simplePanel().addToCenter(scrollPane);
  centerPanel.setPreferredSize(JBUI.size(400, 300));
  setTitle(ResBundle.message("configurable.prj.autoFetch.exclusions.add.title"));
  init();
}
 
Example #6
Source File: Messages.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected JComponent createCenterPanel() {
  if (myInfoText == null) {
    return null;
  }
  final JPanel panel = new JPanel(new BorderLayout());
  final JTextArea area = new JTextArea(myInfoText);
  area.setEditable(false);
  final JBScrollPane scrollPane = new JBScrollPane(area) {
    @Override
    public Dimension getPreferredSize() {
      final Dimension preferredSize = super.getPreferredSize();
      final Container parent = getParent();
      if (parent != null) {
        return new Dimension(preferredSize.width, Math.min(150, preferredSize.height));
      }
      return preferredSize;
    }
  };
  panel.add(scrollPane);
  return panel;
}
 
Example #7
Source File: CmtFileEditor.java    From reasonml-idea-plugin with MIT License 6 votes vote down vote up
@NotNull
@Override
public JComponent getComponent() {
    m_rootTabbedPane = new JBTabbedPane(JTabbedPane.TOP, JTabbedPane.SCROLL_TAB_LAYOUT);

    InsightManager insightManager = ServiceManager.getService(m_project, InsightManager.class);
    List<String> meta = insightManager.dumpMeta(m_file);
    String xmlSource = insightManager.dumpTree(m_file);
    List<String> types = insightManager.dumpInferredTypes(m_file);

    m_rootTabbedPane.addTab("Meta", AllIcons.Nodes.DataTables, new JBScrollPane(new Table(new MetaTableModel(meta))));
    m_rootTabbedPane.addTab("AST", AllIcons.FileTypes.Xml, new CmtXmlComponent(m_project, m_rootTabbedPane, xmlSource));
    m_rootTabbedPane.addTab("Inferred", AllIcons.Nodes.DataSchema, new JBScrollPane(new Table(new InferredTableModel(types))));

    return m_rootTabbedPane;
}
 
Example #8
Source File: MongoResultPanel.java    From nosql4idea with Apache License 2.0 6 votes vote down vote up
public void updateResultTableTree(MongoResult mongoResult) {
    resultTableView = new JsonTreeTableView(JsonTreeModel.buildJsonTree(mongoResult), JsonTreeTableView.COLUMNS_FOR_READING);
    resultTableView.setName("resultTreeTable");

    resultTableView.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent mouseEvent) {
            if (mouseEvent.getClickCount() == 2 && MongoResultPanel.this.isSelectedNodeId()) {
                MongoResultPanel.this.editSelectedMongoDocument();
            }
        }
    });

    buildPopupMenu();

    resultTreePanel.invalidate();
    resultTreePanel.removeAll();
    resultTreePanel.add(new JBScrollPane(resultTableView));
    resultTreePanel.validate();
}
 
Example #9
Source File: SarosMainPanelView.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates the content of the tool window panel, with {@link SarosToolbar} and the {@link
 * SessionAndContactsTreeView}.
 */
public SarosMainPanelView(@NotNull Project project) throws HeadlessException {
  super(new BorderLayout());
  SessionAndContactsTreeView sarosTree = new SessionAndContactsTreeView(project);
  SarosToolbar sarosToolbar = new SarosToolbar(project);

  JScrollPane treeScrollPane = new JBScrollPane(sarosTree);
  treeScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
  treeScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

  // chartPane is empty at the moment
  Container chartPane = new JPanel(new BorderLayout());

  JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treeScrollPane, chartPane);
  splitPane.setOneTouchExpandable(true);
  splitPane.setDividerLocation(350);

  // Provide minimum sizes for the two components in the split pane
  Dimension minimumSize = new Dimension(300, 50);
  treeScrollPane.setMinimumSize(minimumSize);
  splitPane.setMinimumSize(minimumSize);

  add(splitPane, BorderLayout.CENTER);
  add(sarosToolbar, BorderLayout.NORTH);
}
 
Example #10
Source File: ActionTracer.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public JComponent getComponent() {
  if (myComponent == null) {
    myText = new JTextArea();
    final JBScrollPane log = new JBScrollPane(myText);
    final AnAction clear = new AnAction("Clear", "Clear log", AllIcons.General.Reset) {
      @Override
      public void actionPerformed(AnActionEvent e) {
        myText.setText(null);
      }
    };
    myComponent = new JPanel(new BorderLayout());
    final DefaultActionGroup group = new DefaultActionGroup();
    group.add(clear);
    myComponent.add(ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true).getComponent(), BorderLayout.NORTH);
    myComponent.add(log);

    myListenerDisposable = Disposable.newDisposable();
    Application.get().getMessageBus().connect(myListenerDisposable).subscribe(AnActionListener.TOPIC, this);
  }

  return myComponent;
}
 
Example #11
Source File: SolutionPanel.java    From leetcode-editor with Apache License 2.0 6 votes vote down vote up
public SolutionPanel(@Nullable Project project, TableModel tableModel) {
    super(project, true);
    this.jpanel = new JBPanel(new BorderLayout());;
    jpanel.setPreferredSize(new Dimension(600, 400));
    table = new JBTable(tableModel);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.getTableHeader().setReorderingAllowed(false);
    table.setRowSelectionAllowed(true);
    table.setRowSelectionInterval(0, 0);
    table.getColumnModel().getColumn(0).setPreferredWidth(350);
    table.getColumnModel().getColumn(1).setPreferredWidth(200);
    table.getColumnModel().getColumn(2).setPreferredWidth(700);
    jpanel.add(new JBScrollPane(table, JBScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JBScrollPane.HORIZONTAL_SCROLLBAR_NEVER),  BorderLayout.CENTER);

    setModal(true);
    init();
}
 
Example #12
Source File: CourseTabFactory.java    From tmc-intellij with MIT License 6 votes vote down vote up
private void addRightMouseButtonFunctionality(MouseEvent mouseEvent,
                                              final JBList list,
                                              JBScrollPane panel) {

    logger.info("Adding functionality for right mouse button. @CourseTabFactory");
    if (!SwingUtilities.isRightMouseButton(mouseEvent)) {
        return;
    }

    int index = list.locationToIndex(mouseEvent.getPoint());
    list.setSelectedIndex(index);
    PopUpMenu menu = new PopUpMenu();
    JBMenuItem openInExplorer = new JBMenuItem("Open path");
    final Object selectedItem = list.getSelectedValue();
    JBMenuItem deleteFolder = new JBMenuItem("Delete folder");

    openInExplorer.addActionListener(createOpenInExploreListener(list, selectedItem));

    deleteFolder.addActionListener(createDeleteButtonActionListener(list, selectedItem));

    menu.add(openInExplorer);
    menu.add(deleteFolder);
    menu.show(panel, mouseEvent.getX(), mouseEvent.getY());
    menu.setLocation(mouseEvent.getXOnScreen(), mouseEvent.getYOnScreen());

}
 
Example #13
Source File: TextAreaPage.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
private void create() {
  setLayout(new BorderLayout());

  JPanel middlePanel = new JPanel();
  middlePanel.setBorder(new TitledBorder(new EtchedBorder(), title));

  display = new JTextArea(10, 48);
  display.getDocument().putProperty(DefaultEditorKit.EndOfLineStringProperty, "\n");
  display.setEditable(false);
  display.setForeground(fontColor);

  JScrollPane scroll = new JBScrollPane(display);
  scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
  middlePanel.add(scroll);

  add(middlePanel, BorderLayout.CENTER);

  JPanel progressPanel = new JPanel();
  progressPanel.setLayout(new BoxLayout(progressPanel, BoxLayout.Y_AXIS));
}
 
Example #14
Source File: NewItemWithTemplatesPopupPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
public NewItemWithTemplatesPopupPanel(List<T> templatesList, ListCellRenderer<T> renderer) {
  setBackground(JBUI.CurrentTheme.NewClassDialog.panelBackground());

  myTemplatesListModel = new MyListModel(templatesList);
  myTemplatesList = createTemplatesList(myTemplatesListModel, renderer);

  ScrollingUtil.installMoveUpAction(myTemplatesList, (JComponent)TargetAWT.to(myTextField));
  ScrollingUtil.installMoveDownAction(myTemplatesList, (JComponent)TargetAWT.to(myTextField));

  JBScrollPane scrollPane = new JBScrollPane(myTemplatesList);
  scrollPane.setBorder(JBUI.Borders.empty());
  scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
  templatesListHolder = new Box(BoxLayout.Y_AXIS);
  Border border = JBUI.Borders
          .merge(JBUI.Borders.emptyTop(JBUI.CurrentTheme.NewClassDialog.fieldsSeparatorWidth()), JBUI.Borders.customLine(JBUI.CurrentTheme.NewClassDialog.bordersColor(), 1, 0, 0, 0), true);

  templatesListHolder.setBorder(border);
  templatesListHolder.add(scrollPane);

  add(templatesListHolder, BorderLayout.CENTER);
}
 
Example #15
Source File: ProcessPopup.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void buildActiveContent() {
  myActiveFocusedContent = new ActiveContent();

  final JPanel wrapper = new JPanel(new BorderLayout());
  wrapper.add(myProcessBox, BorderLayout.NORTH);

  myActiveFocusedContent.add(wrapper, BorderLayout.CENTER);

  final JScrollPane scrolls = new JBScrollPane(myActiveFocusedContent) {
    @Override
    public Dimension getPreferredSize() {
      if (myProcessBox.getComponentCount() > 0) {
        return super.getPreferredSize();
      } else {
        return getEmptyPreferredSize();
      }
    }
  };
  scrolls.getViewport().setBackground(myActiveFocusedContent.getBackground());
  scrolls.setBorder(null);
  myActiveContentComponent = scrolls;
}
 
Example #16
Source File: AnalyzeSizeToolWindowTest.java    From size-analyzer with Apache License 2.0 6 votes vote down vote up
@Test
public void autofixIsNotShownWhenNull() {
  JPanel toolPanel = toolWindow.getContent();
  Component[] components = toolPanel.getComponents();
  OnePixelSplitter splitter = (OnePixelSplitter) components[0];
  JBScrollPane leftPane = (JBScrollPane) splitter.getFirstComponent();
  JViewport leftView = leftPane.getViewport();
  Tree suggestionTree = (Tree) leftView.getView();
  JPanel rightPane = (JPanel) splitter.getSecondComponent();

  TreePath streamingPath =
      getTreePathWithString(suggestionTree, streamingSuggestionData.toString());
  suggestionTree.addSelectionPath(streamingPath);

  for (Component component : rightPane.getComponents()) {
    if (component instanceof JButton) {
      assertThat(component.isVisible()).isFalse();
    }
  }
}
 
Example #17
Source File: AnalyzeSizeToolWindowTest.java    From size-analyzer with Apache License 2.0 6 votes vote down vote up
@Test
public void categoryNodesHaveCorrectExtraInformation() {
  JPanel toolPanel = toolWindow.getContent();
  Component[] components = toolPanel.getComponents();
  OnePixelSplitter splitter = (OnePixelSplitter) components[0];
  JBScrollPane leftPane = (JBScrollPane) splitter.getFirstComponent();
  JViewport leftView = leftPane.getViewport();
  Tree suggestionTree = (Tree) leftView.getView();

  TreePath webPPath = getTreePathWithString(suggestionTree, webPCategoryData.toString());
  TreeCellRenderer treeCellRenderer = suggestionTree.getCellRenderer();
  Component renderedNode =
      treeCellRenderer.getTreeCellRendererComponent(
          suggestionTree,
          webPPath.getLastPathComponent(),
          false,
          false,
          false,
          suggestionTree.getRowForPath(webPPath),
          false);
  assertThat(renderedNode.toString()).contains("2 recommendations");
  assertThat(renderedNode.toString()).contains("29.30 KB");
}
 
Example #18
Source File: PreviewPanel.java    From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static Pair<UberTreeViewer,JPanel> createParseTreePanel() {
	// wrap tree and slider in panel
	JPanel treePanel = new JPanel(new BorderLayout(0, 0));
	treePanel.setBackground(JBColor.white);

	final UberTreeViewer viewer =
		isTrackpadZoomSupported ?
			new TrackpadZoomingTreeView(null, null, false) :
			new UberTreeViewer(null, null, false);

	JSlider scaleSlider = createTreeViewSlider(viewer);

	// Wrap tree viewer component in scroll pane
	JScrollPane scrollPane = new JBScrollPane(viewer); // use Intellij's scroller

	treePanel.add(scrollPane, BorderLayout.CENTER);

	treePanel.add(scaleSlider, BorderLayout.SOUTH);

	return new Pair<>(viewer, treePanel);
}
 
Example #19
Source File: BuckTreeViewPanelImpl.java    From buck with Apache License 2.0 6 votes vote down vote up
public BuckTreeViewPanelImpl() {
  mRoot = new BuckTextNode("", BuckTextNode.TextType.INFO);
  DefaultTreeModel treeModel = new DefaultTreeModel(mRoot);
  mModifiableModel =
      new ModifiableModelImpl(
          treeModel,
          new Tree(treeModel) {
            @Override
            public int getScrollableUnitIncrement(
                Rectangle visibleRect, int orientation, int direction) {
              return 5;
            }
          });
  mScrollPane = new JBScrollPane(mModifiableModel.getTree());
  mScrollPane.setAutoscrolls(true);
}
 
Example #20
Source File: QueryPlanPanel.java    From jetbrains-plugin-graph-database-support with Apache License 2.0 5 votes vote down vote up
public void initialize(Container container) {
    JTextArea queryLabel = new JTextArea(originalQuery);
    queryLabel.setRows(3);
    queryLabel.setEditable(false);

    GraphQueryPlan graphQueryPlan = result.getPlan()
            .orElseThrow(() ->
                    new ShouldNeverHappenException("Sergey Ishchenko",
                            "GraphQueryPanel is initialized when explain or profile queries are executed"));

    ListTreeTableModelOnColumns model = createModel(graphQueryPlan, result.isProfilePlan());

    treeTable = new TreeTableView(model);
    treeTable.setAutoCreateColumnsFromModel(true);
    treeTable.setRootVisible(true);
    treeTable.setCellSelectionEnabled(false);
    treeTable.setRowSelectionAllowed(true);
    treeTable.setAutoResizeMode(TreeTableView.AUTO_RESIZE_OFF);

    treeTable.getTree().setShowsRootHandles(true);

    DefaultTreeExpander expander = new DefaultTreeExpander(treeTable.getTree());
    expander.expandAll();
    initTreeCellRenderer(model);

    JBLabel infoLabel = new JBLabel(getStatusText(result));
    infoLabel.setHorizontalAlignment(SwingConstants.LEFT);

    container.add(new JBScrollPane(queryLabel), BorderLayout.NORTH);
    // scroll pane is needed to correctly fit all the tree content and to show table header
    container.add(new JBScrollPane(treeTable, JBScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JBScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER);
    container.add(infoLabel, BorderLayout.SOUTH);

    new ColumnResizer(treeTable).resize();
}
 
Example #21
Source File: ResolveConflictsForm.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
/**
 * Method generated by IntelliJ IDEA GUI Designer
 * >>> IMPORTANT!! <<<
 * DO NOT edit this method OR call it in your code!
 *
 * @noinspection ALL
 */
private void $$$setupUI$$$() {
    myContentPanel = new JPanel();
    myContentPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
    final JPanel panel1 = new JPanel();
    panel1.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1));
    myContentPanel.add(panel1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
    myAcceptYoursButton = new JButton();
    myAcceptYoursButton.setEnabled(false);
    myAcceptYoursButton.setText("Accept Yours");
    myAcceptYoursButton.setMnemonic('Y');
    myAcceptYoursButton.setDisplayedMnemonicIndex(7);
    panel1.add(myAcceptYoursButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    final Spacer spacer1 = new Spacer();
    panel1.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
    myAcceptTheirsButton = new JButton();
    myAcceptTheirsButton.setEnabled(false);
    myAcceptTheirsButton.setText("Accept Theirs");
    myAcceptTheirsButton.setMnemonic('T');
    myAcceptTheirsButton.setDisplayedMnemonicIndex(7);
    panel1.add(myAcceptTheirsButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    myMergeButton = new JButton();
    myMergeButton.setEnabled(false);
    myMergeButton.setText("Merge");
    myMergeButton.setMnemonic('M');
    myMergeButton.setDisplayedMnemonicIndex(0);
    panel1.add(myMergeButton, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    final JBScrollPane jBScrollPane1 = new JBScrollPane();
    myContentPanel.add(jBScrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
    myItemsTable = new JBTable();
    myItemsTable.putClientProperty("Table.isFileList", Boolean.FALSE);
    jBScrollPane1.setViewportView(myItemsTable);
}
 
Example #22
Source File: VcsPullRequestsForm.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
protected void createCustomView() {
    //Tree in a scroll panel
    pullRequestsTree = new Tree();
    pullRequestsTree.setCellRenderer(new PRTreeCellRenderer());
    pullRequestsTree.setShowsRootHandles(true);
    pullRequestsTree.setRootVisible(false);
    pullRequestsTree.setRowHeight(0); //dynamically have row height computed for each row
    scrollPanel = new JBScrollPane(pullRequestsTree);
}
 
Example #23
Source File: TaskDefaultFavoriteListProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void showNotePopup(Project project,
                           final DnDAwareTree tree,
                           final Consumer<String> after, final String initText) {
  final JTextArea textArea = new JTextArea(3, 50);
  textArea.setFont(UIUtil.getTreeFont());
  textArea.setText(initText);
  final JBScrollPane pane = new JBScrollPane(textArea);
  final ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(pane, textArea)
    .setCancelOnClickOutside(true)
    .setAdText(KeymapUtil.getShortcutsText(CommonShortcuts.CTRL_ENTER.getShortcuts()) + " to finish")
    .setTitle("Comment")
    .setMovable(true)
    .setRequestFocus(true).setResizable(true).setMayBeParent(true);
  final JBPopup popup = builder.createPopup();
  final JComponent content = popup.getContent();
  final AnAction action = new AnAction() {
    @Override
    public void actionPerformed(AnActionEvent e) {
      popup.closeOk(e.getInputEvent());
      unregisterCustomShortcutSet(content);
      after.consume(textArea.getText());
    }
  };
  action.registerCustomShortcutSet(CommonShortcuts.CTRL_ENTER, content);
  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      popup.showInCenterOf(tree);
    }
  }, ModalityState.NON_MODAL, project.getDisposed());
}
 
Example #24
Source File: OptionTableWithPreviewPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void init() {
  super.init();

  myPanel.setLayout(new GridBagLayout());
  initTables();

  myTreeTable = createOptionsTree(getSettings());
  myTreeTable.setBackground(UIUtil.getPanelBackground());
  myTreeTable.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));
  JBScrollPane scrollPane = new JBScrollPane(myTreeTable) {
    @Override
    public Dimension getMinimumSize() {
      return super.getPreferredSize();
    }
  };
  myPanel.add(scrollPane, new GridBagConstraints(0, 0, 1, 1, 0, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, JBUI.emptyInsets(), 0, 0));

  final JPanel previewPanel = createPreviewPanel();
  myPanel.add(previewPanel, new GridBagConstraints(1, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, JBUI.emptyInsets(), 0, 0));

  installPreviewPanel(previewPanel);
  addPanelToWatch(myPanel);

  isFirstUpdate = false;
  customizeSettings();
}
 
Example #25
Source File: LabeledTextComponent.java    From consulo with Apache License 2.0 5 votes vote down vote up
public LabeledTextComponent() {
  myTextPane = new JTextPane();

  myComponent.setLabelLocation(BorderLayout.NORTH);
  myComponent.getLabel().setMinimumSize(new Dimension(0, -1));
  myComponent.getComponent().setLayout(new BorderLayout());
  myTextPane.setBackground(UIUtil.getTextFieldBackground());
  myComponent.getComponent().add(new JBScrollPane(myTextPane));
  myComponent.getComponent().setBorder(IdeBorderFactory.createBorder());
}
 
Example #26
Source File: ManageWorkspacesForm.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
/**
 * Method generated by IntelliJ IDEA GUI Designer
 * >>> IMPORTANT!! <<<
 * DO NOT edit this method OR call it in your code!
 *
 * @noinspection ALL
 */
private void $$$setupUI$$$() {
    createUIComponents();
    contentPane = new JPanel();
    contentPane.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1));
    final JBScrollPane jBScrollPane1 = new JBScrollPane();
    contentPane.add(jBScrollPane1, new GridConstraints(0, 0, 3, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
    jBScrollPane1.setViewportView(treeTable);
    final JPanel panel1 = new JPanel();
    panel1.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));
    contentPane.add(panel1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
    panel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin").getString("Tfvc.ManageWorkspaces.Accounts.Panel.Title")));
    reloadWorkspacesButton = new JButton();
    this.$$$loadButtonText$$$(reloadWorkspacesButton, ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin").getString("Tfvc.ManageWorkspaces.Reload.Button"));
    panel1.add(reloadWorkspacesButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    proxySettingsButton = new JButton();
    this.$$$loadButtonText$$$(proxySettingsButton, ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin").getString("Tfvc.ManageWorkspaces.Proxy.Button"));
    panel1.add(proxySettingsButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    workspacesPanel = new JPanel();
    workspacesPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));
    contentPane.add(workspacesPanel, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
    workspacesPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin").getString("Tfvc.ManageWorkspaces.Workspaces.Panel.Title")));
    editWorkspaceButton = new JButton();
    this.$$$loadButtonText$$$(editWorkspaceButton, ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin").getString("Tfvc.ManageWorkspaces.Edit.Button"));
    workspacesPanel.add(editWorkspaceButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    deleteWorkspaceButton = new JButton();
    this.$$$loadButtonText$$$(deleteWorkspaceButton, ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin").getString("Tfvc.ManageWorkspaces.Delete.Button"));
    workspacesPanel.add(deleteWorkspaceButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    final Spacer spacer1 = new Spacer();
    contentPane.add(spacer1, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
}
 
Example #27
Source File: PantsProjectSettingsControl.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
@Override
protected void fillExtraControls(@NotNull PaintAwarePanel content, int indentLevel) {
  PantsProjectSettings initialSettings = getInitialSettings();
  myLibsWithSourcesCheckBox.setSelected(initialSettings.libsWithSources);
  myEnableIncrementalImportCheckBox.setSelected(initialSettings.incrementalImportEnabled);
  myImportDepthSpinner.setValue(initialSettings.incrementalImportDepth);
  myUseIdeaProjectJdkCheckBox.setSelected(initialSettings.useIdeaProjectJdk);
  myImportSourceDepsAsJarsCheckBox.setSelected(initialSettings.importSourceDepsAsJars);
  myUseIntellijCompilerCheckBox.setSelected(initialSettings.useIntellijCompiler);
  LinkLabel<?> intellijCompilerHelpMessage = LinkLabel.create(
    PantsBundle.message("pants.settings.text.use.intellij.compiler.help.messasge"),
    () -> BrowserUtil.browse(PantsBundle.message("pants.settings.text.use.intellij.compiler.help.messasge.link"))
  );

  myTargetSpecsBox.setItems(initialSettings.getAllAvailableTargetSpecs(), x -> x);
  initialSettings.getSelectedTargetSpecs().forEach(spec -> myTargetSpecsBox.setItemSelected(spec, true));

  insertNameFieldBeforeProjectPath(content);

  List<JComponent> boxes = ContainerUtil.newArrayList(
    myLibsWithSourcesCheckBox,
    myEnableIncrementalImportCheckBox,
    myImportDepthPanel,
    myUseIdeaProjectJdkCheckBox,
    myImportSourceDepsAsJarsCheckBox,
    myUseIntellijCompilerCheckBox,
    intellijCompilerHelpMessage,
    new JBLabel(PantsBundle.message("pants.settings.text.targets")),
    new JBScrollPane(myTargetSpecsBox)
  );

  GridBag lineConstraints = ExternalSystemUiUtil.getFillLineConstraints(indentLevel);

  for (JComponent component : boxes) {
    content.add(component, lineConstraints);
  }
}
 
Example #28
Source File: TestResultsPanel.java    From tmc-intellij with MIT License 5 votes vote down vote up
private void createLayout() {
    logger.info("Creating layout. @TestResultsPanel");
    this.setLayout(new GridBagLayout());

    // we want the progress bar to be separate from the scroll panel
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    gbc.weightx = 1.0;
    gbc.anchor = GridBagConstraints.PAGE_START;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    addProgressBar(gbc);


    final JScrollPane scrollPane1 = new JBScrollPane();
    scrollPane1.setVerticalScrollBarPolicy(JBScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane1.setHorizontalScrollBarPolicy(JBScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    gbc.gridy = 1;
    gbc.weighty = 1.0;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.fill = GridBagConstraints.BOTH;
    this.add(scrollPane1, gbc);

    resultsList = new JPanel();
    resultsList.setLayout(new GridBagLayout());
    scrollPane1.setViewportView(resultsList);
}
 
Example #29
Source File: ArrangementMatchingRulesControl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void showEditor(@Nonnull ArrangementMatchingRuleEditor editor, int rowToEdit) {
  if (myEditorRow == rowToEdit + 1) {
    return;
  }
  if (myEditorRow >= 0) {
    if (myEditorRow < rowToEdit) {
      rowToEdit--;
    }
    hideEditor();
  }
  myEditorRow = rowToEdit + 1;
  ArrangementEditorComponent editorComponent = new ArrangementEditorComponent(this, myEditorRow, editor);
  int width = getBounds().width;
  JScrollPane scrollPane = JBScrollPane.findScrollPane(getParent());
  if (scrollPane != null) {
    width -= scrollPane.getVerticalScrollBar().getWidth();
  }
  editorComponent.applyAvailableWidth(width);
  editor.reset(rowToEdit);
  mySkipSelectionChange = true;
  try {
    getModel().insertRow(myEditorRow, new Object[]{editorComponent});
  }
  finally {
    mySkipSelectionChange = false;
  }

  Rectangle bounds = getRowsBounds(rowToEdit, myEditorRow);
  if (bounds != null) {
    myRepresentationCallback.ensureVisible(bounds);
  }

  // We can't just subscribe to the model modification events and update cached renderers automatically because we need to use
  // the cached renderer on atom condition removal (via click on 'close' button). The model is modified immediately then but
  // corresponding cached renderer is used for animation.
  editorComponent.expand();
  repaintRows(rowToEdit, getModel().getRowCount() - 1, false);
  editCellAt(myEditorRow, 0);
}
 
Example #30
Source File: CourseTabFactory.java    From tmc-intellij with MIT License 5 votes vote down vote up
private void setScrollBarToBottom(String course,
                                  JTabbedPane tabbedPanelBase,
                                  JBScrollPane panel) {

    tabbedPanelBase.addTab(course, panel);
    JScrollBar bar = panel.getVerticalScrollBar();
    AdjustmentListener listener = event -> event.getAdjustable().setValue(event.getAdjustable().getMaximum());

    bar.addAdjustmentListener(listener);
    bar.setValueIsAdjusting(true);
    bar.removeAdjustmentListener(listener);
    bar.setValue(bar.getMaximum());
}