com.intellij.ui.components.panels.VerticalLayout Java Examples

The following examples show how to use com.intellij.ui.components.panels.VerticalLayout. 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: SelectBazelBinaryControl.java    From intellij with Apache License 2.0 6 votes vote down vote up
private void initUi() {
  bazelBinaryPath =
      FileSelectorWithStoredHistory.create(
          BlazeUserSettingsConfigurable.BAZEL_BINARY_PATH_KEY, "Specify the bazel binary path");
  bazelBinaryPath.setText(getInitialBinaryPath());
  bazelBinaryPath.setName("bazel-binary-path-field");

  component = new JPanel(new VerticalLayout(4));
  component.add(new JLabel("Select a bazel binary"));
  component.add(new JSeparator());

  JPanel content = new JPanel(new VerticalLayout(12));
  content.setBorder(Borders.empty(50, 100, 0, 100));
  component.add(content);

  content.add(new JLabel("Specify a bazel binary to be used for all bazel projects"));
  content.add(bazelBinaryPath);
}
 
Example #2
Source File: AddSourceToProjectDialog.java    From intellij with Apache License 2.0 6 votes vote down vote up
AddSourceToProjectDialog(Project project, List<TargetInfo> targets) {
  super(project, /* canBeParent= */ true, IdeModalityType.MODELESS);
  this.project = project;

  mainPanel = new JPanel(new VerticalLayout(12));

  JList<TargetInfo> targetsComponent = new JBList<>(targets);
  if (targets.size() == 1) {
    targetsComponent.setSelectedIndex(0);
  }
  this.targetsComponent = targetsComponent;

  setTitle("Add Source File to Project");
  setupUi();
  init();
}
 
Example #3
Source File: WidgetPerfTipsPanel.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public WidgetPerfTipsPanel(Disposable parentDisposable, @NotNull FlutterApp app) {
  setLayout(new VerticalLayout(5));

  add(new JSeparator());

  perfManager = FlutterWidgetPerfManager.getInstance(app.getProject());
  perfTips = new JPanel();
  perfTips.setLayout(new VerticalLayout(0));

  linkListener = (source, tip) -> handleTipSelection(tip);
  final Project project = app.getProject();
  final MessageBusConnection bus = project.getMessageBus().connect(project);
  final FileEditorManagerListener listener = new FileEditorManagerListener() {
    @Override
    public void selectionChanged(@NotNull FileEditorManagerEvent event) {
      selectedEditorChanged();
    }
  };
  selectedEditorChanged();
  bus.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, listener);

  // Computing performance tips is somewhat expensive so we don't want to
  // compute them too frequently. Performance tips are only computed when
  // new performance stats are available but performance stats are updated
  // at 60fps so to be conservative we delay computing perf tips.
  final Timer perfTipComputeDelayTimer = new Timer(PERF_TIP_COMPUTE_DELAY, this::onComputePerfTips);
  perfTipComputeDelayTimer.start();
  Disposer.register(parentDisposable, perfTipComputeDelayTimer::stop);
}
 
Example #4
Source File: WidgetPerfTipsPanel.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public WidgetPerfTipsPanel(Disposable parentDisposable, @NotNull FlutterApp app) {
  setLayout(new VerticalLayout(5));

  add(new JSeparator());

  perfManager = FlutterWidgetPerfManager.getInstance(app.getProject());
  perfTips = new JPanel();
  perfTips.setLayout(new VerticalLayout(0));

  linkListener = (source, tip) -> handleTipSelection(tip);
  final Project project = app.getProject();
  final MessageBusConnection bus = project.getMessageBus().connect(project);
  final FileEditorManagerListener listener = new FileEditorManagerListener() {
    @Override
    public void selectionChanged(@NotNull FileEditorManagerEvent event) {
      selectedEditorChanged();
    }
  };
  selectedEditorChanged();
  bus.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, listener);

  // Computing performance tips is somewhat expensive so we don't want to
  // compute them too frequently. Performance tips are only computed when
  // new performance stats are available but performance stats are updated
  // at 60fps so to be conservative we delay computing perf tips.
  final Timer perfTipComputeDelayTimer = new Timer(PERF_TIP_COMPUTE_DELAY, this::onComputePerfTips);
  perfTipComputeDelayTimer.start();
  Disposer.register(parentDisposable, perfTipComputeDelayTimer::stop);
}
 
