Search in sources :

Example 1 with BorderLayoutPanel

use of com.intellij.util.ui.components.BorderLayoutPanel in project intellij-community by JetBrains.

the class ToBeMergedDialog method initUI.

private void initUI() {
    final ListSelectionListener selectionListener = e -> {
        List<SvnChangeList> changeLists = myRevisionsList.getSelectedObjects();
        myAlreadyMerged.clear();
        for (SvnChangeList changeList : changeLists) {
            myAlreadyMerged.addAll(getAlreadyMergedPaths(changeList));
        }
        myRepositoryChangesBrowser.setChangesToDisplay(collectChanges(changeLists, false));
        mySplitter.doLayout();
        myRepositoryChangesBrowser.repaint();
    };
    final MyListCellRenderer listCellRenderer = new MyListCellRenderer();
    myRevisionsList = new TableView<SvnChangeList>() {

        @Override
        public TableCellRenderer getCellRenderer(int row, int column) {
            return listCellRenderer;
        }

        @Override
        public void valueChanged(ListSelectionEvent e) {
            super.valueChanged(e);
            selectionListener.valueChanged(e);
        }
    };
    myRevisionsList.setExpandableItemsEnabled(false);
    new TableViewSpeedSearch<SvnChangeList>(myRevisionsList) {

        @Override
        protected String getItemText(@NotNull SvnChangeList element) {
            return element.getComment();
        }
    };
    myRevisionsList.setModelAndUpdateColumns(myRevisionsModel);
    myRevisionsList.setTableHeader(null);
    myRevisionsList.setShowGrid(false);
    final AbstractBaseTagMouseListener mouseListener = new AbstractBaseTagMouseListener() {

        @Override
        public Object getTagAt(@NotNull MouseEvent e) {
            JTable table = (JTable) e.getSource();
            int row = table.rowAtPoint(e.getPoint());
            int column = table.columnAtPoint(e.getPoint());
            if (row == -1 || column == -1)
                return null;
            listCellRenderer.customizeCellRenderer(table, table.getValueAt(row, column), table.isRowSelected(row));
            return listCellRenderer.myRenderer.getFragmentTagAt(e.getPoint().x - table.getCellRect(row, column, false).x);
        }
    };
    mouseListener.installOn(myRevisionsList);
    myMore100Action = new MoreXAction(100);
    myMore500Action = new MoreXAction(500);
    BorderLayoutPanel panel = JBUI.Panels.simplePanel().addToCenter(ScrollPaneFactory.createScrollPane(myRevisionsList)).addToTop(createToolbar().getComponent());
    mySplitter = new Splitter(false, 0.7f);
    mySplitter.setFirstComponent(panel);
    myRepositoryChangesBrowser = new RepositoryChangesBrowser(myMergeContext.getProject(), Collections.<SvnChangeList>emptyList(), emptyList(), null);
    myRepositoryChangesBrowser.getDiffAction().registerCustomShortcutSet(myRepositoryChangesBrowser.getDiffAction().getShortcutSet(), myRevisionsList);
    setChangesDecorator();
    mySplitter.setSecondComponent(myRepositoryChangesBrowser);
    mySplitter.setDividerWidth(2);
    addRevisionListListeners();
    myPanel.add(mySplitter, BorderLayout.CENTER);
}
Also used : UIUtil(com.intellij.util.ui.UIUtil) AllIcons(com.intellij.icons.AllIcons) MessageType(com.intellij.openapi.ui.MessageType) CommittedChangesTreeBrowser.collectChanges(com.intellij.openapi.vcs.changes.committed.CommittedChangesTreeBrowser.collectChanges) Change(com.intellij.openapi.vcs.changes.Change) MergeChecker(org.jetbrains.idea.svn.mergeinfo.MergeChecker) ColumnInfo(com.intellij.util.ui.ColumnInfo) MergeCalculatorTask.getBunchSize(org.jetbrains.idea.svn.integrate.MergeCalculatorTask.getBunchSize) TableCellRenderer(javax.swing.table.TableCellRenderer) Collections.singletonList(java.util.Collections.singletonList) Task(com.intellij.openapi.progress.Task) BorderLayoutPanel(com.intellij.util.ui.components.BorderLayoutPanel) JBUI(com.intellij.util.ui.JBUI) Collections.synchronizedMap(java.util.Collections.synchronizedMap) CommittedChangeListRenderer(com.intellij.openapi.vcs.changes.committed.CommittedChangeListRenderer) VcsException(com.intellij.openapi.vcs.VcsException) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ContainerUtilRt.newHashSet(com.intellij.util.containers.ContainerUtilRt.newHashSet) TableView(com.intellij.ui.table.TableView) KeyEvent(java.awt.event.KeyEvent) com.intellij.ui(com.intellij.ui) Collectors(java.util.stream.Collectors) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) SvnChangeList(org.jetbrains.idea.svn.history.SvnChangeList) List(java.util.List) ApplicationManager(com.intellij.openapi.application.ApplicationManager) NotNull(org.jetbrains.annotations.NotNull) AbstractBaseTagMouseListener(com.intellij.openapi.vcs.changes.issueLinks.AbstractBaseTagMouseListener) java.util(java.util) KeyAdapter(java.awt.event.KeyAdapter) ContainerUtil(com.intellij.util.containers.ContainerUtil) MergeCalculatorTask.loadChangeLists(org.jetbrains.idea.svn.integrate.MergeCalculatorTask.loadChangeLists) SvnMergeInfoCache(org.jetbrains.idea.svn.mergeinfo.SvnMergeInfoCache) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) ListTableModel(com.intellij.util.ui.ListTableModel) ContainerUtilRt.emptyList(com.intellij.util.containers.ContainerUtilRt.emptyList) Splitter(com.intellij.openapi.ui.Splitter) ListMergeStatus(org.jetbrains.idea.svn.mergeinfo.ListMergeStatus) ChangeNodeDecorator(com.intellij.openapi.vcs.changes.ui.ChangeNodeDecorator) PopupUtil(com.intellij.openapi.ui.popup.util.PopupUtil) ActionEvent(java.awt.event.ActionEvent) MouseEvent(java.awt.event.MouseEvent) java.awt(java.awt) com.intellij.openapi.actionSystem(com.intellij.openapi.actionSystem) ChangesBrowserNodeRenderer(com.intellij.openapi.vcs.changes.ui.ChangesBrowserNodeRenderer) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) RepositoryChangesBrowser(com.intellij.openapi.vcs.changes.committed.RepositoryChangesBrowser) Pair(com.intellij.openapi.util.Pair) ObjectUtils(com.intellij.util.ObjectUtils) ListSelectionListener(javax.swing.event.ListSelectionListener) Condition(com.intellij.openapi.util.Condition) javax.swing(javax.swing) TableCellRenderer(javax.swing.table.TableCellRenderer) MouseEvent(java.awt.event.MouseEvent) Splitter(com.intellij.openapi.ui.Splitter) RepositoryChangesBrowser(com.intellij.openapi.vcs.changes.committed.RepositoryChangesBrowser) SvnChangeList(org.jetbrains.idea.svn.history.SvnChangeList) ListSelectionEvent(javax.swing.event.ListSelectionEvent) NotNull(org.jetbrains.annotations.NotNull) BorderLayoutPanel(com.intellij.util.ui.components.BorderLayoutPanel) ListSelectionListener(javax.swing.event.ListSelectionListener) AbstractBaseTagMouseListener(com.intellij.openapi.vcs.changes.issueLinks.AbstractBaseTagMouseListener) Collections.singletonList(java.util.Collections.singletonList) SvnChangeList(org.jetbrains.idea.svn.history.SvnChangeList) List(java.util.List) ContainerUtilRt.emptyList(com.intellij.util.containers.ContainerUtilRt.emptyList)

