com.intellij.ui.components.JBLabel Java Examples

The following examples show how to use com.intellij.ui.components.JBLabel. 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: AsyncPopupImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected JComponent createContent() {
  if (myPanel != null) return myPanel;
  myPanel = new JPanel(new BorderLayout());
  //myPanel.add(new AsyncProcessIcon("Async Popup Step"), BorderLayout.WEST);
  JBLabel label = new JBLabel("Loading...");
  label.setForeground(UIUtil.getLabelDisabledForeground());
  myPanel.add(label, BorderLayout.CENTER);
  myPanel.setBorder(new EmptyBorder(UIUtil.getListCellPadding()));
  myPanel.setBackground(UIUtil.getListBackground());
  myPanel.registerKeyboardAction(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      goBack();
    }
  }, KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), JComponent.WHEN_FOCUSED);
  return myPanel;
}
 
Example #2
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 #3
Source File: UsageViewImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void addButtonAction(int index, @Nonnull Action action) {
  JButton button = new JButton(action);
  add(button, index);
  DialogUtil.registerMnemonic(button);

  if (getBorder() == null) setBorder(IdeBorderFactory.createBorder(SideBorder.TOP));
  update();
  Object s = action.getValue(Action.LONG_DESCRIPTION);
  if (s instanceof String) {
    JBLabel label = new JBLabel((String)s);
    label.setEnabled(false);
    label.setFont(JBUI.Fonts.smallFont());
    add(JBUI.Borders.emptyLeft(-1).wrap(label));
  }
  s = action.getValue(Action.SHORT_DESCRIPTION);
  if (s instanceof String) {
    button.setToolTipText((String)s);
  }
  invalidate();
  if (getParent() != null) {
    getParent().validate();
  }
}
 
Example #4
Source File: TextNodeRenderer.java    From buck with Apache License 2.0 6 votes vote down vote up
@Override
public Component render(Object value) {
  BuckTextNode node = (BuckTextNode) value;

  if (node.getText().isEmpty()) {
    return new JLabel("");
  }

  Icon icon = AllIcons.General.Information;
  if (node.getTextType() == BuckTextNode.TextType.ERROR) {
    icon = AllIcons.Ide.FatalError;
  } else if (node.getTextType() == BuckTextNode.TextType.WARNING) {
    icon = AllIcons.General.Warning;
  }

  String message =
      "<html><pre style='margin:0px'>"
          + HtmlEscapers.htmlEscaper().escape(node.getText())
          + "</pre></html>";

  JBLabel result = new JBLabel(message, icon, SwingConstants.LEFT);

  result.setToolTipText("<pre>" + node.getText() + "</pre>");

  return result;
}
 
Example #5
Source File: FileErrorNodeRenderer.java    From buck with Apache License 2.0 6 votes vote down vote up
@Override
public Component render(Object value) {

  JBLabel result =
      new JBLabel(
          ((BuckFileErrorNode) value).getText(),
          AllIcons.Ide.Warning_notifications,
          SwingConstants.HORIZONTAL);

  BuckFileErrorNode buckNode = (BuckFileErrorNode) value;
  for (int i = 0; i < buckNode.getChildCount(); i++) {
    BuckTextNode childNode = (BuckTextNode) buckNode.getChildAt(i);
    if (childNode.getTextType() == BuckTextNode.TextType.ERROR) {
      result.setIcon(AllIcons.Ide.Error);
      result.setForeground(Color.RED);
      break;
    }
  }
  return result;
}
 
Example #6
Source File: BuckTreeCellRenderer.java    From buck with Apache License 2.0 6 votes vote down vote up
@Override
public Component getTreeCellRendererComponent(
    JTree tree,
    Object value,
    boolean selected,
    boolean expanded,
    boolean leaf,
    int row,
    boolean hasFocus) {

  Class<?> cc = value.getClass();
  if (mRenderers.containsKey(cc)) {
    TreeNodeRenderer renderer = mRenderers.get(value.getClass());
    return renderer.render(value);
  }
  return new JBLabel("unknown kind of element");
}
 