Example #5
Source File: CamelIgnoreAndExcludePage.java    From camel-idea-plugin with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public JComponent createComponent() {
    result = new JPanel(new BorderLayout());
    JPanel propertyTablePanel = new JPanel(new VerticalLayout(1));
    propertyTablePanel.add(createIgnorePropertiesFilesTable());
    propertyTablePanel.add(createExcludePropertiesFilesTable());
    result.add(propertyTablePanel);

    return result;
}
 
Example #6
Source File: UseExistingBazelWorkspaceOption.java    From intellij with Apache License 2.0 5 votes vote down vote up
public UseExistingBazelWorkspaceOption(BlazeNewProjectBuilder builder) {
  directoryField = new TextFieldWithHistory();
  directoryField.setName("workspace-directory-field");
  directoryField.setHistory(builder.getWorkspaceHistory(BuildSystem.Bazel));
  directoryField.setHistorySize(BlazeNewProjectBuilder.HISTORY_SIZE);
  directoryField.setText(builder.getLastImportedWorkspace(BuildSystem.Bazel));
  directoryField.setMinimumAndPreferredWidth(MINIMUM_FIELD_WIDTH);

  JButton button = new JButton("...");
  button.addActionListener(action -> this.chooseDirectory());
  int buttonSize = this.directoryField.getPreferredSize().height;
  button.setPreferredSize(new Dimension(buttonSize, buttonSize));

  JPanel canvas = new JPanel(new VerticalLayout(4));
  canvas.setPreferredSize(ProjectViewUi.getContainerSize());
  canvas.add(new JLabel("Select an existing Bazel workspace"));
  canvas.add(new JSeparator());

  // Explicitly specify alignment, so preferred widths of children are honored.
  JPanel content =
      new JPanel(new VerticalLayout(/* gap= */ 12, /* alignment= */ SwingConstants.LEFT));
  content.setBorder(Borders.empty(20, 20, 0, 0));

  JComponent box =
      UiUtil.createHorizontalBox(
          BlazeWizardOption.HORIZONTAL_LAYOUT_GAP,
          getIconComponent(),
          new JLabel("Workspace:"),
          this.directoryField,
          button);
  UiUtil.setPreferredWidth(box, BlazeWizardOption.PREFERRED_COMPONENT_WIDTH);
  content.add(box);
  canvas.add(content);
  this.component = canvas;
}
 
Example #7
Source File: BlazeUserSettingsCompositeConfigurable.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public JComponent createComponent() {
  JPanel panel = new JPanel(new VerticalLayout(/* gap= */ 0));
  for (UnnamedConfigurable configurable : getConfigurables()) {
    JComponent component = configurable.createComponent();
    if (component != null) {
      panel.add(component);
    }
  }
  return panel;
}
 
Example #8
Source File: AddSourceToProjectDialog.java    From intellij with Apache License 2.0 5 votes vote down vote up
private void setupUi() {
  JPanel panel = new JPanel(new VerticalLayout(12));
  panel.setBorder(
      IdeBorderFactory.createTitledBorder(
          String.format("Add %s target(s) to project", Blaze.buildSystemName(project)), false));
  panel.add(targetsComponent);
  mainPanel.add(panel);
}
 
Example #9
Source File: DependencyDetail.java    From intellij-spring-assistant with MIT License 4 votes vote down vote up
private void createUIComponents() {
  referenceContainer = new JPanel();
  referenceContainer.setLayout(new VerticalLayout(GAP_BETWEEN_COMPONENTS));
}
 
