Java Code Examples for com.intellij.ui.ScrollPaneFactory#createScrollPane()

The following examples show how to use com.intellij.ui.ScrollPaneFactory#createScrollPane() . 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: TipPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
public TipPanel() {
  setLayout(new BorderLayout());
  myBrowser = TipUIUtil.createTipBrowser();
  JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myBrowser, true);
  add(scrollPane, BorderLayout.CENTER);

  JPanel southPanel = new JPanel(new BorderLayout());

  myPoweredByLabel = new JBLabel();
  myPoweredByLabel.setHorizontalAlignment(SwingConstants.RIGHT);
  myPoweredByLabel.setForeground(SimpleTextAttributes.GRAY_ITALIC_ATTRIBUTES.getFgColor());

  southPanel.add(myPoweredByLabel, BorderLayout.EAST);
  add(southPanel, BorderLayout.SOUTH);

  myTips.addAll(TipAndTrickBean.EP_NAME.getExtensionList());
}
 
Example 2
Source File: ConflictsDialog.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected JComponent createCenterPanel() {
  JPanel panel = new JPanel(new BorderLayout(0, 2));

  panel.add(new JLabel(RefactoringBundle.message("the.following.problems.were.found")), BorderLayout.NORTH);

  @NonNls StringBuilder buf = new StringBuilder();
  for (String description : myConflictDescriptions) {
    buf.append(description);
    buf.append("<br><br>");
  }
  JEditorPane messagePane = new JEditorPane(UIUtil.HTML_MIME, buf.toString());
  messagePane.setEditable(false);
  JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(messagePane,
                                                              ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
                                                              ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  scrollPane.setPreferredSize(new Dimension(500, 400));
  panel.add(scrollPane, BorderLayout.CENTER);

  if (getOKAction().isEnabled()) {
    panel.add(new JLabel(RefactoringBundle.message("do.you.wish.to.ignore.them.and.continue")), BorderLayout.SOUTH);
  }

  return panel;
}
 
Example 3
Source File: UnsafeUsagesDialog.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected JComponent createCenterPanel() {
  JPanel panel = new JPanel(new BorderLayout());
  myMessagePane = new JEditorPane(UIUtil.HTML_MIME, "");
  myMessagePane.setEditable(false);
  JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myMessagePane);
  scrollPane.setPreferredSize(new Dimension(500, 400));
  panel.add(new JLabel(RefactoringBundle.message("the.following.problems.were.found")), BorderLayout.NORTH);
  panel.add(scrollPane, BorderLayout.CENTER);

  @NonNls StringBuffer buf = new StringBuffer();
  for (String description : myConflictDescriptions) {
    buf.append(description);
    buf.append("<br><br>");
  }
  myMessagePane.setText(buf.toString());
  return panel;
}
 
Example 4
Source File: AddModuleDependencyDialog.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
public AddModuleDependencyDialog(@Nonnull ClasspathPanel panel, StructureConfigurableContext context) {
  super(panel.getComponent(), true);

  ModifiableRootModel rootModel = panel.getRootModel();

  myTabs = new StripeTabPanel();

  for (AddModuleDependencyTabFactory factory : AddModuleDependencyTabFactory.EP_NAME.getExtensions()) {
    if(!factory.isAvailable(rootModel)) {
      continue;
    }
    AddModuleDependencyTabContext tabContext = factory.createTabContext(myDisposable, panel, context);

    JComponent component = tabContext.getComponent();
    JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(component, true);

    StripeTabPanel.TabInfo tabInfo = myTabs.addTab(tabContext.getTabName(), scrollPane, component);
    tabInfo.setEnabled(!tabContext.isEmpty());
    tabInfo.putUserData(CONTEXT_KEY, tabContext);
  }

  setTitle("Add Dependencies");
  init();
}
 
