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);
}
}
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);
}
}
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;
}
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;
}
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));
}
Aggregations