Search in sources :

Example 16 with VerticalFlowLayout

use of com.intellij.openapi.ui.VerticalFlowLayout in project android by JetBrains.

the class NetworkRadioView method populateUI.

private void populateUI(@NotNull JComponent panel) {
    JLabel label = new JLabel(LABEL);
    label.setVerticalAlignment(SwingConstants.TOP);
    LegendComponent legend = new LegendComponent(LegendComponent.Orientation.HORIZONTAL, Integer.MAX_VALUE);
    legend.setLegendData(getLegendData());
    // As legend doesn't change over time, it doesn't need to be in {@code Choreographer}}, so draw it by animating once.
    legend.animate(1);
    JPanel topPane = new JPanel(new BorderLayout());
    topPane.setOpaque(false);
    topPane.add(label, BorderLayout.WEST);
    topPane.add(legend, BorderLayout.EAST);
    panel.setLayout(new VerticalFlowLayout(true, true));
    panel.add(topPane);
    panel.add(myRadioChart);
}
Also used : LegendComponent(com.android.tools.adtui.LegendComponent) VerticalFlowLayout(com.intellij.openapi.ui.VerticalFlowLayout)

Example 17 with VerticalFlowLayout

use of com.intellij.openapi.ui.VerticalFlowLayout in project intellij-community by JetBrains.

the class ShowFeatureUsageStatisticsDialog method createCenterPanel.

protected JComponent createCenterPanel() {
    Splitter splitter = new Splitter(true);
    splitter.setShowDividerControls(true);
    ProductivityFeaturesRegistry registry = ProductivityFeaturesRegistry.getInstance();
    ArrayList<FeatureDescriptor> features = new ArrayList<>();
    for (String id : registry.getFeatureIds()) {
        features.add(registry.getFeatureDescriptor(id));
    }
    final TableView table = new TableView<>(new ListTableModel<>(COLUMNS, features, 0));
    new TableViewSpeedSearch<FeatureDescriptor>(table) {

        @Override
        protected String getItemText(@NotNull FeatureDescriptor element) {
            return element.getDisplayName();
        }
    };
    JPanel controlsPanel = new JPanel(new VerticalFlowLayout());
    Application app = ApplicationManager.getApplication();
    long uptime = System.currentTimeMillis() - app.getStartTime();
    long idleTime = app.getIdleTime();
    final String uptimeS = FeatureStatisticsBundle.message("feature.statistics.application.uptime", ApplicationNamesInfo.getInstance().getFullProductName(), DateFormatUtil.formatDuration(uptime));
    final String idleTimeS = FeatureStatisticsBundle.message("feature.statistics.application.idle.time", DateFormatUtil.formatDuration(idleTime));
    String labelText = uptimeS + ", " + idleTimeS;
    CompletionStatistics stats = ((FeatureUsageTrackerImpl) FeatureUsageTracker.getInstance()).getCompletionStatistics();
    if (stats.dayCount > 0 && stats.sparedCharacters > 0) {
        String total = formatCharacterCount(stats.sparedCharacters, true);
        String perDay = formatCharacterCount(stats.sparedCharacters / stats.dayCount, false);
        labelText += "<br>Code completion has saved you from typing at least " + total + " since " + DateFormatUtil.formatDate(stats.startDate) + " (~" + perDay + " per working day)";
    }
    CumulativeStatistics fstats = ((FeatureUsageTrackerImpl) FeatureUsageTracker.getInstance()).getFixesStats();
    if (fstats.dayCount > 0 && fstats.invocations > 0) {
        labelText += "<br>Quick fixes have saved you from " + fstats.invocations + " possible bugs since " + DateFormatUtil.formatDate(fstats.startDate) + " (~" + fstats.invocations / fstats.dayCount + " per working day)";
    }
    controlsPanel.add(new JLabel(XmlStringUtil.wrapInHtml(labelText)), BorderLayout.NORTH);
    JPanel topPanel = new JPanel(new BorderLayout());
    topPanel.add(controlsPanel, BorderLayout.NORTH);
    topPanel.add(ScrollPaneFactory.createScrollPane(table), BorderLayout.CENTER);
    splitter.setFirstComponent(topPanel);
    final JEditorPane browser = TipUIUtil.createTipBrowser();
    splitter.setSecondComponent(ScrollPaneFactory.createScrollPane(browser));
    table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            Collection selection = table.getSelection();
            try {
                if (selection.isEmpty()) {
                    browser.read(new StringReader(""), null);
                } else {
                    FeatureDescriptor feature = (FeatureDescriptor) selection.iterator().next();
                    TipUIUtil.openTipInBrowser(feature.getTipFileName(), browser, feature.getProvider());
                }
            } catch (IOException ex) {
                LOG.info(ex);
            }
        }
    });
    return splitter;
}
Also used : ArrayList(java.util.ArrayList) ListSelectionEvent(javax.swing.event.ListSelectionEvent) TableViewSpeedSearch(com.intellij.ui.TableViewSpeedSearch) NotNull(org.jetbrains.annotations.NotNull) StringReader(java.io.StringReader) TableView(com.intellij.ui.table.TableView) VerticalFlowLayout(com.intellij.openapi.ui.VerticalFlowLayout) Splitter(com.intellij.openapi.ui.Splitter) IOException(java.io.IOException) ListSelectionListener(javax.swing.event.ListSelectionListener) Collection(java.util.Collection) Application(com.intellij.openapi.application.Application)