Example 5
Source File: OptionsEditor.java    From consulo with Apache License 2.0 5 votes vote down vote up
void setContent(final JComponent component, ConfigurationException e, @Nonnull Configurable configurable) {
  if (component != null && mySimpleContent == component && myException == e) {
    return;
  }

  removeAll();

  if (component != null) {
    boolean noMargin = ConfigurableWrapper.isNoMargin(configurable);
    JComponent wrapComponent = component;
    if (!noMargin) {
      wrapComponent = JBUI.Panels.simplePanel().addToCenter(wrapComponent);
      wrapComponent.setBorder(new EmptyBorder(UIUtil.PANEL_SMALL_INSETS));
    }


    boolean noScroll = ConfigurableWrapper.isNoScroll(configurable);
    if (!noScroll) {
      JScrollPane scroll = ScrollPaneFactory.createScrollPane(wrapComponent, true);
      scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
      scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
      add(scroll, BorderLayout.CENTER);
    }
    else {
      add(wrapComponent, BorderLayout.CENTER);
    }
  }

  if (e != null) {
    myErrorLabel.setText(UIUtil.toHtml(e.getMessage()));
    add(myErrorLabel, BorderLayout.NORTH);
  }

  mySimpleContent = component;
  myException = e;
}
 
Example 6
Source File: ExecutionErrorDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void show(final ExecutionException e, final String title, final Project project) {
  if (e instanceof RunCanceledByUserException) {
    return;
  }

  if (ApplicationManager.getApplication().isUnitTestMode()) {
    throw new RuntimeException(e.getLocalizedMessage());
  }
  final String message = e.getMessage();
  if (message == null || message.length() < 100) {
    Messages.showErrorDialog(project, message == null ? "exception was thrown" : message, title);
    return;
  }
  final DialogBuilder builder = new DialogBuilder(project);
  builder.setTitle(title);
  final JTextArea textArea = new JTextArea();
  textArea.setEditable(false);
  textArea.setForeground(UIUtil.getLabelForeground());
  textArea.setBackground(UIUtil.getLabelBackground());
  textArea.setFont(UIUtil.getLabelFont());
  textArea.setText(message);
  textArea.setWrapStyleWord(false);
  textArea.setLineWrap(true);
  final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(textArea);
  scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
  final JPanel panel = new JPanel(new BorderLayout(10, 0));
  panel.setPreferredSize(new Dimension(500, 200));
  panel.add(scrollPane, BorderLayout.CENTER);
  panel.add(new JLabel(Messages.getErrorIcon()), BorderLayout.WEST);
  builder.setCenterPanel(panel);
  builder.setButtonsAlignment(SwingConstants.CENTER);
  builder.addOkAction();
  builder.show();
}
 
Example 7
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 8
Source File: PopupTableAdapter.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public JScrollPane createScrollPane() {
  if (myTable instanceof TreeTable) {
    TreeUtil.expandAll(((TreeTable)myTable).getTree());
  }

  JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTable);

  scrollPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));

  if (myTable.getSelectedRow() == -1) {
    myTable.getSelectionModel().setSelectionInterval(0, 0);
  }

  if (myTable.getRowCount() >= 20) {
    scrollPane.getViewport().setPreferredSize(new Dimension(myTable.getPreferredScrollableViewportSize().width, 300));
  }
  else {
    scrollPane.getViewport().setPreferredSize(myTable.getPreferredSize());
  }

  if (myBuilder.isAutoselectOnMouseMove()) {
    myTable.addMouseMotionListener(new MouseMotionAdapter() {
      boolean myIsEngaged = false;

      @Override
      public void mouseMoved(MouseEvent e) {
        if (myIsEngaged) {
          int index = myTable.rowAtPoint(e.getPoint());
          myTable.getSelectionModel().setSelectionInterval(index, index);
        }
        else {
          myIsEngaged = true;
        }
      }
    });
  }

  return scrollPane;
}
 
