Search in sources :

Example 6 with JBTabbedPane

use of com.intellij.ui.components.JBTabbedPane in project intellij-plugins by JetBrains.

the class JstdRunConfigurationEditor method createTabbedPane.

@NotNull
private static JBTabbedPane createTabbedPane(@NotNull Project project, @NotNull Map<String, RunSettingsSection> tabs) {
    JBTabbedPane tabbedPane = new JBTabbedPane();
    CreationContext content = new CreationContext(project);
    for (Map.Entry<String, RunSettingsSection> entry : tabs.entrySet()) {
        JComponent component = entry.getValue().getComponent(content);
        tabbedPane.addTab(entry.getKey(), component);
    }
    tabbedPane.setSelectedIndex(0);
    return tabbedPane;
}
Also used : JBTabbedPane(com.intellij.ui.components.JBTabbedPane) EnumMap(java.util.EnumMap) Map(java.util.Map) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with JBTabbedPane

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

the class UsageViewImpl method setupCentralPanel.

private void setupCentralPanel() {
    ApplicationManager.getApplication().assertIsDispatchThread();
    myCentralPanel.removeAll();
    disposeUsageContextPanels();
    JScrollPane treePane = ScrollPaneFactory.createScrollPane(myTree);
    // add reaction to scrolling:
    // since the UsageViewTreeCellRenderer ignores invisible nodes (outside the viewport), their preferred size is incorrect
    // and we need to recalculate them when the node scrolled into the visible rectangle
    treePane.getViewport().addChangeListener(__ -> clearRendererCache());
    myPreviewSplitter = new Splitter(false, 0.5f, 0.1f, 0.9f);
    myPreviewSplitter.setFirstComponent(treePane);
    myCentralPanel.add(myPreviewSplitter, BorderLayout.CENTER);
    if (UsageViewSettings.getInstance().IS_PREVIEW_USAGES) {
        myPreviewSplitter.setProportion(UsageViewSettings.getInstance().PREVIEW_USAGES_SPLITTER_PROPORTIONS);
        treePane.putClientProperty(UIUtil.KEEP_BORDER_SIDES, SideBorder.RIGHT);
        final JBTabbedPane tabbedPane = new JBTabbedPane(SwingConstants.BOTTOM) {

            @NotNull
            @Override
            protected Insets getInsetsForTabComponent() {
                return new Insets(0, 0, 0, 0);
            }
        };
        UsageContextPanel.Provider[] extensions = Extensions.getExtensions(UsageContextPanel.Provider.EP_NAME, myProject);
        myUsageContextPanelProviders = ContainerUtil.filter(extensions, provider -> provider.isAvailableFor(this));
        for (UsageContextPanel.Provider provider : myUsageContextPanelProviders) {
            JComponent component;
            if (myCurrentUsageContextProvider == null || myCurrentUsageContextProvider == provider) {
                myCurrentUsageContextProvider = provider;
                myCurrentUsageContextPanel = provider.create(this);
                component = myCurrentUsageContextPanel.createComponent();
            } else {
                component = new JLabel();
            }
            tabbedPane.addTab(provider.getTabTitle(), component);
        }
        int index = myUsageContextPanelProviders.indexOf(myCurrentUsageContextProvider);
        tabbedPane.setSelectedIndex(index);
        tabbedPane.addChangeListener(e -> {
            int currentIndex = tabbedPane.getSelectedIndex();
            UsageContextPanel.Provider selectedProvider = myUsageContextPanelProviders.get(currentIndex);
            if (selectedProvider != myCurrentUsageContextProvider) {
                tabSelected(selectedProvider);
            }
        });
        tabbedPane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT));
        myPreviewSplitter.setSecondComponent(tabbedPane);
    } else {
        myPreviewSplitter.setProportion(1);
    }
    myCentralPanel.add(myAdditionalComponent, BorderLayout.SOUTH);
    myAdditionalComponent.add(myButtonPanel, BorderLayout.SOUTH);
    myRootPanel.revalidate();
    myRootPanel.repaint();
}
Also used : EdtExecutorService(com.intellij.util.concurrency.EdtExecutorService) UIUtil(com.intellij.util.ui.UIUtil) AllIcons(com.intellij.icons.AllIcons) ScheduledFuture(java.util.concurrent.ScheduledFuture) VirtualFile(com.intellij.openapi.vfs.VirtualFile) THashSet(gnu.trove.THashSet) Disposer(com.intellij.openapi.util.Disposer) Messages(com.intellij.openapi.ui.Messages) MultiMap(com.intellij.util.containers.MultiMap) TIntArrayList(gnu.trove.TIntArrayList) UsageViewManager(com.intellij.usageView.UsageViewManager) Extensions(com.intellij.openapi.extensions.Extensions) DumbService(com.intellij.openapi.project.DumbService) ReflectionUtil(com.intellij.util.ReflectionUtil) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) com.intellij.ide(com.intellij.ide) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Content(com.intellij.ui.content.Content) ExclusionHandler(com.intellij.ide.actions.exclusion.ExclusionHandler) com.intellij.ui(com.intellij.ui) FindManager(com.intellij.find.FindManager) Nullable(org.jetbrains.annotations.Nullable) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) SimpleToolWindowPanel(com.intellij.openapi.ui.SimpleToolWindowPanel) List(java.util.List) SmartPsiElementPointer(com.intellij.psi.SmartPsiElementPointer) PsiDocumentManagerBase(com.intellij.psi.impl.PsiDocumentManagerBase) java.awt.event(java.awt.event) ApplicationManager(com.intellij.openapi.application.ApplicationManager) javax.swing.tree(javax.swing.tree) NotNull(org.jetbrains.annotations.NotNull) Factory(com.intellij.openapi.util.Factory) TreeExpansionListener(javax.swing.event.TreeExpansionListener) Consumer(com.intellij.util.Consumer) JBTabbedPane(com.intellij.ui.components.JBTabbedPane) com.intellij.usages.rules(com.intellij.usages.rules) NavigationItem(com.intellij.navigation.NavigationItem) java.util(java.util) TreeExpansionEvent(javax.swing.event.TreeExpansionEvent) ReadonlyStatusHandler(com.intellij.openapi.vfs.ReadonlyStatusHandler) NonNls(org.jetbrains.annotations.NonNls) UsageInfo(com.intellij.usageView.UsageInfo) ContainerUtil(com.intellij.util.containers.ContainerUtil) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) EditSourceOnDoubleClickHandler(com.intellij.util.EditSourceOnDoubleClickHandler) MessageBusConnection(com.intellij.util.messages.MessageBusConnection) TreeSelectionListener(javax.swing.event.TreeSelectionListener) Comparing(com.intellij.openapi.util.Comparing) ProgressWrapper(com.intellij.openapi.progress.util.ProgressWrapper) Project(com.intellij.openapi.project.Project) Tree(com.intellij.ui.treeStructure.Tree) PsiDocumentManager(com.intellij.psi.PsiDocumentManager) Splitter(com.intellij.openapi.ui.Splitter) PsiInvalidElementAccessException(com.intellij.psi.PsiInvalidElementAccessException) TreeUtil(com.intellij.util.ui.tree.TreeUtil) VfsUtilCore(com.intellij.openapi.vfs.VfsUtilCore) BasicTreeUI(javax.swing.plaf.basic.BasicTreeUI) EmptyEnumeration(com.intellij.util.enumeration.EmptyEnumeration) CloseTabToolbarAction(com.intellij.ide.actions.CloseTabToolbarAction) com.intellij.usages(com.intellij.usages) Disposable(com.intellij.openapi.Disposable) SystemInfo(com.intellij.openapi.util.SystemInfo) DialogUtil(com.intellij.util.ui.DialogUtil) SmartPointerManager(com.intellij.psi.SmartPointerManager) java.awt(java.awt) TimeUnit(java.util.concurrent.TimeUnit) com.intellij.openapi.actionSystem(com.intellij.openapi.actionSystem) CommandProcessor(com.intellij.openapi.command.CommandProcessor) TreeUI(javax.swing.plaf.TreeUI) LinkedMultiMap(com.intellij.util.containers.LinkedMultiMap) UsageViewBundle(com.intellij.usageView.UsageViewBundle) Navigatable(com.intellij.pom.Navigatable) Alarm(com.intellij.util.Alarm) javax.swing(javax.swing) JBTabbedPane(com.intellij.ui.components.JBTabbedPane) Splitter(com.intellij.openapi.ui.Splitter)

