Search in sources :

Example 6 with NonOpaquePanel

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

the class TraceViewPanel method createUIComponents.

private void createUIComponents() {
    MouseAdapter l = new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            if (e.getSource() == myCloseLabel) {
                closeSearchComponent();
            } else if (e.getSource() == mySearchLabel) {
                showSearchComponent();
            } else if (e.getSource() == myZoomFitLabel) {
                myTraceViewCanvas.zoomFit();
            }
        }
    };
    myDefaultHeaderPanel = new EditorHeaderComponent();
    mySearchLabel = new JLabel(AllIcons.Actions.Search);
    mySearchLabel.addMouseListener(l);
    mySearchLabel.setToolTipText("Find (Ctrl + F)");
    myZoomFitLabel = new JLabel(AndroidIcons.ZoomFit);
    myZoomFitLabel.setToolTipText("Zoom Fit");
    myZoomFitLabel.addMouseListener(l);
    myFindPanel = new EditorHeaderComponent();
    myFindFieldWrapper = new NonOpaquePanel(new BorderLayout());
    mySearchField = createSearchField();
    myFindFieldWrapper.add(mySearchField);
    myCloseLabel = new JLabel(AllIcons.Actions.Cross);
    myCloseLabel.addMouseListener(l);
    myVmStatsTreeTableModel = new VmStatsTreeTableModel();
    myTreeTable = new TreeTable(myVmStatsTreeTableModel);
    myTraceViewCanvas = new TraceViewCanvasWrapper();
    JBScrollPane scrollPane = new JBScrollPane(myTreeTable);
    mySplitter = new JBSplitter(true, 0.75f);
    mySplitter.setShowDividerControls(true);
    mySplitter.setShowDividerIcon(true);
    mySplitter.setFirstComponent(myTraceViewCanvas);
    mySplitter.setSecondComponent(scrollPane);
}
Also used : NonOpaquePanel(com.intellij.ui.components.panels.NonOpaquePanel) TreeTable(com.intellij.ui.treeStructure.treetable.TreeTable) EditorHeaderComponent(com.intellij.openapi.editor.impl.EditorHeaderComponent) JBSplitter(com.intellij.ui.JBSplitter) JBScrollPane(com.intellij.ui.components.JBScrollPane) VmStatsTreeTableModel(com.android.tools.idea.editors.vmtrace.treemodel.VmStatsTreeTableModel)

Example 7 with NonOpaquePanel

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

the class SearchEverywhereAction method actionPerformed.