Example 2 with BorderLayoutPanel

use of com.intellij.util.ui.components.BorderLayoutPanel in project intellij-community by JetBrains.

the class CaptureConfigurable method createComponent.

@Nullable
@Override
public JComponent createComponent() {
    myTableModel = new MyTableModel();
    JBTable table = new JBTable(myTableModel);
    table.setColumnSelectionAllowed(false);
    TableColumnModel columnModel = table.getColumnModel();
    TableUtil.setupCheckboxColumn(columnModel.getColumn(MyTableModel.ENABLED_COLUMN));
    ToolbarDecorator decorator = ToolbarDecorator.createDecorator(table);
    decorator.setAddAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            myTableModel.addRow();
        }
    });
    decorator.setRemoveAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            TableUtil.removeSelectedItems(table);
        }
    });
    decorator.setMoveUpAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            TableUtil.moveSelectedItemsUp(table);
        }
    });
    decorator.setMoveDownAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            TableUtil.moveSelectedItemsDown(table);
        }
    });
    decorator.addExtraAction(new DumbAwareActionButton("Duplicate", "Duplicate", PlatformIcons.COPY_ICON) {

        @Override
        public boolean isEnabled() {
            return table.getSelectedRowCount() == 1;
        }

        @Override
        public void actionPerformed(@NotNull AnActionEvent e) {
            selectedCapturePoints(table).forEach(c -> {
                try {
                    int idx = myTableModel.add(c.clone());
                    table.getSelectionModel().setSelectionInterval(idx, idx);
                } catch (CloneNotSupportedException ex) {
                    LOG.error(ex);
                }
            });
        }
    });
    decorator.addExtraAction(new DumbAwareActionButton("Enable Selected", "Enable Selected", PlatformIcons.SELECT_ALL_ICON) {

        @Override
        public boolean isEnabled() {
            return table.getSelectedRowCount() > 0;
        }

        @Override
        public void actionPerformed(@NotNull AnActionEvent e) {
            selectedCapturePoints(table).forEach(c -> c.myEnabled = true);
            table.repaint();
        }
    });
    decorator.addExtraAction(new DumbAwareActionButton("Disable Selected", "Disable Selected", PlatformIcons.UNSELECT_ALL_ICON) {

        @Override
        public boolean isEnabled() {
            return table.getSelectedRowCount() > 0;
        }

        @Override
        public void actionPerformed(@NotNull AnActionEvent e) {
            selectedCapturePoints(table).forEach(c -> c.myEnabled = false);
            table.repaint();
        }
    });
    new DumbAwareAction("Toggle") {

        @Override
        public void update(@NotNull AnActionEvent e) {
            e.getPresentation().setEnabled(table.getSelectedRowCount() == 1);
        }

        @Override
        public void actionPerformed(@NotNull final AnActionEvent e) {
            selectedCapturePoints(table).forEach(c -> c.myEnabled = !c.myEnabled);
            table.repaint();
        }
    }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0)), table);
    decorator.addExtraAction(new DumbAwareActionButton("Import", "Import", AllIcons.Actions.Install) {

        @Override
        public void actionPerformed(@NotNull final AnActionEvent e) {
            FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, true, false, true, true) {

                @Override
                public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
                    return super.isFileVisible(file, showHiddenFiles) && (file.isDirectory() || "xml".equals(file.getExtension()) || file.getFileType() == FileTypes.ARCHIVE);
                }

                @Override
                public boolean isFileSelectable(VirtualFile file) {
                    return file.getFileType() == StdFileTypes.XML;
                }
            };
            descriptor.setDescription("Please select a file to import.");
            descriptor.setTitle("Import Capture Points");
            VirtualFile[] files = FileChooser.chooseFiles(descriptor, e.getProject(), null);
            if (ArrayUtil.isEmpty(files))
                return;
            table.getSelectionModel().clearSelection();
            for (VirtualFile file : files) {
                try {
                    Document document = JDOMUtil.loadDocument(file.getInputStream());
                    List<Element> children = document.getRootElement().getChildren();
                    children.forEach(element -> {
                        int idx = myTableModel.addIfNeeded(XmlSerializer.deserialize(element, CapturePoint.class));
                        table.getSelectionModel().addSelectionInterval(idx, idx);
                    });
                } catch (Exception ex) {
                    final String msg = ex.getLocalizedMessage();
                    Messages.showErrorDialog(e.getProject(), msg != null && msg.length() > 0 ? msg : ex.toString(), "Export Failed");
                }
            }
        }
    });
    decorator.addExtraAction(new DumbAwareActionButton("Export", "Export", AllIcons.Actions.Export) {

        @Override
        public void actionPerformed(@NotNull final AnActionEvent e) {
            VirtualFileWrapper wrapper = FileChooserFactory.getInstance().createSaveFileDialog(new FileSaverDescriptor("Export Selected Capture Points to File...", "", "xml"), e.getProject()).save(null, null);
            if (wrapper == null)
                return;
            Element rootElement = new Element("capture-points");
            selectedCapturePoints(table).forEach(c -> {
                try {
                    CapturePoint clone = c.clone();
                    clone.myEnabled = false;
                    rootElement.addContent(XmlSerializer.serialize(clone));
                } catch (CloneNotSupportedException ex) {
                    LOG.error(ex);
                }
            });
            try {
                JDOMUtil.write(rootElement, wrapper.getFile());
            } catch (Exception ex) {
                final String msg = ex.getLocalizedMessage();
                Messages.showErrorDialog(e.getProject(), msg != null && msg.length() > 0 ? msg : ex.toString(), "Export Failed");
            }
        }

        @Override
        public boolean isEnabled() {
            return table.getSelectedRowCount() > 0;
        }
    });
    BorderLayoutPanel panel = JBUI.Panels.simplePanel();
    panel.addToCenter(decorator.createPanel());
    myCaptureVariables = new JCheckBox(DebuggerBundle.message("label.capture.configurable.capture.variables"));
    panel.addToBottom(myCaptureVariables);
    return panel;
}
Also used : JVMNameUtil(com.intellij.debugger.engine.JVMNameUtil) JavaDebuggerSupport(com.intellij.debugger.ui.JavaDebuggerSupport) AllIcons(com.intellij.icons.AllIcons) VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileSaverDescriptor(com.intellij.openapi.fileChooser.FileSaverDescriptor) Document(org.jdom.Document) Nls(org.jetbrains.annotations.Nls) BorderLayoutPanel(com.intellij.util.ui.components.BorderLayoutPanel) JBUI(com.intellij.util.ui.JBUI) VirtualFileWrapper(com.intellij.openapi.vfs.VirtualFileWrapper) FileTypes(com.intellij.openapi.fileTypes.FileTypes) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) Messages(com.intellij.openapi.ui.Messages) Logger(com.intellij.openapi.diagnostic.Logger) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) FileChooserFactory(com.intellij.openapi.fileChooser.FileChooserFactory) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) KeyEvent(java.awt.event.KeyEvent) com.intellij.ui(com.intellij.ui) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) Debugger(org.jetbrains.annotations.Debugger) AnnotatedElementsSearch(com.intellij.psi.search.searches.AnnotatedElementsSearch) StreamEx(one.util.streamex.StreamEx) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Registry(com.intellij.openapi.util.registry.Registry) IntStreamEx(one.util.streamex.IntStreamEx) com.intellij.psi(com.intellij.psi) ConfigurationException(com.intellij.openapi.options.ConfigurationException) NotNull(org.jetbrains.annotations.NotNull) XmlSerializer(com.intellij.util.xmlb.XmlSerializer) ArrayUtil(com.intellij.util.ArrayUtil) CustomShortcutSet(com.intellij.openapi.actionSystem.CustomShortcutSet) TableColumnModel(javax.swing.table.TableColumnModel) ArrayList(java.util.ArrayList) JDOMUtil(com.intellij.openapi.util.JDOMUtil) AbstractTableModel(javax.swing.table.AbstractTableModel) Project(com.intellij.openapi.project.Project) DebuggerBundle(com.intellij.debugger.DebuggerBundle) PlatformIcons(com.intellij.util.PlatformIcons) DecompiledLocalVariable(com.intellij.debugger.jdi.DecompiledLocalVariable) StdFileTypes(com.intellij.openapi.fileTypes.StdFileTypes) StringUtil(com.intellij.openapi.util.text.StringUtil) ItemRemovable(com.intellij.util.ui.ItemRemovable) JBTable(com.intellij.ui.table.JBTable) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) Element(org.jdom.Element) FileChooser(com.intellij.openapi.fileChooser.FileChooser) SearchableConfigurable(com.intellij.openapi.options.SearchableConfigurable) javax.swing(javax.swing) VirtualFile(com.intellij.openapi.vfs.VirtualFile) Element(org.jdom.Element) TableColumnModel(javax.swing.table.TableColumnModel) JBTable(com.intellij.ui.table.JBTable) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Document(org.jdom.Document) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) CustomShortcutSet(com.intellij.openapi.actionSystem.CustomShortcutSet) List(java.util.List) ArrayList(java.util.ArrayList) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) BorderLayoutPanel(com.intellij.util.ui.components.BorderLayoutPanel) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) ConfigurationException(com.intellij.openapi.options.ConfigurationException) FileSaverDescriptor(com.intellij.openapi.fileChooser.FileSaverDescriptor) VirtualFileWrapper(com.intellij.openapi.vfs.VirtualFileWrapper) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with BorderLayoutPanel