Example #7
Source File: DiffUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static JComponent createTitle(@Nonnull String title,
                                     @Nullable Charset charset,
                                     @Nullable LineSeparator separator,
                                     boolean readOnly) {
  if (readOnly) title += " " + DiffBundle.message("diff.content.read.only.content.title.suffix");

  JPanel panel = new JPanel(new BorderLayout());
  panel.setBorder(IdeBorderFactory.createEmptyBorder(0, 4, 0, 4));
  panel.add(new JBLabel(title).setCopyable(true), BorderLayout.CENTER);
  if (charset != null && separator != null) {
    JPanel panel2 = new JPanel();
    panel2.setLayout(new BoxLayout(panel2, BoxLayout.X_AXIS));
    panel2.add(createCharsetPanel(charset));
    panel2.add(Box.createRigidArea(new Dimension(4, 0)));
    panel2.add(createSeparatorPanel(separator));
    panel.add(panel2, BorderLayout.EAST);
  }
  else if (charset != null) {
    panel.add(createCharsetPanel(charset), BorderLayout.EAST);
  }
  else if (separator != null) {
    panel.add(createSeparatorPanel(separator), BorderLayout.EAST);
  }
  return panel;
}
 
Example #8
Source File: CommentNodeRenderer.java    From Crucible4IDEA with MIT License 6 votes vote down vote up
CommentRendererPanel() {
  super(new BorderLayout());
  setOpaque(false);

  myIconLabel = new JBLabel();
  myMessageLabel = new JBLabel();
  myMessageLabel.setOpaque(false);

  JPanel actionsPanel = new JPanel();
  myPostLink = new LinkLabel("Publish", null);
  actionsPanel.add(myPostLink);

  myMainPanel = new JPanel(new GridBagLayout());
  GridBag bag = new GridBag()
    .setDefaultInsets(UIUtil.DEFAULT_VGAP, UIUtil.DEFAULT_HGAP, UIUtil.DEFAULT_VGAP, UIUtil.DEFAULT_HGAP)
    .setDefaultPaddingY(UIUtil.DEFAULT_VGAP);
  myMainPanel.add(myIconLabel, bag.next().coverColumn().anchor(GridBagConstraints.NORTHWEST).weightx(0.1));
  myMainPanel.add(myMessageLabel, bag.next().fillCell().anchor(GridBagConstraints.NORTH).weightx(1.0));
  myMainPanel.add(myPostLink, bag.nextLine().anchor(GridBagConstraints.SOUTHEAST));

  add(myMainPanel);
}
 
Example #9
Source File: ReportDialog.java    From PackageTemplates with Apache License 2.0 6 votes vote down vote up
private void addFailed(final BaseReport report) {
    //Icon
    JBLabel iconLabel = new JBLabel(PluginIcons.REPORT_FAIL);
    iconLabel.setToolTipText(Localizer.get("tooltip.ReportFailed"));

    //Label
    JBLabel label = new JBLabel(report.getAction().toString(), report.toIcon(), SwingConstants.LEFT);

    // Button details
    JButton btnDetails = new JButton(Localizer.get("action.ShowDetails"), AllIcons.General.InspectionsEye);
    btnDetails.repaint();
    btnDetails.addMouseListener(new ClickListener() {
        @Override
        public void mouseClicked(MouseEvent e) {
            Messages.showMessageDialog(
                    report.getMessage(),
                    Localizer.get("title.ErrorDetails"),
                    Messages.getInformationIcon()
            );
        }
    });

    panel.add(iconLabel, new CC().spanX().split(3));
    panel.add(label, new CC());
    panel.add(btnDetails, new CC().wrap().pad(0, 0, 0, 0));
}
 
