use of com.intellij.ui.components.panels.HorizontalLayout in project intellij-community by JetBrains.
the class FileTemplateConfigurable method createEditor.
private Editor createEditor() {
EditorFactory editorFactory = EditorFactory.getInstance();
Document doc = myFile == null ? editorFactory.createDocument(myTemplate == null ? "" : myTemplate.getText()) : PsiDocumentManager.getInstance(myFile.getProject()).getDocument(myFile);
assert doc != null;
Editor editor = editorFactory.createEditor(doc, myProject);
EditorSettings editorSettings = editor.getSettings();
editorSettings.setVirtualSpace(false);
editorSettings.setLineMarkerAreaShown(false);
editorSettings.setIndentGuidesShown(false);
editorSettings.setLineNumbersShown(false);
editorSettings.setFoldingOutlineShown(false);
editorSettings.setAdditionalColumnsCount(3);
editorSettings.setAdditionalLinesCount(3);
editorSettings.setCaretRowShown(false);
editor.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
onTextChanged();
}
});
((EditorEx) editor).setHighlighter(createHighlighter());
JPanel topPanel = new JPanel(new BorderLayout());
JPanel southPanel = new JPanel(new HorizontalLayout(40));
southPanel.add(myAdjustBox);
southPanel.add(myLiveTemplateBox);
topPanel.add(southPanel, BorderLayout.SOUTH);
topPanel.add(editor.getComponent(), BorderLayout.CENTER);
mySplitter.setFirstComponent(topPanel);
return editor;
}
use of com.intellij.ui.components.panels.HorizontalLayout in project intellij-community by JetBrains.
the class NotificationsManagerImpl method createButtons.
@Nullable
private static JPanel createButtons(@NotNull Notification notification, @NotNull final JPanel content, @Nullable HyperlinkListener listener) {
if (notification instanceof NotificationActionProvider) {
JPanel buttons = new JPanel(new HorizontalLayout(5));
buttons.setOpaque(false);
content.add(BorderLayout.SOUTH, buttons);
final Ref<JButton> defaultButton = new Ref<>();
NotificationActionProvider provider = (NotificationActionProvider) notification;
for (NotificationActionProvider.Action action : provider.getActions(listener)) {
JButton button = new JButton(action) {
@Override
public void setUI(ButtonUI ui) {
boolean isDarcula = ui instanceof DarculaButtonUI && UIUtil.isUnderDarcula();
if (isDarcula) {
ui = new DarculaButtonUI() {
@Override
protected Color getButtonColor1() {
return new ColorUIResource(0x464b4c);
}
@Override
protected Color getButtonColor2() {
return new ColorUIResource(0x383c3d);
}
};
}
super.setUI(ui);
if (isDarcula) {
setBorder(new DarculaButtonPainter() {
@Override
protected Color getBorderColor() {
return new ColorUIResource(0x616263);
}
});
}
}
};
button.setOpaque(false);
if (action.isDefaultAction()) {
defaultButton.setIfNull(button);
}
buttons.add(HorizontalLayout.RIGHT, button);
}
if (!defaultButton.isNull()) {
UIUtil.addParentChangeListener(content, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event.getOldValue() == null && event.getNewValue() != null) {
UIUtil.removeParentChangeListener(content, this);
JRootPane rootPane = UIUtil.getRootPane(content);
if (rootPane != null) {
rootPane.setDefaultButton(defaultButton.get());
}
}
}
});
}
return buttons;
}
return null;
}
use of com.intellij.ui.components.panels.HorizontalLayout in project intellij-community by JetBrains.
the class NotificationsManagerImpl method createActionPanel.
private static void createActionPanel(@NotNull final Notification notification, @NotNull JPanel centerPanel, int gap, @NotNull HoverAdapter hoverAdapter) {
JPanel actionPanel = new NonOpaquePanel(new HorizontalLayout(gap, SwingConstants.CENTER));
centerPanel.add(BorderLayout.SOUTH, actionPanel);
List<AnAction> actions = notification.getActions();
if (actions.size() > 2) {
DropDownAction action = new DropDownAction(notification.getDropDownText(), new LinkListener<Void>() {
@Override
public void linkSelected(LinkLabel link, Void ignored) {
Container parent = link.getParent();
int size = parent.getComponentCount();
DefaultActionGroup group = new DefaultActionGroup();
for (int i = 1; i < size; i++) {
Component component = parent.getComponent(i);
if (!component.isVisible()) {
group.add(((LinkLabel<AnAction>) component).getLinkData());
}
}
showPopup(link, group);
}
});
Notification.setDataProvider(notification, action);
action.setVisible(false);
actionPanel.add(action);
}
for (AnAction action : actions) {
Presentation presentation = action.getTemplatePresentation();
actionPanel.add(HorizontalLayout.LEFT, new LinkLabel<>(presentation.getText(), presentation.getIcon(), new LinkListener<AnAction>() {
@Override
public void linkSelected(LinkLabel aSource, AnAction action) {
Notification.fire(notification, action);
}
}, action));
}
Insets hover = JBUI.insets(8, 5, 8, 7);
int count = actionPanel.getComponentCount();
for (int i = 0; i < count; i++) {
hoverAdapter.addComponent(actionPanel.getComponent(i), hover);
}
hoverAdapter.addSource(actionPanel);
}
Aggregations