public void actionPerformed(AnActionEvent e, MouseEvent me) {
    if (myBalloon != null && myBalloon.isVisible()) {
        showAll.set(!showAll.get());
        myNonProjectCheckBox.setSelected(showAll.get());
        //      myPopupField.getTextEditor().setBackground(showAll.get() ? new JBColor(new Color(0xffffe4), new Color(0x494539)) : UIUtil.getTextFieldBackground());
        rebuildList(myPopupField.getText());
        return;
    }
    myCurrentWorker = ActionCallback.DONE;
    if (e != null) {
        myEditor = e.getData(CommonDataKeys.EDITOR);
        myFileEditor = e.getData(PlatformDataKeys.FILE_EDITOR);
        myFile = e.getData(CommonDataKeys.PSI_FILE);
    }
    if (e == null && myFocusOwner != null) {
        e = AnActionEvent.createFromAnAction(this, me, ActionPlaces.UNKNOWN, DataManager.getInstance().getDataContext(myFocusOwner));
    }
    if (e == null)
        return;
    final Project project = e.getProject();
    if (project == null)
        return;
    //noinspection SSBasedInspection
    SwingUtilities.invokeLater(() -> LookupManager.getInstance(project).hideActiveLookup());
    updateComponents();
    myContextComponent = PlatformDataKeys.CONTEXT_COMPONENT.getData(e.getDataContext());
    Window wnd = myContextComponent != null ? SwingUtilities.windowForComponent(myContextComponent) : KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
    if (wnd == null && myContextComponent instanceof Window) {
        wnd = (Window) myContextComponent;
    }
    if (wnd == null || wnd.getParent() != null)
        return;
    myActionEvent = e;
    if (myPopupField != null) {
        Disposer.dispose(myPopupField);
    }
    myPopupField = new MySearchTextField();
    myPopupField.getTextEditor().addKeyListener(new KeyAdapter() {

        @Override
        public void keyTyped(KeyEvent e) {
            myHistoryIndex = 0;
            myHistoryItem = null;
        }

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_SHIFT) {
                myList.repaint();
            }
        }

        @Override
        public void keyReleased(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_SHIFT) {
                myList.repaint();
            }
        }
    });
    initSearchField(myPopupField);
    myPopupField.setOpaque(false);
    final JTextField editor = myPopupField.getTextEditor();
    editor.setColumns(SEARCH_FIELD_COLUMNS);
    final JPanel panel = new JPanel(new BorderLayout()) {

        @Override
        protected void paintComponent(Graphics g) {
            final Gradient gradient = getGradientColors();
            ((Graphics2D) g).setPaint(new GradientPaint(0, 0, gradient.getStartColor(), 0, getHeight(), gradient.getEndColor()));
            g.fillRect(0, 0, getWidth(), getHeight());
        }
    };
    final JLabel title = new JLabel(" Search Everywhere:       ");
    final JPanel topPanel = new NonOpaquePanel(new BorderLayout());
    title.setForeground(new JBColor(Gray._240, Gray._200));
    if (SystemInfo.isMac) {
        title.setFont(title.getFont().deriveFont(Font.BOLD, title.getFont().getSize() - 1f));
    } else {
        title.setFont(title.getFont().deriveFont(Font.BOLD));
    }
    topPanel.add(title, BorderLayout.WEST);
    final JPanel controls = new JPanel(new BorderLayout());
    controls.setOpaque(false);
    final JLabel settings = new JLabel(AllIcons.General.SearchEverywhereGear);
    new ClickListener() {

        @Override
        public boolean onClick(@NotNull MouseEvent event, int clickCount) {
            showSettings();
            return true;
        }
    }.installOn(settings);
    controls.add(settings, BorderLayout.EAST);
    myNonProjectCheckBox.setForeground(new JBColor(Gray._240, Gray._200));
    myNonProjectCheckBox.setText("Include non-project items (" + getShortcut() + ")  ");
    if (!NonProjectScopeDisablerEP.isSearchInNonProjectDisabled()) {
        controls.add(myNonProjectCheckBox, BorderLayout.WEST);
    }
    topPanel.add(controls, BorderLayout.EAST);
    panel.add(myPopupField, BorderLayout.CENTER);
    panel.add(topPanel, BorderLayout.NORTH);
    panel.setBorder(IdeBorderFactory.createEmptyBorder(3, 5, 4, 5));
    DataManager.registerDataProvider(panel, this);
    final ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(panel, editor);
    myBalloon = builder.setCancelOnClickOutside(true).setModalContext(false).setRequestFocus(true).setCancelCallback(() -> !mySkipFocusGain).createPopup();
    myBalloon.getContent().setBorder(JBUI.Borders.empty());
    final Window window = WindowManager.getInstance().suggestParentWindow(project);
    project.getMessageBus().connect(myBalloon).subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() {

        @Override
        public void enteredDumbMode() {
        }

        @Override
        public void exitDumbMode() {
            ApplicationManager.getApplication().invokeLater(() -> rebuildList(myPopupField.getText()));
        }
    });
    Component parent = UIUtil.findUltimateParent(window);
    registerDataProvider(panel, project);
    final RelativePoint showPoint;
    if (parent != null) {
        int height = UISettings.getInstance().getShowMainToolbar() ? 135 : 115;
        if (parent instanceof IdeFrameImpl && ((IdeFrameImpl) parent).isInFullScreen()) {
            height -= 20;
        }
        showPoint = new RelativePoint(parent, new Point((parent.getSize().width - panel.getPreferredSize().width) / 2, height));
    } else {
        showPoint = JBPopupFactory.getInstance().guessBestPopupLocation(e.getDataContext());
    }
    myList.setFont(UIUtil.getListFont());
    myBalloon.show(showPoint);
    initSearchActions(myBalloon, myPopupField);
    IdeFocusManager focusManager = IdeFocusManager.getInstance(project);
    focusManager.requestFocus(editor, true);
    FeatureUsageTracker.getInstance().triggerFeatureUsed(IdeActions.ACTION_SEARCH_EVERYWHERE);
}
Also used : RelativePoint(com.intellij.ui.awt.RelativePoint) NonOpaquePanel(com.intellij.ui.components.panels.NonOpaquePanel) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) IdeFrameImpl(com.intellij.openapi.wm.impl.IdeFrameImpl) RelativePoint(com.intellij.ui.awt.RelativePoint) DumbService(com.intellij.openapi.project.DumbService) RelativePoint(com.intellij.ui.awt.RelativePoint) Project(com.intellij.openapi.project.Project) ComponentPopupBuilder(com.intellij.openapi.ui.popup.ComponentPopupBuilder)