Example 8 with JBTabbedPane

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

the class DnDDemo method main.

public static void main(String[] args) {
    JFrame frame = new JFrame("DnD Demo");
    frame.getContentPane().setLayout(new BorderLayout());
    JPanel panel = new JPanel(new BorderLayout());
    final JTree source = new Tree();
    panel.add(source, BorderLayout.WEST);
    final DnDManager dndManager = new DnDManagerImpl(null);
    dndManager.registerSource(new DnDSource() {

        public boolean canStartDragging(DnDAction action, Point dragOrigin) {
            return true;
        }

        public DnDDragStartBean startDragging(DnDAction action, Point point) {
            return new DnDDragStartBean(source.getLastSelectedPathComponent().toString());
        }

        @Nullable
        public Pair<Image, Point> createDraggedImage(DnDAction action, Point dragOrigin) {
            return null;
        }

        public void dragDropEnd() {
        }

        public void dropActionChanged(final int gestureModifiers) {
        }
    }, source);
    JTabbedPane tabs = new JBTabbedPane();
    JPanel delegates = new JPanel(new FlowLayout());
    final JLabel delegate1Label = new JLabel("Delegate 1");
    delegates.add(delegate1Label);
    final JLabel delegate2Label = new JLabel("Delegate 2");
    delegates.add(delegate2Label);
    final DnDTarget delegee1 = new DnDTarget() {

        public boolean update(DnDEvent aEvent) {
            aEvent.setDropPossible(true, "Delegee 1");
            aEvent.setHighlighting(delegate1Label, H_ARROWS | RECTANGLE);
            return false;
        }

        public void drop(DnDEvent aEvent) {
            System.out.println("Delegee 1 accepted drop");
        }

        public void cleanUpOnLeave() {
        }

        public void updateDraggedImage(Image image, Point dropPoint, Point imageOffset) {
        }
    };
    final DnDTarget delegee2 = new DnDTarget() {

        public boolean update(DnDEvent aEvent) {
            aEvent.setDropPossible("Delegee 2", new DropActionHandler() {

                public void performDrop(DnDEvent aEvent) {
                    System.out.println("Delegee 2 accepted drop");
                }
            });
            aEvent.setHighlighting(delegate2Label, V_ARROWS | RECTANGLE);
            return false;
        }

        public void drop(DnDEvent aEvent) {
        }

        public void cleanUpOnLeave() {
        }

        public void updateDraggedImage(Image image, Point dropPoint, Point imageOffset) {
        }
    };
    dndManager.registerTarget(new DnDTarget() {

        public boolean update(DnDEvent aEvent) {
            if (aEvent.getCurrentOverComponent() == delegate1Label) {
                return aEvent.delegateUpdateTo(delegee1);
            } else if (aEvent.getCurrentOverComponent() == delegate2Label) {
                return aEvent.delegateUpdateTo(delegee2);
            }
            aEvent.setDropPossible(false, "Nothing can be dropped here");
            return false;
        }

        public void drop(DnDEvent aEvent) {
            if (aEvent.getCurrentOverComponent() == delegate1Label) {
                aEvent.delegateDropTo(delegee1);
            }
        }

        public void cleanUpOnLeave() {
        }

        public void updateDraggedImage(Image image, Point dropPoint, Point imageOffset) {
        }
    }, delegates);
    tabs.add("Delegates", delegates);
    final JPanel xy = new JPanel();
    dndManager.registerTarget(new DnDTarget() {

        public boolean update(DnDEvent aEvent) {
            aEvent.setDropPossible(true, "Drop to " + asXyString(aEvent));
            return false;
        }

        public void drop(DnDEvent aEvent) {
            System.out.println("Droppped to " + asXyString(aEvent));
        }

        public void cleanUpOnLeave() {
        }

        public void updateDraggedImage(Image image, Point dropPoint, Point imageOffset) {
        }
    }, xy);
    tabs.add("XY drop", xy);
    panel.add(tabs, BorderLayout.CENTER);
    frame.getContentPane().add(panel, BorderLayout.CENTER);
    frame.setBounds(100, 100, 500, 500);
    frame.show();
}
Also used : JBTabbedPane(com.intellij.ui.components.JBTabbedPane) FlowLayout(java.awt.FlowLayout) Point(java.awt.Point) Image(java.awt.Image) Point(java.awt.Point) BorderLayout(java.awt.BorderLayout) Tree(com.intellij.ui.treeStructure.Tree) Nullable(org.jetbrains.annotations.Nullable) Pair(com.intellij.openapi.util.Pair)

