Search in sources :

Example 1 with OnePixelSplitter

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

the class CommonContentEntriesEditor method createComponentImpl.

@Override
public JPanel createComponentImpl() {
    final Module module = getModule();
    final Project project = module.getProject();
    myContentEntryEditorListener = new MyContentEntryEditorListener();
    final JPanel mainPanel = new JPanel(new BorderLayout());
    addAdditionalSettingsToPanel(mainPanel);
    final DefaultActionGroup group = new DefaultActionGroup();
    final AddContentEntryAction action = new AddContentEntryAction();
    action.registerCustomShortcutSet(KeyEvent.VK_C, InputEvent.ALT_DOWN_MASK, mainPanel);
    group.add(action);
    myEditorsPanel = new ScrollablePanel(new VerticalStackLayout());
    myEditorsPanel.setBackground(BACKGROUND_COLOR);
    JScrollPane myScrollPane = ScrollPaneFactory.createScrollPane(myEditorsPanel, true);
    final ToolbarPanel toolbarPanel = new ToolbarPanel(myScrollPane, group);
    int border = myWithBorders ? 1 : 0;
    toolbarPanel.setBorder(new CustomLineBorder(1, 0, border, border));
    final JBSplitter splitter = new OnePixelSplitter(false);
    splitter.setProportion(0.6f);
    splitter.setHonorComponentsMinimumSize(true);
    myRootTreeEditor = createContentEntryTreeEditor(project);
    final JComponent component = myRootTreeEditor.createComponent();
    component.setBorder(new CustomLineBorder(1, border, border, 0));
    splitter.setFirstComponent(component);
    splitter.setSecondComponent(toolbarPanel);
    JPanel contentPanel = new JPanel(new GridBagLayout());
    final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, myRootTreeEditor.getEditingActionsGroup(), true);
    contentPanel.add(new JLabel("Mark as:"), new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, 0, JBUI.insets(0, 10), 0, 0));
    contentPanel.add(actionToolbar.getComponent(), new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, JBUI.emptyInsets(), 0, 0));
    contentPanel.add(splitter, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, JBUI.emptyInsets(), 0, 0));
    mainPanel.add(contentPanel, BorderLayout.CENTER);
    final JPanel innerPanel = createBottomControl(module);
    if (innerPanel != null) {
        mainPanel.add(innerPanel, BorderLayout.SOUTH);
    }
    final ModifiableRootModel model = getModel();
    if (model != null) {
        final ContentEntry[] contentEntries = model.getContentEntries();
        if (contentEntries.length > 0) {
            for (final ContentEntry contentEntry : contentEntries) {
                addContentEntryPanel(contentEntry.getUrl());
            }
            selectContentEntry(contentEntries[0].getUrl());
        }
    }
    return mainPanel;
}
Also used : OnePixelSplitter(com.intellij.ui.OnePixelSplitter) ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) Project(com.intellij.openapi.project.Project) VerticalStackLayout(com.intellij.openapi.roots.ui.componentsList.layout.VerticalStackLayout) ScrollablePanel(com.intellij.openapi.roots.ui.componentsList.components.ScrollablePanel) CustomLineBorder(com.intellij.ui.border.CustomLineBorder) ContentEntry(com.intellij.openapi.roots.ContentEntry) JBSplitter(com.intellij.ui.JBSplitter) Module(com.intellij.openapi.module.Module) ToolbarPanel(com.intellij.ui.roots.ToolbarPanel)

Example 2 with OnePixelSplitter

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

the class ProjectStructureConfigurable method createComponent.

@Override
public JComponent createComponent() {
    myComponent = new MyPanel();
    mySplitter = new OnePixelSplitter(false, .15f);
    mySplitter.setSplitterProportionKey("ProjectStructure.TopLevelElements");
    mySplitter.setHonorComponentsMinimumSize(true);
    initSidePanel();
    final JPanel left = new JPanel(new BorderLayout()) {

        @Override
        public Dimension getMinimumSize() {
            final Dimension original = super.getMinimumSize();
            return new Dimension(Math.max(original.width, 100), original.height);
        }
    };
    final DefaultActionGroup toolbarGroup = new DefaultActionGroup();
    toolbarGroup.add(new BackAction(myComponent));
    toolbarGroup.add(new ForwardAction(myComponent));
    final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, toolbarGroup, true);
    toolbar.setTargetComponent(myComponent);
    myToolbarComponent = toolbar.getComponent();
    left.setBackground(UIUtil.SIDE_PANEL_BACKGROUND);
    myToolbarComponent.setBackground(UIUtil.SIDE_PANEL_BACKGROUND);
    left.add(myToolbarComponent, BorderLayout.NORTH);
    left.add(mySidePanel, BorderLayout.CENTER);
    mySplitter.setFirstComponent(left);
    mySplitter.setSecondComponent(myDetails);
    myComponent.add(mySplitter, BorderLayout.CENTER);
    myUiInitialized = true;
    return myComponent;
}
Also used : ForwardAction(com.intellij.ui.navigation.ForwardAction) OnePixelSplitter(com.intellij.ui.OnePixelSplitter) BackAction(com.intellij.ui.navigation.BackAction)

