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