Java Code Examples for com.intellij.ui.components.JBLabel#setBorder()

The following examples show how to use com.intellij.ui.components.JBLabel#setBorder() . 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: FlutterLogView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@NotNull
@Override
public JComponent createCustomComponent(@NotNull Presentation presentation) {
  panel = new JPanel();

  label = new JBLabel();
  label.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL));
  label.setForeground(UIUtil.getInactiveTextColor());
  label.setBorder(JBUI.Borders.emptyRight(10));
  panel.add(label);

  logTree.addListener(this, FlutterLogView.this);

  return panel;
}
 
Example 2
Source File: FlutterLogView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@NotNull
@Override
public JComponent createCustomComponent(@NotNull Presentation presentation) {
  panel = new JPanel();

  label = new JBLabel();
  label.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL));
  label.setForeground(UIUtil.getInactiveTextColor());
  label.setBorder(JBUI.Borders.emptyRight(10));
  panel.add(label);

  logTree.addListener(this, FlutterLogView.this);

  return panel;
}
 
Example 3
Source File: DetailsPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void rebuildCommitPanels(int[] selection) {
  myEmptyText.setText("");

  int selectionLength = selection.length;

  // for each commit besides the first there are two components: Separator and CommitPanel
  int existingCount = (myMainContentPanel.getComponentCount() + 1) / 2;
  int requiredCount = Math.min(selectionLength, MAX_ROWS);
  for (int i = existingCount; i < requiredCount; i++) {
    if (i > 0) {
      myMainContentPanel.add(new SeparatorComponent(0, OnePixelDivider.BACKGROUND, null));
    }
    myMainContentPanel.add(new CommitPanel(myLogData, myColorManager));
  }

  // clear superfluous items
  while (myMainContentPanel.getComponentCount() > 2 * requiredCount - 1) {
    myMainContentPanel.remove(myMainContentPanel.getComponentCount() - 1);
  }

  if (selectionLength > MAX_ROWS) {
    myMainContentPanel.add(new SeparatorComponent(0, OnePixelDivider.BACKGROUND, null));
    JBLabel label = new JBLabel("(showing " + MAX_ROWS + " of " + selectionLength + " selected commits)");
    label.setFont(VcsHistoryUtil.getCommitDetailsFont());
    label.setBorder(CommitPanel.getDetailsBorder());
    myMainContentPanel.add(label);
  }

  mySelection = Ints.asList(Arrays.copyOf(selection, requiredCount));

  repaint();
}
 
Example 4
Source File: AbstractPopup.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void setWarning(@Nonnull String text) {
  JBLabel label = new JBLabel(text, AllIcons.General.BalloonWarning, SwingConstants.CENTER);
  label.setOpaque(true);
  Color color = HintUtil.getInformationColor();
  label.setBackground(color);
  label.setBorder(BorderFactory.createLineBorder(color, 3));
  myHeaderPanel.add(label, BorderLayout.SOUTH);
}
 
Example 5
Source File: XLightBreakpointPropertiesPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void loadProperties() {
  for (XBreakpointPropertiesSubPanel panel : mySubPanels) {
    panel.loadProperties();
  }

  if (myConditionComboBox != null) {
    XExpression condition = myBreakpoint.getConditionExpressionInt();
    myConditionComboBox.setExpression(condition);
    boolean hideCheckbox = !myShowAllOptions && condition == null;
    myConditionEnabledCheckbox.setSelected(hideCheckbox || (myBreakpoint.isConditionEnabled() && condition != null));
    myConditionEnabledPanel.removeAll();
    if (hideCheckbox) {
      JBLabel label = new JBLabel(XDebuggerBundle.message("xbreakpoints.condition.checkbox"));
      label.setBorder(JBUI.Borders.empty(0, 4));
      label.setLabelFor(myConditionComboBox.getComboBox());
      myConditionEnabledPanel.add(label);
    }
    else {
      myConditionEnabledPanel.add(myConditionEnabledCheckbox);
    }

    onCheckboxChanged();
  }

  for (XBreakpointCustomPropertiesPanel customPanel : myCustomPanels) {
    customPanel.loadFrom(myBreakpoint);
  }
  myEnabledCheckbox.setSelected(myBreakpoint.isEnabled());
  myBreakpointNameLabel.setText(XBreakpointUtil.getShortText(myBreakpoint));
}
 