Example #10
Source File: PerfWidgetRebuildsPanel.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
PerfWidgetRebuildsPanel(@NotNull FlutterApp app, @NotNull Disposable parentDisposable) {
  this.app = app;

  setLayout(new BorderLayout());
  setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), REBUILD_STATS_TAB_LABEL));
  setPreferredSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));

  final JPanel rebuildStatsPanel = new JPanel(new BorderLayout(0, 5));
  add(rebuildStatsPanel, BorderLayout.CENTER);

  // rebuild stats
  perfSummaryContainer = new JPanel(new BorderLayout(0, 5));
  currentSummaryView = null;
  perfSummaryPlaceholder = new JPanel(new BorderLayout());
  final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(
    new JBLabel(
      "<html><body style='padding-left:15px; padding-right:15px;'>" +
      "Widget rebuild information tells you what widgets have been " +
      "recently rebuilt for your application's current screen." +
      "<br>" +
      "</body></html>"),
    ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER
  );
  scrollPane.setBorder(JBUI.Borders.empty());
  scrollPane.setViewportBorder(JBUI.Borders.empty());
  perfSummaryPlaceholder.add(scrollPane);

  final JPanel perfViewSettings = new JPanel(new VerticalLayout(5, 4));
  trackRebuildsCheckbox = new JCheckBox("Track widget rebuilds");
  trackRebuildsCheckbox.setHorizontalAlignment(JLabel.RIGHT);
  trackRebuildsCheckbox.setToolTipText(
    "<html><body><p><b>This profiler identifies widgets that are rebuilt when the UI changes.</b></p>" +
    "<br>" +
    "<p>Look for the indicators on the left margin of the code editor<br>and a list of the top rebuilt widgets in this window.</p>" +
    "</body></html>");
  perfViewSettings.add(trackRebuildsCheckbox);
  if (ENABLE_TRACK_REPAINTS) {
    trackRepaintsCheckbox = new JCheckBox("Show widget repaint information");
    trackRepaintsCheckbox.setHorizontalAlignment(JLabel.RIGHT);
    perfViewSettings.add(trackRepaintsCheckbox);
  }
  perfViewSettings.add(new JSeparator());
  perfSummary = new WidgetPerfSummary(parentDisposable, app, PerfMetric.lastFrame, PerfReportKind.rebuild);
  perfSummaryContainer.add(perfViewSettings, BorderLayout.NORTH);

  updateShowPerfSummaryView();
  rebuildStatsPanel.add(perfSummaryContainer, BorderLayout.CENTER);

  // perf tips
  final JPanel perfTipsPanel = perfSummary.getWidgetPerfTipsPanel();
  rebuildStatsPanel.add(perfTipsPanel, BorderLayout.SOUTH);
  perfTipsPanel.setVisible(false);

  final FlutterWidgetPerfManager widgetPerfManager = FlutterWidgetPerfManager.getInstance(app.getProject());

  trackRebuildsCheckbox.setSelected(widgetPerfManager.isTrackRebuildWidgets());
  if (ENABLE_TRACK_REPAINTS) {
    trackRepaintsCheckbox.setSelected(widgetPerfManager.isTrackRepaintWidgets());
  }

  app.hasServiceExtension(ServiceExtensions.trackRebuildWidgets.getExtension(), trackRebuildsCheckbox::setEnabled, parentDisposable);

  if (ENABLE_TRACK_REPAINTS) {
    app.hasServiceExtension(ServiceExtensions.trackRepaintWidgets.getExtension(), trackRepaintsCheckbox::setEnabled, parentDisposable);
  }

  trackRebuildsCheckbox.addChangeListener((l) -> {
    if (app.getProject().isDisposed()) return;

    setTrackRebuildWidgets(trackRebuildsCheckbox.isSelected());
    updateShowPerfSummaryView();
  });

  if (ENABLE_TRACK_REPAINTS) {
    trackRepaintsCheckbox.addChangeListener((l) -> {
      if (app.getProject().isDisposed()) return;

      setTrackRepaintWidgets(trackRepaintsCheckbox.isSelected());
      updateShowPerfSummaryView();
    });
  }
}
 