Example 18 with VerticalFlowLayout

use of com.intellij.openapi.ui.VerticalFlowLayout in project intellij-community by JetBrains.

the class CustomizeFeaturedPluginsStepPanel method onPluginGroupsLoaded.

private void onPluginGroupsLoaded() {
    List<IdeaPluginDescriptor> pluginsFromRepository = myPluginGroups.getPluginsFromRepository();
    if (pluginsFromRepository.isEmpty()) {
        myInProgressLabel.setText("Cannot get featured plugins description online.");
        return;
    }
    removeAll();
    JPanel gridPanel = new JPanel(new GridLayout(0, 3));
    JBScrollPane scrollPane = CustomizePluginsStepPanel.createScrollPane(gridPanel);
    Map<String, String> config = myPluginGroups.getFeaturedPlugins();
    for (Map.Entry<String, String> entry : config.entrySet()) {
        JPanel groupPanel = new JPanel(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.fill = GridBagConstraints.BOTH;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.gridwidth = GridBagConstraints.REMAINDER;
        gbc.weightx = 1;
        String title = entry.getKey();
        String s = entry.getValue();
        int i = s.indexOf(':');
        String topic = s.substring(0, i);
        int j = s.indexOf(':', i + 1);
        String description = s.substring(i + 1, j);
        final String pluginId = s.substring(j + 1);
        IdeaPluginDescriptor foundDescriptor = null;
        for (IdeaPluginDescriptor descriptor : pluginsFromRepository) {
            if (descriptor.getPluginId().getIdString().equals(pluginId) && !PluginManagerCore.isBrokenPlugin(descriptor)) {
                foundDescriptor = descriptor;
                break;
            }
        }
        if (foundDescriptor == null)
            continue;
        final IdeaPluginDescriptor descriptor = foundDescriptor;
        final boolean isVIM = PluginGroups.IDEA_VIM_PLUGIN_ID.equals(descriptor.getPluginId().getIdString());
        boolean isCloud = "#Cloud".equals(topic);
        if (isCloud) {
            title = descriptor.getName();
            description = StringUtil.defaultIfEmpty(descriptor.getDescription(), "No description available");
            topic = StringUtil.defaultIfEmpty(descriptor.getCategory(), "Unknown");
        }
        JLabel titleLabel = new JLabel("<html><body><h2 style=\"text-align:left;\">" + title + "</h2></body></html>");
        JLabel topicLabel = new JLabel("<html><body><h4 style=\"text-align:left;color:#808080;font-weight:bold;\">" + topic + "</h4></body></html>");
        JLabel descriptionLabel = createHTMLLabel(description);
        JLabel warningLabel = null;
        if (isVIM || isCloud) {
            if (isCloud) {
                warningLabel = createHTMLLabel("From your JetBrains account");
                warningLabel.setIcon(AllIcons.General.BalloonInformation);
            } else {
                warningLabel = createHTMLLabel("Recommended only if you are<br> familiar with Vim.");
                warningLabel.setIcon(AllIcons.General.BalloonWarning);
            }
            if (!SystemInfo.isWindows)
                UIUtil.applyStyle(UIUtil.ComponentStyle.SMALL, warningLabel);
        }
        final CardLayout wrapperLayout = new CardLayout();
        final JPanel buttonWrapper = new JPanel(wrapperLayout);
        final JButton installButton = new JButton(isVIM ? "Install and Enable" : "Install");
        final JProgressBar progressBar = new JProgressBar(0, 100);
        progressBar.setStringPainted(true);
        JPanel progressPanel = new JPanel(new VerticalFlowLayout(true, false));
        progressPanel.add(progressBar);
        final LinkLabel cancelLink = new LinkLabel("Cancel", AllIcons.Actions.Cancel);
        JPanel linkWrapper = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
        linkWrapper.add(cancelLink);
        progressPanel.add(linkWrapper);
        final JPanel buttonPanel = new JPanel(new VerticalFlowLayout(0, 0));
        buttonPanel.add(installButton);
        buttonWrapper.add(buttonPanel, "button");
        buttonWrapper.add(progressPanel, "progress");
        wrapperLayout.show(buttonWrapper, "button");
        final ProgressIndicatorEx indicator = new AbstractProgressIndicatorExBase(true) {

            @Override
            public void start() {
                myCanceled.set(false);
                super.start();
                SwingUtilities.invokeLater(() -> wrapperLayout.show(buttonWrapper, "progress"));
            }

            @Override
            public void processFinish() {
                super.processFinish();
                SwingUtilities.invokeLater(() -> {
                    wrapperLayout.show(buttonWrapper, "button");
                    installButton.setEnabled(false);
                    installButton.setText("Installed");
                });
            }

            @Override
            public void setFraction(final double fraction) {
                super.setFraction(fraction);
                SwingUtilities.invokeLater(() -> {
                    int value = (int) (100 * fraction + .5);
                    progressBar.setValue(value);
                    progressBar.setString(value + "%");
                });
            }

            @Override
            public void cancel() {
                stop();
                myCanceled.set(true);
                super.cancel();
                SwingUtilities.invokeLater(() -> {
                    wrapperLayout.show(buttonWrapper, "button");
                    progressBar.setValue(0);
                    progressBar.setString("0%");
                });
            }
        };
        installButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                wrapperLayout.show(buttonWrapper, "progress");
                ourService.execute(new Runnable() {

                    @Override
                    public void run() {
                        try {
                            indicator.start();
                            IdeInitialConfigButtonUsages.addDownloadedPlugin(descriptor.getPluginId().getIdString());
                            PluginDownloader downloader = PluginDownloader.createDownloader(descriptor);
                            downloader.prepareToInstall(indicator);
                            downloader.install();
                            indicator.processFinish();
                        } catch (Exception ignored) {
                            if (!myCanceled.get()) {
                                onFail();
                            }
                        }
                    }

                    void onFail() {
                        //noinspection SSBasedInspection
                        SwingUtilities.invokeLater(() -> {
                            indicator.stop();
                            wrapperLayout.show(buttonWrapper, "progress");
                            progressBar.setString("Cannot download plugin");
                        });
                    }
                });
            }
        });
        cancelLink.setListener(new LinkListener() {

            @Override
            public void linkSelected(LinkLabel aSource, Object aLinkData) {
                indicator.cancel();
            }
        }, null);
        gbc.insets.left = installButton.getInsets().left / 2;
        gbc.insets.right = installButton.getInsets().right / 2;
        gbc.insets.bottom = -5;
        groupPanel.add(titleLabel, gbc);
        gbc.insets.bottom = SMALL_GAP;
        groupPanel.add(topicLabel, gbc);
        groupPanel.add(descriptionLabel, gbc);
        gbc.weighty = 1;
        groupPanel.add(Box.createVerticalGlue(), gbc);
        gbc.weighty = 0;
        if (warningLabel != null) {
            Insets insetsBefore = gbc.insets;
            gbc.insets = new Insets(0, -10, SMALL_GAP, -10);
            gbc.insets.left += insetsBefore.left;
            gbc.insets.right += insetsBefore.right;
            JPanel warningPanel = new JPanel(new BorderLayout());
            warningPanel.setBorder(new EmptyBorder(5, 10, 5, 10));
            warningPanel.add(warningLabel);
            groupPanel.add(warningPanel, gbc);
            gbc.insets = insetsBefore;
        }
        gbc.insets.bottom = gbc.insets.left = gbc.insets.right = 0;
        groupPanel.add(buttonWrapper, gbc);
        gridPanel.add(groupPanel);
    }
    while (gridPanel.getComponentCount() < 4) {
        gridPanel.add(Box.createVerticalBox());
    }
    int cursor = 0;
    Component[] components = gridPanel.getComponents();
    int rowCount = components.length / COLS;
    for (Component component : components) {
        ((JComponent) component).setBorder(new CompoundBorder(new CustomLineBorder(ColorUtil.withAlpha(JBColor.foreground(), .2), 0, 0, cursor / 3 < rowCount && (!(component instanceof Box)) ? 1 : 0, cursor % COLS != COLS - 1 && (!(component instanceof Box)) ? 1 : 0) {

            @Override
            protected Color getColor() {
                return ColorUtil.withAlpha(JBColor.foreground(), .2);
            }
        }, BorderFactory.createEmptyBorder(0, SMALL_GAP, 0, SMALL_GAP)));
        cursor++;
    }
    add(scrollPane);
    revalidate();
    repaint();
}
Also used : VerticalFlowLayout(com.intellij.openapi.ui.VerticalFlowLayout) ActionEvent(java.awt.event.ActionEvent) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginDownloader(com.intellij.openapi.updateSettings.impl.PluginDownloader) CompoundBorder(javax.swing.border.CompoundBorder) EmptyBorder(javax.swing.border.EmptyBorder) VerticalFlowLayout(com.intellij.openapi.ui.VerticalFlowLayout) LinkListener(com.intellij.ui.components.labels.LinkListener) AbstractProgressIndicatorExBase(com.intellij.openapi.progress.util.AbstractProgressIndicatorExBase) CustomLineBorder(com.intellij.ui.border.CustomLineBorder) ActionListener(java.awt.event.ActionListener) LinkLabel(com.intellij.ui.components.labels.LinkLabel) ProgressIndicatorEx(com.intellij.openapi.wm.ex.ProgressIndicatorEx) Map(java.util.Map) JBScrollPane(com.intellij.ui.components.JBScrollPane)