use of com.intellij.util.ui.components.BorderLayoutPanel in project intellij-community by JetBrains.

the class MacIntelliJComboBoxUI method createPopup.

@Override
protected ComboPopup createPopup() {
    return new BasicComboPopup(myComboBox) {

        @Override
        protected void configurePopup() {
            super.configurePopup();
            setBorderPainted(false);
            setBorder(JBUI.Borders.empty());
            setBackground(Gray.xFF);
        }

        @Override
        protected void configureList() {
            super.configureList();
            wrapRenderer();
        }

        @Override
        protected PropertyChangeListener createPropertyChangeListener() {
            final PropertyChangeListener listener = super.createPropertyChangeListener();
            return new PropertyChangeListener() {

                @Override
                public void propertyChange(PropertyChangeEvent evt) {
                    listener.propertyChange(evt);
                    if ("renderer".equals(evt.getPropertyName())) {
                        wrapRenderer();
                    }
                }
            };
        }

        class ComboBoxRendererWrapper implements ListCellRenderer {

            private final ListCellRenderer myRenderer;

            public ComboBoxRendererWrapper(@NotNull ListCellRenderer renderer) {
                myRenderer = renderer;
            }

            @Override
            public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
                Component c = myRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
                BorderLayoutPanel panel = JBUI.Panels.simplePanel(c).withBorder(JBUI.Borders.empty(0, 8));
                panel.setBackground(c.getBackground());
                return panel;
            }
        }

        private void wrapRenderer() {
            ListCellRenderer renderer = list.getCellRenderer();
            if (!(renderer instanceof ComboBoxRendererWrapper) && renderer != null) {
                list.setCellRenderer(new ComboBoxRendererWrapper(renderer));
            }
        }
    };
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) BorderLayoutPanel(com.intellij.util.ui.components.BorderLayoutPanel)