Example 8 with NonOpaquePanel

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

the class RunnerContentUi method initUi.

public void initUi() {
    if (myTabs != null)
        return;
    myTabs = (JBRunnerTabs) new JBRunnerTabs(myProject, myActionManager, myFocusManager, this).setDataProvider(new DataProvider() {

        @Override
        public Object getData(@NonNls final String dataId) {
            if (ViewContext.CONTENT_KEY.is(dataId)) {
                TabInfo info = myTabs.getTargetInfo();
                if (info != null) {
                    return getGridFor(info).getData(dataId);
                }
            } else if (ViewContext.CONTEXT_KEY.is(dataId)) {
                return RunnerContentUi.this;
            }
            return null;
        }
    }).setTabLabelActionsAutoHide(false).setInnerInsets(JBUI.emptyInsets()).setToDrawBorderIfTabsHidden(false).setTabDraggingEnabled(isMoveToGridActionEnabled()).setUiDecorator(null).getJBTabs();
    rebuildTabPopup();
    myTabs.getPresentation().setPaintBorder(0, 0, 0, 0).setPaintFocus(false).setRequestFocusOnLastFocusedComponent(true);
    myTabs.getComponent().setBackground(myToolbar.getBackground());
    myTabs.getComponent().setBorder(new EmptyBorder(0, 1, 0, 0));
    final NonOpaquePanel wrappper = new MyComponent(new BorderLayout(0, 0));
    wrappper.add(myToolbar, BorderLayout.WEST);
    wrappper.add(myTabs.getComponent(), BorderLayout.CENTER);
    wrappper.setBorder(new EmptyBorder(-1, 0, 0, 0));
    myComponent = wrappper;
    myTabs.addListener(new TabsListener.Adapter() {

        @Override
        public void beforeSelectionChanged(TabInfo oldSelection, TabInfo newSelection) {
            if (oldSelection != null && !isStateBeingRestored()) {
                final GridImpl grid = getGridFor(oldSelection);
                if (grid != null && getTabFor(grid) != null) {
                    grid.saveUiState();
                }
            }
        }

        @Override
        public void tabsMoved() {
            saveUiState();
        }

        @Override
        public void selectionChanged(final TabInfo oldSelection, final TabInfo newSelection) {
            if (!myTabs.getComponent().isShowing())
                return;
            if (newSelection != null) {
                newSelection.stopAlerting();
                getGridFor(newSelection).processAddToUi(false);
            }
            if (oldSelection != null) {
                getGridFor(oldSelection).processRemoveFromUi();
            }
        }
    });
    myTabs.addTabMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(@NotNull MouseEvent e) {
            if (UIUtil.isCloseClick(e)) {
                final TabInfo tabInfo = myTabs.findInfo(e);
                final GridImpl grid = tabInfo == null ? null : getGridFor(tabInfo);
                final Content[] contents = grid != null ? CONTENT_KEY.getData(grid) : null;
                if (contents == null)
                    return;
                // see GridCellImpl.closeOrMinimize as well
                if (CloseViewAction.isEnabled(contents)) {
                    CloseViewAction.perform(RunnerContentUi.this, contents[0]);
                } else if (MinimizeViewAction.isEnabled(RunnerContentUi.this, contents, ViewContext.TAB_TOOLBAR_PLACE)) {
                    grid.getCellFor(contents[0]).minimize(contents[0]);
                }
            }
        }
    });
    if (myOriginal != null) {
        final ContentManager manager = ContentFactory.SERVICE.getInstance().createContentManager(this, false, myProject);
        Disposer.register((Disposable) myRunnerUi, manager);
        manager.getComponent();
    } else {
        final DockManager dockManager = DockManager.getInstance(myProject);
        if (dockManager != null) {
            //default project
            dockManager.register(this);
        }
    }
}
Also used : MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) NonOpaquePanel(com.intellij.ui.components.panels.NonOpaquePanel) TabsListener(com.intellij.ui.tabs.TabsListener) DockManager(com.intellij.ui.docking.DockManager) TabInfo(com.intellij.ui.tabs.TabInfo) EmptyBorder(javax.swing.border.EmptyBorder)

Example 9 with NonOpaquePanel

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

the class ShowRunningListAction method getCurrentState.

