Search in sources :

Example 61 with JBLabel

use of com.intellij.ui.components.JBLabel in project intellij-community by JetBrains.

the class DiffPanelImpl method createComponentForTitle.

static JComponent createComponentForTitle(@Nullable String title, @Nullable final LineSeparator sep1, @Nullable final LineSeparator sep2, boolean left) {
    if (sep1 != null && sep2 != null && !sep1.equals(sep2)) {
        LineSeparator separator = left ? sep1 : sep2;
        JPanel bottomPanel = new JPanel(new BorderLayout());
        JLabel sepLabel = new JLabel(separator.name());
        sepLabel.setForeground(separator.equals(LineSeparator.CRLF) ? JBColor.RED : PlatformColors.BLUE);
        bottomPanel.add(sepLabel, left ? BorderLayout.EAST : BorderLayout.WEST);
        JPanel panel = new JPanel(new BorderLayout());
        panel.add(new JLabel(title == null ? "" : title));
        panel.add(bottomPanel, BorderLayout.SOUTH);
        return panel;
    } else {
        return new JBLabel(title == null ? "" : title);
    }
}
Also used : JBLabel(com.intellij.ui.components.JBLabel) LineSeparator(com.intellij.util.LineSeparator)

Example 62 with JBLabel

use of com.intellij.ui.components.JBLabel in project intellij-community by JetBrains.

the class ToolWindowsWidget method mouseEntered.

public void mouseEntered() {
    final boolean active = ApplicationManager.getApplication().isActive();
    if (!active) {
        return;
    }
    if (myAlarm.getActiveRequestCount() == 0) {
        myAlarm.addRequest(() -> {
            final IdeFrameImpl frame = UIUtil.getParentOfType(IdeFrameImpl.class, this);
            if (frame == null)
                return;
            List<ToolWindow> toolWindows = new ArrayList<>();
            final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(frame.getProject());
            for (String id : toolWindowManager.getToolWindowIds()) {
                final ToolWindow tw = toolWindowManager.getToolWindow(id);
                if (tw.isAvailable() && tw.isShowStripeButton()) {
                    toolWindows.add(tw);
                }
            }
            Collections.sort(toolWindows, (o1, o2) -> StringUtil.naturalCompare(o1.getStripeTitle(), o2.getStripeTitle()));
            final JBList list = new JBList(toolWindows);
            list.setCellRenderer(new ListCellRenderer() {

                final JBLabel label = new JBLabel();

                @Override
                public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
                    final ToolWindow toolWindow = (ToolWindow) value;
                    label.setText(toolWindow.getStripeTitle());
                    label.setIcon(toolWindow.getIcon());
                    label.setBorder(JBUI.Borders.empty(4, 10));
                    label.setForeground(UIUtil.getListForeground(isSelected));
                    label.setBackground(UIUtil.getListBackground(isSelected));
                    final JPanel panel = new JPanel(new BorderLayout());
                    panel.add(label, BorderLayout.CENTER);
                    panel.setBackground(UIUtil.getListBackground(isSelected));
                    return panel;
                }
            });
            final Dimension size = list.getPreferredSize();
            final JComponent c = this;
            final Insets padding = UIUtil.getListViewportPadding();
            final RelativePoint point = new RelativePoint(c, new Point(-4, -padding.top - padding.bottom - 4 - size.height + (SystemInfo.isMac ? 2 : 0)));
            if (popup != null && popup.isVisible()) {
                return;
            }
            list.setSelectedIndex(list.getItemsCount() - 1);
            PopupChooserBuilder builder = JBPopupFactory.getInstance().createListPopupBuilder(list);
            popup = builder.setAutoselectOnMouseMove(true).setRequestFocus(false).setItemChoosenCallback(() -> {
                if (popup != null)
                    popup.closeOk(null);
                final Object value = list.getSelectedValue();
                if (value instanceof ToolWindow) {
                    ((ToolWindow) value).activate(null, true, true);
                }
            }).createPopup();
            // override default of 15 set when createPopup() is called
            list.setVisibleRowCount(30);
            popup.show(point);
        }, 300);
    }
}
Also used : IdeFrameImpl(com.intellij.openapi.wm.impl.IdeFrameImpl) ArrayList(java.util.ArrayList) RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint) JBLabel(com.intellij.ui.components.JBLabel) JBList(com.intellij.ui.components.JBList) PopupChooserBuilder(com.intellij.openapi.ui.popup.PopupChooserBuilder)

Example 63 with JBLabel

use of com.intellij.ui.components.JBLabel in project intellij-community by JetBrains.

the class PerFileConfigurableBase method createDefaultMappingComponent.