Example 4 with BorderLayoutPanel

use of com.intellij.util.ui.components.BorderLayoutPanel in project intellij-community by JetBrains.

the class ChooseModulesDialog method createNorthPanel.

protected JComponent createNorthPanel() {
    BorderLayoutPanel panel = JBUI.Panels.simplePanel(15, 10);
    if (myIcon != null) {
        JLabel iconLabel = new JLabel(myIcon);
        panel.addToLeft(JBUI.Panels.simplePanel().addToTop(iconLabel));
    }
    BorderLayoutPanel messagePanel = JBUI.Panels.simplePanel();
    if (myMessage != null) {
        JLabel textLabel = new JLabel(myMessage);
        textLabel.setBorder(JBUI.Borders.emptyBottom(5));
        textLabel.setUI(new MultiLineLabelUI());
        messagePanel.addToTop(textLabel);
    }
    panel.add(messagePanel, BorderLayout.CENTER);
    final JScrollPane jScrollPane = ScrollPaneFactory.createScrollPane();
    jScrollPane.setViewportView(myView);
    jScrollPane.setPreferredSize(JBUI.size(300, 80));
    panel.addToBottom(jScrollPane);
    return panel;
}
Also used : MultiLineLabelUI(com.intellij.openapi.ui.MultiLineLabelUI) BorderLayoutPanel(com.intellij.util.ui.components.BorderLayoutPanel)

