Search in sources :

Example 6 with Splitter

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

the class AllFileTemplatesConfigurable method createComponent.

@Override
public JComponent createComponent() {
    myUIDisposable = Disposer.newDisposable();
    myTemplatesList = new FileTemplateTabAsList(TEMPLATES_TITLE) {

        @Override
        public void onTemplateSelected() {
            onListSelectionChanged();
        }
    };
    myIncludesList = new FileTemplateTabAsList(INCLUDES_TITLE) {

        @Override
        public void onTemplateSelected() {
            onListSelectionChanged();
        }
    };
    myCodeTemplatesList = new FileTemplateTabAsList(CODE_TITLE) {

        @Override
        public void onTemplateSelected() {
            onListSelectionChanged();
        }
    };
    myCurrentTab = myTemplatesList;
    final List<FileTemplateTab> allTabs = new ArrayList<>(Arrays.asList(myTemplatesList, myIncludesList, myCodeTemplatesList));
    final FileTemplateGroupDescriptorFactory[] factories = Extensions.getExtensions(FileTemplateGroupDescriptorFactory.EXTENSION_POINT_NAME);
    if (factories.length != 0) {
        myOtherTemplatesList = new FileTemplateTabAsTree(OTHER_TITLE) {

            @Override
            public void onTemplateSelected() {
                onListSelectionChanged();
            }

            @Override
            protected FileTemplateNode initModel() {
                SortedSet<FileTemplateGroupDescriptor> categories = new TreeSet<>((o1, o2) -> o1.getTitle().compareTo(o2.getTitle()));
                for (FileTemplateGroupDescriptorFactory templateGroupFactory : factories) {
                    ContainerUtil.addIfNotNull(categories, templateGroupFactory.getFileTemplatesDescriptor());
                }
                //noinspection HardCodedStringLiteral
                return new FileTemplateNode("ROOT", null, ContainerUtil.map2List(categories, s -> new FileTemplateNode(s)));
            }
        };
        allTabs.add(myOtherTemplatesList);
    }
    myEditor = new FileTemplateConfigurable(myProject);
    myEditor.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            onEditorChanged();
        }
    });
    myEditorComponent = myEditor.createComponent();
    myEditorComponent.setBorder(JBUI.Borders.empty(10, 0, 10, 10));
    myTabs = allTabs.toArray(new FileTemplateTab[allTabs.size()]);
    myTabbedPane = new TabbedPaneWrapper(myUIDisposable);
    myTabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
    myLeftPanel = new JPanel(new CardLayout());
    myLeftPanel.setBorder(JBUI.Borders.empty(10, 10, 10, 0));
    for (FileTemplateTab tab : myTabs) {
        myLeftPanel.add(ScrollPaneFactory.createScrollPane(tab.getComponent()), tab.getTitle());
        JPanel fakePanel = new JPanel();
        fakePanel.setPreferredSize(new Dimension(0, 0));
        myTabbedPane.addTab(tab.getTitle(), fakePanel);
    }
    myTabbedPane.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            onTabChanged();
        }
    });
    DefaultActionGroup group = new DefaultActionGroup();
    AnAction removeAction = new AnAction(IdeBundle.message("action.remove.template"), null, AllIcons.General.Remove) {

        @Override
        public void actionPerformed(AnActionEvent e) {
            onRemove();
        }

        @Override
        public void update(AnActionEvent e) {
            super.update(e);
            FileTemplate selectedItem = myCurrentTab.getSelectedTemplate();
            e.getPresentation().setEnabled(selectedItem != null && !isInternalTemplate(selectedItem.getName(), myCurrentTab.getTitle()));
        }
    };
    AnAction addAction = new AnAction(IdeBundle.message("action.create.template"), null, AllIcons.General.Add) {

        @Override
        public void actionPerformed(AnActionEvent e) {
            onAdd();
        }

        @Override
        public void update(AnActionEvent e) {
            super.update(e);
            e.getPresentation().setEnabled(!(myCurrentTab == myCodeTemplatesList || myCurrentTab == myOtherTemplatesList));
        }
    };
    AnAction cloneAction = new AnAction(IdeBundle.message("action.copy.template"), null, PlatformIcons.COPY_ICON) {

        @Override
        public void actionPerformed(AnActionEvent e) {
            onClone();
        }

        @Override
        public void update(AnActionEvent e) {
            super.update(e);
            e.getPresentation().setEnabled(myCurrentTab != myCodeTemplatesList && myCurrentTab != myOtherTemplatesList && myCurrentTab.getSelectedTemplate() != null);
        }
    };
    AnAction resetAction = new AnAction(IdeBundle.message("action.reset.to.default"), null, AllIcons.Actions.Reset) {

        @Override
        public void actionPerformed(AnActionEvent e) {
            onReset();
        }

        @Override
        public void update(AnActionEvent e) {
            super.update(e);
            final FileTemplate selectedItem = myCurrentTab.getSelectedTemplate();
            e.getPresentation().setEnabled(selectedItem instanceof BundledFileTemplate && !selectedItem.isDefault());
        }
    };
    group.add(addAction);
    group.add(removeAction);
    group.add(cloneAction);
    group.add(resetAction);
    addAction.registerCustomShortcutSet(CommonShortcuts.INSERT, myCurrentTab.getComponent());
    removeAction.registerCustomShortcutSet(CommonShortcuts.getDelete(), myCurrentTab.getComponent());
    myToolBar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true).getComponent();
    myToolBar.setBorder(IdeBorderFactory.createEmptyBorder());
    JPanel toolbarPanel = new JPanel(new BorderLayout());
    toolbarPanel.add(myToolBar, BorderLayout.WEST);
    JComponent schemaComponent = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, new DefaultCompactActionGroup(new ChangeSchemaCombo(this)), true).getComponent();
    JPanel schemaPanel = new JPanel(new BorderLayout());
    schemaPanel.add(schemaComponent, BorderLayout.EAST);
    schemaPanel.add(new JLabel("Schema:"), BorderLayout.WEST);
    toolbarPanel.add(schemaPanel, BorderLayout.EAST);
    JPanel centerPanel = new JPanel(new BorderLayout());
    centerPanel.add(myTabbedPane.getComponent(), BorderLayout.NORTH);
    Splitter splitter = new Splitter(false, 0.3f);
    splitter.setDividerWidth(JBUI.scale(10));
    splitter.setFirstComponent(myLeftPanel);
    splitter.setSecondComponent(myEditorComponent);
    centerPanel.add(splitter, BorderLayout.CENTER);
    myMainPanel = new JPanel(new BorderLayout());
    myMainPanel.add(toolbarPanel, BorderLayout.NORTH);
    myMainPanel.add(centerPanel, BorderLayout.CENTER);
    final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
    final String tabName = propertiesComponent.getValue(CURRENT_TAB);
    if (selectTab(tabName)) {
    //final String selectedTemplateName = propertiesComponent.getValue(SELECTED_TEMPLATE);
    //for (FileTemplate template : myCurrentTab.getTemplates()) {
    //  if (Comparing.strEqual(template.getName(), selectedTemplateName)) {
    //    myCurrentTab.selectTemplate(template);
    //    break;
    //  }
    //}
    }
    return myMainPanel;
}
Also used : java.util(java.util) AllIcons(com.intellij.icons.AllIcons) ShowSettingsUtil(com.intellij.openapi.options.ShowSettingsUtil) ArrayUtil(com.intellij.util.ArrayUtil) URL(java.net.URL) com.intellij.ide.fileTemplates(com.intellij.ide.fileTemplates) ContainerUtil(com.intellij.util.containers.ContainerUtil) MessageFormat(java.text.MessageFormat) Comparing(com.intellij.openapi.util.Comparing) JBUI(com.intellij.util.ui.JBUI) Disposer(com.intellij.openapi.util.Disposer) Project(com.intellij.openapi.project.Project) Messages(com.intellij.openapi.ui.Messages) ChangeListener(javax.swing.event.ChangeListener) Logger(com.intellij.openapi.diagnostic.Logger) Splitter(com.intellij.openapi.ui.Splitter) PlatformIcons(com.intellij.util.PlatformIcons) ChangeEvent(javax.swing.event.ChangeEvent) Extensions(com.intellij.openapi.extensions.Extensions) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) FileTemplateManager(com.intellij.ide.fileTemplates.FileTemplateManager) Configurable(com.intellij.openapi.options.Configurable) Disposable(com.intellij.openapi.Disposable) TestOnly(org.jetbrains.annotations.TestOnly) java.awt(java.awt) IdeBundle(com.intellij.ide.IdeBundle) com.intellij.openapi.actionSystem(com.intellij.openapi.actionSystem) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) IdeBorderFactory(com.intellij.ui.IdeBorderFactory) ApplicationManager(com.intellij.openapi.application.ApplicationManager) ConfigurationException(com.intellij.openapi.options.ConfigurationException) NotNull(org.jetbrains.annotations.NotNull) TabbedPaneWrapper(com.intellij.ui.TabbedPaneWrapper) SearchableConfigurable(com.intellij.openapi.options.SearchableConfigurable) ScrollPaneFactory(com.intellij.ui.ScrollPaneFactory) javax.swing(javax.swing) ChangeListener(javax.swing.event.ChangeListener) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) Splitter(com.intellij.openapi.ui.Splitter) TabbedPaneWrapper(com.intellij.ui.TabbedPaneWrapper) ChangeEvent(javax.swing.event.ChangeEvent)

