use of com.intellij.util.ui.AbstractLayoutManager in project intellij-community by JetBrains.
the class NotificationsManagerImpl method createMergeAction.
private static void createMergeAction(@NotNull final BalloonLayoutData layoutData, @NotNull JPanel panel) {
StringBuilder title = new StringBuilder().append(layoutData.mergeData.count).append(" more");
String shortTitle = NotificationParentGroup.getShortTitle(layoutData.groupId);
if (shortTitle != null) {
title.append(" from ").append(shortTitle);
}
LinkLabel<BalloonLayoutData> action = new LinkLabel<BalloonLayoutData>(title.toString(), null, new LinkListener<BalloonLayoutData>() {
@Override
public void linkSelected(LinkLabel aSource, BalloonLayoutData layoutData) {
EventLog.showNotification(layoutData.project, layoutData.groupId, layoutData.getMergeIds());
}
}, layoutData) {
@Override
protected boolean isInClickableArea(Point pt) {
return true;
}
@Override
protected Color getTextColor() {
return new JBColor(0x666666, 0x8C8C8C);
}
};
action.setFont(FontUtil.minusOne(action.getFont()));
action.setHorizontalAlignment(SwingConstants.CENTER);
action.setPaintUnderline(false);
AbstractLayoutManager layout = new AbstractLayoutManager() {
@Override
public Dimension preferredLayoutSize(Container parent) {
return new Dimension(parent.getWidth(), JBUI.scale(20) + 2);
}
@Override
public void layoutContainer(Container parent) {
parent.getComponent(0).setBounds(2, 1, parent.getWidth() - 4, JBUI.scale(20));
}
};
JPanel mergePanel = new NonOpaquePanel(layout) {
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(new JBColor(0xE3E3E3, 0x3A3C3D));
((Graphics2D) g).fill(new Rectangle2D.Double(1.5, 1, getWidth() - 2.5, getHeight() - 2));
g.setColor(new JBColor(0xDBDBDB, 0x353738));
if (SystemInfo.isMac) {
((Graphics2D) g).draw(new Rectangle2D.Double(2, 0, getWidth() - 3.5, 0.5));
} else if (SystemInfo.isWindows) {
((Graphics2D) g).draw(new Rectangle2D.Double(1.5, 0, getWidth() - 3, 0.5));
} else {
((Graphics2D) g).draw(new Rectangle2D.Double(1.5, 0, getWidth() - 2.5, 0.5));
}
}
};
mergePanel.add(action);
panel.add(BorderLayout.SOUTH, mergePanel);
}
use of com.intellij.util.ui.AbstractLayoutManager in project intellij-community by JetBrains.
the class EventLogToolWindowFactory method createContent.
static void createContent(Project project, ToolWindow toolWindow, EventLogConsole console, String title) {
// update default Event Log tab title
ContentManager contentManager = toolWindow.getContentManager();
Content generalContent = contentManager.getContent(0);
if (generalContent != null && contentManager.getContentCount() == 1) {
generalContent.setDisplayName("General");
}
final Editor editor = console.getConsoleEditor();
JPanel editorPanel = new JPanel(new AbstractLayoutManager() {
private int getOffset() {
return JBUI.scale(4);
}
@Override
public Dimension preferredLayoutSize(Container parent) {
Dimension size = parent.getComponent(0).getPreferredSize();
return new Dimension(size.width + getOffset(), size.height);
}
@Override
public void layoutContainer(Container parent) {
int offset = getOffset();
parent.getComponent(0).setBounds(offset, 0, parent.getWidth() - offset, parent.getHeight());
}
}) {
@Override
public Color getBackground() {
return ((EditorEx) editor).getBackgroundColor();
}
};
editorPanel.add(editor.getComponent());
SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true) {
@Override
public Object getData(@NonNls String dataId) {
return PlatformDataKeys.HELP_ID.is(dataId) ? EventLog.HELP_ID : super.getData(dataId);
}
};
panel.setContent(editorPanel);
panel.addAncestorListener(new LogShownTracker(project));
ActionToolbar toolbar = createToolbar(project, editor, console);
toolbar.setTargetComponent(editor.getContentComponent());
panel.setToolbar(toolbar.getComponent());
Content content = ContentFactory.SERVICE.getInstance().createContent(panel, title, false);
contentManager.addContent(content);
contentManager.setSelectedContent(content);
}
use of com.intellij.util.ui.AbstractLayoutManager in project android by JetBrains.
the class DeviceConfiguratorPanel method createUIComponents.
private void createUIComponents() {
myQualifierOptionsPanel = new JPanel(new CardLayout());
final JPanel leftPanel = new JPanel(new BorderLayout(JBUI.scale(5), JBUI.scale(5)));
myAvailableQualifiersList = new JBList();
myAvailableQualifiersList.setMinimumSize(JBUI.size(10, 10));
JBLabel label = new JBLabel(AndroidBundle.message("android.layout.preview.edit.configuration.available.qualifiers.label"));
label.setLabelFor(myAvailableQualifiersList);
leftPanel.add(label, BorderLayout.NORTH);
leftPanel.add(new JBScrollPane(myAvailableQualifiersList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER), BorderLayout.CENTER);
final JPanel rightPanel = new JPanel(new BorderLayout(JBUI.scale(5), JBUI.scale(5)));
myChosenQualifiersList = new JBList();
myChosenQualifiersList.setMinimumSize(JBUI.size(10, 10));
label = new JBLabel(AndroidBundle.message("android.layout.preview.edit.configuration.choosen.qualifiers.label"));
label.setLabelFor(myChosenQualifiersList);
rightPanel.add(label, BorderLayout.NORTH);
rightPanel.add(new JBScrollPane(myChosenQualifiersList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER), BorderLayout.CENTER);
final JPanel buttonsPanel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.MIDDLE, 0, 0, true, false));
myAddQualifierButton = new JButton(">>");
buttonsPanel.add(myAddQualifierButton);
myRemoveQualifierButton = new JButton("<<");
buttonsPanel.add(myRemoveQualifierButton);
final int gap = 5;
final JPanel listsPanel = new JPanel(new AbstractLayoutManager() {
@SuppressWarnings("NonPrivateFieldAccessedInSynchronizedContext")
@Override
public Dimension preferredLayoutSize(Container target) {
synchronized (target.getTreeLock()) {
final Dimension leftPref = leftPanel.getPreferredSize();
final Dimension rightPref = rightPanel.getPreferredSize();
final Dimension middlePref = buttonsPanel.getPreferredSize();
final Insets insets = target.getInsets();
final int width = leftPref.width + middlePref.width + rightPref.width + insets.left + insets.right + gap * 2;
final int height = Math.max(leftPref.height, Math.max(rightPref.height, middlePref.height)) + insets.top + insets.bottom;
return new Dimension(width, height);
}
}
@SuppressWarnings("NonPrivateFieldAccessedInSynchronizedContext")
@Override
public void layoutContainer(Container target) {
synchronized (target.getTreeLock()) {
final Insets insets = target.getInsets();
int top = insets.top;
int bottom = target.getHeight() - insets.bottom;
int left = insets.left;
int right = target.getWidth() - insets.right;
final int middleWidth = buttonsPanel.getPreferredSize().width + gap * 2;
final int listWidth = (right - left - middleWidth) / 2;
final int height = bottom - top;
leftPanel.setSize(listWidth, height);
rightPanel.setSize(listWidth, height);
buttonsPanel.setSize(middleWidth, height);
leftPanel.setBounds(left, top, listWidth, height);
rightPanel.setBounds(right - listWidth, top, listWidth, height);
buttonsPanel.setBounds(left + listWidth + gap, top, middleWidth - gap * 2, height);
}
}
});
listsPanel.add(leftPanel);
listsPanel.add(buttonsPanel);
listsPanel.add(rightPanel);
add(listsPanel, BorderLayout.CENTER);
add(myQualifierOptionsPanel, BorderLayout.EAST);
}
Aggregations