Search in sources :

Example 6 with CustomLineBorder

use of com.intellij.ui.border.CustomLineBorder in project intellij-community by JetBrains.

the class EditorHeaderComponent method uiSettingsChanged.

@Override
public void uiSettingsChanged(UISettings uiSettings) {
    boolean topBorderRequired = uiSettings.getEditorTabPlacement() != SwingConstants.TOP && (uiSettings.getShowNavigationBar() || uiSettings.getShowMainToolbar());
    setBorder(new CustomLineBorder(JBColor.border(), topBorderRequired ? 1 : 0, 0, 1, 0));
}
Also used : CustomLineBorder(com.intellij.ui.border.CustomLineBorder)

Example 7 with CustomLineBorder

use of com.intellij.ui.border.CustomLineBorder in project intellij-community by JetBrains.

the class AbstractExpandableItemsHandler method createToolTipImage.

@Nullable
private Point createToolTipImage(@NotNull KeyType key) {
    UIUtil.putClientProperty(myComponent, EXPANDED_RENDERER, true);
    Pair<Component, Rectangle> rendererAndBounds = getCellRendererAndBounds(key);
    UIUtil.putClientProperty(myComponent, EXPANDED_RENDERER, null);
    if (rendererAndBounds == null)
        return null;
    JComponent renderer = ObjectUtils.tryCast(rendererAndBounds.first, JComponent.class);
    if (renderer == null)
        return null;
    if (UIUtil.isClientPropertyTrue(renderer, RENDERER_DISABLED))
        return null;
    if (UIUtil.isClientPropertyTrue(rendererAndBounds.getFirst(), USE_RENDERER_BOUNDS)) {
        rendererAndBounds.getSecond().translate(renderer.getX(), renderer.getY());
        rendererAndBounds.getSecond().setSize(renderer.getSize());
    }
    myKeyItemBounds = rendererAndBounds.second;
    Rectangle cellBounds = myKeyItemBounds;
    Rectangle visibleRect = getVisibleRect(key);
    if (cellBounds.y < visibleRect.y)
        return null;
    int cellMaxY = cellBounds.y + cellBounds.height;
    int visMaxY = visibleRect.y + visibleRect.height;
    if (cellMaxY > visMaxY)
        return null;
    int cellMaxX = cellBounds.x + cellBounds.width;
    int visMaxX = visibleRect.x + visibleRect.width;
    Point location = new Point(visMaxX, cellBounds.y);
    SwingUtilities.convertPointToScreen(location, myComponent);
    Rectangle screen = ScreenUtil.getScreenRectangle(location);
    int borderWidth = isPaintBorder() ? 1 : 0;
    int width = Math.min(screen.width + screen.x - location.x - borderWidth, cellMaxX - visMaxX);
    int height = cellBounds.height;
    if (width <= 0 || height <= 0)
        return null;
    Dimension size = getImageSize(width, height);
    myImage = UIUtil.createImage(myComponent, size.width, size.height, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = myImage.createGraphics();
    g.setClip(null);
    doFillBackground(height, width, g);
    g.translate(cellBounds.x - visMaxX, 0);
    doPaintTooltipImage(renderer, cellBounds, g, key);
    CustomLineBorder border = null;
    if (borderWidth > 0) {
        border = new CustomLineBorder(getBorderColor(), borderWidth, 0, borderWidth, borderWidth);
        Insets insets = border.getBorderInsets(myTipComponent);
        location.y -= insets.top;
        JBInsets.addTo(size, insets);
    }
    g.dispose();
    myRendererPane.remove(renderer);
    myTipComponent.setBorder(border);
    myTipComponent.setPreferredSize(size);
    return location;
}
Also used : CustomLineBorder(com.intellij.ui.border.CustomLineBorder) Nullable(org.jetbrains.annotations.Nullable)

Example 8 with CustomLineBorder

use of com.intellij.ui.border.CustomLineBorder in project android by JetBrains.

the class GradleVersionRecommendedUpdateDialog method createSouthPanel.

@Override
@NotNull
protected JComponent createSouthPanel() {
    Action[] actions = createActions();
    List<JButton> buttons = Lists.newArrayList();
    JPanel panel = new JPanel(new BorderLayout());
    if (actions.length > 0) {
        JPanel buttonsPanel = createButtons(actions, buttons);
        panel.add(buttonsPanel, BorderLayout.CENTER);
        myButtons = buttons.toArray(new JButton[buttons.size()]);
    }
    if (getStyle() == DialogStyle.COMPACT) {
        Border line = new CustomLineBorder(OnePixelDivider.BACKGROUND, 1, 0, 0, 0);
        panel.setBorder(new CompoundBorder(line, empty(8, 12)));
    } else {
        panel.setBorder(emptyTop(8));
    }
    return panel;
}
Also used : CustomLineBorder(com.intellij.ui.border.CustomLineBorder) CompoundBorder(javax.swing.border.CompoundBorder) Border(javax.swing.border.Border) CompoundBorder(javax.swing.border.CompoundBorder) CustomLineBorder(com.intellij.ui.border.CustomLineBorder) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with CustomLineBorder

use of com.intellij.ui.border.CustomLineBorder in project android by JetBrains.

the class RecommendedPluginVersionUpdateDialog method createSouthPanel.

@Override
@NotNull
protected JComponent createSouthPanel() {
    Action[] actions = createActions();
    List<JButton> buttons = Lists.newArrayList();
    JPanel panel = new JPanel(new BorderLayout());
    if (actions.length > 0) {
        JPanel buttonsPanel = createButtons(actions, buttons);
        panel.add(buttonsPanel, BorderLayout.CENTER);
        myButtons = buttons.toArray(new JButton[buttons.size()]);
    }
    if (getStyle() == DialogStyle.COMPACT) {
        Border line = new CustomLineBorder(OnePixelDivider.BACKGROUND, 1, 0, 0, 0);
        panel.setBorder(new CompoundBorder(line, empty(8, 12)));
    } else {
        panel.setBorder(emptyTop(8));
    }
    return panel;
}
Also used : CustomLineBorder(com.intellij.ui.border.CustomLineBorder) CompoundBorder(javax.swing.border.CompoundBorder) Border(javax.swing.border.Border) CompoundBorder(javax.swing.border.CompoundBorder) CustomLineBorder(com.intellij.ui.border.CustomLineBorder) NotNull(org.jetbrains.annotations.NotNull)

Example 10 with CustomLineBorder

use of com.intellij.ui.border.CustomLineBorder in project intellij-community by JetBrains.

the class LibraryRootsComponent method init.

private void init(AbstractTreeStructure treeStructure) {
    myTree = new Tree(new DefaultTreeModel(new DefaultMutableTreeNode()));
    myTree.setRootVisible(false);
    myTree.setShowsRootHandles(true);
    new LibraryRootsTreeSpeedSearch(myTree);
    myTree.setCellRenderer(new LibraryTreeRenderer());
    myTreeBuilder = new LibraryTableTreeBuilder(myTree, (DefaultTreeModel) myTree.getModel(), treeStructure);
    myTreePanel.setLayout(new BorderLayout());
    ToolbarDecorator toolbarDecorator = ToolbarDecorator.createDecorator(myTree).disableUpDownActions().setRemoveActionName(ProjectBundle.message("library.remove.action")).disableRemoveAction();
    toolbarDecorator.setPanelBorder(new CustomLineBorder(1, 0, 0, 0));
    final List<AttachRootButtonDescriptor> popupItems = new ArrayList<>();
    for (AttachRootButtonDescriptor descriptor : myDescriptor.createAttachButtons()) {
        Icon icon = descriptor.getToolbarIcon();
        if (icon != null) {
            AttachItemAction action = new AttachItemAction(descriptor, descriptor.getButtonText(), icon);
            toolbarDecorator.addExtraAction(AnActionButton.fromAction(action));
        } else {
            popupItems.add(descriptor);
        }
    }
    myAddExcludedRootActionButton = new AddExcludedRootActionButton();
    toolbarDecorator.addExtraAction(myAddExcludedRootActionButton);
    toolbarDecorator.addExtraAction(new AnActionButton("Remove", IconUtil.getRemoveIcon()) {

        @Override
        public void actionPerformed(AnActionEvent e) {
            final Object[] selectedElements = getSelectedElements();
            if (selectedElements.length == 0) {
                return;
            }
            ApplicationManager.getApplication().runWriteAction(() -> {
                for (Object selectedElement : selectedElements) {
                    if (selectedElement instanceof ItemElement) {
                        final ItemElement itemElement = (ItemElement) selectedElement;
                        getLibraryEditor().removeRoot(itemElement.getUrl(), itemElement.getRootType());
                    } else if (selectedElement instanceof OrderRootTypeElement) {
                        final OrderRootType rootType = ((OrderRootTypeElement) selectedElement).getOrderRootType();
                        final String[] urls = getLibraryEditor().getUrls(rootType);
                        for (String url : urls) {
                            getLibraryEditor().removeRoot(url, rootType);
                        }
                    } else if (selectedElement instanceof ExcludedRootElement) {
                        getLibraryEditor().removeExcludedRoot(((ExcludedRootElement) selectedElement).getUrl());
                    }
                }
            });
            libraryChanged(true);
        }

        @Override
        public void updateButton(AnActionEvent e) {
            super.updateButton(e);
            Object[] elements = getSelectedElements();
            Presentation presentation = e.getPresentation();
            if (ContainerUtil.and(elements, new FilteringIterator.InstanceOf<>(ExcludedRootElement.class))) {
                presentation.setText("Cancel Exclusion");
            } else {
                presentation.setText(getTemplatePresentation().getText());
            }
        }

        @Override
        public ShortcutSet getShortcut() {
            return CommonShortcuts.getDelete();
        }
    });
    toolbarDecorator.setAddAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            if (popupItems.isEmpty()) {
                new AttachFilesAction(myDescriptor.getAttachFilesActionName()).actionPerformed(null);
                return;
            }
            List<AnAction> actions = new ArrayList<>();
            actions.add(new AttachFilesAction(myDescriptor.getAttachFilesActionName()));
            for (AttachRootButtonDescriptor descriptor : popupItems) {
                actions.add(new AttachItemAction(descriptor, descriptor.getButtonText(), null));
            }
            final DefaultActionGroup group = new DefaultActionGroup(actions);
            JBPopupFactory.getInstance().createActionGroupPopup(null, group, DataManager.getInstance().getDataContext(button.getContextComponent()), JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true).show(button.getPreferredPopupPoint());
        }
    });
    myTreePanel.add(toolbarDecorator.createPanel(), BorderLayout.CENTER);
    Disposer.register(this, myTreeBuilder);
}
Also used : AnActionButtonRunnable(com.intellij.ui.AnActionButtonRunnable) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Tree(com.intellij.ui.treeStructure.Tree) ToolbarDecorator(com.intellij.ui.ToolbarDecorator) List(java.util.List) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) AnActionButton(com.intellij.ui.AnActionButton) CustomLineBorder(com.intellij.ui.border.CustomLineBorder) PersistentOrderRootType(com.intellij.openapi.roots.PersistentOrderRootType) OrderRootType(com.intellij.openapi.roots.OrderRootType)

