Java Code Examples for com.intellij.util.ui.FormBuilder#addLabeledComponent()

The following examples show how to use com.intellij.util.ui.FormBuilder#addLabeledComponent() . 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: CertificateInfoPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
public CertificateInfoPanel(@Nonnull X509Certificate certificate) {
  myCertificateWrapper = new CertificateWrapper(certificate);
  setLayout(new BorderLayout());

  FormBuilder builder = FormBuilder.createFormBuilder();

  // I'm not using separate panels and form builders to preserve alignment of labels
  updateBuilderWithTitle(builder, "Issued To");
  updateBuilderWithPrincipalData(builder, myCertificateWrapper.getSubjectFields());
  updateBuilderWithTitle(builder, "Issued By");
  updateBuilderWithPrincipalData(builder, myCertificateWrapper.getIssuerFields());
  updateBuilderWithTitle(builder, "Validity Period");
  String notBefore = DATE_FORMAT.format(myCertificateWrapper.getNotBefore());
  String notAfter = DATE_FORMAT.format(myCertificateWrapper.getNotAfter());
  builder = builder
    .setIndent(IdeBorderFactory.TITLED_BORDER_INDENT)
    .addLabeledComponent("Valid from:", createColoredComponent(notBefore, "not yet valid", myCertificateWrapper.isNotYetValid()))
    .addLabeledComponent("Valid until:", createColoredComponent(notAfter, "expired", myCertificateWrapper.isExpired()));
  builder.setIndent(0);
  updateBuilderWithTitle(builder, "Fingerprints");
  builder.setIndent(IdeBorderFactory.TITLED_BORDER_INDENT);
  builder.addLabeledComponent("SHA-256:", getTextPane(formatHex(myCertificateWrapper.getSha256Fingerprint())));
  builder.addLabeledComponent("SHA-1:", getTextPane(formatHex(myCertificateWrapper.getSha1Fingerprint())));
  add(builder.getPanel(), BorderLayout.NORTH);
}
 
Example 2
Source File: QuarkusModuleInfoStep.java    From intellij-quarkus with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void _init() {
    ProgressIndicator indicator = new EmptyProgressIndicator() {
        @Override
        public void setText(String text) {
            SwingUtilities.invokeLater(() -> panel.setLoadingText(text));
        }
    };
    try {
        QuarkusModel model = QuarkusModelRegistry.INSTANCE.load(context.getUserData(QuarkusConstants.WIZARD_ENDPOINT_URL_KEY), indicator);
        context.putUserData(QuarkusConstants.WIZARD_MODEL_KEY, model);
        final FormBuilder formBuilder = new FormBuilder();
        final CollectionComboBoxModel<ToolDelegate> toolModel = new CollectionComboBoxModel<>(Arrays.asList(ToolDelegate.getDelegates()));
        toolComboBox = new ComboBox<>(toolModel);
        toolComboBox.setRenderer(new ColoredListCellRenderer<ToolDelegate>() {
            @Override
            protected void customizeCellRenderer(@NotNull JList<? extends ToolDelegate> list, ToolDelegate toolDelegate, int index, boolean selected, boolean hasFocus) {
                this.append(toolDelegate.getDisplay());
            }
        });
        formBuilder.addLabeledComponent("Tool:", toolComboBox);
        groupIdField = new JBTextField("org.acme");
        formBuilder.addLabeledComponent("Group:", groupIdField);
        artifactIdField = new JBTextField("code-with-quarkus");
        formBuilder.addLabeledComponent("Artifact:", artifactIdField);
        versionField = new JBTextField("1.0.0-SNAPSHOT");
        formBuilder.addLabeledComponent("Version:", versionField);
        classNameField = new JBTextField("org.acme.ExampleResource");
        formBuilder.addLabeledComponent("Class name:", classNameField);
        pathField = new JBTextField("/hello");
        formBuilder.addLabeledComponent("Path:", pathField);
        panel.add(ScrollPaneFactory.createScrollPane(formBuilder.getPanel(), true), "North");
    } catch (IOException e) {
        LOGGER.error(e.getLocalizedMessage(), e);
        throw new RuntimeException(e);
    }
}
 
Example 3
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 4
Source File: CreateNewLibraryDialog.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected void addNorthComponents(FormBuilder formBuilder) {
  formBuilder.addLabeledComponent("&Level:", myLibraryLevelCombobox);
}
 
Example 5
Source File: CopyFilesOrDirectoriesDialog.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected JComponent createNorthPanel() {
  myInformationLabel = JBLabelDecorator.createJBLabelDecorator().setBold(true);
  final FormBuilder formBuilder = FormBuilder.createFormBuilder().addComponent(myInformationLabel).addVerticalGap(
    UIUtil.LARGE_VGAP - UIUtil.DEFAULT_VGAP);
  DocumentListener documentListener = new DocumentAdapter() {
    @Override
    public void textChanged(DocumentEvent event) {
      validateOKButton();
    }
  };

  if (myShowNewNameField) {
    myNewNameField = new JTextField();
    myNewNameField.getDocument().addDocumentListener(documentListener);
    formBuilder.addLabeledComponent(RefactoringBundle.message("copy.files.new.name.label"), myNewNameField);
  }

  if (myShowDirectoryField) {
    myTargetDirectoryField = new TextFieldWithHistoryWithBrowseButton();
    myTargetDirectoryField.setTextFieldPreferredWidth(MAX_PATH_LENGTH);
    final List<String> recentEntries = RecentsManager.getInstance(myProject).getRecentEntries(RECENT_KEYS);
    if (recentEntries != null) {
      myTargetDirectoryField.getChildComponent().setHistory(recentEntries);
    }
    final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    myTargetDirectoryField.addBrowseFolderListener(RefactoringBundle.message("select.target.directory"),
                                                   RefactoringBundle.message("the.file.will.be.copied.to.this.directory"),
                                                   myProject, descriptor,
                                                   TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT);
    myTargetDirectoryField.getChildComponent().addDocumentListener(new DocumentAdapter() {
      @Override
      protected void textChanged(DocumentEvent e) {
        validateOKButton();
      }
    });
    formBuilder.addLabeledComponent(RefactoringBundle.message("copy.files.to.directory.label"), myTargetDirectoryField);

    String shortcutText =
      KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_CODE_COMPLETION));
    formBuilder.addTooltip(RefactoringBundle.message("path.completion.shortcut", shortcutText));
  }

  final JPanel wrapper = new JPanel(new BorderLayout());
  wrapper.add(myOpenFilesInEditor, BorderLayout.EAST);
  formBuilder.addComponent(wrapper);
  return formBuilder.getPanel();
}