com.intellij.ui.ScrollPaneFactory Java Examples

The following examples show how to use com.intellij.ui.ScrollPaneFactory. 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: StructureFilteringStrategy.java    From consulo with Apache License 2.0 6 votes vote down vote up
public MyUI() {
  myStructureTree = new Tree();
  myStructureTree.setRootVisible(false);
  myStructureTree.setShowsRootHandles(true);
  myStructureTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
    public void valueChanged(final TreeSelectionEvent e) {
      final List<FilePath> filePaths = new ArrayList<>(mySelection);

      mySelection.clear();
      final TreePath[] selectionPaths = myStructureTree.getSelectionPaths();
      if (selectionPaths != null) {
        for (TreePath selectionPath : selectionPaths) {
          mySelection.addAll(getFilePathsUnder((ChangesBrowserNode<?>)selectionPath.getLastPathComponent()));
        }
      }

      if (Comparing.haveEqualElements(filePaths, mySelection)) return;

      for (ChangeListener listener : myListeners) {
        listener.stateChanged(new ChangeEvent(this));
      }
    }
  });
  myScrollPane = ScrollPaneFactory.createScrollPane(myStructureTree);
}
 
Example #2
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 #3
Source File: EarlyAccessProgramConfigurable.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
@Nullable
@Override
public JComponent createComponent() {
  myList = new CheckBoxList<>();
  myList.setBorder(null);

  EarlyAccessProgramDescriptor[] extensions = EarlyAccessProgramDescriptor.EP_NAME.getExtensions();
  Arrays.sort(extensions, (o1, o2) -> {
    if (o1.isAvailable() && !o2.isAvailable()) {
      return -1;
    }
    else if (o2.isAvailable() && !o1.isAvailable()) {
      return 1;
    }
    return o1.getName().compareToIgnoreCase(o2.getName());
  });
  myList.setItems(Arrays.asList(extensions), EarlyAccessProgramDescriptor::getName, desc -> EarlyAccessProgramManager.is(desc.getClass()));
  myList.setCellRenderer(new EarlyAccessCellRender());

  return JBUI.Panels.simplePanel().addToTop(createWarningPanel()).addToCenter(ScrollPaneFactory.createScrollPane(myList, true));
}
 
Example #4
Source File: LiteralChooser.java    From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Nullable
	@Override
	protected JComponent createCenterPanel() {
		JPanel panel = new JPanel(new BorderLayout());
		new DoubleClickListener() {
			@Override
			protected boolean onDoubleClick(MouseEvent e) {
				if (tree.getPathForLocation(e.getX(), e.getY()) != null) {
					doOKAction();
					return true;
				}
				return false;
			}
		}.installOn(tree);

		TreeUtil.installActions(tree);
		JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(tree);
//		scrollPane.setPreferredSize(new Dimension(350, 450));
		panel.add(scrollPane, BorderLayout.CENTER);

		return panel;
	}
 
Example #5
Source File: HaxeRestoreReferencesDialog.java    From intellij-haxe with Apache License 2.0 6 votes vote down vote up
@Override
protected JComponent createCenterPanel() {
  final JPanel panel = new JPanel(new BorderLayout(UIUtil.DEFAULT_HGAP, UIUtil.DEFAULT_VGAP));
  myList = new JBList((Object[])myNamedElements);
  myList.setCellRenderer(new FQNameCellRenderer());
  panel.add(ScrollPaneFactory.createScrollPane(myList), BorderLayout.CENTER);

  panel.add(new JBLabel(CodeInsightBundle.message("dialog.paste.on.import.text"), SMALL, BRIGHTER), BorderLayout.NORTH);

  final JPanel buttonPanel = new JPanel(new VerticalFlowLayout());
  final JButton okButton = new JButton(CommonBundle.getOkButtonText());
  getRootPane().setDefaultButton(okButton);
  buttonPanel.add(okButton);
  final JButton cancelButton = new JButton(CommonBundle.getCancelButtonText());
  buttonPanel.add(cancelButton);

  panel.setPreferredSize(new Dimension(500, 400));

  return panel;
}
 