Example 9 with JBTabbedPane

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

the class CompositeConfigurable method createComponent.

public JComponent createComponent() {
    tabbedPane = new JBTabbedPane();
    for (Configurable configurable : configurables) {
        JComponent component = configurable.createComponent();
        tabbedPane.add(configurable.getDisplayName(), component);
    }
    return tabbedPane;
}
Also used : JBTabbedPane(com.intellij.ui.components.JBTabbedPane) Configurable(com.intellij.openapi.options.Configurable)

Aggregations

JBTabbedPane (com.intellij.ui.components.JBTabbedPane)9 Nullable (org.jetbrains.annotations.Nullable)4 NotNull (org.jetbrains.annotations.NotNull)3 Tree (com.intellij.ui.treeStructure.Tree)2 FindManager (com.intellij.find.FindManager)1 AllIcons (com.intellij.icons.AllIcons)1 com.intellij.ide (com.intellij.ide)1 CloseTabToolbarAction (com.intellij.ide.actions.CloseTabToolbarAction)1 ExclusionHandler (com.intellij.ide.actions.exclusion.ExclusionHandler)1 NavigationItem (com.intellij.navigation.NavigationItem)1 Disposable (com.intellij.openapi.Disposable)1 com.intellij.openapi.actionSystem (com.intellij.openapi.actionSystem)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 ApplicationManager (com.intellij.openapi.application.ApplicationManager)1 CommandProcessor (com.intellij.openapi.command.CommandProcessor)1 Extensions (com.intellij.openapi.extensions.Extensions)1 Module (com.intellij.openapi.module.Module)1 ModuleConfigurationEditor (com.intellij.openapi.module.ModuleConfigurationEditor)1 Configurable (com.intellij.openapi.options.Configurable)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1