Example #10
Source File: LibraryDialog.java    From PackageTemplates with Apache License 2.0 6 votes vote down vote up
private void createBinaryFileList() {
    ArrayList<Pair<String, BinaryFileLibModel>> libModels = new ArrayList<>();
    libModels.add(new Pair<>("key1", new BinaryFileLibModel("C:/foo/bar/path1")));
    libModels.add(new Pair<>("key2", new BinaryFileLibModel("C:/foo/bar/path2")));
    libModels.add(new Pair<>("key3", new BinaryFileLibModel("C:/foo/bar/path3")));


    listBinaryFiles = new JBList<>(libModels);
    listBinaryFiles.setCellRenderer((list, value, index, isSelected, cellHasFocus) -> {
        return new JBLabel(value.first);
    });
    listBinaryFiles.addListSelectionListener(arg0 -> {
        if (!arg0.getValueIsAdjusting()) {
            presenter.onBinaryFileSelected(listBinaryFiles.getSelectedValue());
        }
    });

}
 
Example #11
Source File: Switcher.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
private static JPanel createTopPanel(@Nonnull JBCheckBox showOnlyEditedFilesCheckBox, @Nonnull String title, boolean isMovable) {
  JPanel topPanel = new CaptionPanel();
  JBLabel titleLabel = new JBLabel(title);
  titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD));
  topPanel.add(titleLabel, BorderLayout.WEST);
  topPanel.add(showOnlyEditedFilesCheckBox, BorderLayout.EAST);

  Dimension size = topPanel.getPreferredSize();
  size.height = JBUIScale.scale(29);
  size.width = titleLabel.getPreferredSize().width + showOnlyEditedFilesCheckBox.getPreferredSize().width + JBUIScale.scale(50);
  topPanel.setPreferredSize(size);
  topPanel.setMinimumSize(size);
  topPanel.setBorder(JBUI.Borders.empty(5, 8));

  if (isMovable) {
    WindowMoveListener moveListener = new WindowMoveListener(topPanel);
    topPanel.addMouseListener(moveListener);
    topPanel.addMouseMotionListener(moveListener);
  }

  return topPanel;
}
 
Example #12
Source File: JavaExtractSuperBaseDialog.java    From intellij-haxe with Apache License 2.0 6 votes vote down vote up
@Override
protected JPanel createDestinationRootPanel() {
  final List<VirtualFile> sourceRoots = JavaProjectRootsUtil.getSuitableDestinationSourceRoots(myProject);
  if (sourceRoots.size() <= 1) return super.createDestinationRootPanel();
  final JPanel panel = new JPanel(new BorderLayout());
  panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
  final JBLabel label = new JBLabel(RefactoringBundle.message("target.destination.folder"));
  panel.add(label, BorderLayout.NORTH);
  label.setLabelFor(myDestinationFolderComboBox);
  myDestinationFolderComboBox.setData(myProject, myTargetDirectory, new Pass<String>() {
    @Override
    public void pass(String s) {
    }
  }, ((PackageNameReferenceEditorCombo)myPackageNameField).getChildComponent());
  panel.add(myDestinationFolderComboBox, BorderLayout.CENTER);
  return panel;
}
 
Example #13
Source File: FlutterView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void updateForEmptyContent(ToolWindow toolWindow) {
  // There's a possible race here where the tool window gets disposed while we're displaying contents.
  if (toolWindow.isDisposed()) {
    return;
  }

  toolWindow.setIcon(FlutterIcons.Flutter_13);

  // Display a 'No running applications' message.
  final ContentManager contentManager = toolWindow.getContentManager();
  final JPanel panel = new JPanel(new BorderLayout());
  final JBLabel label = new JBLabel("No running applications", SwingConstants.CENTER);
  label.setForeground(UIUtil.getLabelDisabledForeground());
  panel.add(label, BorderLayout.CENTER);
  emptyContent = contentManager.getFactory().createContent(panel, null, false);
  contentManager.addContent(emptyContent);
}
 
