Search in sources :

Example 6 with TabbedPaneWrapper

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

the class AbstractTreeClassChooserDialog method createCenterPanel.

@Override
protected JComponent createCenterPanel() {
    final DefaultTreeModel model = new DefaultTreeModel(new DefaultMutableTreeNode());
    myTree = new Tree(model);
    ProjectAbstractTreeStructureBase treeStructure = new AbstractProjectTreeStructure(myProject) {

        @Override
        public boolean isFlattenPackages() {
            return false;
        }

        @Override
        public boolean isShowMembers() {
            return myIsShowMembers;
        }

        @Override
        public boolean isHideEmptyMiddlePackages() {
            return true;
        }

        @Override
        public boolean isAbbreviatePackageNames() {
            return false;
        }

        @Override
        public boolean isShowLibraryContents() {
            return myIsShowLibraryContents;
        }

        @Override
        public boolean isShowModules() {
            return false;
        }
    };
    myBuilder = new ProjectTreeBuilder(myProject, myTree, model, AlphaComparator.INSTANCE, treeStructure);
    myTree.setRootVisible(false);
    myTree.setShowsRootHandles(true);
    myTree.expandRow(0);
    myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    myTree.setCellRenderer(new NodeRenderer());
    UIUtil.setLineStyleAngled(myTree);
    JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTree);
    scrollPane.setPreferredSize(JBUI.size(500, 300));
    myTree.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (KeyEvent.VK_ENTER == e.getKeyCode()) {
                doOKAction();
            }
        }
    });
    new DoubleClickListener() {

        @Override
        protected boolean onDoubleClick(MouseEvent event) {
            TreePath path = myTree.getPathForLocation(event.getX(), event.getY());
            if (path != null && myTree.isPathSelected(path)) {
                doOKAction();
                return true;
            }
            return false;
        }
    }.installOn(myTree);
    myTree.addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {
            handleSelectionChanged();
        }
    });
    new TreeSpeedSearch(myTree);
    myTabbedPane = new TabbedPaneWrapper(getDisposable());
    final JPanel dummyPanel = new JPanel(new BorderLayout());
    String name = null;
    /*
    if (myInitialClass != null) {
      name = myInitialClass.getName();
    }
*/
    myGotoByNamePanel = new ChooseByNamePanel(myProject, createChooseByNameModel(), name, myScope.isSearchInLibraries(), getContext()) {

        @Override
        protected void showTextFieldPanel() {
        }

        @Override
        protected void close(boolean isOk) {
            super.close(isOk);
            if (isOk) {
                doOKAction();
            } else {
                doCancelAction();
            }
        }

        @NotNull
        @Override
        protected Set<Object> filter(@NotNull Set<Object> elements) {
            return doFilter(elements);
        }

        @Override
        protected void initUI(ChooseByNamePopupComponent.Callback callback, ModalityState modalityState, boolean allowMultipleSelection) {
            super.initUI(callback, modalityState, allowMultipleSelection);
            dummyPanel.add(myGotoByNamePanel.getPanel(), BorderLayout.CENTER);
            IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
                IdeFocusManager.getGlobalInstance().requestFocus(IdeFocusTraversalPolicy.getPreferredFocusedComponent(myGotoByNamePanel.getPanel()), true);
            });
        }

        @Override
        protected void showList() {
            super.showList();
            if (myInitialClass != null && myList.getModel().getSize() > 0) {
                myList.setSelectedValue(myInitialClass, true);
                myInitialClass = null;
            }
        }

        @Override
        protected void chosenElementMightChange() {
            handleSelectionChanged();
        }
    };
    Disposer.register(myDisposable, myGotoByNamePanel);
    myTabbedPane.addTab(IdeBundle.message("tab.chooser.search.by.name"), dummyPanel);
    myTabbedPane.addTab(IdeBundle.message("tab.chooser.project"), scrollPane);
    myGotoByNamePanel.invoke(new MyCallback(), getModalityState(), false);
    myTabbedPane.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            handleSelectionChanged();
        }
    });
    return myTabbedPane.getComponent();
}
Also used : Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) DoubleClickListener(com.intellij.ui.DoubleClickListener) KeyAdapter(java.awt.event.KeyAdapter) TreeSpeedSearch(com.intellij.ui.TreeSpeedSearch) TreeSelectionListener(javax.swing.event.TreeSelectionListener) NotNull(org.jetbrains.annotations.NotNull) AbstractProjectTreeStructure(com.intellij.ide.projectView.impl.AbstractProjectTreeStructure) NodeRenderer(com.intellij.ide.util.treeView.NodeRenderer) KeyEvent(java.awt.event.KeyEvent) ProjectAbstractTreeStructureBase(com.intellij.ide.projectView.impl.ProjectAbstractTreeStructureBase) Tree(com.intellij.ui.treeStructure.Tree) ChangeListener(javax.swing.event.ChangeListener) MouseEvent(java.awt.event.MouseEvent) TabbedPaneWrapper(com.intellij.ui.TabbedPaneWrapper) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) TreePath(javax.swing.tree.TreePath) ChangeEvent(javax.swing.event.ChangeEvent) BaseProjectTreeBuilder(com.intellij.ide.projectView.BaseProjectTreeBuilder) ProjectTreeBuilder(com.intellij.ide.projectView.impl.ProjectTreeBuilder) ModalityState(com.intellij.openapi.application.ModalityState) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent)

