Search in sources :

Example 16 with NonOpaquePanel

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

the class DialogWrapper method createButtonsPanel.

@NotNull
private JPanel createButtonsPanel(@NotNull List<JButton> buttons) {
    int hgap = SystemInfo.isMacOSLeopard ? UIUtil.isUnderIntelliJLaF() ? 8 : 0 : 5;
    JPanel buttonsPanel = new NonOpaquePanel(new GridLayout(1, buttons.size(), hgap, 0));
    for (final JButton button : buttons) {
        buttonsPanel.add(button);
    }
    return buttonsPanel;
}
Also used : NonOpaquePanel(com.intellij.ui.components.panels.NonOpaquePanel) RelativePoint(com.intellij.ui.awt.RelativePoint) NotNull(org.jetbrains.annotations.NotNull)

Example 17 with NonOpaquePanel

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

the class DialogWrapper method createSouthPanel.

@NotNull
private JPanel createSouthPanel(@NotNull List<JButton> leftSideButtons, @NotNull List<JButton> rightSideButtons, boolean hasHelpToMoveToLeftSide) {
    JPanel panel = new JPanel(new BorderLayout()) {

        @Override
        public Color getBackground() {
            final Color bg = UIManager.getColor("DialogWrapper.southPanelBackground");
            if (getStyle() == DialogStyle.COMPACT && bg != null) {
                return bg;
            }
            return super.getBackground();
        }
    };
    if (myDoNotAsk != null) {
        myCheckBoxDoNotShowDialog = new JCheckBox(myDoNotAsk.getDoNotShowMessage());
        myCheckBoxDoNotShowDialog.setVisible(myDoNotAsk.canBeHidden());
        myCheckBoxDoNotShowDialog.setSelected(!myDoNotAsk.isToBeShown());
        DialogUtil.registerMnemonic(myCheckBoxDoNotShowDialog, '&');
    }
    JComponent doNotAskCheckbox = createDoNotAskCheckbox();
    final JPanel lrButtonsPanel = new NonOpaquePanel(new GridBagLayout());
    //noinspection UseDPIAwareInsets
    //don't wrap to JBInsets
    final Insets insets = SystemInfo.isMacOSLeopard ? UIUtil.isUnderIntelliJLaF() ? JBUI.insets(0, 8) : JBUI.emptyInsets() : new Insets(8, 0, 0, 0);
    if (rightSideButtons.size() > 0 || leftSideButtons.size() > 0) {
        GridBag bag = new GridBag().setDefaultInsets(insets);
        if (leftSideButtons.size() > 0) {
            JPanel buttonsPanel = createButtonsPanel(leftSideButtons);
            if (rightSideButtons.size() > 0) {
                // leave some space between button groups
                buttonsPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 20));
            }
            lrButtonsPanel.add(buttonsPanel, bag.next());
        }
        // left strut
        lrButtonsPanel.add(Box.createHorizontalGlue(), bag.next().weightx(1).fillCellHorizontally());
        if (rightSideButtons.size() > 0) {
            JPanel buttonsPanel = createButtonsPanel(rightSideButtons);
            if (shouldAddErrorNearButtons()) {
                lrButtonsPanel.add(myErrorText, bag.next());
                lrButtonsPanel.add(Box.createHorizontalStrut(10), bag.next());
            }
            lrButtonsPanel.add(buttonsPanel, bag.next());
        }
        if (SwingConstants.CENTER == myButtonAlignment && doNotAskCheckbox == null) {
            // right strut
            lrButtonsPanel.add(Box.createHorizontalGlue(), bag.next().weightx(1).fillCellHorizontally());
        }
    }
    JComponent helpButton = null;
    if (hasHelpToMoveToLeftSide) {
        helpButton = createHelpButton(insets);
    }
    if (helpButton != null || doNotAskCheckbox != null) {
        JPanel leftPanel = new JPanel(new BorderLayout());
        if (helpButton != null)
            leftPanel.add(helpButton, BorderLayout.WEST);
        if (doNotAskCheckbox != null) {
            doNotAskCheckbox.setBorder(JBUI.Borders.emptyRight(20));
            leftPanel.add(doNotAskCheckbox, BorderLayout.CENTER);
        }
        panel.add(leftPanel, BorderLayout.WEST);
    }
    panel.add(lrButtonsPanel, BorderLayout.CENTER);
    if (getStyle() == DialogStyle.COMPACT) {
        final Color color = UIManager.getColor("DialogWrapper.southPanelDivider");
        Border line = new CustomLineBorder(color != null ? color : OnePixelDivider.BACKGROUND, 1, 0, 0, 0);
        panel.setBorder(new CompoundBorder(line, JBUI.Borders.empty(8, 12)));
    } else {
        panel.setBorder(JBUI.Borders.emptyTop(8));
    }
    return panel;
}
Also used : NonOpaquePanel(com.intellij.ui.components.panels.NonOpaquePanel) CustomLineBorder(com.intellij.ui.border.CustomLineBorder) JBColor(com.intellij.ui.JBColor) CompoundBorder(javax.swing.border.CompoundBorder) Border(javax.swing.border.Border) CompoundBorder(javax.swing.border.CompoundBorder) EmptyBorder(javax.swing.border.EmptyBorder) CustomLineBorder(com.intellij.ui.border.CustomLineBorder) NotNull(org.jetbrains.annotations.NotNull)