Example #11
Source File: PerfWidgetRebuildsPanel.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
PerfWidgetRebuildsPanel(@NotNull FlutterApp app, @NotNull Disposable parentDisposable) {
  this.app = app;

  setLayout(new BorderLayout());
  setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), REBUILD_STATS_TAB_LABEL));
  setPreferredSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));

  final JPanel rebuildStatsPanel = new JPanel(new BorderLayout(0, 5));
  add(rebuildStatsPanel, BorderLayout.CENTER);

  // rebuild stats
  perfSummaryContainer = new JPanel(new BorderLayout(0, 5));
  currentSummaryView = null;
  perfSummaryPlaceholder = new JPanel(new BorderLayout());
  final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(
    new JBLabel(
      "<html><body style='padding-left:15px; padding-right:15px;'>" +
      "Widget rebuild information tells you what widgets have been " +
      "recently rebuilt for your application's current screen." +
      "<br>" +
      "</body></html>"),
    ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER
  );
  scrollPane.setBorder(JBUI.Borders.empty());
  scrollPane.setViewportBorder(JBUI.Borders.empty());
  perfSummaryPlaceholder.add(scrollPane);

  final JPanel perfViewSettings = new JPanel(new VerticalLayout(5, 4));
  trackRebuildsCheckbox = new JCheckBox("Track widget rebuilds");
  trackRebuildsCheckbox.setHorizontalAlignment(JLabel.RIGHT);
  trackRebuildsCheckbox.setToolTipText(
    "<html><body><p><b>This profiler identifies widgets that are rebuilt when the UI changes.</b></p>" +
    "<br>" +
    "<p>Look for the indicators on the left margin of the code editor<br>and a list of the top rebuilt widgets in this window.</p>" +
    "</body></html>");
  perfViewSettings.add(trackRebuildsCheckbox);
  if (ENABLE_TRACK_REPAINTS) {
    trackRepaintsCheckbox = new JCheckBox("Show widget repaint information");
    trackRepaintsCheckbox.setHorizontalAlignment(JLabel.RIGHT);
    perfViewSettings.add(trackRepaintsCheckbox);
  }
  perfViewSettings.add(new JSeparator());
  perfSummary = new WidgetPerfSummary(parentDisposable, app, PerfMetric.lastFrame, PerfReportKind.rebuild);
  perfSummaryContainer.add(perfViewSettings, BorderLayout.NORTH);

  updateShowPerfSummaryView();
  rebuildStatsPanel.add(perfSummaryContainer, BorderLayout.CENTER);

  // perf tips
  final JPanel perfTipsPanel = perfSummary.getWidgetPerfTipsPanel();
  rebuildStatsPanel.add(perfTipsPanel, BorderLayout.SOUTH);
  perfTipsPanel.setVisible(false);

  final FlutterWidgetPerfManager widgetPerfManager = FlutterWidgetPerfManager.getInstance(app.getProject());

  trackRebuildsCheckbox.setSelected(widgetPerfManager.isTrackRebuildWidgets());
  if (ENABLE_TRACK_REPAINTS) {
    trackRepaintsCheckbox.setSelected(widgetPerfManager.isTrackRepaintWidgets());
  }

  app.hasServiceExtension(ServiceExtensions.trackRebuildWidgets.getExtension(), trackRebuildsCheckbox::setEnabled, parentDisposable);

  if (ENABLE_TRACK_REPAINTS) {
    app.hasServiceExtension(ServiceExtensions.trackRepaintWidgets.getExtension(), trackRepaintsCheckbox::setEnabled, parentDisposable);
  }

  trackRebuildsCheckbox.addChangeListener((l) -> {
    if (app.getProject().isDisposed()) return;

    setTrackRebuildWidgets(trackRebuildsCheckbox.isSelected());
    updateShowPerfSummaryView();
  });

  if (ENABLE_TRACK_REPAINTS) {
    trackRepaintsCheckbox.addChangeListener((l) -> {
      if (app.getProject().isDisposed()) return;

      setTrackRepaintWidgets(trackRepaintsCheckbox.isSelected());
      updateShowPerfSummaryView();
    });
  }
}
 
