Example usage for com.intellij.openapi.ui.popup IconButton IconButton

List of usage examples for com.intellij.openapi.ui.popup IconButton IconButton

Introduction

In this page you can find the example usage for com.intellij.openapi.ui.popup IconButton IconButton.

Prototype

public IconButton(final String tooltip, final Icon regular, final Icon hovered) 

Source Link

Usage

From source file:com.android.tools.profilers.network.ConnectionDetailsView.java

License:Apache License

public ConnectionDetailsView() {
    super(new BorderLayout());

    // Create 2x2 pane
    //     * Fit//ww  w.j a  va2s . co m
    // Fit _ _
    // *   _ _
    //
    // where main contents span the whole area and a close button fits into the top right
    JPanel rootPanel = new JPanel(new TabularLayout("*,Fit", "Fit,*"));

    JBTabbedPane tabPanel = new JBTabbedPane();

    myResponsePanel = new JPanel(new BorderLayout());
    myEditorPanel = new JPanel(new BorderLayout());
    myResponsePanel.add(myEditorPanel, BorderLayout.CENTER);

    myFieldsPanel = new JPanel(new TabularLayout("Fit,20px,*").setVGap(10));
    JBScrollPane scrollPane = new JBScrollPane(myFieldsPanel);
    scrollPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 10, 0));
    myResponsePanel.add(scrollPane, BorderLayout.SOUTH);

    myCallstackView = new JTextArea();
    myCallstackView.setEditable(false);

    tabPanel.addTab("Response", myResponsePanel);
    tabPanel.addTab("Call Stack", myCallstackView);

    IconButton closeIcon = new IconButton("Close", AllIcons.Actions.Close, AllIcons.Actions.CloseHovered);
    InplaceButton closeButton = new InplaceButton(closeIcon, e -> this.update((HttpData) null));
    closeButton.setMinimumSize(closeButton.getPreferredSize()); // Prevent layout phase from squishing this button

    rootPanel.add(closeButton, new TabularLayout.Constraint(0, 1));
    rootPanel.add(tabPanel, new TabularLayout.Constraint(0, 0, 2, 2));

    add(rootPanel);
}

From source file:com.intellij.ui.InplaceButton.java

License:Apache License

public InplaceButton(String tooltip, final Icon icon, final ActionListener listener) {
    this(new IconButton(tooltip, icon, icon), listener, null);
}

From source file:com.intellij.ui.InplaceButton.java

License:Apache License

public InplaceButton(String tooltip, final Icon icon, final ActionListener listener,
        final Pass<MouseEvent> me) {
    this(new IconButton(tooltip, icon, icon), listener, me);
}

From source file:com.intellij.ui.popup.util.MasterDetailPopupBuilder.java

License:Apache License

public JBPopup createMasterDetailPopup() {

    setupRenderer();/*from www  .j a  va2s .c o  m*/

    myPathLabel = new JLabel(" ");
    myPathLabel.setHorizontalAlignment(SwingConstants.RIGHT);

    final Font font = myPathLabel.getFont();
    myPathLabel.setFont(font.deriveFont((float) 10));

    if (myDetailView == null) {
        myDetailView = new DetailViewImpl(myProject);
    }

    JPanel footerPanel = new JPanel(new BorderLayout()) {
        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.setColor(BORDER_COLOR);
            g.drawLine(0, 0, getWidth(), 0);
        }
    };

    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            IdeFocusManager.getInstance(myProject).doWhenFocusSettlesDown(new Runnable() {
                @Override
                public void run() {
                    Object[] values = getSelectedItems();
                    if (values.length == 1) {
                        myDelegate.itemChosen((ItemWrapper) values[0], myProject, myPopup, false);
                    } else {
                        for (Object value : values) {
                            if (value instanceof ItemWrapper) {
                                myDelegate.itemChosen((ItemWrapper) value, myProject, myPopup, false);
                            }
                        }
                    }
                }
            });
        }
    };

    footerPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    footerPanel.add(myPathLabel);

    JComponent toolBar = null;
    if (myActions != null) {
        myActionToolbar = ActionManager.getInstance().createActionToolbar("", myActions, true);
        myActionToolbar.setReservePlaceAutoPopupIcon(false);
        myActionToolbar.setMinimumButtonSize(new Dimension(20, 20));
        toolBar = myActionToolbar.getComponent();
        toolBar.setOpaque(false);
    }

    final PopupChooserBuilder builder = createInnerBuilder().setMovable(true).setResizable(true)
            .setAutoselectOnMouseMove(false).setSettingButton(toolBar).setSouthComponent(footerPanel)
            .setCancelOnWindowDeactivation(myCancelOnWindowDeactivation)
            .setCancelOnClickOutside(myCancelOnClickOutside)
            .setUseDimensionServiceForXYLocation(myUseDimensionServiceForXYLocation);

    if (myDoneRunnable != null) {

        ActionListener actionListener = new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent event) {
                myDoneRunnable.run();
            }
        };
        //native button is pretty enough
        if ((SystemInfo.isMacOSLion || SystemInfo.isMacOSMountainLion) && !UIUtil.isUnderDarcula()) {
            final JButton done = new JButton("Done");
            done.setMnemonic('o');
            done.addActionListener(actionListener);

            builder.setCommandButton(new ActiveComponent() {
                @Override
                public void setActive(boolean active) {
                }

                @Override
                public JComponent getComponent() {
                    return done;
                }
            });
        } else {
            builder.setCommandButton(new InplaceButton(
                    new IconButton("Close", AllIcons.Actions.CloseNew, AllIcons.Actions.CloseNewHovered),
                    actionListener));
        }
    }

    String title = myDelegate.getTitle();
    if (title != null) {
        builder.setTitle(title);
    }

    builder.setItemChoosenCallback(runnable).setCloseOnEnter(myCloseOnEnter).setMayBeParent(true)
            .setDimensionServiceKey(myDimensionServiceKey).setFilteringEnabled(new Function<Object, String>() {
                @Override
                public String fun(Object o) {
                    return ((ItemWrapper) o).speedSearchText();
                }
            });

    if (myMinSize != null) {
        builder.setMinSize(myMinSize);
    }

    myPopup = builder.createPopup();
    builder.getScrollPane().setBorder(IdeBorderFactory.createBorder(SideBorder.RIGHT));
    myPopup.addListener(new JBPopupListener() {
        @Override
        public void beforeShown(LightweightWindowEvent event) {
        }

        @Override
        public void onClosed(LightweightWindowEvent event) {
            myDetailView.clearEditor();
        }
    });

    if (myDoneRunnable != null) {
        new AnAction("Done") {
            @Override
            public void actionPerformed(AnActionEvent e) {
                myDoneRunnable.run();
            }
        }.registerCustomShortcutSet(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK, myPopup.getContent());
    }

    return myPopup;
}