Example #6
Source File: SpecificFilesViewDialog.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void createPanel() {
  myPanel = new JPanel(new BorderLayout());

  final DefaultActionGroup group = new DefaultActionGroup();
  final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar("SPECIFIC_FILES_DIALOG", group, true);

  addCustomActions(group, actionToolbar);

  final CommonActionsManager cam = CommonActionsManager.getInstance();
  final Expander expander = new Expander();
  group.addSeparator();
  group.add(new ToggleShowFlattenAction());
  group.add(cam.createExpandAllAction(expander, myView));
  group.add(cam.createCollapseAllAction(expander, myView));

  myPanel.add(actionToolbar.getComponent(), BorderLayout.NORTH);
  myPanel.add(ScrollPaneFactory.createScrollPane(myView), BorderLayout.CENTER);
  myView.setShowFlatten(false);
}
 
Example #7
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 #8
Source File: NewProjectPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
protected JComponent createLeftComponent(@Nonnull Disposable parentDisposable) {
  NewModuleContext context = new NewModuleContext();

  NewModuleBuilder.EP_NAME.composite().setupContext(context);

  myTree = new Tree(new AsyncTreeModel(new StructureTreeModel<>(new NewProjectTreeStructure(context), parentDisposable), parentDisposable));
  myTree.setFont(UIUtil.getFont(UIUtil.FontSize.BIGGER, null));
  myTree.setOpaque(false);
  myTree.setBackground(SwingUIDecorator.get(SwingUIDecorator::getSidebarColor));
  myTree.setRootVisible(false);
  myTree.setRowHeight(JBUI.scale(24));

  TreeUtil.expandAll(myTree);
  return ScrollPaneFactory.createScrollPane(myTree, true);
}
 
Example #9
Source File: PackagesNotificationPanel.java    From vue-for-idea with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static void doShowError(String title, String description, DialogBuilder builder) {
    builder.setTitle(title);
    final JTextArea textArea = new JTextArea();
    textArea.setEditable(false);
    textArea.setText(description);
    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(600, 400));
    panel.add(scrollPane, BorderLayout.CENTER);
    panel.add(new JBLabel("Details:", Messages.getErrorIcon(), SwingConstants.LEFT), BorderLayout.NORTH);
    builder.setCenterPanel(panel);
    builder.setButtonsAlignment(SwingConstants.CENTER);
    builder.addOkAction();
    builder.show();
}
 
Example #10
Source File: KnowledgeViewPane.java    From netbeans-mmd-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public JComponent createComponent() {
  if (myComponent != null) {
    return myComponent;
  }

  DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(null);
  DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
  myTree = createTree(treeModel);
  enableDnD();
  myComponent = ScrollPaneFactory.createScrollPane(myTree);
  myTreeStructure = createStructure();
  setTreeBuilder(createBuilder(treeModel));

  installComparator();
  initTree();

  return myComponent;
}
 
Example #11
Source File: Browser.java    From consulo with Apache License 2.0 6 votes vote down vote up
public Browser(@Nonnull InspectionResultsView view) {
  super(new BorderLayout());
  myView = view;

  myCurrentEntity = null;
  myCurrentDescriptor = null;

  myHTMLViewer = new JEditorPane(UIUtil.HTML_MIME, InspectionsBundle.message("inspection.offline.view.empty.browser.text"));
  myHTMLViewer.setEditable(false);
  myHyperLinkListener = new HyperlinkListener() {
    @Override
    public void hyperlinkUpdate(HyperlinkEvent e) {
      Browser.this.hyperlinkUpdate(e);
    }
  };
  myHTMLViewer.addHyperlinkListener(myHyperLinkListener);

  final JScrollPane pane = ScrollPaneFactory.createScrollPane(myHTMLViewer);
  pane.setBorder(null);
  add(pane, BorderLayout.CENTER);
  setupStyle();
}
 
Example #12
Source File: TabbedLanguageCodeStylePanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected MyIndentOptionsWrapper(CodeStyleSettings settings, LanguageCodeStyleSettingsProvider provider, IndentOptionsEditor editor) {
  super(settings);
  myProvider = provider;
  myTopPanel.add(myLeftPanel, BorderLayout.WEST);
  myRightPanel = new JPanel();
  installPreviewPanel(myRightPanel);
  myEditor = editor;
  if (myEditor != null) {
    JPanel panel = myEditor.createPanel();
    panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    JScrollPane scroll = ScrollPaneFactory.createScrollPane(panel, true);
    scroll.setPreferredSize(new Dimension(panel.getPreferredSize().width + scroll.getVerticalScrollBar().getPreferredSize().width + 5, -1));
    myLeftPanel.add(scroll, BorderLayout.CENTER);
  }
  myTopPanel.add(myRightPanel, BorderLayout.CENTER);
}
 