Example #14
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 #15
Source File: ErrorPanel.java    From nosql4idea with Apache License 2.0 6 votes vote down vote up
public ErrorPanel(final Exception ex) {
    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
    JBLabel comp = new JBLabel("Error during query execution:");
    comp.setForeground(JBColor.RED);
    add(comp);
    final HoverHyperlinkLabel hoverHyperlinkLabel = new HoverHyperlinkLabel("more detail...");
    hoverHyperlinkLabel.addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) {
            if (hyperlinkEvent.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                Messages.showErrorDialog(ex.toString(), "Error During Query Execution");
            }
        }
    });
    add(Box.createRigidArea(new Dimension(10, 10)));
    add(hoverHyperlinkLabel);

}
 
Example #16
Source File: EarlyAccessProgramConfigurable.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static JComponent createWarningPanel() {
  VerticalLayoutPanel panel = JBUI.Panels.verticalPanel();
  panel.setBackground(LightColors.RED);
  panel.setBorder(new CompoundBorder(JBUI.Borders.customLine(JBColor.GRAY), JBUI.Borders.empty(5)));

  JBLabel warnLabel = new JBLabel("WARNING", AllIcons.General.BalloonWarning, SwingConstants.LEFT);
  warnLabel.setFont(UIUtil.getFont(UIUtil.FontSize.BIGGER, warnLabel.getFont()).deriveFont(Font.BOLD));
  panel.addComponent(warnLabel);
  JTextArea textArea = new JTextArea(IdeBundle.message("eap.configurable.warning.text"));
  textArea.setLineWrap(true);
  textArea.setFont(JBUI.Fonts.label());
  textArea.setOpaque(false);
  textArea.setEditable(false);
  panel.addComponent(textArea);
  return panel;
}
 
Example #17
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 #18
Source File: OpenBlazeWorkspaceFileAction.java    From intellij with Apache License 2.0 6 votes vote down vote up
OpenBlazeWorkspaceFileActionDialog(
    Project project, WorkspacePathResolver workspacePathResolver) {
  super(project, /* canBeParent= */ false, IdeModalityType.PROJECT);
  this.project = project;

  component = new JPanel(new GridBagLayout());
  FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileDescriptor();
  fileTextField =
      WorkspaceFileTextField.create(
          workspacePathResolver, descriptor, PATH_FIELD_WIDTH, myDisposable);

  component.add(new JBLabel("Path:"));
  component.add(fileTextField.getField(), UiUtil.getFillLineConstraints(0));

  UiUtil.fillBottom(component);
  init();
}
 
Example #19
Source File: FlutterPerformanceView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void updateForEmptyContent(ToolWindow toolWindow) {
  // There's a possible race here where the tool window gets disposed while we're displaying contents.
  if (toolWindow.isDisposed()) {
    return;
  }

  toolWindow.setIcon(FlutterIcons.Flutter_13);

  // Display a 'No running applications' message.
  final ContentManager contentManager = toolWindow.getContentManager();
  final JPanel panel = new JPanel(new BorderLayout());
  final JBLabel label = new JBLabel("No running applications", SwingConstants.CENTER);
  label.setForeground(UIUtil.getLabelDisabledForeground());
  panel.add(label, BorderLayout.CENTER);
  emptyContent = contentManager.getFactory().createContent(panel, null, false);
  contentManager.addContent(emptyContent);
}
 
Example #20
Source File: ReplacementView.java    From consulo with Apache License 2.0 5 votes vote down vote up
public ReplacementView(@Nullable String replacement) {
  String textToShow = StringUtil.notNullize(replacement, MALFORMED_REPLACEMENT_STRING);
  textToShow = StringUtil.escapeXmlEntities(StringUtil.shortenTextWithEllipsis(textToShow, 500, 0, true)).replaceAll("\n+", "\n").replace("\n", "<br>");
  //noinspection HardCodedStringLiteral
  JLabel jLabel = new JBLabel("<html>" + textToShow).setAllowAutoWrapping(true);
  jLabel.setForeground(replacement != null ? new JBColor(Gray._240, Gray._200) : JBColor.RED);
  add(jLabel);
}
 
