Search in sources :

Example 1 with Splitter

use of com.intellij.openapi.ui.Splitter 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 Splitter

use of com.intellij.openapi.ui.Splitter in project intellij-community by JetBrains.

the class ModuleAwareProjectConfigurable method createComponent.

@Override
public JComponent createComponent() {
    if (myProject.isDefault()) {
        T configurable = createDefaultProjectConfigurable();
        if (configurable != null) {
            myModuleConfigurables.put(null, configurable);
            return configurable.createComponent();
        }
    }
    final List<Module> modules = ContainerUtil.filter(ModuleAttachProcessor.getSortedModules(myProject), module -> isSuitableForModule(module));
    final T projectConfigurable = createProjectConfigurable();
    if (modules.size() == 1 && projectConfigurable == null) {
        Module module = modules.get(0);
        final T configurable = createModuleConfigurable(module);
        myModuleConfigurables.put(module, configurable);
        return configurable.createComponent();
    }
    final Splitter splitter = new Splitter(false, 0.25f);
    CollectionListModel<Module> listDataModel = new CollectionListModel<>(modules);
    final JBList moduleList = new JBList(listDataModel);
    new ListSpeedSearch(moduleList, (Function<Object, String>) o -> {
        if (o == null) {
            return getProjectConfigurableItemName();
        } else if (o instanceof Module) {
            return ((Module) o).getName();
        }
        return null;
    });
    moduleList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    moduleList.setCellRenderer(new ModuleListCellRenderer() {

        @Override
        public void customize(JList list, Module module, int index, boolean selected, boolean hasFocus) {
            if (module == null) {
                setText(getProjectConfigurableItemName());
                setIcon(getProjectConfigurableItemIcon());
            } else {
                super.customize(list, module, index, selected, hasFocus);
            }
        }
    });
    splitter.setFirstComponent(new JBScrollPane(moduleList));
    final CardLayout layout = new CardLayout();
    final JPanel cardPanel = new JPanel(layout);
    splitter.setSecondComponent(cardPanel);
    if (projectConfigurable != null) {
        myModuleConfigurables.put(null, projectConfigurable);
        final JComponent component = projectConfigurable.createComponent();
        cardPanel.add(component, PROJECT_ITEM_KEY);
        listDataModel.add(0, null);
    }
    for (Module module : modules) {
        final T configurable = createModuleConfigurable(module);
        myModuleConfigurables.put(module, configurable);
        final JComponent component = configurable.createComponent();
        cardPanel.add(component, module.getName());
    }
    moduleList.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            final Module value = (Module) moduleList.getSelectedValue();
            layout.show(cardPanel, value == null ? PROJECT_ITEM_KEY : value.getName());
        }
    });
    if (moduleList.getItemsCount() > 0) {
        moduleList.setSelectedIndex(0);
        Module module = listDataModel.getElementAt(0);
        layout.show(cardPanel, module == null ? PROJECT_ITEM_KEY : module.getName());
    }
    return splitter;
}
Also used : ModuleAttachProcessor(com.intellij.platform.ModuleAttachProcessor) AllIcons(com.intellij.icons.AllIcons) HashMap(java.util.HashMap) ContainerUtil(com.intellij.util.containers.ContainerUtil) Nls(org.jetbrains.annotations.Nls) Map(java.util.Map) Project(com.intellij.openapi.project.Project) Module(com.intellij.openapi.module.Module) ListSelectionEvent(javax.swing.event.ListSelectionEvent) Splitter(com.intellij.openapi.ui.Splitter) JBList(com.intellij.ui.components.JBList) UnnamedConfigurable(com.intellij.openapi.options.UnnamedConfigurable) Configurable(com.intellij.openapi.options.Configurable) CollectionListModel(com.intellij.ui.CollectionListModel) JBScrollPane(com.intellij.ui.components.JBScrollPane) java.awt(java.awt) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) Function(com.intellij.util.Function) ConfigurationException(com.intellij.openapi.options.ConfigurationException) NotNull(org.jetbrains.annotations.NotNull) ListSelectionListener(javax.swing.event.ListSelectionListener) SearchableConfigurable(com.intellij.openapi.options.SearchableConfigurable) ListSpeedSearch(com.intellij.ui.ListSpeedSearch) javax.swing(javax.swing) Splitter(com.intellij.openapi.ui.Splitter) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ListSelectionListener(javax.swing.event.ListSelectionListener) ListSpeedSearch(com.intellij.ui.ListSpeedSearch) JBList(com.intellij.ui.components.JBList) Module(com.intellij.openapi.module.Module) CollectionListModel(com.intellij.ui.CollectionListModel) JBScrollPane(com.intellij.ui.components.JBScrollPane)

Example 3 with Splitter

use of com.intellij.openapi.ui.Splitter in project intellij-community by JetBrains.

the class TodoPanel method createCenterComponent.

protected JComponent createCenterComponent() {
    Splitter splitter = new OnePixelSplitter(false);
    splitter.setSecondComponent(myUsagePreviewPanel);
    splitter.setFirstComponent(ScrollPaneFactory.createScrollPane(myTree));
    return splitter;
}
Also used : Splitter(com.intellij.openapi.ui.Splitter)

Example 4 with Splitter

use of com.intellij.openapi.ui.Splitter in project intellij-community by JetBrains.

the class SlicePanel method layoutPanel.

