use of com.intellij.openapi.ui.popup.ListSeparator in project intellij-community by JetBrains.
the class CompoundRunConfigurationSettingsEditor method createEditor.
@NotNull
@Override
protected JComponent createEditor() {
final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myList);
return decorator.disableUpDownActions().setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
final List<RunConfiguration> all = new ArrayList<>();
for (ConfigurationType type : myRunManager.getConfigurationFactories()) {
if (!(type instanceof UnknownConfigurationType)) {
for (RunnerAndConfigurationSettings settings : myRunManager.getConfigurationSettingsList(type)) {
all.add(settings.getConfiguration());
}
}
}
final List<RunConfiguration> configurations = ContainerUtil.filter(all, configuration -> !mySnapshot.getSetToRun().contains(configuration) && canBeAdded(configuration, mySnapshot));
JBPopupFactory.getInstance().createListPopup(new MultiSelectionListPopupStep<RunConfiguration>(null, configurations) {
@Nullable
@Override
public ListSeparator getSeparatorAbove(RunConfiguration value) {
int i = configurations.indexOf(value);
if (i < 1)
return null;
RunConfiguration previous = configurations.get(i - 1);
return value.getType() != previous.getType() ? new ListSeparator() : null;
}
@Override
public Icon getIconFor(RunConfiguration value) {
return value.getType().getIcon();
}
@Override
public boolean isSpeedSearchEnabled() {
return true;
}
@NotNull
@Override
public String getTextFor(RunConfiguration value) {
return value.getName();
}
@Override
public PopupStep<?> onChosen(List<RunConfiguration> selectedValues, boolean finalChoice) {
myList.clearSelection();
myModel.addAll(selectedValues);
return FINAL_CHOICE;
}
}).showUnderneathOf(decorator.getActionsPanel());
}
}).setEditAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
int index = myList.getSelectedIndex();
if (index == -1)
return;
RunConfiguration configuration = myModel.get(index);
RunConfigurationSelector selector = RunConfigurationSelector.KEY.getData(DataManager.getInstance().getDataContext(button.getContextComponent()));
if (selector != null) {
selector.select(configuration);
}
}
}).setToolbarPosition(ActionToolbarPosition.TOP).createPanel();
}
use of com.intellij.openapi.ui.popup.ListSeparator in project intellij-community by JetBrains.
the class PluginDescriptorChooser method show.
public static void show(final Project project, final Editor editor, final PsiFile file, final Consumer<DomFileElement<IdeaPlugin>> consumer) {
final Module module = ModuleUtilCore.findModuleForPsiElement(file);
assert module != null;
List<DomFileElement<IdeaPlugin>> elements = DomService.getInstance().getFileElements(IdeaPlugin.class, project, module.getModuleWithDependentsScope());
elements = ContainerUtil.filter(elements, element -> {
VirtualFile virtualFile = element.getFile().getVirtualFile();
return virtualFile != null && ProjectRootManager.getInstance(project).getFileIndex().isInContent(virtualFile);
});
elements = findAppropriateIntelliJModule(module.getName(), elements);
if (elements.isEmpty()) {
HintManager.getInstance().showErrorHint(editor, "Cannot find plugin descriptor");
return;
}
if (elements.size() == 1) {
consumer.consume(elements.get(0));
return;
}
final BaseListPopupStep<PluginDescriptorCandidate> popupStep = new BaseListPopupStep<PluginDescriptorCandidate>("Choose Plugin Descriptor", createCandidates(module, elements)) {
@Override
public boolean isSpeedSearchEnabled() {
return true;
}
@Override
public Icon getIconFor(PluginDescriptorCandidate candidate) {
return candidate.getIcon();
}
@NotNull
@Override
public String getTextFor(PluginDescriptorCandidate candidate) {
return candidate.getText();
}
@Nullable
@Override
public ListSeparator getSeparatorAbove(PluginDescriptorCandidate candidate) {
final String separatorText = candidate.getSeparatorText();
if (separatorText != null) {
return new ListSeparator(separatorText);
}
return null;
}
@Override
public PopupStep onChosen(PluginDescriptorCandidate selectedValue, boolean finalChoice) {
consumer.consume(selectedValue.myDomFileElement);
return FINAL_CHOICE;
}
};
JBPopupFactory.getInstance().createListPopup(popupStep).showInBestPositionFor(editor);
}
use of com.intellij.openapi.ui.popup.ListSeparator in project intellij-community by JetBrains.
the class ListPopupModel method rebuildLists.
private void rebuildLists() {
myFilteredList.clear();
mySeparators.clear();
myFullMatchIndex = -1;
myStartsWithIndex = -1;
ListSeparator lastSeparator = null;
for (Object each : myOriginalList) {
lastSeparator = ObjectUtils.chooseNotNull(myStep.getSeparatorAbove(each), lastSeparator);
if (myFilter.shouldBeShowing(each)) {
addToFiltered(each);
if (lastSeparator != null) {
mySeparators.put(each, lastSeparator);
lastSeparator = null;
}
}
}
}
use of com.intellij.openapi.ui.popup.ListSeparator in project intellij-community by JetBrains.
the class GitPushTargetPanel method showRemoteSelector.
private void showRemoteSelector(@NotNull Component component, @NotNull Point point) {
List<PopupItem> remotes = getPopupItems();
if (remotes.size() <= 1) {
return;
}
ListPopup popup = new ListPopupImpl(new BaseListPopupStep<PopupItem>(null, remotes) {
@Override
public PopupStep onChosen(@NotNull PopupItem selectedValue, boolean finalChoice) {
return doFinalStep(() -> {
if (selectedValue.isDefineRemote()) {
showDefineRemoteDialog();
} else {
myRemoteRenderer.updateLinkText(selectedValue.getPresentable());
if (myFireOnChangeAction != null && !myTargetEditor.isShowing()) {
//fireOnChange only when editing completed
myFireOnChangeAction.run();
}
}
});
}
@Nullable
@Override
public ListSeparator getSeparatorAbove(PopupItem value) {
return value.isDefineRemote() ? new ListSeparator() : null;
}
}) {
@Override
public void cancel(InputEvent e) {
super.cancel(e);
if (myTargetEditor.isShowing()) {
//repaint and force move focus to target editor component
GitPushTargetPanel.this.repaint();
IdeFocusManager.getInstance(myProject).requestFocus(myTargetEditor, true);
}
}
};
popup.show(new RelativePoint(component, point));
}
Aggregations