Search in sources :

Example 31 with Splitter

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

the class CallerChooserBase method createCenterPanel.

@Override
protected JComponent createCenterPanel() {
    Splitter splitter = new Splitter(false, (float) 0.6);
    JPanel result = new JPanel(new BorderLayout());
    if (myTree == null) {
        myTree = createTree();
    } else {
        final CheckedTreeNode root = (CheckedTreeNode) myTree.getModel().getRoot();
        myRoot = (MethodNodeBase) root.getFirstChild();
    }
    myTreeSelectionListener = new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {
            final TreePath path = e.getPath();
            if (path != null) {
                final MethodNodeBase<M> node = (MethodNodeBase) path.getLastPathComponent();
                myAlarm.cancelAllRequests();
                myAlarm.addRequest(() -> updateEditorTexts(node), 300);
            }
        }
    };
    myTree.getSelectionModel().addTreeSelectionListener(myTreeSelectionListener);
    JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTree);
    splitter.setFirstComponent(scrollPane);
    final JComponent callSitesViewer = createCallSitesViewer();
    TreePath selectionPath = myTree.getSelectionPath();
    if (selectionPath == null) {
        selectionPath = new TreePath(myRoot.getPath());
        myTree.getSelectionModel().addSelectionPath(selectionPath);
    }
    final MethodNodeBase<M> node = (MethodNodeBase) selectionPath.getLastPathComponent();
    updateEditorTexts(node);
    splitter.setSecondComponent(callSitesViewer);
    result.add(splitter);
    return result;
}
Also used : Splitter(com.intellij.openapi.ui.Splitter) TreeSelectionListener(javax.swing.event.TreeSelectionListener) TreePath(javax.swing.tree.TreePath) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent)

Example 32 with Splitter

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

the class CallerChooserBase method createCallSitesViewer.

private JComponent createCallSitesViewer() {
    Splitter splitter = new Splitter(true);
    myCallerEditor = createEditor();
    myCalleeEditor = createEditor();
    final JComponent callerComponent = myCallerEditor.getComponent();
    callerComponent.setBorder(IdeBorderFactory.createTitledBorder(RefactoringBundle.message("caller.chooser.caller.method"), false));
    splitter.setFirstComponent(callerComponent);
    final JComponent calleeComponent = myCalleeEditor.getComponent();
    calleeComponent.setBorder(IdeBorderFactory.createTitledBorder(RefactoringBundle.message("caller.chooser.callee.method"), false));
    splitter.setSecondComponent(calleeComponent);
    splitter.setBorder(IdeBorderFactory.createRoundedBorder());
    return splitter;
}
Also used : Splitter(com.intellij.openapi.ui.Splitter)

Example 33 with Splitter

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

the class SelectTemplateDialog method createCenterPanel.

protected JComponent createCenterPanel() {
    final JPanel centerPanel = new JPanel(new BorderLayout());
    Splitter splitter;
    centerPanel.add(BorderLayout.CENTER, splitter = new Splitter(false, 0.3f));
    centerPanel.add(splitter);
    splitter.setFirstComponent(showHistory ? existingTemplatesComponent.getHistoryPanel() : existingTemplatesComponent.getTemplatesPanel());
    final JPanel panel;
    splitter.setSecondComponent(panel = new JPanel(new BorderLayout()));
    searchPatternEditor = UIUtil.createEditor(EditorFactory.getInstance().createDocument(""), project, false, true, ContainerUtil.findInstance(TemplateContextType.EP_NAME.getExtensions(), TemplateContextType.class));
    JComponent centerComponent;
    if (replace) {
        replacePatternEditor = UIUtil.createEditor(EditorFactory.getInstance().createDocument(""), project, false, true, ContainerUtil.findInstance(TemplateContextType.EP_NAME.getExtensions(), TemplateContextType.class));
        centerComponent = new Splitter(true);
        ((Splitter) centerComponent).setFirstComponent(searchPatternEditor.getComponent());
        ((Splitter) centerComponent).setSecondComponent(replacePatternEditor.getComponent());
    } else {
        centerComponent = searchPatternEditor.getComponent();
    }
    myCardLayout = new CardLayout();
    myPreviewPanel = new JPanel(myCardLayout);
    myPreviewPanel.add(centerComponent, PREVIEW_CARD);
    JPanel selectPanel = new JPanel(new GridBagLayout());
    GridBagConstraints gb = new GridBagConstraints(0, 0, 0, 0, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
    selectPanel.add(new JLabel(SSRBundle.message("selecttemplate.template.label.please.select.template")), gb);
    myPreviewPanel.add(selectPanel, SELECT_TEMPLATE_CARD);
    panel.add(BorderLayout.CENTER, myPreviewPanel);
    final JPanel labelPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 0));
    labelPanel.add(new JLabel(SSRBundle.message("selecttemplate.template.preview")));
    labelPanel.add(UIUtil.createCompleteMatchInfo(() -> {
        final Configuration[] configurations = getSelectedConfigurations();
        return configurations.length != 1 ? null : configurations[0];
    }));
    panel.add(BorderLayout.NORTH, labelPanel);
    return centerPanel;
}
Also used : Splitter(com.intellij.openapi.ui.Splitter)