Example #21
Source File: BuckCommandToolEditorDialog.java    From buck with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
protected JPanel createCenterPanel() {
  JPanel panel = new JPanel(new GridBagLayout());
  GridBagConstraints c = new GridBagConstraints();
  c.fill = GridBagConstraints.HORIZONTAL;
  c.gridx = 0;
  c.gridy = 0;
  label = new JBLabel("Arguments:");
  panel.add(label, c);
  commandLineEditor = new RawCommandLineEditor();
  c.gridy = 1;
  panel.add(commandLineEditor, c);
  return panel;
}
 
Example #22
Source File: ShowAmbigTreesDialog.java    From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void popupAmbigTreesDialog(PreviewState previewState, AmbiguityInfo ambigInfo) {
	// pop up subtrees for ambig intrepretation
	ShowAmbigTreesDialog dialog = new ShowAmbigTreesDialog();
	Parser parser = previewState.parsingResult.parser;
	int startRuleIndex = parser.getRuleIndex(previewState.startRuleName);
	List<ParserRuleContext> ambiguousParseTrees = null;
	try {
		ambiguousParseTrees =
			GrammarParserInterpreter.getAllPossibleParseTrees(previewState.g,
			                                                  parser,
			                                                  parser.getTokenStream(),
			                                                  ambigInfo.decision,
			                                                  ambigInfo.ambigAlts,
			                                                  ambigInfo.startIndex,
			                                                  ambigInfo.stopIndex,
			                                                  startRuleIndex);
	} catch (ParseCancellationException pce) {
		// should be no errors for ambiguities, unless original
		// input itself has errors. Just display error in this case.
		JBPanel errPanel = new JBPanel(new BorderLayout());
		errPanel.add(new JBLabel("Cannot display ambiguous trees while there are syntax errors in your input."));
		dialog.treeScrollPane.setViewportView(errPanel);
	}

	if ( ambiguousParseTrees!=null ) {
		TokenStream tokens = previewState.parsingResult.parser.getInputStream();
		String phrase = tokens.getText(Interval.of(ambigInfo.startIndex, ambigInfo.stopIndex));
		if ( phrase.length()>MAX_PHRASE_WIDTH ) {
			phrase = phrase.substring(0, MAX_PHRASE_WIDTH)+"...";
		}
		String title = ambiguousParseTrees.size()+
			" Interpretations of Ambiguous Input Phrase: "+
			phrase;
		dialog.ambigPhraseLabel.setText(title);
		dialog.setTrees(previewState, ambiguousParseTrees, title, 0, true);
	}

	dialog.pack();
	dialog.setVisible(true);
}
 
Example #23
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 #24
Source File: SettingComponent.java    From intellij with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a {@link LabeledComponent} for the given label text and Swing component.
 *
 * @param getter a {@link Getter} for accessing the component's value
 * @param setter a {@link Setter} for modifying the component's value
 */
public static <T, C extends JComponent> LabeledComponent<T, C> create(
    String label, C component, Getter<C, T> getter, Setter<C, T> setter) {

  JBLabel labelComponent = new JBLabel(label);
  labelComponent.setLabelFor(component);
  Property<T> property = Property.create(() -> component, getter, setter);

  return new LabeledComponent<>(labelComponent, component, property);
}
 
Example #25
Source File: BlazeCommandRunConfiguration.java    From intellij with Apache License 2.0 5 votes vote down vote up
BlazeCommandRunConfigurationSettingsEditor(BlazeCommandRunConfiguration config) {
  Project project = config.getProject();
  elementState = config.blazeElementState.clone();
  targetsUi = new TargetExpressionListUi(project);
  targetExpressionLabel = new JBLabel(UIUtil.ComponentStyle.LARGE);
  keepInSyncCheckBox = new JBCheckBox("Keep in sync with source XML");
  outputFileUi = new ConsoleOutputFileSettingsUi<>();
  editorWithoutSyncCheckBox = UiUtil.createBox(targetExpressionLabel, targetsUi);
  editor =
      UiUtil.createBox(
          editorWithoutSyncCheckBox, outputFileUi.getComponent(), keepInSyncCheckBox);
  updateEditor(config);
  updateHandlerEditor(config);
  keepInSyncCheckBox.addItemListener(e -> updateEnabledStatus());
}
 
