Search in sources :

Example 1 with HorizontalLayout

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;
}
Also used : EditorFactory(com.intellij.openapi.editor.EditorFactory) EditorSettings(com.intellij.openapi.editor.EditorSettings) EditorEx(com.intellij.openapi.editor.ex.EditorEx) DocumentAdapter(com.intellij.openapi.editor.event.DocumentAdapter) Document(com.intellij.openapi.editor.Document) Editor(com.intellij.openapi.editor.Editor) DocumentEvent(com.intellij.openapi.editor.event.DocumentEvent) HorizontalLayout(com.intellij.ui.components.panels.HorizontalLayout)

Example 2 with HorizontalLayout

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;
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) DarculaButtonPainter(com.intellij.ide.ui.laf.darcula.ui.DarculaButtonPainter) ButtonUI(javax.swing.plaf.ButtonUI) DarculaButtonUI(com.intellij.ide.ui.laf.darcula.ui.DarculaButtonUI) ColorUIResource(javax.swing.plaf.ColorUIResource) HorizontalLayout(com.intellij.ui.components.panels.HorizontalLayout) Ref(com.intellij.openapi.util.Ref) DarculaButtonUI(com.intellij.ide.ui.laf.darcula.ui.DarculaButtonUI) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with HorizontalLayout

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);
}
Also used : JBInsets(com.intellij.util.ui.JBInsets) LinkListener(com.intellij.ui.components.labels.LinkListener) HorizontalLayout(com.intellij.ui.components.panels.HorizontalLayout) NonOpaquePanel(com.intellij.ui.components.panels.NonOpaquePanel) LinkLabel(com.intellij.ui.components.labels.LinkLabel)

Aggregations

HorizontalLayout (com.intellij.ui.components.panels.HorizontalLayout)3 DarculaButtonPainter (com.intellij.ide.ui.laf.darcula.ui.DarculaButtonPainter)1 DarculaButtonUI (com.intellij.ide.ui.laf.darcula.ui.DarculaButtonUI)1 Document (com.intellij.openapi.editor.Document)1 Editor (com.intellij.openapi.editor.Editor)1 EditorFactory (com.intellij.openapi.editor.EditorFactory)1 EditorSettings (com.intellij.openapi.editor.EditorSettings)1 DocumentAdapter (com.intellij.openapi.editor.event.DocumentAdapter)1 DocumentEvent (com.intellij.openapi.editor.event.DocumentEvent)1 EditorEx (com.intellij.openapi.editor.ex.EditorEx)1 Ref (com.intellij.openapi.util.Ref)1 LinkLabel (com.intellij.ui.components.labels.LinkLabel)1 LinkListener (com.intellij.ui.components.labels.LinkListener)1 NonOpaquePanel (com.intellij.ui.components.panels.NonOpaquePanel)1 JBInsets (com.intellij.util.ui.JBInsets)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 ButtonUI (javax.swing.plaf.ButtonUI)1 ColorUIResource (javax.swing.plaf.ColorUIResource)1 Nullable (org.jetbrains.annotations.Nullable)1