Example #13
Source File: CompareWithSelectedRevisionAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static JPanel createCommentsPanel(final TableView<VcsFileRevision> table) {
  final JTextArea textArea = createTextArea();
  table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
      final VcsFileRevision revision = table.getSelectedObject();
      if (revision == null) {
        textArea.setText("");
      } else {
        textArea.setText(revision.getCommitMessage());
        textArea.select(0, 0);
      }
    }
  });

  JPanel jPanel = new JPanel(new BorderLayout());
  final JScrollPane textScrollPane = ScrollPaneFactory.createScrollPane(textArea);
  textScrollPane.setBorder(IdeBorderFactory.createTitledBorder(VcsBundle.message("border.selected.revision.commit.message"), false
  ));
  jPanel.add(textScrollPane, BorderLayout.SOUTH);

  jPanel.setPreferredSize(new Dimension(300, 100));
  return jPanel;
}
 
Example #14
Source File: CompareWithSelectedRevisionAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static JPanel createCommentsPanel(final TreeTableView treeTable) {
  JPanel panel = new JPanel(new BorderLayout());
  final JTextArea textArea = createTextArea();
  treeTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
      final int index = treeTable.getSelectionModel().getMinSelectionIndex();
      if (index == -1) {
        textArea.setText("");
      } else {
        final VcsFileRevision revision = getRevisionAt(treeTable, index);
        if (revision != null) {
          textArea.setText(revision.getCommitMessage());
        } else {
          textArea.setText("");
        }
      }
    }
  });
  final JScrollPane textScrollPane = ScrollPaneFactory.createScrollPane(textArea);
  panel.add(textScrollPane, BorderLayout.CENTER);
  textScrollPane.setBorder(IdeBorderFactory.createTitledBorder(VcsBundle.message("border.selected.revision.commit.message"), false
  ));
  return panel;
}
 
Example #15
Source File: VcsSelectionHistoryDialog.java    From consulo with Apache License 2.0 6 votes vote down vote up
private JComponent createBottomPanel(final JComponent addComp) {
  JBSplitter splitter = new JBSplitter(true, COMMENTS_SPLITTER_PROPORTION_KEY, COMMENTS_SPLITTER_PROPORTION);
  splitter.setDividerWidth(4);

  JPanel tablePanel = new JPanel(new BorderLayout());
  tablePanel.add(ScrollPaneFactory.createScrollPane(myList), BorderLayout.CENTER);

  JPanel statusPanel = new JPanel(new FlowLayout());
  statusPanel.add(myStatusSpinner);
  statusPanel.add(myStatusLabel);

  JPanel separatorPanel = new JPanel(new BorderLayout());
  separatorPanel.add(myChangesOnlyCheckBox, BorderLayout.WEST);
  separatorPanel.add(statusPanel, BorderLayout.EAST);

  tablePanel.add(separatorPanel, BorderLayout.NORTH);

  splitter.setFirstComponent(tablePanel);
  splitter.setSecondComponent(createComments(addComp));

  return splitter;
}
 
Example #16
Source File: TipPanel.java    From IntelliJ-Key-Promoter-X with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
TipPanel() {
  setLayout(new BorderLayout());
  if (isWin10OrNewer && !isUnderDarcula()) {
    setBorder(JBUI.Borders.customLine(xD0, 1, 0, 0, 0));
  }
  myBrowser = TipUIUtil.createBrowser();
  myBrowser.getComponent().setBorder(JBUI.Borders.empty(8, 12));
  JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myBrowser.getComponent(), true);
  scrollPane.setBorder(JBUI.Borders.customLine(DIVIDER_COLOR, 0, 0, 1, 0));
  add(scrollPane, BorderLayout.CENTER);

  JLabel kpxIcon = new JBLabel(IconUtil.scale(KeyPromoterIcons.KP_ICON, this, 3.0f));
  kpxIcon.setSize(128, 128);
  kpxIcon.setBorder(JBUI.Borders.empty(0, 10));
  kpxIcon.setForeground(SimpleTextAttributes.GRAY_ITALIC_ATTRIBUTES.getFgColor());

  JLabel versionLabel = new JBLabel(KeyPromoterBundle.message("kp.tool.window.name"));
  versionLabel.setFont(new Font(versionLabel.getName(), Font.BOLD, 24));
  versionLabel.setForeground(JBUI.CurrentTheme.Label.foreground(false));
  JBBox horizontalBox = JBBox.createHorizontalBox();
  horizontalBox.setAlignmentX(.5f);
  horizontalBox.add(kpxIcon);
  horizontalBox.add(versionLabel);

  add(horizontalBox, BorderLayout.NORTH);
}
 