private static Pair<? extends JComponent, String> getCurrentState(@NotNull List<Project> projects) {
    NonOpaquePanel panel = new NonOpaquePanel(new GridLayout(0, 1, 10, 10));
    StringBuilder state = new StringBuilder();
    for (int i = 0; i < projects.size(); i++) {
        Project project = projects.get(i);
        final ExecutionManagerImpl executionManager = ExecutionManagerImpl.getInstance(project);
        List<RunContentDescriptor> runningDescriptors = executionManager.getRunningDescriptors(Condition.TRUE);
        if (!runningDescriptors.isEmpty() && projects.size() > 1) {
            state.append(project.getName());
            panel.add(new JLabel("<html><body><b>Project '" + project.getName() + "'</b></body></html>"));
        }
        for (RunContentDescriptor descriptor : runningDescriptors) {
            Set<Executor> executors = executionManager.getExecutors(descriptor);
            for (Executor executor : executors) {
                state.append(System.identityHashCode(descriptor.getAttachedContent())).append("@").append(System.identityHashCode(executor.getIcon())).append(";");
                ProcessHandler processHandler = descriptor.getProcessHandler();
                Icon icon = (processHandler instanceof KillableProcess && processHandler.isProcessTerminating()) ? AllIcons.Debugger.KillProcess : executor.getIcon();
                JLabel label = new JLabel("<html><body><a href=\"\">" + descriptor.getDisplayName() + "</a></body></html>", icon, SwingConstants.LEADING);
                label.setIconTextGap(JBUI.scale(2));
                label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                label.putClientProperty(KEY, Trinity.create(project, executor, descriptor));
                panel.add(label);
            }
        }
    }
    if (panel.getComponentCount() == 0) {
        panel.setBorder(JBUI.Borders.empty(10));
        panel.add(new JLabel(ExecutionBundle.message("show.running.list.balloon.nothing"), SwingConstants.CENTER));
    } else {
        panel.setBorder(JBUI.Borders.empty(10, 10, 0, 10));
        JLabel label = new JLabel(ExecutionBundle.message("show.running.list.balloon.hint"));
        label.setFont(JBUI.Fonts.miniFont());
        panel.add(label);
    }
    return Pair.create(panel, state.toString());
}
Also used : RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) RelativePoint(com.intellij.ui.awt.RelativePoint) KillableProcess(com.intellij.execution.KillableProcess) NonOpaquePanel(com.intellij.ui.components.panels.NonOpaquePanel) Project(com.intellij.openapi.project.Project) Executor(com.intellij.execution.Executor) ProcessHandler(com.intellij.execution.process.ProcessHandler) LayeredIcon(com.intellij.ui.LayeredIcon) ExecutionManagerImpl(com.intellij.execution.impl.ExecutionManagerImpl)

Example 10 with NonOpaquePanel

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

the class NewRecentProjectPanel method createRenderer.