Example 3 with OnePixelSplitter

use of com.intellij.ui.OnePixelSplitter in project android by JetBrains.

the class ProjectStructureConfigurable method createComponent.

@Override
@Nullable
public JComponent createComponent() {
    JPanel component = new MyPanel();
    mySplitter = new OnePixelSplitter(false, .15f);
    mySplitter.setHonorComponentsMinimumSize(true);
    initSidePanel();
    JPanel left = new JPanel(new BorderLayout()) {

        @Override
        public Dimension getMinimumSize() {
            Dimension original = super.getMinimumSize();
            return new Dimension(Math.max(original.width, 100), original.height);
        }
    };
    DefaultActionGroup toolbarGroup = new DefaultActionGroup();
    toolbarGroup.add(new BackAction(component));
    toolbarGroup.add(new ForwardAction(component));
    ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("AndroidProjectStructure", toolbarGroup, true);
    toolbar.setTargetComponent(component);
    myToolbarComponent = toolbar.getComponent();
    left.setBackground(SIDE_PANEL_BACKGROUND);
    myToolbarComponent.setBackground(SIDE_PANEL_BACKGROUND);
    left.add(myToolbarComponent, BorderLayout.NORTH);
    left.add(mySidePanel, BorderLayout.CENTER);
    mySplitter.setFirstComponent(left);
    mySplitter.setSecondComponent(myDetails);
    component.add(mySplitter, BorderLayout.CENTER);
    myErrorsComponent = new ConfigurationErrorsComponent(myProject);
    component.add(myErrorsComponent, BorderLayout.SOUTH);
    myUiInitialized = true;
    return component;
}
Also used : ForwardAction(com.intellij.ui.navigation.ForwardAction) OnePixelSplitter(com.intellij.ui.OnePixelSplitter) BackAction(com.intellij.ui.navigation.BackAction) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with OnePixelSplitter

use of com.intellij.ui.OnePixelSplitter 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 5 with OnePixelSplitter

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

the class IpnbEditablePanel method initPanel.

protected void initPanel() {
    mySplitter = new OnePixelSplitter(true);
    addViewPanel();
    addEditablePanel();
    mySplitter.setFirstComponent(myViewPrompt);
    mySplitter.setSecondComponent(null);
    setBackground(IpnbEditorUtil.getBackground());
    add(mySplitter);
    addRightClickMenu();
}
Also used : OnePixelSplitter(com.intellij.ui.OnePixelSplitter)

Aggregations

OnePixelSplitter (com.intellij.ui.OnePixelSplitter)6 Nullable (org.jetbrains.annotations.Nullable)3 BackAction (com.intellij.ui.navigation.BackAction)2 ForwardAction (com.intellij.ui.navigation.ForwardAction)2 ListEditForm (com.intellij.codeInspection.ui.ListEditForm)1 FileEditor (com.intellij.openapi.fileEditor.FileEditor)1 Module (com.intellij.openapi.module.Module)1 Project (com.intellij.openapi.project.Project)1 ContentEntry (com.intellij.openapi.roots.ContentEntry)1 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)1 ScrollablePanel (com.intellij.openapi.roots.ui.componentsList.components.ScrollablePanel)1 VerticalStackLayout (com.intellij.openapi.roots.ui.componentsList.layout.VerticalStackLayout)1 Splitter (com.intellij.openapi.ui.Splitter)1 ThreeComponentsSplitter (com.intellij.openapi.ui.ThreeComponentsSplitter)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 JBSplitter (com.intellij.ui.JBSplitter)1 CustomLineBorder (com.intellij.ui.border.CustomLineBorder)1 ToolbarPanel (com.intellij.ui.roots.ToolbarPanel)1 CheckBox (com.intellij.util.ui.CheckBox)1