本文整理汇总了Java中com.intellij.ide.util.gotoByName.ChooseByNamePopup类的典型用法代码示例。如果您正苦于以下问题:Java ChooseByNamePopup类的具体用法?Java ChooseByNamePopup怎么用?Java ChooseByNamePopup使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChooseByNamePopup类属于com.intellij.ide.util.gotoByName包,在下文中一共展示了ChooseByNamePopup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calcPopupElements
import com.intellij.ide.util.gotoByName.ChooseByNamePopup; //导入依赖的package包/类
private List<Object> calcPopupElements(ChooseByNamePopup popup, String text, boolean checkboxState) {
List<Object> elements = new ArrayList<>();
CountDownLatch latch = new CountDownLatch(1);
SwingUtilities.invokeLater(() ->
popup.scheduleCalcElements(text, checkboxState, ModalityState.NON_MODAL,
set -> {
elements.addAll(set);
latch.countDown();
}));
try {
if (!latch.await(10, TimeUnit.SECONDS)) {
Assert.fail();
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
return elements;
}
示例2: gotoActionPerformed
import com.intellij.ide.util.gotoByName.ChooseByNamePopup; //导入依赖的package包/类
@Override
public void gotoActionPerformed(@NotNull final AnActionEvent e) {
final Project project = e.getData(CommonDataKeys.PROJECT);
final Component component = e.getData(PlatformDataKeys.CONTEXT_COMPONENT);
Editor editor = e.getData(CommonDataKeys.EDITOR);
PsiFile file = e.getData(CommonDataKeys.PSI_FILE);
FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.popup.action");
GotoActionModel model = new GotoActionModel(project, component, editor, file);
GotoActionCallback<Object> callback = new GotoActionCallback<Object>() {
@Override
public void elementChosen(@NotNull ChooseByNamePopup popup, @NotNull Object element) {
String enteredText = popup.getTrimmedText();
openOptionOrPerformAction(((GotoActionModel.MatchedValue)element).value, enteredText, project, component, e);
}
};
Pair<String, Integer> start = getInitialText(false, e);
showNavigationPopup(callback, null, createPopup(project, model, start.first, start.second, component, e), false);
}
示例3: processOptionInplace
import com.intellij.ide.util.gotoByName.ChooseByNamePopup; //导入依赖的package包/类
private static boolean processOptionInplace(Object value, ChooseByNamePopup popup, Component component, AnActionEvent e) {
if (value instanceof BooleanOptionDescription) {
BooleanOptionDescription option = (BooleanOptionDescription)value;
option.setOptionState(!option.isOptionEnabled());
repaint(popup);
return true;
}
else if (value instanceof GotoActionModel.ActionWrapper) {
AnAction action = ((GotoActionModel.ActionWrapper)value).getAction();
if (action instanceof ToggleAction) {
performAction(action, component, e);
repaint(popup);
return true;
}
}
return false;
}
示例4: filterElements
import com.intellij.ide.util.gotoByName.ChooseByNamePopup; //导入依赖的package包/类
@Override
public boolean filterElements(@NotNull ChooseByNameBase base,
@NotNull String pattern,
boolean everywhere,
@NotNull ProgressIndicator indicator,
@NotNull Processor<Object> consumer) {
if (pattern.contains("/") || pattern.contains("\\")) {
String path = FileUtil.toSystemIndependentName(ChooseByNamePopup.getTransformedPattern(pattern, myModel));
VirtualFile vFile = LocalFileSystem.getInstance().findFileByPathIfCached(path);
if (vFile != null) {
ProjectFileIndex index = ProjectFileIndex.SERVICE.getInstance(myProject);
if (index.isInContent(vFile) || index.isInLibraryClasses(vFile) || index.isInLibrarySource(vFile)) {
PsiFileSystemItem fileOrDir = vFile.isDirectory() ?
PsiManager.getInstance(myProject).findDirectory(vFile) :
PsiManager.getInstance(myProject).findFile(vFile);
if (fileOrDir != null && !consumer.process(fileOrDir)) {
return false;
}
}
}
}
return super.filterElements(base, pattern, everywhere, indicator, consumer);
}
示例5: elementChosen
import com.intellij.ide.util.gotoByName.ChooseByNamePopup; //导入依赖的package包/类
@Override
public void elementChosen(final ChooseByNamePopup popup, final Object element) {
if (element == null) return;
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (!(element instanceof PomWrapper)) {
return;
}
PomWrapper wrapper = (PomWrapper) element;
if (wrapper.getVirtualFile() == null) return;
Navigatable n = new OpenFileDescriptor(project, wrapper.getVirtualFile(), popup.getLinePosition(),
popup.getColumnPosition()).setUseCurrentWindow(popup.isOpenInCurrentWindowRequested());
if (!n.canNavigate()) return;
n.navigate(true);
}
}, ModalityState.NON_MODAL);
}
示例6: gotoActionPerformed
import com.intellij.ide.util.gotoByName.ChooseByNamePopup; //导入依赖的package包/类
@Override
public void gotoActionPerformed(final AnActionEvent e) {
final Project project = e.getData(PlatformDataKeys.PROJECT);
final Component component = e.getData(PlatformDataKeys.CONTEXT_COMPONENT);
FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.popup.action");
final GotoActionModel model = new GotoActionModel(project, component);
final GotoActionCallback<Object> callback = new GotoActionCallback<Object>() {
@Override
public void elementChosen(ChooseByNamePopup popup, final Object element) {
final String enteredText = popup.getEnteredText();
openOptionOrPerformAction(element, enteredText, project, component, e);
}
};
Pair<String, Integer> start = getInitialText(false, e);
showNavigationPopup(callback, null, createPopup(project, model, start.first, start.second));
}
示例7: CurrentInputText
import com.intellij.ide.util.gotoByName.ChooseByNamePopup; //导入依赖的package包/类
CurrentInputText(Project project) {
ChooseByNamePopup chooseByNamePopup =
project.getUserData(ChooseByNamePopup.CHOOSE_BY_NAME_POPUP_IN_PROJECT_KEY);
if (chooseByNamePopup == null) {
buildDir = null;
hasBuildRule = false;
return;
}
String currentText =
chooseByNamePopup
.getEnteredText()
// Remove the begining //
.replaceFirst("^/*", "");
// check if we have as input a proper target
int targetSeparatorIndex = currentText.lastIndexOf(TARGET_NAME_SEPARATOR);
if (targetSeparatorIndex != -1) {
hasBuildRule = true;
buildDir = currentText.substring(0, targetSeparatorIndex);
} else {
hasBuildRule = false;
buildDir = currentText;
}
}
示例8: gotoActionPerformed
import com.intellij.ide.util.gotoByName.ChooseByNamePopup; //导入依赖的package包/类
@Override
public void gotoActionPerformed(@Nonnull final AnActionEvent e) {
final Project project = e.getData(CommonDataKeys.PROJECT);
final Component component = e.getData(PlatformDataKeys.CONTEXT_COMPONENT);
Editor editor = e.getData(CommonDataKeys.EDITOR);
PsiFile file = e.getData(CommonDataKeys.PSI_FILE);
FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.popup.action");
GotoActionModel model = new GotoActionModel(project, component, editor, file);
GotoActionCallback<Object> callback = new GotoActionCallback<Object>() {
@Override
public void elementChosen(@Nonnull ChooseByNamePopup popup, @Nonnull Object element) {
String enteredText = popup.getEnteredText();
openOptionOrPerformAction(((GotoActionModel.MatchedValue)element).value, enteredText, project, component, e);
}
};
Pair<String, Integer> start = getInitialText(false, e);
showNavigationPopup(callback, null, createPopup(project, model, start.first, start.second, component, e), false);
}
示例9: actionPerformed
import com.intellij.ide.util.gotoByName.ChooseByNamePopup; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
final Module module = e.getData(LangDataKeys.MODULE);
if (module == null) return;
final Project project = module.getProject();
final ListChooseByNameModel<SetupTask> model = new ListChooseByNameModel<SetupTask>(project, "Enter setup.py task name",
"No tasks found",
SetupTaskIntrospector.getTaskList(module));
final ChooseByNamePopup popup = ChooseByNamePopup.createPopup(project, model, GotoActionBase.getPsiContext(e));
popup.setShowListForEmptyPattern(true);
popup.invoke(new ChooseByNamePopupComponent.Callback() {
public void onClose() {
}
public void elementChosen(Object element) {
if (element != null) {
final SetupTask task = (SetupTask) element;
ApplicationManager.getApplication().invokeLater(new Runnable() {
public void run() {
runSetupTask(task.getName(), module);
}
}, ModalityState.NON_MODAL);
}
}
}, ModalityState.current(), false);
}
示例10: gotoActionPerformed
import com.intellij.ide.util.gotoByName.ChooseByNamePopup; //导入依赖的package包/类
@Override
protected void gotoActionPerformed(AnActionEvent e) {
final Project project = e.getData(CommonDataKeys.PROJECT);
if (project == null) {
return;
}
final ChooseTargetModel model = new ChooseTargetModel(project);
GotoActionCallback<BuckBuildTarget> callback = new GotoActionCallback<BuckBuildTarget>() {
@Override
public void elementChosen(ChooseByNamePopup chooseByNamePopup, Object element) {
if (element == null) {
return;
}
BuckSettingsProvider buckSettingsProvider = BuckSettingsProvider.getInstance();
if (buckSettingsProvider == null || buckSettingsProvider.getState() == null) {
return;
}
ChooseTargetItem item = (ChooseTargetItem) element;
if (buckSettingsProvider.getState().lastAlias != null) {
buckSettingsProvider.getState().lastAlias.put(
project.getBasePath(), item.getBuildTarget());
}
BuckToolWindowFactory.updateBuckToolWindowTitle(project);
}
};
DefaultChooseByNameItemProvider provider =
new DefaultChooseByNameItemProvider(getPsiContext(e));
showNavigationPopup(e, model, callback, "Choose Build Target", true, false, provider);
}
示例11: showNavigationPopup
import com.intellij.ide.util.gotoByName.ChooseByNamePopup; //导入依赖的package包/类
protected <T> void showNavigationPopup(AnActionEvent e,
ChooseByNameModel model,
final GotoActionCallback<T> callback,
@Nullable final String findUsagesTitle,
boolean useSelectionFromEditor) {
final Project project = e.getData(PlatformDataKeys.PROJECT);
boolean mayRequestOpenInCurrentWindow = model.willOpenEditor() && FileEditorManagerEx.getInstanceEx(project).hasSplitOrUndockedWindows();
Pair<String, Integer> start = getInitialText(useSelectionFromEditor, e);
showNavigationPopup(callback, findUsagesTitle,
ChooseByNamePopup.createPopup(project, model, getPsiContext(e), start.first,
mayRequestOpenInCurrentWindow, start.second));
}
示例12: createPopup
import com.intellij.ide.util.gotoByName.ChooseByNamePopup; //导入依赖的package包/类
private static ChooseByNamePopup createPopup(Project project, GotoActionModel model, String initialText, int initialIndex) {
return ChooseByNamePopup.createPopup(project,
model,
new DefaultChooseByNameItemProvider(null) {
@Override
protected void sortNamesList(@NotNull String namePattern, @NotNull List<MatchResult> namesList) {
Collections.sort(namesList, ELEMENTS_COMPARATOR);
}
},
initialText,
false,
initialIndex);
}
示例13: getBuildTargetFromBuildProjectFile
import com.intellij.ide.util.gotoByName.ChooseByNamePopup; //导入依赖的package包/类
private List<String> getBuildTargetFromBuildProjectFile(Project project, String buildDir) {
List<String> names = new ArrayList<>();
names.add(getAllBuildTargetsInSameDirectory(buildDir));
names.addAll(
BuckQueryAction.execute(
project,
"//" + buildDir + TARGET_NAME_SEPARATOR,
new Function<List<String>, Void>() {
@Nullable
@Override
public Void apply(@Nullable List<String> strings) {
ApplicationManager.getApplication()
.invokeLater(
new Runnable() {
public void run() {
ChooseByNamePopup chooseByNamePopup =
project.getUserData(
ChooseByNamePopup.CHOOSE_BY_NAME_POPUP_IN_PROJECT_KEY);
// the user might have closed the window
if (chooseByNamePopup != null) {
// if we don't have them, just refresh the view when we do, if the
// window is still open
chooseByNamePopup.rebuildList(true);
}
}
});
return null;
}
}));
return names;
}
示例14: create
import com.intellij.ide.util.gotoByName.ChooseByNamePopup; //导入依赖的package包/类
public SearchStringFilter create(ChooseByNamePopup popup, SearchStringModel model) {
return new SearchStringFilter(popup, model, project);
}
示例15: SearchStringFilter
import com.intellij.ide.util.gotoByName.ChooseByNamePopup; //导入依赖的package包/类
private SearchStringFilter(ChooseByNamePopup popup, SearchStringModel model, Project project) {
super(popup, model, SearchStringConfiguration.getInstance(project), project);
}