Example 7 with TabbedPaneWrapper

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

the class PrintDialog method createCenterPanel.

@Override
protected JComponent createCenterPanel() {
    TabbedPaneWrapper tabbedPaneWrapper = new TabbedPaneWrapper(myDisposable);
    tabbedPaneWrapper.addTab(CodeEditorBundle.message("print.settings.tab"), createPrintSettingsPanel());
    tabbedPaneWrapper.addTab(CodeEditorBundle.message("print.header.footer.tab"), createHeaderAndFooterPanel());
    tabbedPaneWrapper.addTab(CodeEditorBundle.message("print.advanced.tab"), createAdvancedPanel());
    return tabbedPaneWrapper.getComponent();
}
Also used : TabbedPaneWrapper(com.intellij.ui.TabbedPaneWrapper)

Example 8 with TabbedPaneWrapper

use of com.intellij.ui.TabbedPaneWrapper 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 9 with TabbedPaneWrapper

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

the class TabbedLanguageCodeStylePanel method ensureTabs.

protected void ensureTabs() {
    if (myTabs == null) {
        myPanel = new JPanel();
        myPanel.setLayout(new BorderLayout());
        myTabbedPane = new TabbedPaneWrapper(this);
        myTabbedPane.addChangeListener(new ChangeListener() {

            @Override
            public void stateChanged(ChangeEvent e) {
                if (myListener != null) {
                    String title = myTabbedPane.getSelectedTitle();
                    if (title != null) {
                        myListener.tabChanged(TabbedLanguageCodeStylePanel.this, title);
                    }
                }
            }
        });
        myTabs = new ArrayList<>();
        myPanel.add(myTabbedPane.getComponent());
        initTabs(getSettings());
    }
    assert !myTabs.isEmpty();
}
Also used : ChangeEvent(javax.swing.event.ChangeEvent) TabbedPaneWrapper(com.intellij.ui.TabbedPaneWrapper) ChangeListener(javax.swing.event.ChangeListener)

Example 10 with TabbedPaneWrapper

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

the class TabbedModuleEditor method createCenterPanel.

@Override
protected JComponent createCenterPanel() {
    myTabbedPane = new TabbedPaneWrapper(this);
    for (ModuleConfigurationEditor editor : myEditors) {
        myTabbedPane.addTab(editor.getDisplayName(), editor.createComponent());
        editor.reset();
    }
    restoreSelectedEditor();
    myTabbedPane.addChangeListener(new javax.swing.event.ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            saveSelectedEditor();
            if (myHistory != null) {
                myHistory.pushQueryPlace();
            }
        }
    });
    return myTabbedPane.getComponent();
}
Also used : ChangeEvent(javax.swing.event.ChangeEvent) TabbedPaneWrapper(com.intellij.ui.TabbedPaneWrapper) ModuleConfigurationEditor(com.intellij.openapi.module.ModuleConfigurationEditor)

Aggregations

TabbedPaneWrapper (com.intellij.ui.TabbedPaneWrapper)15 ChangeEvent (javax.swing.event.ChangeEvent)8 ChangeListener (javax.swing.event.ChangeListener)7 SkipSelfSearchComponent (com.intellij.application.options.SkipSelfSearchComponent)2 BaseProjectTreeBuilder (com.intellij.ide.projectView.BaseProjectTreeBuilder)2 AbstractProjectTreeStructure (com.intellij.ide.projectView.impl.AbstractProjectTreeStructure)2 ProjectAbstractTreeStructureBase (com.intellij.ide.projectView.impl.ProjectAbstractTreeStructureBase)2 ProjectTreeBuilder (com.intellij.ide.projectView.impl.ProjectTreeBuilder)2 NodeRenderer (com.intellij.ide.util.treeView.NodeRenderer)2 Disposable (com.intellij.openapi.Disposable)2 ModalityState (com.intellij.openapi.application.ModalityState)2 Configurable (com.intellij.openapi.options.Configurable)2 DoubleClickListener (com.intellij.ui.DoubleClickListener)2 SimpleColoredComponent (com.intellij.ui.SimpleColoredComponent)2 TreeSpeedSearch (com.intellij.ui.TreeSpeedSearch)2 Tree (com.intellij.ui.treeStructure.Tree)2 NotNull (org.jetbrains.annotations.NotNull)2 DocumentationComponent (com.intellij.codeInsight.documentation.DocumentationComponent)1 DocumentationManager (com.intellij.codeInsight.documentation.DocumentationManager)1 FacetEditorTab (com.intellij.facet.ui.FacetEditorTab)1