Example #17
Source File: ContentEntryTreeEditor.java    From consulo with Apache License 2.0 6 votes vote down vote up
public ContentEntryTreeEditor(Project project, ModuleConfigurationState state) {
  myProject = project;
  myState = state;
  myTree = new Tree();
  myTree.setRootVisible(true);
  myTree.setShowsRootHandles(true);

  myEditingActionsGroup = new DefaultActionGroup();

  TreeUtil.installActions(myTree);
  new TreeSpeedSearch(myTree);

  myTreePanel = new MyPanel(new BorderLayout());
  final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTree);
  myTreePanel.add(scrollPane, BorderLayout.CENTER);

  myTreePanel.setVisible(false);
  myDescriptor = FileChooserDescriptorFactory.createMultipleFoldersDescriptor();
  myDescriptor.setShowFileSystemRoots(false);
}
 
Example #18
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 #19
Source File: OptionsPanelImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public OptionsPanelImpl(ColorAndFontOptions options,
                        SchemesPanel schemesProvider,
                        String categoryName) {
  super(new BorderLayout());
  myOptions = options;
  mySchemesProvider = schemesProvider;
  myCategoryName = categoryName;
  myProperties = PropertiesComponent.getInstance();

  myOptionsPanel = new ColorAndFontDescriptionPanel() {
    @Override
    protected void onSettingsChanged(ActionEvent e) {
      super.onSettingsChanged(e);
      myDispatcher.getMulticaster().settingsChanged();
    }
  };

  myOptionsTree = new ColorOptionsTree(myCategoryName);

  myOptionsTree.addTreeSelectionListener(new TreeSelectionListener() {
    @Override
    public void valueChanged(TreeSelectionEvent e) {
      if (!mySchemesProvider.areSchemesLoaded()) return;
      processListValueChanged();
    }
  });

  JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myOptionsTree);
  add(scrollPane, BorderLayout.CENTER);
  add(myOptionsPanel, BorderLayout.EAST);

}
 
Example #20
Source File: ChangeListViewerDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void initCommitMessageArea(final Project project, final CommittedChangeList changeList) {
  myCommitMessageArea = new JEditorPane(UIUtil.HTML_MIME, "");
  myCommitMessageArea.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
  myCommitMessageArea.setEditable(false);
  @NonNls final String text = IssueLinkHtmlRenderer.formatTextIntoHtml(project, changeList.getComment().trim());
  myCommitMessageArea.setBackground(UIUtil.getComboBoxDisabledBackground());
  myCommitMessageArea.addHyperlinkListener(BrowserHyperlinkListener.INSTANCE);
  commitMessageScroll = ScrollPaneFactory.createScrollPane(myCommitMessageArea);
  myCommitMessageArea.setText(text);
  myCommitMessageArea.setCaretPosition(0);
}
 
Example #21
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 #22
Source File: LayoutTreeComponent.java    From consulo with Apache License 2.0 5 votes vote down vote up
public LayoutTreeComponent(ArtifactEditorImpl artifactsEditor,
                           ComplexElementSubstitutionParameters substitutionParameters,
                           ArtifactEditorContext context,
                           Artifact originalArtifact,
                           boolean sortElements) {
  myArtifactsEditor = artifactsEditor;
  mySubstitutionParameters = substitutionParameters;
  myContext = context;
  myOriginalArtifact = originalArtifact;
  mySortElements = sortElements;
  myTree = new LayoutTree(myArtifactsEditor);
  myTreeStructure = new LayoutTreeStructure();
  myBuilder = new LayoutTreeBuilder();
  Disposer.register(this, myTree);
  Disposer.register(this, myBuilder);

  myTree.addTreeSelectionListener(new TreeSelectionListener() {
    @Override
    public void valueChanged(TreeSelectionEvent e) {
      updatePropertiesPanel(false);
    }
  });
  createPropertiesPanel();
  myTreePanel = new JPanel(new BorderLayout());
  myTreePanel.add(ScrollPaneFactory.createScrollPane(myTree), BorderLayout.CENTER);
  myTreePanel.add(myPropertiesPanelWrapper, BorderLayout.SOUTH);
  if (!ApplicationManager.getApplication().isUnitTestMode()) {
    DnDManager.getInstance().registerTarget(this, myTree);
  }
}
 