Example #26
Source File: ProjectViewUi.java    From intellij with Apache License 2.0 5 votes vote down vote up
public void fillUi(JPanel canvas) {
  String tooltip =
      "Enter a project view descriptor file."
          + (Blaze.defaultBuildSystem() == BuildSystem.Blaze
              ? " See 'go/intellij/docs/project-views.md' for more information."
              : "");

  projectViewEditor = createEditor(tooltip);
  projectViewEditor
      .getColorsScheme()
      .setColor(EditorColors.READONLY_BACKGROUND_COLOR, UIManager.getColor("Label.background"));
  Disposer.register(
      parentDisposable, () -> EditorFactory.getInstance().releaseEditor(projectViewEditor));

  JBLabel labelsLabel = new JBLabel("Project View");
  labelsLabel.setToolTipText(tooltip);
  canvas.add(labelsLabel, UiUtil.getFillLineConstraints(0));

  canvas.add(projectViewEditor.getComponent(), UiUtil.getFillLineConstraints(0));

  useShared = new JCheckBox(USE_SHARED_PROJECT_VIEW);
  useShared.addActionListener(
      e -> {
        useSharedProjectView = useShared.isSelected();
        if (useSharedProjectView) {
          setProjectViewText(sharedProjectViewText);
        }
        updateTextAreasEnabled();
      });
  canvas.add(useShared, UiUtil.getFillLineConstraints(0));
}
 
Example #27
Source File: RecentLocationsAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static JLabel createTitle(boolean showChanged) {
  JBLabel title = new JBLabel();
  title.setFont(title.getFont().deriveFont(Font.BOLD));
  updateTitleText(title, showChanged);
  return title;
}
 
Example #28
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 #29
Source File: CertificateInfoPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void updateBuilderWithPrincipalData(FormBuilder builder, Map<String, String> fields) {
  builder = builder.setIndent(IdeBorderFactory.TITLED_BORDER_INDENT);
  for (CommonField field : CommonField.values()) {
    String value = fields.get(field.getShortName());
    if (value == null) {
      continue;
    }
    String label = String.format("<html>%s (<b>%s</b>)</html>", field.getShortName(), field.getLongName());
    builder = builder.addLabeledComponent(label, new JBLabel(value));
  }
  builder.setIndent(0);
}
 
Example #30
Source File: InplaceChangeSignature.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected void showBalloon() {
  NonFocusableCheckBox checkBox = new NonFocusableCheckBox(RefactoringBundle.message("delegation.panel.delegate.via.overloading.method"));
  checkBox.addActionListener(e -> {
    myDelegate = checkBox.isSelected();
    updateCurrentInfo();
  });
  JPanel content = new JPanel(new BorderLayout());
  content.add(new JBLabel("Performed signature modifications:"), BorderLayout.NORTH);
  content.add(myPreview.getComponent(), BorderLayout.CENTER);
  updateMethodSignature(myStableChange);
  content.add(checkBox, BorderLayout.SOUTH);
  final BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createDialogBalloonBuilder(content, null).setSmallVariant(true);
  myBalloon = balloonBuilder.createBalloon();
  myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
  myBalloon.show(new PositionTracker<Balloon>(myEditor.getContentComponent()) {
    @Override
    public RelativePoint recalculateLocation(Balloon object) {
      int offset = myStableChange.getMethod().getTextOffset();
      VisualPosition visualPosition = myEditor.offsetToVisualPosition(offset);
      Point point = myEditor.visualPositionToXY(new VisualPosition(visualPosition.line, visualPosition.column));
      return new RelativePoint(myEditor.getContentComponent(), point);
    }
  }, Balloon.Position.above);
  Disposer.register(myBalloon, () -> {
    EditorFactory.getInstance().releaseEditor(myPreview);
    myPreview = null;
  });
}