@Override
protected ListCellRenderer createRenderer(UniqueNameBuilder<ReopenProjectAction> pathShortener) {
    return new RecentProjectItemRenderer(myPathShortener) {

        private GridBagConstraints nameCell;

        private GridBagConstraints pathCell;

        private GridBagConstraints closeButtonCell;

        private void initConstraints() {
            nameCell = new GridBagConstraints();
            pathCell = new GridBagConstraints();
            closeButtonCell = new GridBagConstraints();
            nameCell.gridx = 0;
            nameCell.gridy = 0;
            nameCell.weightx = 1.0;
            nameCell.weighty = 1.0;
            nameCell.anchor = GridBagConstraints.FIRST_LINE_START;
            nameCell.insets = JBUI.insets(6, 5, 1, 5);
            pathCell.gridx = 0;
            pathCell.gridy = 1;
            pathCell.insets = JBUI.insets(1, 5, 6, 5);
            pathCell.anchor = GridBagConstraints.LAST_LINE_START;
            closeButtonCell.gridx = 1;
            closeButtonCell.gridy = 0;
            closeButtonCell.anchor = GridBagConstraints.FIRST_LINE_END;
            closeButtonCell.insets = JBUI.insets(7, 7, 7, 7);
            closeButtonCell.gridheight = 2;
        //closeButtonCell.anchor = GridBagConstraints.WEST;
        }

        @Override
        protected Color getListBackground(boolean isSelected, boolean hasFocus) {
            return isSelected ? FlatWelcomeFrame.getListSelectionColor(hasFocus) : FlatWelcomeFrame.getProjectsBackground();
        }

        @Override
        protected Color getListForeground(boolean isSelected, boolean hasFocus) {
            return UIUtil.getListForeground(isSelected && hasFocus);
        }

        @Override
        protected void layoutComponents() {
            setLayout(new GridBagLayout());
            initConstraints();
            add(myName, nameCell);
            add(myPath, pathCell);
        }

        JComponent spacer = new NonOpaquePanel() {

            @Override
            public Dimension getPreferredSize() {
                return new Dimension(JBUI.scale(22), super.getPreferredSize().height);
            }
        };

        @Override
        public Component getListCellRendererComponent(JList list, final Object value, int index, final boolean isSelected, boolean cellHasFocus) {
            final Color fore = getListForeground(isSelected, list.hasFocus());
            final Color back = getListBackground(isSelected, list.hasFocus());
            final JLabel name = new JLabel();
            final JLabel path = new JLabel();
            name.setForeground(fore);
            path.setForeground(isSelected ? fore : UIUtil.getInactiveTextColor());
            setBackground(back);
            return new JPanel() {

                {
                    setLayout(new BorderLayout());
                    setBackground(back);
                    boolean isGroup = value instanceof ProjectGroupActionGroup;
                    boolean isInsideGroup = false;
                    if (value instanceof ReopenProjectAction) {
                        final String path = ((ReopenProjectAction) value).getProjectPath();
                        for (ProjectGroup group : RecentProjectsManager.getInstance().getGroups()) {
                            final List<String> projects = group.getProjects();
                            if (projects.contains(path)) {
                                isInsideGroup = true;
                                break;
                            }
                        }
                    }
                    setBorder(JBUI.Borders.empty(5, 7));
                    if (isInsideGroup) {
                        add(spacer, BorderLayout.WEST);
                    }
                    if (isGroup) {
                        final ProjectGroup group = ((ProjectGroupActionGroup) value).getGroup();
                        name.setText(" " + group.getName());
                        name.setIcon(IconUtil.toSize(group.isExpanded() ? UIUtil.getTreeExpandedIcon() : UIUtil.getTreeCollapsedIcon(), JBUI.scale(16), JBUI.scale(16)));
                        name.setFont(name.getFont().deriveFont(Font.BOLD));
                        add(name);
                    } else if (value instanceof ReopenProjectAction) {
                        final NonOpaquePanel p = new NonOpaquePanel(new BorderLayout());
                        name.setText(((ReopenProjectAction) value).getProjectName());
                        final String realPath = ((ReopenProjectAction) value).getProjectPath();
                        path.setText(getTitle2Text((ReopenProjectAction) value, path, JBUI.scale(isInsideGroup ? 80 : 60)));
                        if (!realPath.equals(path.getText())) {
                            projectsWithLongPathes.add((ReopenProjectAction) value);
                        }
                        p.add(name, BorderLayout.NORTH);
                        p.add(path, BorderLayout.SOUTH);
                        String projectPath = ((ReopenProjectAction) value).getProjectPath();
                        Icon icon = RecentProjectsManagerBase.getProjectIcon(projectPath, UIUtil.isUnderDarcula());
                        if (icon == null) {
                            if (UIUtil.isUnderDarcula()) {
                                //No dark icon for this project
                                icon = RecentProjectsManagerBase.getProjectIcon(projectPath, false);
                            }
                        }
                        if (icon == null) {
                            icon = EmptyIcon.ICON_16;
                        }
                        final JLabel projectIcon = new JLabel("", icon, SwingConstants.LEFT) {

                            @Override
                            protected void paintComponent(Graphics g) {
                                getIcon().paintIcon(this, g, 0, (getHeight() - getIcon().getIconHeight()) / 2);
                            }
                        };
                        projectIcon.setBorder(JBUI.Borders.emptyRight(8));
                        projectIcon.setVerticalAlignment(SwingConstants.CENTER);
                        final NonOpaquePanel panel = new NonOpaquePanel(new BorderLayout());
                        panel.add(p);
                        panel.add(projectIcon, BorderLayout.WEST);
                        add(panel);
                    }
                    AccessibleContextUtil.setCombinedName(this, name, " - ", path);
                    AccessibleContextUtil.setCombinedDescription(this, name, " - ", path);
                }

                @Override
                public Dimension getPreferredSize() {
                    return new Dimension(super.getPreferredSize().width, JBUI.scale(44));
                }
            };
        }
    };
}
Also used : JBDimension(com.intellij.util.ui.JBDimension) NonOpaquePanel(com.intellij.ui.components.panels.NonOpaquePanel) EmptyIcon(com.intellij.util.ui.EmptyIcon)

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