Example #23
Source File: LayoutTreeComponent.java    From consulo with Apache License 2.0 5 votes vote down vote up
private SelectedElementInfo(@Nullable E element) {
  myElement = element;
  if (myElement != null) {
    //noinspection unchecked
    myCurrentPanel = element.getType().createElementPropertiesPanel(myElement, myContext);
    myPropertiesPanel.removeAll();
    if (myCurrentPanel != null) {
      myPropertiesPanel.add(BorderLayout.CENTER, ScrollPaneFactory.createScrollPane(myCurrentPanel.createComponent(), true));
      myCurrentPanel.reset();
      myPropertiesPanel.revalidate();
    }
  }
}
 
Example #24
Source File: PostfixTemplatesChildConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Nullable
@Override
public JComponent createComponent() {
  PostfixTemplateProvider postfixTemplateProvider = myExtensionPoint.getInstance();
  if (postfixTemplateProvider == null) {
    return null;
  }

  OnePixelSplitter splitter = new OnePixelSplitter();
  splitter.setSplitterProportionKey("PostfixTemplatesChildConfigurable.splitter");

  myCheckBoxList = new CheckBoxList<>();

  splitter.setFirstComponent(ScrollPaneFactory.createScrollPane(myCheckBoxList, true));

  myPostfixDescriptionPanel = new PostfixDescriptionPanel();
  JPanel component = myPostfixDescriptionPanel.getComponent();
  component.setBorder(JBUI.Borders.empty(0, 8, 0, 0));
  splitter.setSecondComponent(component);

  myCheckBoxList.setItems(new ArrayList<>(postfixTemplateProvider.getTemplates()), PostfixTemplate::getPresentableName, postfixTemplate -> Boolean.TRUE);

  myCheckBoxList.addListSelectionListener(new ListSelectionListener() {
    @Override
    public void valueChanged(ListSelectionEvent e) {
      PostfixTemplate itemAt = myCheckBoxList.getItemAt(myCheckBoxList.getSelectedIndex());

      myPostfixDescriptionPanel.reset(PostfixTemplateMetaData.createMetaData(itemAt));
    }
  });
  return splitter;
}
 