Example #12
Source File: BlazeSelectOptionControl.java    From intellij with Apache License 2.0 4 votes vote down vote up
BlazeSelectOptionControl(BlazeNewProjectBuilder builder, Collection<T> options) {
  this.userSettings = builder.getUserSettings();

  JPanel canvas = new JPanel(new VerticalLayout(4));

  canvas.setPreferredSize(ProjectViewUi.getContainerSize());

  titleLabel = new JLabel(getTitle());
  canvas.add(titleLabel);
  canvas.add(new JSeparator());

  JPanel content = new JPanel(new VerticalLayout(12));
  content.setBorder(Borders.empty(20, 20, 0, 0));
  JScrollPane scrollPane = new JBScrollPane(content);
  scrollPane.setBorder(BorderFactory.createEmptyBorder());
  canvas.add(scrollPane);

  ButtonGroup buttonGroup = new ButtonGroup();
  Collection<OptionUiEntry<T>> optionUiEntryList = Lists.newArrayList();
  for (T option : options) {
    JPanel vertical = new JPanel(new VerticalLayout(10));
    JRadioButton radioButton = new JRadioButton();
    radioButton.setText(option.getDescription());
    vertical.add(radioButton);

    JComponent optionComponent = option.getUiComponent();
    if (optionComponent != null) {
      JPanel horizontal = new JPanel(new HorizontalLayout(0));
      horizontal.setBorder(Borders.emptyLeft(25));
      horizontal.add(optionComponent);
      vertical.add(horizontal);

      option.optionDeselected();
      radioButton.addItemListener(
          itemEvent -> {
            if (radioButton.isSelected()) {
              option.optionSelected();
            } else {
              option.optionDeselected();
            }
          });
    }

    content.add(vertical);
    buttonGroup.add(radioButton);
    optionUiEntryList.add(new OptionUiEntry<>(option, radioButton));
  }

  OptionUiEntry selected = null;
  String previouslyChosenOption = userSettings.get(getOptionKey(), null);
  if (previouslyChosenOption != null) {
    for (OptionUiEntry<T> entry : optionUiEntryList) {
      if (entry.option.getOptionName().equals(previouslyChosenOption)) {
        selected = entry;
        break;
      }
    }
  }
  if (selected == null) {
    selected = Iterables.getFirst(optionUiEntryList, null);
  }
  if (selected != null) {
    selected.radioButton.setSelected(true);
  }

  this.canvas = canvas;
  this.optionUiEntryList = optionUiEntryList;
}
 
Example #13
Source File: BreadcrumbsConfigurable.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public JComponent createComponent() {
  if (component == null) {
    for (final BreadcrumbsProviderConfigurable configurable : getConfigurables()) {
      final String id = configurable.getId();
      if (!map.containsKey(id)) {
        map.put(id, configurable.createComponent());
      }
    }
    JPanel boxes = new JPanel(new GridLayout(0, 3, UIUtil.isUnderDarcula() ? JBUIScale.scale(10) : 0, 0));
    map.values().stream().sorted((box1, box2) -> naturalCompare(box1.getText(), box2.getText())).forEach(box -> boxes.add(box));

    show = new JCheckBox(message("checkbox.show.breadcrumbs"));
    show.addItemListener(event -> updateEnabled());

    above = new JRadioButton(message("radio.show.breadcrumbs.above"));
    below = new JRadioButton(message("radio.show.breadcrumbs.below"));

    ButtonGroup group = new ButtonGroup();
    group.add(above);
    group.add(below);

    placement = new JLabel(message("label.breadcrumbs.placement"));

    JPanel placementPanel = new JPanel(new HorizontalLayout(JBUIScale.scale(UIUtil.DEFAULT_HGAP)));
    placementPanel.setBorder(JBUI.Borders.emptyLeft(24));
    placementPanel.add(placement);
    placementPanel.add(above);
    placementPanel.add(below);

    languages = new JLabel(message("label.breadcrumbs.languages"));

    JPanel languagesPanel = new JPanel(new VerticalLayout(JBUIScale.scale(6)));
    languagesPanel.setBorder(JBUI.Borders.empty(0, 24, 12, 0));
    languagesPanel.add(languages);
    languagesPanel.add(boxes);

    component = new JPanel(new VerticalLayout(JBUIScale.scale(12), LEFT));
    component.add(show);
    component.add(placementPanel);
    component.add(languagesPanel);
    component.add(LinkLabel.create(message("configure.breadcrumbs.colors"), () -> {
      DataContext context = DataManager.getInstance().getDataContext(component);
      selectOrEditColor(context, "Breadcrumbs//Current", GeneralColorsPage.class);
    }));
  }
  return component;
}
 
Example #14
Source File: AutoConfigurable.java    From intellij with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a panel containing the root Swing components of the given settings, stacked vertically.
 *
 * @throws IllegalStateException if any setting was not a {@link ConfigurableSetting} instance
 *     passed to the constructor of this {@link AutoConfigurable}.
 */
protected JPanel createVerticalPanel(List<ConfigurableSetting<?, ?>> settings) {
  JPanel panel = new JPanel(new VerticalLayout(/* gap= */ AbstractLayout.DEFAULT_VGAP));
  settings.stream().map(this::getRootComponent).forEach(panel::add);
  return panel;
}