Aggregations

CustomLineBorder (com.intellij.ui.border.CustomLineBorder)14 CompoundBorder (javax.swing.border.CompoundBorder)5 ActionEvent (java.awt.event.ActionEvent)4 ActionListener (java.awt.event.ActionListener)4 Border (javax.swing.border.Border)4 EmptyBorder (javax.swing.border.EmptyBorder)4 NotNull (org.jetbrains.annotations.NotNull)4 TypeSafeDataProviderAdapter (com.intellij.ide.impl.TypeSafeDataProviderAdapter)1 IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)1 Module (com.intellij.openapi.module.Module)1 AbstractProgressIndicatorExBase (com.intellij.openapi.progress.util.AbstractProgressIndicatorExBase)1 Project (com.intellij.openapi.project.Project)1 ContentEntry (com.intellij.openapi.roots.ContentEntry)1 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)1 OrderRootType (com.intellij.openapi.roots.OrderRootType)1 PersistentOrderRootType (com.intellij.openapi.roots.PersistentOrderRootType)1 ScrollablePanel (com.intellij.openapi.roots.ui.componentsList.components.ScrollablePanel)1 VerticalStackLayout (com.intellij.openapi.roots.ui.componentsList.layout.VerticalStackLayout)1 VerticalFlowLayout (com.intellij.openapi.ui.VerticalFlowLayout)1 PluginDownloader (com.intellij.openapi.updateSettings.impl.PluginDownloader)1