Example #25
Source File: ColumnFilteringStrategy.java    From consulo with Apache License 2.0 5 votes vote down vote up
public ColumnFilteringStrategy(final ChangeListColumn column,
                               final Class<? extends CommittedChangesProvider> providerClass) {
  myModel = new MyListModel();
  myValueList = new JBList();
  myScrollPane = ScrollPaneFactory.createScrollPane(myValueList);
  myValueList.setModel(myModel);
  myValueList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(final ListSelectionEvent e) {
      for (ChangeListener listener : myListeners) {
        listener.stateChanged(new ChangeEvent(this));
      }
    }
  });
  myValueList.setCellRenderer(new ColoredListCellRenderer() {
    protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      if (index == 0) {
        append(value.toString(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
      }
      else if (value.toString().length() == 0) {
        append(VcsBundle.message("committed.changes.filter.none"), SimpleTextAttributes.GRAYED_ATTRIBUTES);
      }
      else {
        append(value.toString(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
      }
    }
  });
  myColumn = column;
  myProviderClass = providerClass;
}
 
Example #26
Source File: XDebuggerTreePanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public XDebuggerTreePanel(final @Nonnull Project project,
                          final @Nonnull XDebuggerEditorsProvider editorsProvider,
                          @Nonnull Disposable parentDisposable,
                          final @Nullable XSourcePosition sourcePosition,
                          @Nonnull @NonNls final String popupActionGroupId,
                          @Nullable XValueMarkers<?, ?> markers) {
  myTree = new XDebuggerTree(project, editorsProvider, sourcePosition, popupActionGroupId, markers);
  myMainPanel = new JPanel(new BorderLayout());
  myMainPanel.add(ScrollPaneFactory.createScrollPane(myTree), BorderLayout.CENTER);
  Disposer.register(parentDisposable, myTree);
  Disposer.register(parentDisposable, myMainPanel::removeAll);
}
 
Example #27
Source File: DirectoryChooser.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected JComponent createCenterPanel(){
  final JPanel panel = new JPanel(new BorderLayout());

  final DefaultActionGroup actionGroup = new DefaultActionGroup();
  actionGroup.add(new FilterExistentAction());
  final JComponent toolbarComponent = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, actionGroup, true).getComponent();
  toolbarComponent.setBorder(null);
  panel.add(toolbarComponent, BorderLayout.NORTH);

  final Runnable runnable = new Runnable() {
    @Override
    public void run() {
      enableButtons();
    }
  };
  myView.onSelectionChange(runnable);
  final JComponent component = myView.getComponent();
  final JScrollPane jScrollPane = ScrollPaneFactory.createScrollPane(component);
  //noinspection HardCodedStringLiteral
  int prototypeWidth = component.getFontMetrics(component.getFont()).stringWidth("X:\\1234567890\\1234567890\\com\\company\\system\\subsystem");
  jScrollPane.setPreferredSize(new Dimension(Math.max(300, prototypeWidth),300));

  installEnterAction(component);
  panel.add(jScrollPane, BorderLayout.CENTER);
  myTabbedPaneWrapper.addTab("Directory Structure", panel);

  myChooseByNamePanel.invoke(new ChooseByNamePopupComponent.Callback() {
    @Override
    public void elementChosen(Object element) {
      setSelection(element);
    }
  }, ModalityState.stateForComponent(getRootPane()), false);
  myTabbedPaneWrapper.addTab("Choose By Neighbor Class", myChooseByNamePanel.getPanel());

  return myTabbedPaneWrapper.getComponent();
}
 
Example #28
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 #29
Source File: InstalledPluginsManagerMain.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected JScrollPane createTable() {
  myPluginsModel = new InstalledPluginsTableModel();
  myPluginTable = new PluginTable(myPluginsModel);
  myPluginTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

  JScrollPane installedScrollPane = ScrollPaneFactory.createScrollPane(myPluginTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  myPluginTable.registerKeyboardAction(e -> {
    final int column = InstalledPluginsTableModel.getCheckboxColumn();
    final int[] selectedRows = myPluginTable.getSelectedRows();
    boolean currentlyMarked = true;
    for (final int selectedRow : selectedRows) {
      if (selectedRow < 0 || !myPluginTable.isCellEditable(selectedRow, column)) {
        return;
      }
      final Boolean enabled = (Boolean)myPluginTable.getValueAt(selectedRow, column);
      currentlyMarked &= enabled == null || enabled;
    }
    final PluginDescriptor[] selected = new PluginDescriptor[selectedRows.length];
    for (int i = 0, selectedLength = selected.length; i < selectedLength; i++) {
      selected[i] = myPluginsModel.getObjectAt(myPluginTable.convertRowIndexToModel(selectedRows[i]));
    }
    ((InstalledPluginsTableModel)myPluginsModel).enableRows(selected, currentlyMarked ? Boolean.FALSE : Boolean.TRUE);
    myPluginTable.repaint();
  }, KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), JComponent.WHEN_FOCUSED);
  myPluginTable.setExpandableItemsEnabled(false);
  return installedScrollPane;
}
 
Example #30
Source File: AbstractRefactoringPanel.java    From IntelliJDeodorant with MIT License 5 votes vote down vote up
/**
 * Creates scrollable treeTable panel and adds listeners.
 *
 * @return treeTable which can display available refactorings.
 */
private JScrollPane createTablePanel() {
    treeTable.setRootVisible(false);
    treeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    treeTable.addMouseListener((DoubleClickListener) this::highlightCode);
    treeTable.addKeyListener((EnterKeyListener) this::highlightCode);
    treeTable.getTree().addTreeSelectionListener((ElementSelectionListener) this::enableRefactorButtonIfAnySelected);
    scrollPane = ScrollPaneFactory.createScrollPane(treeTable);
    return scrollPane;
}