Example 6
Source File: VcsDirectoryConfigurationPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
private JComponent createProjectMappingDescription() {
  final JBLabel label = new JBLabel(myProjectMessage);
  label.setComponentStyle(UIUtil.ComponentStyle.SMALL);
  label.setFontColor(UIUtil.FontColor.BRIGHTER);
  label.setBorder(JBUI.Borders.empty(2, 5, 2, 0));
  return label;
}
 
Example 7
Source File: VcsDirectoryConfigurationPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
private JComponent createStoreBaseRevisionOption() {
  final JBLabel noteLabel = new JBLabel("File texts bigger than " + ourMaximumFileForBaseRevisionSize / 1000 + "K are not stored");
  noteLabel.setComponentStyle(UIUtil.ComponentStyle.SMALL);
  noteLabel.setFontColor(UIUtil.FontColor.BRIGHTER);
  noteLabel.setBorder(JBUI.Borders.empty(2, 25, 5, 0));

  final JPanel panel = new JPanel(new BorderLayout());
  panel.add(myBaseRevisionTexts, BorderLayout.NORTH);
  panel.add(noteLabel, BorderLayout.SOUTH);
  return panel;
}
 
Example 8
Source File: DaemonTooltipWithActionRenderer.java    From consulo with Apache License 2.0 5 votes vote down vote up
private JComponent createKeymapHint(String shortcutRunAction) {
  JBLabel fixHint = new JBLabel(shortcutRunAction) {
    @Override
    public Color getForeground() {
      return getKeymapColor();
    }
  };
  fixHint.setBorder(JBUI.Borders.empty());
  fixHint.setFont(getActionFont());
  return fixHint;
}
 
Example 9
Source File: JSGraphQLLanguageUIProjectService.java    From js-graphql-intellij-plugin with MIT License 4 votes vote down vote up
private void createToolWindowResultEditor(ToolWindow toolWindow) {

        final LightVirtualFile virtualFile = new LightVirtualFile("GraphQL.result.json", JsonFileType.INSTANCE, "");
        fileEditor = PsiAwareTextEditorProvider.getInstance().createEditor(myProject, virtualFile);

        if (fileEditor instanceof TextEditor) {
            final Editor editor = ((TextEditor) fileEditor).getEditor();
            final EditorEx editorEx = (EditorEx) editor;

            // set read-only mode
            editorEx.setViewer(true);
            editorEx.getSettings().setShowIntentionBulb(false);
            editor.getSettings().setAdditionalLinesCount(0);
            editor.getSettings().setCaretRowShown(false);
            editor.getSettings().setBlinkCaret(false);

            // query result header
            final JSGraphQLEditorHeaderComponent header = new JSGraphQLEditorHeaderComponent();

            querySuccessLabel = new JBLabel();
            querySuccessLabel.setVisible(false);
            querySuccessLabel.setIconTextGap(0);
            header.add(querySuccessLabel, BorderLayout.WEST);

            queryResultLabel = new JBLabel("", null, SwingConstants.LEFT);
            queryResultLabel.setBorder(new EmptyBorder(4, 6, 4, 6));
            queryResultLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            queryResultLabel.setVisible(false);
            queryResultLabel.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    final String fileUrl = (String) queryResultLabel.getClientProperty(FILE_URL_PROPERTY);
                    if (fileUrl != null) {
                        final VirtualFile queryFile = VirtualFileManager.getInstance().findFileByUrl(fileUrl);
                        if (queryFile != null) {
                            final FileEditorManager fileEditorManager = FileEditorManager.getInstance(myProject);
                            fileEditorManager.openFile(queryFile, true, true);
                        }
                    }
                }
            });
            header.add(queryResultLabel, BorderLayout.CENTER);

            // finally set the header as permanent such that it's restored after searches
            editor.setHeaderComponent(header);
            editorEx.setPermanentHeaderComponent(header);
        }

        final ContentImpl content = new ContentImpl(fileEditor.getComponent(), "Query result", true);
        content.setCloseable(false);
        content.setShouldDisposeContent(false);
        toolWindow.getContentManager().addContent(content);
        Disposer.register(content, fileEditor);
    }
 