Example 9
Source File: CreateFromTemplatePanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public JComponent getComponent() {
  if (myMainPanel == null) {
    myMainPanel = new JPanel(new GridBagLayout()) {
      @Override
      public Dimension getPreferredSize() {
        return getMainPanelPreferredSize(super.getPreferredSize());
      }
    };
    myAttrPanel = new JPanel(new GridBagLayout());
    JPanel myScrollPanel = new JPanel(new GridBagLayout());
    updateShown();

    myScrollPanel.setBorder(null);
    int attrCount = myUnsetAttributes.length;
    if (myMustEnterName && !Arrays.asList(myUnsetAttributes).contains(FileTemplate.ATTRIBUTE_NAME)) {
      attrCount++;
    }
    Insets insets = (attrCount > 1) ? new Insets(2, 2, 2, 2) : new Insets(0, 0, 0, 0);
    myScrollPanel.add(myAttrPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insets, 0, 0));
    if (attrCount > 1) {
      myScrollPanel.add(new JPanel(), new GridBagConstraints(0, 1, 1, 1, 0.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
      JScrollPane attrScroll = ScrollPaneFactory.createScrollPane(myScrollPanel);
      attrScroll.setViewportBorder(null);
      myMainPanel.add(attrScroll, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    }
    else {
      myMainPanel.add(myScrollPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    }
  }
  return myMainPanel;
}
 
Example 10
Source File: AvailablePluginsManagerMain.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected JScrollPane createTable() {
  myPluginsModel = new AvailablePluginsTableModel();
  myPluginTable = new PluginTable(myPluginsModel);
  myPluginTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  //pluginTable.setColumnWidth(PluginManagerColumnInfo.COLUMN_DOWNLOADS, 70);
  //pluginTable.setColumnWidth(PluginManagerColumnInfo.COLUMN_DATE, 80);
  //pluginTable.setColumnWidth(PluginManagerColumnInfo.COLUMN_RATE, 80);

  return ScrollPaneFactory.createScrollPane(myPluginTable);
}
 
Example 11
Source File: CodeStyleBlankLinesPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void init() {
  super.init();

  JPanel optionsPanel = new JPanel(new GridBagLayout());

  Map<CodeStyleSettingPresentation.SettingsGroup, List<CodeStyleSettingPresentation>> settings = CodeStyleSettingPresentation.getStandardSettings(getSettingsType());

  OptionGroup keepBlankLinesOptionsGroup = createOptionsGroup(BLANK_LINES_KEEP, settings.get(new CodeStyleSettingPresentation.SettingsGroup(BLANK_LINES_KEEP)));
  OptionGroup blankLinesOptionsGroup = createOptionsGroup(BLANK_LINES, settings.get(new CodeStyleSettingPresentation.SettingsGroup(BLANK_LINES)));
  if (keepBlankLinesOptionsGroup != null) {
    keepBlankLinesOptionsGroup.setAnchor(keepBlankLinesOptionsGroup.findAnchor());
    optionsPanel.add(keepBlankLinesOptionsGroup.createPanel(), new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, JBUI.emptyInsets(), 0, 0));
  }
  if (blankLinesOptionsGroup != null) {
    blankLinesOptionsGroup.setAnchor(blankLinesOptionsGroup.findAnchor());
    optionsPanel.add(blankLinesOptionsGroup.createPanel(), new GridBagConstraints(0, 1, 1, 1, 1, 0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, JBUI.emptyInsets(), 0, 0));
  }
  UIUtil.mergeComponentsWithAnchor(keepBlankLinesOptionsGroup, blankLinesOptionsGroup);

  optionsPanel.add(new JPanel(), new GridBagConstraints(0, 2, 1, 1, 0, 1, GridBagConstraints.NORTH, GridBagConstraints.BOTH, JBUI.emptyInsets(), 0, 0));

  optionsPanel.setBorder(JBUI.Borders.empty(0, 10));
  JScrollPane scroll = ScrollPaneFactory.createScrollPane(optionsPanel, true);
  scroll.setMinimumSize(new Dimension(optionsPanel.getPreferredSize().width + scroll.getVerticalScrollBar().getPreferredSize().width + 5, -1));
  scroll.setPreferredSize(scroll.getMinimumSize());

  myPanel.add(scroll, new GridBagConstraints(0, 0, 1, 1, 0, 1, GridBagConstraints.NORTH, GridBagConstraints.BOTH, JBUI.emptyInsets(), 0, 0));

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

  installPreviewPanel(previewPanel);
  addPanelToWatch(myPanel);

  myIsFirstUpdate = false;
}
 
Example 12
Source File: CtrlMouseHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private JComponent wrapInScrollPaneIfNeeded(@Nonnull JComponent component, @Nonnull Editor editor) {
  if (!ApplicationManager.getApplication().isHeadlessEnvironment()) {
    Dimension preferredSize = component.getPreferredSize();
    Dimension maxSize = getMaxPopupSize(editor);
    if (preferredSize.width > maxSize.width || preferredSize.height > maxSize.height) {
      // We expect documentation providers to exercise good judgement in limiting the displayed information,
      // but in any case, we don't want the hint to cover the whole screen, so we also implement certain limiting here.
      JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(component, true);
      scrollPane.setPreferredSize(new Dimension(Math.min(preferredSize.width, maxSize.width), Math.min(preferredSize.height, maxSize.height)));
      return scrollPane;
    }
  }
  return component;
}
 
Example 13
Source File: MemberSelectionPanelBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * @param title if title contains 'm' - it would look and feel as mnemonic
 */
public MemberSelectionPanelBase(String title, Table table) {
  super();
  setLayout(new BorderLayout());

  myTable = table;
  JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTable);
  add(SeparatorFactory.createSeparator(title, myTable), BorderLayout.NORTH);
  add(scrollPane, BorderLayout.CENTER);
}
 
Example 14
Source File: DesktopAlertImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected JComponent doCreateCenterPanel() {
  JPanel panel = new JPanel(new BorderLayout(15, 0));

  Icon icon = getIcon();
  if (icon != null) {
    JLabel iconLabel = new JLabel(icon);
    Container container = new Container();
    container.setLayout(new BorderLayout());
    container.add(iconLabel, BorderLayout.NORTH);
    panel.add(container, BorderLayout.WEST);
  }
  if (myText != null) {
    final JTextPane messageComponent = createMessageComponent(myText);

    final Dimension screenSize = messageComponent.getToolkit().getScreenSize();
    final Dimension textSize = messageComponent.getPreferredSize();
    if (myText.length() > 100) {
      final JScrollPane pane = ScrollPaneFactory.createScrollPane(messageComponent);
      pane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
      pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
      pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
      final int scrollSize = (int)new JScrollBar(Adjustable.VERTICAL).getPreferredSize().getWidth();
      final Dimension preferredSize = new Dimension(Math.min(textSize.width, screenSize.width / 2) + scrollSize, Math.min(textSize.height, screenSize.height / 3) + scrollSize);
      pane.setPreferredSize(preferredSize);
      panel.add(pane, BorderLayout.CENTER);
    }
    else {
      panel.add(messageComponent, BorderLayout.CENTER);
    }
  }
  return panel;
}
 
Example 15
Source File: MoveMethodPanel.java    From IntelliJDeodorant with MIT License 5 votes vote down vote up
private JScrollPane createTablePanel() {
    new TableSpeedSearch(table);
    table.setModel(model);
    model.setupRenderer(table);
    table.addMouseListener((DoubleClickListener) this::onDoubleClick);
    table.getSelectionModel().setSelectionMode(SINGLE_SELECTION);
    table.setAutoCreateRowSorter(true);
    setupTableLayout();
    refreshLabel.setForeground(JBColor.GRAY);
    scrollPane = ScrollPaneFactory.createScrollPane(table);
    scrollPane.setViewportView(refreshLabel);
    return scrollPane;
}
 
Example 16
Source File: PopupFactoryImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public BalloonBuilder createHtmlTextBalloonBuilder(@Nonnull final String htmlContent, @Nullable final Icon icon, Color textColor, final Color fillColor, @Nullable final HyperlinkListener listener) {
  JEditorPane text = IdeTooltipManager.initPane(htmlContent, new HintHint().setTextFg(textColor).setAwtTooltip(true), null);

  if (listener != null) {
    text.addHyperlinkListener(listener);
  }
  text.setEditable(false);
  NonOpaquePanel.setTransparent(text);
  text.setBorder(null);


  JLabel label = new JLabel();
  final JPanel content = new NonOpaquePanel(new BorderLayout((int)(label.getIconTextGap() * 1.5), (int)(label.getIconTextGap() * 1.5)));

  final NonOpaquePanel textWrapper = new NonOpaquePanel(new GridBagLayout());
  JScrollPane scrolledText = ScrollPaneFactory.createScrollPane(text, true);
  scrolledText.setBackground(fillColor);
  scrolledText.getViewport().setBackground(fillColor);
  textWrapper.add(scrolledText);
  content.add(textWrapper, BorderLayout.CENTER);
  if (icon != null) {
    final NonOpaquePanel north = new NonOpaquePanel(new BorderLayout());
    north.add(new JLabel(icon), BorderLayout.NORTH);
    content.add(north, BorderLayout.WEST);
  }

  content.setBorder(JBUI.Borders.empty(2, 4));

  final BalloonBuilder builder = createBalloonBuilder(content);

  builder.setFillColor(fillColor);

  return builder;
}
 
Example 17
Source File: ContentEntriesEditor.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public JPanel createComponentImpl() {
  final Module module = getModule();
  final Project project = module.getProject();

  myContentEntryEditorListener = new MyContentEntryEditorListener();

  final JPanel mainPanel = new JPanel(new BorderLayout());

  final JPanel entriesPanel = new JPanel(new BorderLayout());

  final DefaultActionGroup group = new DefaultActionGroup();
  final AddContentEntryAction action = new AddContentEntryAction();
  action.registerCustomShortcutSet(KeyEvent.VK_C, InputEvent.ALT_DOWN_MASK, mainPanel);
  group.add(action);

  myEditorsPanel = new ScrollablePanel(new VerticalStackLayout());
  myEditorsPanel.setBackground(BACKGROUND_COLOR);
  JScrollPane myScrollPane = ScrollPaneFactory.createScrollPane(myEditorsPanel, true);
  entriesPanel.add(new ToolbarPanel(myScrollPane, group), BorderLayout.CENTER);

  final JBSplitter splitter = new OnePixelSplitter(false);
  splitter.setProportion(0.6f);
  splitter.setHonorComponentsMinimumSize(true);

  myRootTreeEditor = new ContentEntryTreeEditor(project, myState);
  JComponent component = myRootTreeEditor.createComponent();
  component.setBorder(new CustomLineBorder(JBUI.scale(1),0,0,0));

  splitter.setFirstComponent(component);
  splitter.setSecondComponent(entriesPanel);
  JPanel contentPanel = new JPanel(new GridBagLayout());

  final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, myRootTreeEditor.getEditingActionsGroup(), true);
  contentPanel.add(new JLabel("Mark as:"),
                   new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, 0, new JBInsets(0, 5, 0, 5), 0,
                                          0));
  contentPanel.add(actionToolbar.getComponent(),
                   new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
                                          new JBInsets(0, 0, 0, 0), 0, 0));
  contentPanel.add(splitter,
                   new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH,
                                          new JBInsets(0, 0, 0, 0), 0, 0));

  mainPanel.add(contentPanel, BorderLayout.CENTER);

  final ModifiableRootModel model = getModel();
  if (model != null) {
    final ContentEntry[] contentEntries = model.getContentEntries();
    if (contentEntries.length > 0) {
      for (final ContentEntry contentEntry : contentEntries) {
        addContentEntryPanel(contentEntry);
      }
      selectContentEntry(contentEntries[0]);
    }
  }

  return mainPanel;
}
 