private void layoutPanel() {
    if (myUsagePreviewPanel != null) {
        Disposer.dispose(myUsagePreviewPanel);
    }
    removeAll();
    JScrollPane pane = ScrollPaneFactory.createScrollPane(myTree);
    if (isPreview()) {
        pane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT | SideBorder.RIGHT));
        boolean vertical = myToolWindow.getAnchor() == ToolWindowAnchor.LEFT || myToolWindow.getAnchor() == ToolWindowAnchor.RIGHT;
        Splitter splitter = new Splitter(vertical, UsageViewSettings.getInstance().PREVIEW_USAGES_SPLITTER_PROPORTIONS);
        splitter.setFirstComponent(pane);
        myUsagePreviewPanel = new UsagePreviewPanel(myProject, new UsageViewPresentation());
        myUsagePreviewPanel.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT));
        Disposer.register(this, myUsagePreviewPanel);
        splitter.setSecondComponent(myUsagePreviewPanel);
        add(splitter, BorderLayout.CENTER);
    } else {
        pane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT));
        add(pane, BorderLayout.CENTER);
    }
    add(createToolbar().getComponent(), BorderLayout.WEST);
    myTree.getParent().setBackground(UIManager.getColor("Tree.background"));
    revalidate();
}
Also used : UsageViewPresentation(com.intellij.usages.UsageViewPresentation) Splitter(com.intellij.openapi.ui.Splitter) UsagePreviewPanel(com.intellij.usages.impl.UsagePreviewPanel)

Example 5 with Splitter

use of com.intellij.openapi.ui.Splitter in project intellij-community by JetBrains.

the class ConsoleConfigurable method createComponent.

@Override
public JComponent createComponent() {
    if (myMainComponent == null) {
        myMainComponent = new JPanel(new BorderLayout());
        myCbUseSoftWrapsAtConsole = new JCheckBox(ApplicationBundle.message("checkbox.use.soft.wraps.at.console"), false);
        myCommandsHistoryLimitField = new JTextField(3);
        myCbOverrideConsoleCycleBufferSize = new JCheckBox(ApplicationBundle.message("checkbox.override.console.cycle.buffer.size", String.valueOf(ConsoleBuffer.getLegacyCycleBufferSize() / 1024)), false);
        myCbOverrideConsoleCycleBufferSize.addChangeListener(e -> myConsoleCycleBufferSizeField.setEnabled(myCbOverrideConsoleCycleBufferSize.isSelected()));
        myConsoleCycleBufferSizeField = new JTextField(3);
        JPanel northPanel = new JPanel(new GridBagLayout());
        GridBag gridBag = new GridBag();
        gridBag.anchor(GridBagConstraints.WEST).setDefaultAnchor(GridBagConstraints.WEST);
        northPanel.add(myCbUseSoftWrapsAtConsole, gridBag.nextLine().next());
        northPanel.add(Box.createHorizontalGlue(), gridBag.next().coverLine());
        northPanel.add(new JLabel(ApplicationBundle.message("editbox.console.history.limit")), gridBag.nextLine().next());
        northPanel.add(myCommandsHistoryLimitField, gridBag.next());
        if (ConsoleBuffer.useCycleBuffer()) {
            northPanel.add(myCbOverrideConsoleCycleBufferSize, gridBag.nextLine().next());
            northPanel.add(myConsoleCycleBufferSizeField, gridBag.next());
            northPanel.add(new JLabel(" KB"), gridBag.next());
        }
        if (!editFoldingsOnly()) {
            JPanel wrapper = new JPanel(new BorderLayout());
            wrapper.add(northPanel, BorderLayout.WEST);
            myMainComponent.add(wrapper, BorderLayout.NORTH);
        }
        Splitter splitter = new Splitter(true);
        myMainComponent.add(splitter, BorderLayout.CENTER);
        myPositivePanel = new MyAddDeleteListPanel("Fold console lines that contain", "Enter a substring of a console line you'd like to see folded:");
        myNegativePanel = new MyAddDeleteListPanel("Exceptions", "Enter a substring of a console line you don't want to fold:");
        splitter.setFirstComponent(myPositivePanel);
        splitter.setSecondComponent(myNegativePanel);
        myPositivePanel.getEmptyText().setText("Fold nothing");
        myNegativePanel.getEmptyText().setText("No exceptions");
    }
    return myMainComponent;
}
Also used : Splitter(com.intellij.openapi.ui.Splitter) GridBag(com.intellij.util.ui.GridBag)

Aggregations

Splitter (com.intellij.openapi.ui.Splitter)47 OnePixelSplitter (com.intellij.ui.OnePixelSplitter)7 NotNull (org.jetbrains.annotations.NotNull)7 ThreeComponentsSplitter (com.intellij.openapi.ui.ThreeComponentsSplitter)6 ListSelectionEvent (javax.swing.event.ListSelectionEvent)6 ListSelectionListener (javax.swing.event.ListSelectionListener)6 Nullable (org.jetbrains.annotations.Nullable)6 AllIcons (com.intellij.icons.AllIcons)4 Disposable (com.intellij.openapi.Disposable)4 Project (com.intellij.openapi.project.Project)4 com.intellij.openapi.actionSystem (com.intellij.openapi.actionSystem)3 ApplicationManager (com.intellij.openapi.application.ApplicationManager)3 UsageInfo (com.intellij.usageView.UsageInfo)3 ContainerUtil (com.intellij.util.containers.ContainerUtil)3 java.awt (java.awt)3 ActionEvent (java.awt.event.ActionEvent)3 List (java.util.List)3 javax.swing (javax.swing)3 PropertiesComponent (com.intellij.ide.util.PropertiesComponent)2 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)2