Example 5 with BorderLayoutPanel

use of com.intellij.util.ui.components.BorderLayoutPanel in project intellij-community by JetBrains.

the class XDebuggerEditorBase method decorate.

protected JPanel decorate(JComponent component, boolean multiline, boolean showEditor) {
    BorderLayoutPanel panel = JBUI.Panels.simplePanel();
    JPanel factoryPanel = JBUI.Panels.simplePanel();
    factoryPanel.add(myChooseFactory, multiline ? BorderLayout.NORTH : BorderLayout.CENTER);
    panel.add(factoryPanel, BorderLayout.WEST);
    if (!multiline && showEditor) {
        component = addMultilineButton(component);
    }
    panel.addToCenter(component);
    return panel;
}
Also used : BorderLayoutPanel(com.intellij.util.ui.components.BorderLayoutPanel)

Aggregations

BorderLayoutPanel (com.intellij.util.ui.components.BorderLayoutPanel)11 JBUI (com.intellij.util.ui.JBUI)3 List (java.util.List)3 javax.swing (javax.swing)3 NotNull (org.jetbrains.annotations.NotNull)3 AllIcons (com.intellij.icons.AllIcons)2 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)2 Project (com.intellij.openapi.project.Project)2 MultiLineLabelUI (com.intellij.openapi.ui.MultiLineLabelUI)2 com.intellij.ui (com.intellij.ui)2 JBLabel (com.intellij.ui.components.JBLabel)2 KeyEvent (java.awt.event.KeyEvent)2 DebuggerBundle (com.intellij.debugger.DebuggerBundle)1 JVMNameUtil (com.intellij.debugger.engine.JVMNameUtil)1 DecompiledLocalVariable (com.intellij.debugger.jdi.DecompiledLocalVariable)1 JavaDebuggerSupport (com.intellij.debugger.ui.JavaDebuggerSupport)1 DataManager (com.intellij.ide.DataManager)1 EditSourceAction (com.intellij.ide.actions.EditSourceAction)1 com.intellij.openapi.actionSystem (com.intellij.openapi.actionSystem)1 ActionToolbar (com.intellij.openapi.actionSystem.ActionToolbar)1