Example 18
Source File: ChangesBrowserBase.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected ChangesBrowserBase(final Project project,
                             @Nonnull List<T> changes,
                             final boolean capableOfExcludingChanges,
                             final boolean highlightProblems,
                             @Nullable final Runnable inclusionListener,
                             ChangesBrowser.MyUseCase useCase,
                             @Nullable VirtualFile toSelect,
                             Class<T> clazz) {
  super(new BorderLayout());
  setFocusable(false);

  myClass = clazz;
  myDataIsDirty = false;
  myProject = project;
  myCapableOfExcludingChanges = capableOfExcludingChanges;
  myToSelect = toSelect;

  ChangeNodeDecorator decorator =
          ChangesBrowser.MyUseCase.LOCAL_CHANGES.equals(useCase) ? RemoteRevisionsCache.getInstance(myProject).getChangesNodeDecorator() : null;

  myViewer = new ChangesTreeList<T>(myProject, changes, capableOfExcludingChanges, highlightProblems, inclusionListener, decorator) {
    protected DefaultTreeModel buildTreeModel(final List<T> changes, ChangeNodeDecorator changeNodeDecorator) {
      return ChangesBrowserBase.this.buildTreeModel(changes, changeNodeDecorator, isShowFlatten());
    }

    protected List<T> getSelectedObjects(final ChangesBrowserNode<T> node) {
      return ChangesBrowserBase.this.getSelectedObjects(node);
    }

    @Nullable
    protected T getLeadSelectedObject(final ChangesBrowserNode node) {
      return ChangesBrowserBase.this.getLeadSelectedObject(node);
    }

    @Override
    public void setScrollPaneBorder(Border border) {
      myViewerScrollPane.setBorder(border);
    }
  };
  myViewerScrollPane = ScrollPaneFactory.createScrollPane(myViewer);
  myHeaderPanel = new JPanel(new BorderLayout());
}
 