Example 7 with Splitter

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

the class FocusDebugger method init.

private JComponent init() {
    final JPanel result = new JPanel(new BorderLayout());
    myLogModel = new DefaultListModel();
    myLog = new JBList(myLogModel);
    myLog.setCellRenderer(new FocusElementRenderer());
    myAllocation = new JEditorPane();
    final DefaultCaret caret = new DefaultCaret();
    myAllocation.setCaret(caret);
    caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    myAllocation.setEditable(false);
    final Splitter splitter = new Splitter(true);
    splitter.setFirstComponent(ScrollPaneFactory.createScrollPane(myLog));
    splitter.setSecondComponent(ScrollPaneFactory.createScrollPane(myAllocation));
    myLog.addListSelectionListener(this);
    KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener(this);
    result.add(splitter, BorderLayout.CENTER);
    final DefaultActionGroup group = new DefaultActionGroup();
    group.add(new ClearAction());
    result.add(ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true).getComponent(), BorderLayout.NORTH);
    return result;
}
Also used : Splitter(com.intellij.openapi.ui.Splitter) DefaultCaret(javax.swing.text.DefaultCaret) JBList(com.intellij.ui.components.JBList)

Example 8 with Splitter

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

the class PlaybackDebugger method initUi.

private void initUi() {
    myComponent = new JPanel(new BorderLayout());
    myLog = new JEditorPane();
    myLog.setEditorKit(new StyledEditorKit());
    myLog.setEditable(false);
    myState = ServiceManager.getService(PlaybackDebuggerState.class);
    final DefaultActionGroup controlGroup = new DefaultActionGroup();
    controlGroup.add(new RunOnFameActivationAction());
    controlGroup.add(new ActivateFrameAndRun());
    controlGroup.add(new StopAction());
    JPanel north = new JPanel(new BorderLayout());
    north.add(ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, controlGroup, true).getComponent(), BorderLayout.WEST);
    final JPanel right = new JPanel(new BorderLayout());
    right.add(myCurrentScript, BorderLayout.CENTER);
    myCurrentScript.setText(myState.currentScript);
    myCurrentScript.setEditable(false);
    final DefaultActionGroup fsGroup = new DefaultActionGroup();
    SaveAction saveAction = new SaveAction();
    saveAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke("control S")), myComponent);
    fsGroup.add(saveAction);
    SetScriptFileAction setScriptFileAction = new SetScriptFileAction();
    setScriptFileAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke("control O")), myComponent);
    fsGroup.add(setScriptFileAction);
    AnAction newScriptAction = new NewScriptAction();
    newScriptAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke("control N")), myComponent);
    fsGroup.add(newScriptAction);
    final ActionToolbar tb = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, fsGroup, true);
    tb.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
    right.add(tb.getComponent(), BorderLayout.EAST);
    north.add(right, BorderLayout.CENTER);
    myComponent.add(north, BorderLayout.NORTH);
    myCodeEditor = new JTextArea();
    myCodeEditor.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(DocumentEvent e) {
            myChanged = true;
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            myChanged = true;
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            myChanged = true;
        }
    });
    if (pathToFile() != null) {
        loadFrom(pathToFile());
    }
    final Splitter script2Log = new Splitter(true);
    script2Log.setFirstComponent(ScrollPaneFactory.createScrollPane(myCodeEditor));
    script2Log.setSecondComponent(ScrollPaneFactory.createScrollPane(myLog));
    myComponent.add(script2Log, BorderLayout.CENTER);
    myVfsListener = new VirtualFileAdapter() {

        @Override
        public void contentsChanged(@NotNull VirtualFileEvent event) {
            final VirtualFile file = pathToFile();
            if (file != null && file.equals(event.getFile())) {
                loadFrom(event.getFile());
            }
        }
    };
    LocalFileSystem.getInstance().addVirtualFileListener(myVfsListener);
}
Also used : DocumentListener(javax.swing.event.DocumentListener) Splitter(com.intellij.openapi.ui.Splitter) DocumentEvent(javax.swing.event.DocumentEvent)

