Search in sources :

Example 1 with PaletteGroup

use of com.intellij.ide.palette.PaletteGroup in project intellij-community by JetBrains.

the class PaletteWindow method collectCurrentGroups.

private ArrayList<PaletteGroup> collectCurrentGroups(@Nullable VirtualFile selectedFile) {
    ArrayList<PaletteGroup> result = new ArrayList<>();
    if (selectedFile != null) {
        for (PaletteItemProvider provider : myProviders) {
            PaletteGroup[] groups = provider.getActiveGroups(selectedFile);
            Collections.addAll(result, groups);
        }
    }
    return result;
}
Also used : PaletteItemProvider(com.intellij.ide.palette.PaletteItemProvider) PaletteGroup(com.intellij.ide.palette.PaletteGroup)

Example 2 with PaletteGroup

use of com.intellij.ide.palette.PaletteGroup in project intellij-community by JetBrains.

the class PaletteWindow method refreshPalette.

private void refreshPalette(@Nullable VirtualFile selectedFile) {
    for (PaletteGroupHeader groupHeader : myGroupHeaders) {
        groupHeader.getComponentList().removeListSelectionListener(myListSelectionListener);
    }
    String[] oldTabNames = collectTabNames(myGroups);
    myTabbedPane.removeAll();
    myGroupHeaders.clear();
    myGroups.clear();
    final ArrayList<PaletteGroup> currentGroups = collectCurrentGroups(selectedFile);
    String[] tabNames = collectTabNames(currentGroups);
    if (tabNames.length == 1) {
        if (oldTabNames.length != 1) {
            remove(myTabbedPane);
            add(myScrollPane);
        }
        PaletteContentWindow contentWindow = new PaletteContentWindow();
        myScrollPane.getViewport().setView(contentWindow);
        for (PaletteGroup group : currentGroups) {
            addGroupToControl(group, contentWindow);
        }
        final JComponent view = (JComponent) myScrollPane.getViewport().getView();
        if (view != null) {
            view.revalidate();
            for (Component component : view.getComponents()) {
                ((JComponent) component).revalidate();
            }
        }
    } else {
        if (oldTabNames.length <= 1) {
            remove(myScrollPane);
            add(myTabbedPane);
        }
        for (String tabName : tabNames) {
            PaletteContentWindow contentWindow = new PaletteContentWindow();
            JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(contentWindow);
            scrollPane.addMouseListener(new MyScrollPanePopupHandler());
            myTabbedPane.add(tabName, scrollPane);
            for (PaletteGroup group : currentGroups) {
                if (group.getTabName().equals(tabName)) {
                    addGroupToControl(group, contentWindow);
                }
            }
        }
        myTabbedPane.revalidate();
    }
}
Also used : PaletteGroup(com.intellij.ide.palette.PaletteGroup)

Example 3 with PaletteGroup

use of com.intellij.ide.palette.PaletteGroup in project intellij-community by JetBrains.

the class PaletteWindow method refreshPaletteIfChanged.

public void refreshPaletteIfChanged(@Nullable GuiEditor designer) {
    removePaletteProviderListener();
    myDesigner = designer;
    if (designer != null) {
        addPaletteProviderListener();
    }
    VirtualFile file = designer == null ? null : designer.getFile();
    Set<PaletteGroup> currentGroups = new HashSet<>(collectCurrentGroups(file));
    if (!currentGroups.equals(myGroups)) {
        refreshPalette(file);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PaletteGroup(com.intellij.ide.palette.PaletteGroup) HashSet(com.intellij.util.containers.HashSet)

Aggregations

PaletteGroup (com.intellij.ide.palette.PaletteGroup)3 PaletteItemProvider (com.intellij.ide.palette.PaletteItemProvider)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 HashSet (com.intellij.util.containers.HashSet)1