Example 18 with NonOpaquePanel

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

the class EditorComposite method manageTopOrBottomComponent.

private void manageTopOrBottomComponent(FileEditor editor, JComponent component, boolean top, boolean remove) {
    final JComponent container = top ? myTopComponents.get(editor) : myBottomComponents.get(editor);
    assert container != null;
    if (remove) {
        container.remove(component.getParent());
    } else {
        NonOpaquePanel wrapper = new NonOpaquePanel(component);
        wrapper.setBorder(createTopBottomSideBorder(top));
        container.add(wrapper, calcComponentInsertionIndex(component, container));
    }
    container.revalidate();
}
Also used : NonOpaquePanel(com.intellij.ui.components.panels.NonOpaquePanel)

Example 19 with NonOpaquePanel

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

the class ShowXPathAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    final Editor editor = CommonDataKeys.EDITOR.getData(e.getDataContext());
    if (editor == null) {
        return;
    }
    final Project project = editor.getProject();
    if (project == null) {
        return;
    }
    final PsiDocumentManager docmgr = PsiDocumentManager.getInstance(project);
    final Document document = editor.getDocument();
    docmgr.commitDocument(document);
    final PsiFile psiFile = docmgr.getPsiFile(document);
    if (!(psiFile instanceof XmlFile)) {
        return;
    }
    final PsiElement element = psiFile.findElementAt(editor.getCaretModel().getOffset());
    if (!(element instanceof XmlElement || element instanceof PsiWhiteSpace)) {
        XPathAppComponent.showEditorHint("No suitable context for an XPath-expression selected.", editor);
        return;
    }
    final PsiElement node = XPathExpressionGenerator.transformToValidShowPathNode(element);
    if (node == null) {
        XPathAppComponent.showEditorHint("No suitable context for an XPath-expression selected.", editor);
        return;
    }
    final Config cfg = XPathAppComponent.getInstance().getConfig();
    final RangeHighlighter h = HighlighterUtil.highlightNode(editor, node, cfg.getContextAttributes(), cfg);
    final String path = XPathSupport.getInstance().getUniquePath((XmlElement) node, null);
    final JTextField label = new JTextField(path);
    label.setPreferredSize(new Dimension(label.getPreferredSize().width + new JLabel("M").getPreferredSize().width, label.getPreferredSize().height));
    label.setOpaque(false);
    label.setEditable(false);
    label.setBorder(null);
    label.setHorizontalAlignment(SwingConstants.CENTER);
    label.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    final JPanel p = new NonOpaquePanel(new BorderLayout());
    final JLabel l = new JLabel("XPath:");
    p.add(l, BorderLayout.WEST);
    p.add(label, BorderLayout.CENTER);
    InplaceButton copy = new InplaceButton(ActionsBundle.message("action.EditorCopy.text"), PlatformIcons.COPY_ICON, new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            CopyPasteManager.getInstance().setContents(new StringSelection(path));
        }
    });
    p.add(copy, BorderLayout.EAST);
    final LightweightHint hint = new LightweightHint(p) {

        public void hide() {
            super.hide();
            HighlighterUtil.removeHighlighter(editor, h);
        }
    };
    final Point point = editor.visualPositionToXY(editor.getCaretModel().getVisualPosition());
    point.y += editor.getLineHeight() / 2;
    HintHint hintHint = new HintHint(editor, point).setAwtTooltip(true).setContentActive(true).setExplicitClose(true).setShowImmediately(true);
    HintManagerImpl.getInstanceImpl().showEditorHint(hint, editor, point, HintManager.HIDE_BY_ANY_KEY, 0, false, hintHint);
}
Also used : ActionEvent(java.awt.event.ActionEvent) Document(com.intellij.openapi.editor.Document) StringSelection(java.awt.datatransfer.StringSelection) RangeHighlighter(com.intellij.openapi.editor.markup.RangeHighlighter) NonOpaquePanel(com.intellij.ui.components.panels.NonOpaquePanel) PsiFile(com.intellij.psi.PsiFile) PsiElement(com.intellij.psi.PsiElement) PsiDocumentManager(com.intellij.psi.PsiDocumentManager) XmlFile(com.intellij.psi.xml.XmlFile) LightweightHint(com.intellij.ui.LightweightHint) InplaceButton(com.intellij.ui.InplaceButton) Project(com.intellij.openapi.project.Project) HintHint(com.intellij.ui.HintHint) ActionListener(java.awt.event.ActionListener) XmlElement(com.intellij.psi.xml.XmlElement) Editor(com.intellij.openapi.editor.Editor) PsiWhiteSpace(com.intellij.psi.PsiWhiteSpace)