Example 9 with Splitter

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

the class ExtractMethodDialog method createCenterPanel.

@Override
protected JComponent createCenterPanel() {
    myCenterPanel = new JPanel(new BorderLayout());
    createParametersPanel();
    final Splitter splitter = new Splitter(true);
    splitter.setShowDividerIcon(false);
    splitter.setFirstComponent(myCenterPanel);
    splitter.setSecondComponent(createSignaturePanel());
    return splitter;
}
Also used : Splitter(com.intellij.openapi.ui.Splitter)

Example 10 with Splitter

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

the class NullableNotNullDialog method createCenterPanel.

@Override
protected JComponent createCenterPanel() {
    final NullableNotNullManager manager = NullableNotNullManager.getInstance(myProject);
    final Splitter splitter = new Splitter(true);
    myNullablePanel = new AnnotationsPanel("Nullable", manager.getDefaultNullable(), manager.getNullables(), NullableNotNullManager.DEFAULT_NULLABLES);
    splitter.setFirstComponent(myNullablePanel.getComponent());
    myNotNullPanel = new AnnotationsPanel("NotNull", manager.getDefaultNotNull(), manager.getNotNulls(), ArrayUtil.toStringArray(manager.getPredefinedNotNulls()));
    splitter.setSecondComponent(myNotNullPanel.getComponent());
    splitter.setHonorComponentsMinimumSize(true);
    splitter.setPreferredSize(JBUI.size(300, 400));
    return splitter;
}
Also used : Splitter(com.intellij.openapi.ui.Splitter)

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