Search in sources :

Example 36 with Splitter

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

the class FileTemplateConfigurable method createComponent.

@Override
public JComponent createComponent() {
    myMainPanel = new JPanel(new GridBagLayout());
    myNameField = new JTextField();
    myExtensionField = new JTextField();
    mySplitter = new Splitter(true, myProportion);
    myAdjustBox = new JCheckBox(IdeBundle.message("checkbox.reformat.according.to.style"));
    myLiveTemplateBox = new JCheckBox(IdeBundle.message("checkbox.enable.live.templates"));
    myTemplateEditor = createEditor();
    myDescriptionComponent = new JEditorPane(UIUtil.HTML_MIME, EMPTY_HTML);
    myDescriptionComponent.setEditable(false);
    myDescriptionComponent.addHyperlinkListener(new BrowserHyperlinkListener());
    myTopPanel = new JPanel(new GridBagLayout());
    JPanel descriptionPanel = new JPanel(new GridBagLayout());
    descriptionPanel.add(SeparatorFactory.createSeparator(IdeBundle.message("label.description"), null), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, JBUI.insetsBottom(2), 0, 0));
    descriptionPanel.add(ScrollPaneFactory.createScrollPane(myDescriptionComponent), new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, JBUI.insetsTop(2), 0, 0));
    myMainPanel.add(myTopPanel, new GridBagConstraints(0, 0, 4, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, JBUI.emptyInsets(), 0, 0));
    myMainPanel.add(mySplitter, new GridBagConstraints(0, 2, 4, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, JBUI.emptyInsets(), 0, 0));
    mySplitter.setSecondComponent(descriptionPanel);
    setShowInternalMessage(null);
    myNameField.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(@NotNull FocusEvent e) {
            onNameChanged();
        }
    });
    myExtensionField.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(@NotNull FocusEvent e) {
            onNameChanged();
        }
    });
    myMainPanel.setPreferredSize(JBUI.size(400, 300));
    return myMainPanel;
}
Also used : FocusAdapter(java.awt.event.FocusAdapter) Splitter(com.intellij.openapi.ui.Splitter) BrowserHyperlinkListener(com.intellij.ui.BrowserHyperlinkListener) FocusEvent(java.awt.event.FocusEvent)

Example 37 with Splitter

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

the class GrIntroduceParameterDialog method createSignaturePanel.

private JPanel createSignaturePanel() {
    mySignature = new GrMethodSignatureComponent("", myProject);
    myTable = new GrParameterTablePanel() {

        @Override
        protected void updateSignature() {
            GrIntroduceParameterDialog.this.updateSignature();
        }

        @Override
        protected void doEnterAction() {
            clickDefaultButton();
        }

        @Override
        protected void doCancelAction() {
            GrIntroduceParameterDialog.this.doCancelAction();
        }
    };
    mySignature.setBorder(IdeBorderFactory.createTitledBorder(GroovyRefactoringBundle.message("signature.preview.border.title"), false));
    Splitter splitter = new Splitter(true);
    splitter.setFirstComponent(myTable);
    splitter.setSecondComponent(mySignature);
    mySignature.setPreferredSize(JBUI.size(500, 100));
    mySignature.setSize(JBUI.size(500, 100));
    splitter.setShowDividerIcon(false);
    final JPanel panel = new JPanel(new BorderLayout());
    panel.add(splitter, BorderLayout.CENTER);
    myForceReturnCheckBox = new JCheckBox(UIUtil.replaceMnemonicAmpersand("Use e&xplicit return statement"));
    panel.add(myForceReturnCheckBox, BorderLayout.NORTH);
    return panel;
}
Also used : GrMethodSignatureComponent(org.jetbrains.plugins.groovy.refactoring.ui.GrMethodSignatureComponent) Splitter(com.intellij.openapi.ui.Splitter) GrParameterTablePanel(org.jetbrains.plugins.groovy.refactoring.extract.GrParameterTablePanel)

Example 38 with Splitter

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

the class VcsSelectionHistoryDialog method createComments.

private JComponent createComments(final JComponent addComp) {
    JPanel panel = new JPanel(new BorderLayout(4, 4));
    panel.add(new JLabel("Commit Message:"), BorderLayout.NORTH);
    panel.add(ScrollPaneFactory.createScrollPane(myComments), BorderLayout.CENTER);
    final Splitter splitter = new Splitter(false);
    splitter.setFirstComponent(panel);
    splitter.setSecondComponent(addComp);
    return splitter;
}
Also used : JBSplitter(com.intellij.ui.JBSplitter) Splitter(com.intellij.openapi.ui.Splitter)

Example 39 with Splitter

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

the class EditorWindow method split.