Example 19 with VerticalFlowLayout

use of com.intellij.openapi.ui.VerticalFlowLayout in project intellij-community by JetBrains.

the class JBTableRowEditor method createLabeledPanel.

public static JPanel createLabeledPanel(String labelText, JComponent component) {
    final JPanel panel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 4, 2, true, false));
    final JBLabel label = new JBLabel(labelText, UIUtil.ComponentStyle.SMALL);
    IJSwingUtilities.adjustComponentsOnMac(label, component);
    panel.add(label);
    panel.add(component);
    return panel;
}
Also used : JBLabel(com.intellij.ui.components.JBLabel) VerticalFlowLayout(com.intellij.openapi.ui.VerticalFlowLayout)

Example 20 with VerticalFlowLayout

use of com.intellij.openapi.ui.VerticalFlowLayout in project intellij-community by JetBrains.

the class InferNullityAnnotationsAction method getAdditionalActionSettings.

@Override
protected JComponent getAdditionalActionSettings(Project project, BaseAnalysisActionDialog dialog) {
    final JPanel panel = new JPanel(new VerticalFlowLayout());
    panel.add(new TitledSeparator());
    myAnnotateLocalVariablesCb = new JCheckBox("Annotate local variables", PropertiesComponent.getInstance().getBoolean(ANNOTATE_LOCAL_VARIABLES));
    panel.add(myAnnotateLocalVariablesCb);
    return panel;
}
Also used : TitledSeparator(com.intellij.ui.TitledSeparator) VerticalFlowLayout(com.intellij.openapi.ui.VerticalFlowLayout)

Aggregations

VerticalFlowLayout (com.intellij.openapi.ui.VerticalFlowLayout)34 Nullable (org.jetbrains.annotations.Nullable)8 JBLabel (com.intellij.ui.components.JBLabel)7 NotNull (org.jetbrains.annotations.NotNull)6 ActionEvent (java.awt.event.ActionEvent)4 ActionListener (java.awt.event.ActionListener)4 EditorTextField (com.intellij.ui.EditorTextField)3 TitledSeparator (com.intellij.ui.TitledSeparator)3 JBList (com.intellij.ui.components.JBList)3 JBScrollPane (com.intellij.ui.components.JBScrollPane)3 FormBuilder (com.intellij.util.ui.FormBuilder)3 ArrayList (java.util.ArrayList)3 Document (com.intellij.openapi.editor.Document)2 ComboBox (com.intellij.openapi.ui.ComboBox)2 JBPanel (com.intellij.ui.components.JBPanel)2 JCheckBox (javax.swing.JCheckBox)2 JPanel (javax.swing.JPanel)2 Density (com.android.resources.Density)1 LegendComponent (com.android.tools.adtui.LegendComponent)1 ImageComponent (com.android.tools.idea.ui.ImageComponent)1