@Nullable
protected JComponent createDefaultMappingComponent() {
    myDefaultProps.addAll(getDefaultMappings());
    if (myMappings instanceof LanguagePerFileMappings && param(ADD_PROJECT_MAPPING)) {
        myDefaultProps.add(Trinity.create("Project " + StringUtil.capitalize(param(MAPPING_TITLE)), () -> ((LanguagePerFileMappings<T>) myMappings).getConfiguredMapping(null), o -> myMappings.setMapping(null, o)));
    }
    if (myDefaultProps.size() == 0)
        return null;
    JPanel panel = new JPanel(new GridBagLayout());
    GridBagConstraints cons1 = new GridBagConstraints();
    cons1.fill = GridBagConstraints.HORIZONTAL;
    cons1.weightx = 0;
    cons1.gridx = 0;
    cons1.insets = JBUI.insets(0, 0, 5, UIUtil.DEFAULT_HGAP);
    GridBagConstraints cons2 = new GridBagConstraints();
    cons2.fill = GridBagConstraints.NONE;
    cons2.anchor = GridBagConstraints.WEST;
    cons2.weightx = 0;
    cons2.gridx = 1;
    cons2.insets = cons1.insets;
    panel.add(Box.createGlue(), new GridBagConstraints(2, 0, 1, 1, 1., 1., GridBagConstraints.CENTER, GridBagConstraints.NONE, JBUI.emptyInsets(), 0, 0));
    for (Trinity<String, Producer<T>, Consumer<T>> prop : myDefaultProps) {
        myDefaultVals.put(prop.first, prop.second.produce());
        JPanel p = createActionPanel(null, new Value<T>() {

            @Override
            public void commit() {
                myModel.fireTableDataChanged();
            }

            @Override
            public T get() {
                return myDefaultVals.get(prop.first);
            }

            @Override
            public void set(T value) {
                myDefaultVals.put(prop.first, adjustChosenValue(null, value));
            }
        });
        panel.add(new JBLabel(prop.first + ":"), cons1);
        panel.add(p, cons2);
    }
    return panel;
}
Also used : com.intellij.openapi.util(com.intellij.openapi.util) VirtualFileWindow(com.intellij.injected.editor.VirtualFileWindow) UIUtil(com.intellij.util.ui.UIUtil) AbstractTableCellEditor(com.intellij.util.ui.AbstractTableCellEditor) java.util(java.util) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) javax.swing.table(javax.swing.table) LanguagePerFileMappings(com.intellij.lang.LanguagePerFileMappings) PerFileMappingsBase(com.intellij.lang.PerFileMappingsBase) ContainerUtil(com.intellij.util.containers.ContainerUtil) JBLabel(com.intellij.ui.components.JBLabel) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) JBUI(com.intellij.util.ui.JBUI) Project(com.intellij.openapi.project.Project) SpeedSearchUtil(com.intellij.ui.speedSearch.SpeedSearchUtil) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) Messages(com.intellij.openapi.ui.Messages) PerFileMappings(com.intellij.lang.PerFileMappings) FileUtil(com.intellij.openapi.util.io.FileUtil) ComboBoxAction(com.intellij.openapi.actionSystem.ex.ComboBoxAction) TIntArrayList(gnu.trove.TIntArrayList) CustomComponentAction(com.intellij.openapi.actionSystem.ex.CustomComponentAction) VfsUtilCore(com.intellij.openapi.vfs.VfsUtilCore) StringUtil(com.intellij.openapi.util.text.StringUtil) Configurable(com.intellij.openapi.options.Configurable) KeymapUtil(com.intellij.openapi.keymap.KeymapUtil) com.intellij.ui(com.intellij.ui) Collectors(java.util.stream.Collectors) JBPopup(com.intellij.openapi.ui.popup.JBPopup) MouseEvent(java.awt.event.MouseEvent) File(java.io.File) java.awt(java.awt) com.intellij.openapi.actionSystem(com.intellij.openapi.actionSystem) JBTable(com.intellij.ui.table.JBTable) Nullable(org.jetbrains.annotations.Nullable) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) List(java.util.List) IdeBorderFactory(com.intellij.ui.IdeBorderFactory) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) ConfigurationException(com.intellij.openapi.options.ConfigurationException) com.intellij.util(com.intellij.util) NotNull(org.jetbrains.annotations.NotNull) SimpleDataContext(com.intellij.openapi.actionSystem.impl.SimpleDataContext) FileChooser(com.intellij.openapi.fileChooser.FileChooser) SearchableConfigurable(com.intellij.openapi.options.SearchableConfigurable) javax.swing(javax.swing) JBLabel(com.intellij.ui.components.JBLabel) LanguagePerFileMappings(com.intellij.lang.LanguagePerFileMappings) Nullable(org.jetbrains.annotations.Nullable)

Example 64 with JBLabel

use of com.intellij.ui.components.JBLabel 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 65 with JBLabel

use of com.intellij.ui.components.JBLabel in project intellij-community by JetBrains.

the class DiffUtil method createMessagePanel.

@NotNull
public static JPanel createMessagePanel(@NotNull String message) {
    String text = StringUtil.replace(message, "\n", "<br>");
    JLabel label = new JBLabel(text) {

        @Override
        public Dimension getMinimumSize() {
            Dimension size = super.getMinimumSize();
            size.width = Math.min(size.width, 200);
            size.height = Math.min(size.height, 100);
            return size;
        }
    }.setCopyable(true);
    label.setForeground(UIUtil.getInactiveTextColor());
    return new CenteredPanel(label, JBUI.Borders.empty(5));
}
Also used : JBLabel(com.intellij.ui.components.JBLabel)

Aggregations

JBLabel (com.intellij.ui.components.JBLabel)98 Nullable (org.jetbrains.annotations.Nullable)23 NotNull (org.jetbrains.annotations.NotNull)11 JBCheckBox (com.intellij.ui.components.JBCheckBox)10 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)9 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 ComboBox (com.intellij.openapi.ui.ComboBox)7 VerticalFlowLayout (com.intellij.openapi.ui.VerticalFlowLayout)7 GridBag (com.intellij.util.ui.GridBag)7 List (java.util.List)7 JBList (com.intellij.ui.components.JBList)6 JBTable (com.intellij.ui.table.JBTable)6 JBTextField (com.intellij.ui.components.JBTextField)5 DocumentEvent (javax.swing.event.DocumentEvent)5 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)4 Project (com.intellij.openapi.project.Project)4 TextFieldWithBrowseButton (com.intellij.openapi.ui.TextFieldWithBrowseButton)4 StringUtil (com.intellij.openapi.util.text.StringUtil)4 java.awt (java.awt)4 ArrayList (java.util.ArrayList)4