Example 19
Source File: FileEncodingConfigurable.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void createUIComponents() {
  myTreePanel = ScrollPaneFactory.createScrollPane(new JBTable());
}
 
Example 20
Source File: CruciblePanel.java    From Crucible4IDEA with MIT License 4 votes vote down vote up
public CruciblePanel(@NotNull final Project project) {
  super(false);
  myProject = project;

  final JBSplitter splitter = new JBSplitter(false, 0.2f);

  myReviewModel = new CrucibleReviewModel(project);
  myReviewTable = new JBTable(myReviewModel);
  myReviewTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  myReviewTable.setStriped(true);
  myReviewTable.setExpandableItemsEnabled(false);

  final TableColumnModel columnModel = myReviewTable.getColumnModel();
  columnModel.getColumn(1).setCellRenderer(new DescriptionCellRenderer());

  setUpColumnWidths(myReviewTable);
  myReviewTable.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
      if (e.getClickCount() == 2) {
        final int viewRow = myReviewTable.getSelectedRow();
        if (viewRow >= 0 &&  viewRow < myReviewTable.getRowCount()) {
          ApplicationManager.getApplication().invokeLater(new Runnable() {
            @Override
            public void run() {
              final Review review =
                CrucibleManager.getInstance(myProject).getDetailsForReview((String)myReviewTable.
                  getValueAt(viewRow, myReviewTable.getColumnModel().getColumnIndex(CrucibleBundle.message("crucible.id"))));
              if (review != null) {
                openDetailsToolWindow(review);
                myReviewTable.clearSelection();
              }
            }
          }, ModalityState.stateForComponent(myReviewTable));

        }
      }
  }});

  final TableRowSorter<TableModel> rowSorter = new TableRowSorter<TableModel>(myReviewModel);
  rowSorter.setSortKeys(Collections.singletonList(new RowSorter.SortKey(4, SortOrder.ASCENDING)));
  rowSorter.sort();
  myReviewTable.setRowSorter(rowSorter);

  final JScrollPane detailsScrollPane = ScrollPaneFactory.createScrollPane(myReviewTable);

  final SimpleTreeStructure reviewTreeStructure = createTreeStructure();
  final DefaultTreeModel model = new CrucibleTreeModel();
  final SimpleTree reviewTree = new SimpleTree(model);

  new AbstractTreeBuilder(reviewTree, model, reviewTreeStructure, null);
  reviewTree.invalidate();

  final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(reviewTree);
  splitter.setFirstComponent(scrollPane);
  splitter.setSecondComponent(detailsScrollPane);
  setContent(splitter);
}