Example 10
Source File: OuterIgnoreWrapper.java    From idea-gitignore with MIT License 4 votes vote down vote up
/** Constructor. */
@SuppressWarnings("unchecked")
public OuterIgnoreWrapper(@NotNull final Project project, @NotNull final IgnoreLanguage language,
                          @NotNull final List<VirtualFile> outerFiles) {
    this.outerFiles = outerFiles;
    settings = IgnoreSettings.getInstance();

    panel = new JPanel(new BorderLayout());
    panel.setBorder(BorderFactory.createEmptyBorder(0, 10, 5, 10));

    northPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 5));

    JBLabel label = new JBLabel(
            IgnoreBundle.message("outer.label"),
            UIUtil.ComponentStyle.REGULAR,
            UIUtil.FontColor.BRIGHTER
    );
    label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));
    northPanel.add(label);

    tabbedPanel = new TabbedPaneWrapper(project);
    messageBus = project.getMessageBus().connect();
    messageBus.subscribe(UISettingsListener.TOPIC, uiSettings -> updateTabbedPanelPolicy());
    updateTabbedPanelPolicy();

    linkLabel = new LinkLabel(
            outerFiles.get(0).getPath(),
            null,
            (aSource, aLinkData) -> Utils.openFile(project, outerFiles.get(tabbedPanel.getSelectedIndex()))
    );
    final VirtualFile userHomeDir = VfsUtil.getUserHomeDir();

    for (final VirtualFile outerFile : outerFiles) {
        Document document = FileDocumentManager.getInstance().getDocument(outerFile);
        Editor outerEditor = document != null ? Utils.createPreviewEditor(document, null, true) : null;

        if (outerEditor != null) {
            final JScrollPane scrollPanel = ScrollPaneFactory.createScrollPane(outerEditor.getComponent());
            scrollPanel.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
            scrollPanel.setPreferredSize(new Dimension(0, settings.getOuterIgnoreWrapperHeight()));

            String path = outerFile.getPath();
            if (userHomeDir != null) {
                path = path.replace(userHomeDir.getPath(), "~");
            }

            Icon icon = ((language instanceof GitLanguage) || (language instanceof GitExcludeLanguage))
                    ? AllIcons.Vcs.Ignore_file : language.getIcon();

            tabbedPanel.addTab(path, icon, scrollPanel, outerFile.getCanonicalPath());
            outerEditors.add(outerEditor);
        }
    }

    northPanel.addMouseListener(this);
    northPanel.addMouseMotionListener(this);
    tabbedPanel.addChangeListener(this);

    panel.add(northPanel, BorderLayout.NORTH);
    panel.add(tabbedPanel.getComponent(), BorderLayout.CENTER);
    panel.add(linkLabel, BorderLayout.SOUTH);
}
 
Example 11
Source File: FormBuilder.java    From consulo with Apache License 2.0 4 votes vote down vote up
public FormBuilder addTooltip(final String text) {
  final JBLabel label = new JBLabel(text, UIUtil.ComponentStyle.SMALL, UIUtil.FontColor.BRIGHTER);
  label.setBorder(new EmptyBorder(0, 10, 0, 0));
  return addComponentToRightColumn(label, 1);
}