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;
}
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();
}
}
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);
}
}
Aggregations