Example 34 with Splitter

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

the class OverridingMethodsDialog method createCenterPanel.

protected JComponent createCenterPanel() {
    JPanel panel = new JPanel(new BorderLayout());
    panel.setBorder(BorderFactory.createEmptyBorder(8, 0, 4, 0));
    final MyTableModel tableModel = new MyTableModel();
    myTable = new Table(tableModel);
    myTable.setShowGrid(false);
    TableColumnModel columnModel = myTable.getColumnModel();
    //    columnModel.getColumn(DISPLAY_NAME_COLUMN).setCellRenderer(new MemberSelectionTable.MyTableRenderer());
    TableColumn checkboxColumn = columnModel.getColumn(CHECK_COLUMN);
    TableUtil.setupCheckboxColumn(checkboxColumn);
    checkboxColumn.setCellRenderer(new BooleanTableCellRenderer());
    // make SPACE check/uncheck selected rows
    @NonNls InputMap inputMap = myTable.getInputMap();
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "enable_disable");
    @NonNls final ActionMap actionMap = myTable.getActionMap();
    actionMap.put("enable_disable", new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            if (myTable.isEditing())
                return;
            int[] rows = myTable.getSelectedRows();
            if (rows.length > 0) {
                boolean valueToBeSet = false;
                for (int row : rows) {
                    if (!myChecked[row]) {
                        valueToBeSet = true;
                        break;
                    }
                }
                for (int row : rows) {
                    myChecked[row] = valueToBeSet;
                }
                tableModel.updateData();
            }
        }
    });
    /*Border titledBorder = IdeBorderFactory.createBoldTitledBorder("Select methods");
    Border emptyBorder = BorderFactory.createEmptyBorder(0, 5, 5, 5);
    Border border = BorderFactory.createCompoundBorder(titledBorder, emptyBorder);
    panel.setBorder(border);*/
    panel.setLayout(new BorderLayout());
    JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTable);
    panel.add(scrollPane, BorderLayout.CENTER);
    ListSelectionListener selectionListener = new ListSelectionListener() {

        public void valueChanged(final ListSelectionEvent e) {
            int index = myTable.getSelectionModel().getLeadSelectionIndex();
            if (index != -1) {
                UsageInfo usageInfo = myOverridingMethods.get(index);
                myUsagePreviewPanel.updateLayout(Collections.singletonList(usageInfo));
            } else {
                myUsagePreviewPanel.updateLayout(null);
            }
        }
    };
    myTable.getSelectionModel().addListSelectionListener(selectionListener);
    final Splitter splitter = new Splitter(true, 0.3f);
    splitter.setFirstComponent(panel);
    splitter.setSecondComponent(myUsagePreviewPanel);
    myUsagePreviewPanel.updateLayout(null);
    Disposer.register(myDisposable, new Disposable() {

        public void dispose() {
            splitter.dispose();
        }
    });
    if (tableModel.getRowCount() != 0) {
        myTable.getSelectionModel().addSelectionInterval(0, 0);
    }
    return splitter;
}
Also used : Disposable(com.intellij.openapi.Disposable) NonNls(org.jetbrains.annotations.NonNls) Table(com.intellij.util.ui.Table) Splitter(com.intellij.openapi.ui.Splitter) ActionEvent(java.awt.event.ActionEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) TableColumnModel(javax.swing.table.TableColumnModel) TableColumn(javax.swing.table.TableColumn) ListSelectionListener(javax.swing.event.ListSelectionListener) BooleanTableCellRenderer(com.intellij.ui.BooleanTableCellRenderer) UsageInfo(com.intellij.usageView.UsageInfo) SafeDeleteOverridingMethodUsageInfo(com.intellij.refactoring.safeDelete.usageInfo.SafeDeleteOverridingMethodUsageInfo)

Example 35 with Splitter

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

the class ReplaceConstructorWithBuilderDialog method createCenterPanel.

protected JComponent createCenterPanel() {
    final Splitter splitter = new Splitter(true);
    splitter.setFirstComponent(createTablePanel());
    splitter.setSecondComponent(myWholePanel);
    final ActionListener enableDisableListener = new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            setEnabled(myCreateBuilderClassRadioButton.isSelected());
            IdeFocusManager.getInstance(myProject).requestFocus(myCreateBuilderClassRadioButton.isSelected() ? myNewClassName : myExistentClassTF.getChildComponent(), true);
            validateButtons();
        }
    };
    myCreateBuilderClassRadioButton.addActionListener(enableDisableListener);
    myExistingBuilderClassRadioButton.addActionListener(enableDisableListener);
    myCreateBuilderClassRadioButton.setSelected(true);
    setEnabled(true);
    final DocumentAdapter validateButtonsListener = new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            validateButtons();
        }
    };
    myNewClassName.getDocument().addDocumentListener(validateButtonsListener);
    final PsiClass psiClass = myConstructors[0].getContainingClass();
    LOG.assertTrue(psiClass != null);
    myNewClassName.setText(psiClass.getName() + "Builder");
    return splitter;
}
Also used : Splitter(com.intellij.openapi.ui.Splitter) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) DocumentEvent(javax.swing.event.DocumentEvent)

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