Example 20 with NonOpaquePanel

use of com.intellij.ui.components.panels.NonOpaquePanel in project intellij-plugins by JetBrains.

the class IDEtalkMessagesWindowImpl method createToolWindowComponent.

@Override
protected void createToolWindowComponent() {
    myContentFactory = ContentFactory.SERVICE.getInstance();
    TabbedPaneContentUI contentUI = new TabbedPaneContentUI(SwingConstants.TOP);
    myContentManager = myContentFactory.createContentManager(contentUI, true, myProject);
    try {
        myTabsWrapper = getWrapper(contentUI);
    } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
    }
    myContentManager.addContentManagerListener(new ContentManagerAdapter() {

        @Override
        public void selectionChanged(ContentManagerEvent event) {
            super.selectionChanged(event);
            // Process tab switching:
            UIUtil.invokeLater(() -> processMessagesOfVisibleTab());
        }
    });
    myPanel = new NonOpaquePanel(new BorderLayout());
    UIUtil.runWhenShown(myPanel, () -> showAllTabsOfUsersWithMessages());
    myPanel.add(myContentManager.getComponent());
    AnAction toolbarGroup = myActionManager.getAction("IDEtalk.MessageWindowToolbar");
    if (toolbarGroup != null) {
        ActionToolbar toolbar = myActionManager.createActionToolbar(PLACE_TOOLBAR, (ActionGroup) toolbarGroup, false);
        myPanel.add(toolbar.getComponent(), BorderLayout.WEST);
    }
}
Also used : NonOpaquePanel(com.intellij.ui.components.panels.NonOpaquePanel) ActionToolbar(com.intellij.openapi.actionSystem.ActionToolbar) AnAction(com.intellij.openapi.actionSystem.AnAction)

Aggregations

NonOpaquePanel (com.intellij.ui.components.panels.NonOpaquePanel)20 NotNull (org.jetbrains.annotations.NotNull)5 RelativePoint (com.intellij.ui.awt.RelativePoint)4 EmptyBorder (javax.swing.border.EmptyBorder)4 Project (com.intellij.openapi.project.Project)3 JBColor (com.intellij.ui.JBColor)3 LinkLabel (com.intellij.ui.components.labels.LinkLabel)3 HintHint (com.intellij.ui.HintHint)2 TabInfo (com.intellij.ui.tabs.TabInfo)2 VmStatsTreeTableModel (com.android.tools.idea.editors.vmtrace.treemodel.VmStatsTreeTableModel)1 Executor (com.intellij.execution.Executor)1 KillableProcess (com.intellij.execution.KillableProcess)1 ExecutionManagerImpl (com.intellij.execution.impl.ExecutionManagerImpl)1 ProcessHandler (com.intellij.execution.process.ProcessHandler)1 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)1 PropertiesComponent (com.intellij.ide.util.PropertiesComponent)1 ActionToolbar (com.intellij.openapi.actionSystem.ActionToolbar)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 Document (com.intellij.openapi.editor.Document)1 Editor (com.intellij.openapi.editor.Editor)1