use of com.intellij.openapi.ui.popup.PopupStep 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));
}
use of com.intellij.openapi.ui.popup.PopupStep in project intellij-community by JetBrains.
the class StudyNewProjectPanel method setupBrowseButton.
private void setupBrowseButton() {
if (SystemInfo.isMac && !UIUtil.isUnderDarcula())
myBrowseButton.putClientProperty("JButton.buttonType", null);
myBrowseButton.setIcon(InteractiveLearningIcons.InterpreterGear);
final FileChooserDescriptor fileChooser = new FileChooserDescriptor(true, false, false, true, false, false) {
@Override
public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
return file.isDirectory() || StudyUtils.isZip(file.getName());
}
@Override
public boolean isFileSelectable(VirtualFile file) {
return StudyUtils.isZip(file.getName());
}
};
myBrowseButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final BaseListPopupStep<String> popupStep = new BaseListPopupStep<String>("", "Add local course", LOGIN_TO_STEPIC) {
@Override
public PopupStep onChosen(final String selectedValue, boolean finalChoice) {
return doFinalStep(() -> {
if ("Add local course".equals(selectedValue)) {
Project[] projects = ProjectManager.getInstance().getOpenProjects();
FileChooser.chooseFile(fileChooser, null, projects.length == 0 ? null : projects[0].getBaseDir(), file -> {
String fileName = file.getPath();
int oldSize = myAvailableCourses.size();
CourseInfo courseInfo = myGenerator.addLocalCourse(fileName);
if (courseInfo != null) {
if (oldSize != myAvailableCourses.size()) {
myCoursesComboBox.addItem(courseInfo);
}
myCoursesComboBox.setSelectedItem(courseInfo);
setOK();
} else {
setError(INVALID_COURSE);
myCoursesComboBox.removeAllItems();
myCoursesComboBox.addItem(CourseInfo.INVALID_COURSE);
for (CourseInfo course : myAvailableCourses) {
myCoursesComboBox.addItem(course);
}
myCoursesComboBox.setSelectedItem(CourseInfo.INVALID_COURSE);
}
});
} else if (LOGIN_TO_STEPIC.equals(selectedValue)) {
showLoginDialog(true, "Signing In And Getting Stepik Course List");
}
});
}
};
final ListPopup popup = JBPopupFactory.getInstance().createListPopup(popupStep);
popup.showInScreenCoordinates(myBrowseButton, myBrowseButton.getLocationOnScreen());
}
});
}
use of com.intellij.openapi.ui.popup.PopupStep in project intellij-plugins by JetBrains.
the class DependenciesConfigurable method addItem.
private void addItem(AnActionButton button) {
initPopupActions();
final JBPopup popup = JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<AddItemPopupAction>(FlexBundle.message("add.dependency.popup.title"), myPopupActions) {
@Override
public Icon getIconFor(AddItemPopupAction aValue) {
return aValue.getIcon();
}
@Override
public boolean hasSubstep(AddItemPopupAction selectedValue) {
return selectedValue.hasSubStep();
}
public boolean isMnemonicsNavigationEnabled() {
return true;
}
public PopupStep onChosen(final AddItemPopupAction selectedValue, final boolean finalChoice) {
if (selectedValue.hasSubStep()) {
return selectedValue.createSubStep();
}
return doFinalStep(() -> selectedValue.run());
}
@NotNull
public String getTextFor(AddItemPopupAction value) {
return "&" + value.getIndex() + " " + value.getTitle();
}
});
popup.show(button.getPreferredPopupPoint());
}
use of com.intellij.openapi.ui.popup.PopupStep in project intellij-plugins by JetBrains.
the class CucumberCreateStepFixBase method applyFix.
public void applyFix(@NotNull final Project project, @NotNull ProblemDescriptor descriptor) {
final GherkinStep step = (GherkinStep) descriptor.getPsiElement();
final GherkinFile featureFile = (GherkinFile) step.getContainingFile();
// TODO + step defs pairs from other content roots
final List<Pair<PsiFile, BDDFrameworkType>> pairs = ContainerUtil.newArrayList(getStepDefinitionContainers(featureFile));
if (!pairs.isEmpty()) {
pairs.add(0, null);
final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
final ListPopup popupStep = popupFactory.createListPopup(new BaseListPopupStep<Pair<PsiFile, BDDFrameworkType>>(CucumberBundle.message("choose.step.definition.file"), ContainerUtil.newArrayList(pairs)) {
@Override
public boolean isSpeedSearchEnabled() {
return true;
}
@NotNull
@Override
public String getTextFor(Pair<PsiFile, BDDFrameworkType> value) {
if (value == null) {
return CucumberBundle.message("create.new.file");
}
final VirtualFile file = value.getFirst().getVirtualFile();
assert file != null;
CucumberStepsIndex stepsIndex = CucumberStepsIndex.getInstance(value.getFirst().getProject());
StepDefinitionCreator stepDefinitionCreator = stepsIndex.getExtensionMap().get(value.getSecond()).getStepDefinitionCreator();
return stepDefinitionCreator.getStepDefinitionFilePath(value.getFirst());
}
@Override
public Icon getIconFor(Pair<PsiFile, BDDFrameworkType> value) {
return value == null ? AllIcons.Actions.CreateFromUsage : value.getFirst().getIcon(0);
}
@Override
public PopupStep onChosen(final Pair<PsiFile, BDDFrameworkType> selectedValue, boolean finalChoice) {
return doFinalStep(() -> createStepOrSteps(step, selectedValue));
}
});
if (!ApplicationManager.getApplication().isUnitTestMode()) {
popupStep.showCenteredInCurrentWindow(step.getProject());
} else {
createStepOrSteps(step, pairs.get(1));
}
} else {
createFileOrStepDefinition(step, null);
}
}
Aggregations