@Nullable
public EditorWindow split(final int orientation, boolean forceSplit, @Nullable VirtualFile virtualFile, boolean focusNew) {
    checkConsistency();
    final FileEditorManagerImpl fileEditorManager = myOwner.getManager();
    if (splitAvailable()) {
        if (!forceSplit && inSplitter()) {
            final EditorWindow[] siblings = findSiblings();
            final EditorWindow target = siblings[0];
            if (virtualFile != null) {
                final FileEditor[] editors = fileEditorManager.openFileImpl3(target, virtualFile, focusNew, null, true).first;
                syncCaretIfPossible(editors);
            }
            return target;
        }
        final JPanel panel = myPanel;
        panel.setBorder(null);
        final int tabCount = getTabCount();
        if (tabCount != 0) {
            final EditorWithProviderComposite firstEC = getEditorAt(0);
            myPanel = new JPanel(new BorderLayout());
            myPanel.setOpaque(false);
            final Splitter splitter = new OnePixelSplitter(orientation == JSplitPane.VERTICAL_SPLIT, 0.5f, 0.1f, 0.9f);
            final EditorWindow res = new EditorWindow(myOwner);
            if (myTabbedPane != null) {
                final EditorWithProviderComposite selectedEditor = getSelectedEditor();
                panel.remove(myTabbedPane.getComponent());
                panel.add(splitter, BorderLayout.CENTER);
                splitter.setFirstComponent(myPanel);
                myPanel.add(myTabbedPane.getComponent(), BorderLayout.CENTER);
                splitter.setSecondComponent(res.myPanel);
                /*
          for (int i = 0; i != tabCount; ++i) {
            final EditorWithProviderComposite eC = getEditorAt(i);
            final VirtualFile file = eC.getFile();
            fileEditorManager.openFileImpl3(res, file, false, null);
            res.setFilePinned (file, isFilePinned (file));
          }
          */
                // open only selected file in the new splitter instead of opening all tabs
                final VirtualFile file = selectedEditor.getFile();
                if (virtualFile == null) {
                    for (FileEditorAssociateFinder finder : Extensions.getExtensions(FileEditorAssociateFinder.EP_NAME)) {
                        VirtualFile associatedFile = finder.getAssociatedFileToOpen(fileEditorManager.getProject(), file);
                        if (associatedFile != null) {
                            virtualFile = associatedFile;
                            break;
                        }
                    }
                }
                final VirtualFile nextFile = virtualFile == null ? file : virtualFile;
                final FileEditor[] editors = fileEditorManager.openFileImpl3(res, nextFile, focusNew, null, true).first;
                syncCaretIfPossible(editors);
                res.setFilePinned(nextFile, isFilePinned(file));
                if (!focusNew) {
                    res.setSelectedEditor(selectedEditor, true);
                    getGlobalInstance().doWhenFocusSettlesDown(() -> {
                        getGlobalInstance().requestFocus(selectedEditor.getComponent(), true);
                    });
                }
                panel.revalidate();
            } else {
                panel.removeAll();
                panel.add(splitter, BorderLayout.CENTER);
                splitter.setFirstComponent(myPanel);
                splitter.setSecondComponent(res.myPanel);
                panel.revalidate();
                final VirtualFile firstFile = firstEC.getFile();
                final VirtualFile nextFile = virtualFile == null ? firstFile : virtualFile;
                final FileEditor[] firstEditors = fileEditorManager.openFileImpl3(this, firstFile, !focusNew, null, true).first;
                syncCaretIfPossible(firstEditors);
                final FileEditor[] secondEditors = fileEditorManager.openFileImpl3(res, nextFile, focusNew, null, true).first;
                syncCaretIfPossible(secondEditors);
            }
            return res;
        }
    }
    return null;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileEditor(com.intellij.openapi.fileEditor.FileEditor) ThreeComponentsSplitter(com.intellij.openapi.ui.ThreeComponentsSplitter) Splitter(com.intellij.openapi.ui.Splitter) OnePixelSplitter(com.intellij.ui.OnePixelSplitter) OnePixelSplitter(com.intellij.ui.OnePixelSplitter) Nullable(org.jetbrains.annotations.Nullable)

Example 40 with Splitter

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

the class EditorsSplitters method getOrderedWindows.

@NotNull
EditorWindow[] getOrderedWindows() {
    final List<EditorWindow> res = new ArrayList<>();
    // Collector for windows in tree ordering:
    class Inner {

        private void collect(final JPanel panel) {
            final Component comp = panel.getComponent(0);
            if (comp instanceof Splitter) {
                final Splitter splitter = (Splitter) comp;
                collect((JPanel) splitter.getFirstComponent());
                collect((JPanel) splitter.getSecondComponent());
            } else if (comp instanceof JPanel || comp instanceof JBTabs) {
                final EditorWindow window = findWindowWith(comp);
                if (window != null) {
                    res.add(window);
                }
            }
        }
    }
    // get root component and traverse splitters tree:
    if (getComponentCount() != 0) {
        final Component comp = getComponent(0);
        LOG.assertTrue(comp instanceof JPanel);
        final JPanel panel = (JPanel) comp;
        if (panel.getComponentCount() != 0) {
            new Inner().collect(panel);
        }
    }
    LOG.assertTrue(res.size() == myWindows.size());
    return res.toArray(new EditorWindow[res.size()]);
}
Also used : Splitter(com.intellij.openapi.ui.Splitter) OnePixelSplitter(com.intellij.ui.OnePixelSplitter) JBTabs(com.intellij.ui.tabs.JBTabs) NotNull(org.jetbrains.annotations.NotNull)

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