本文整理汇总了Java中com.intellij.util.ObjectUtils.chooseNotNull方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectUtils.chooseNotNull方法的具体用法?Java ObjectUtils.chooseNotNull怎么用?Java ObjectUtils.chooseNotNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.util.ObjectUtils
的用法示例。
在下文中一共展示了ObjectUtils.chooseNotNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: show
import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
@Messages.YesNoCancelResult
public int show() {
String yesText = ObjectUtils.chooseNotNull(myYesText, Messages.YES_BUTTON);
String noText = ObjectUtils.chooseNotNull(myNoText, Messages.NO_BUTTON);
String cancelText = ObjectUtils.chooseNotNull(myCancelText, Messages.CANCEL_BUTTON);
try {
if (Messages.canShowMacSheetPanel() && !Messages.isApplicationInUnitTestOrHeadless()) {
return MacMessages.getInstance().showYesNoCancelDialog(myTitle, myMessage, yesText, noText, cancelText, WindowManager.getInstance().suggestParentWindow(myProject), myDoNotAskOption);
}
}
catch (Exception ignored) {}
int buttonNumber = Messages.showDialog(myProject, myMessage, myTitle, new String[]{yesText, noText, cancelText}, 0, myIcon, myDoNotAskOption);
return buttonNumber == 0 ? Messages.YES : buttonNumber == 1 ? Messages.NO : Messages.CANCEL;
}
示例2: getContentManagerFromContext
import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
/**
* This is utility method. It returns <code>ContentManager</code> from the current context.
*/
public static ContentManager getContentManagerFromContext(DataContext dataContext, boolean requiresVisibleToolWindow){
Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project == null) {
return null;
}
ToolWindowManagerEx mgr=ToolWindowManagerEx.getInstanceEx(project);
String id = mgr.getActiveToolWindowId();
if (id == null) {
if(mgr.isEditorComponentActive()){
id = mgr.getLastActiveToolWindowId();
}
}
ToolWindowEx toolWindow = id != null ? (ToolWindowEx)mgr.getToolWindow(id) : null;
if (requiresVisibleToolWindow && (toolWindow == null || !toolWindow.isVisible())) {
return null;
}
ContentManager fromToolWindow = toolWindow != null ? toolWindow.getContentManager() : null;
ContentManager fromContext = PlatformDataKeys.CONTENT_MANAGER.getData(dataContext);
return ObjectUtils.chooseNotNull(fromContext, fromToolWindow);
}
示例3: invokeRemote
import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
private static Object invokeRemote(@NotNull Method localMethod,
@NotNull Method remoteMethod,
@NotNull Object remoteObj,
@Nullable Object[] args,
@Nullable ClassLoader loader,
boolean substituteClassLoader)
throws Exception {
boolean canThrowError = false;
try {
Object result = remoteMethod.invoke(remoteObj, args);
canThrowError = true;
return handleRemoteResult(result, localMethod.getReturnType(), loader, substituteClassLoader);
}
catch (InvocationTargetException e) {
Throwable cause = e.getCause(); // root cause may go deeper than we need, so leave it like this
if (cause instanceof ServerError) cause = ObjectUtils.chooseNotNull(cause.getCause(), cause);
if (cause instanceof RuntimeException) throw (RuntimeException)cause;
else if (canThrowError && cause instanceof Error || cause instanceof LinkageError) throw (Error)cause;
else if (canThrow(cause, localMethod)) throw (Exception)cause;
throw new RuntimeException(cause);
}
}
示例4: doCreateEditorContext
import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
private static SelectInContext doCreateEditorContext(Project project, FileEditor editor, @Nullable DataContext dataContext) {
if (project == null || editor == null) {
return null;
}
VirtualFile file = FileEditorManagerEx.getInstanceEx(project).getFile(editor);
if (file == null) {
file = dataContext == null ? null : CommonDataKeys.VIRTUAL_FILE.getData(dataContext);
if (file == null) {
return null;
}
}
final PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (psiFile == null) {
return null;
}
if (editor instanceof TextEditor) {
return new TextEditorContext((TextEditor)editor, psiFile);
}
else {
StructureViewBuilder builder = editor.getStructureViewBuilder();
StructureView structureView = builder != null ? builder.createStructureView(editor, project) : null;
Object selectorInFile = structureView != null ? structureView.getTreeModel().getCurrentEditorElement() : null;
if (structureView != null) Disposer.dispose(structureView);
return new SimpleSelectInContext(psiFile, ObjectUtils.chooseNotNull(selectorInFile, psiFile));
}
}
示例5: calculateRoot
import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
private Object calculateRoot(DataContext dataContext) {
// Narrow down the root element to the first interesting one
Object root = LangDataKeys.MODULE.getData(dataContext);
if (root != null) return root;
Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project == null) return null;
Object projectChild;
Object projectGrandChild = null;
CommonProcessors.FindFirstAndOnlyProcessor<Object> processor = new CommonProcessors.FindFirstAndOnlyProcessor<Object>();
processChildren(project, processor);
projectChild = processor.reset();
if (projectChild != null) {
processChildren(projectChild, processor);
projectGrandChild = processor.reset();
}
return ObjectUtils.chooseNotNull(projectGrandChild, ObjectUtils.chooseNotNull(projectChild, project));
}
示例6: generateDocstring
import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
private static void generateDocstring(@Nullable PyNamedParameter param, @NotNull PyFunction pyFunction) {
if (!DocStringUtil.ensureNotPlainDocstringFormat(pyFunction)) {
return;
}
final PyDocstringGenerator docstringGenerator = PyDocstringGenerator.forDocStringOwner(pyFunction);
String type = "object";
if (param != null) {
final String paramName = StringUtil.notNullize(param.getName());
final PySignature signature = PySignatureCacheManager.getInstance(pyFunction.getProject()).findSignature(pyFunction);
if (signature != null) {
type = ObjectUtils.chooseNotNull(signature.getArgTypeQualifiedName(paramName), type);
}
docstringGenerator.withParamTypedByName(param, type);
}
else {
docstringGenerator.withReturnValue(type);
}
docstringGenerator.addFirstEmptyLine().buildAndInsert();
docstringGenerator.startTemplate();
}
示例7: merge
import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
@NotNull
public static GitCommandResult merge(@Nullable GitCommandResult first, @NotNull GitCommandResult second) {
if (first == null) return second;
int mergedExitCode;
if (first.myExitCode == 0) {
mergedExitCode = second.myExitCode;
}
else if (second.myExitCode == 0) {
mergedExitCode = first.myExitCode;
}
else {
mergedExitCode = second.myExitCode; // take exit code of the latest command
}
return new GitCommandResult(first.success() && second.success(), mergedExitCode,
ContainerUtil.concat(first.myErrorOutput, second.myErrorOutput),
ContainerUtil.concat(first.myOutput, second.myOutput),
ObjectUtils.chooseNotNull(second.myException, first.myException));
}
示例8: actionPerformed
import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
@Override
public void actionPerformed(final AnActionEvent e) {
String command;
if (myNext) {
command = getModel().getHistoryNext();
if (!myMultiline && command == null) return;
}
else {
command = ObjectUtils.chooseNotNull(getModel().getHistoryPrev(), myMultiline ? "" : StringUtil.notNullize(myHelper.getContent()));
}
setConsoleText(command, myNext && !getModel().hasHistory(false), true);
}
示例9: CommonFindUsagesDialog
import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
public CommonFindUsagesDialog(@NotNull PsiElement element,
@NotNull Project project,
@NotNull FindUsagesOptions findUsagesOptions,
boolean toShowInNewTab,
boolean mustOpenInNewTab,
boolean isSingleFile,
@NotNull FindUsagesHandler handler) {
super(project, findUsagesOptions, toShowInNewTab, mustOpenInNewTab, isSingleFile, isTextSearch(element, isSingleFile, handler),
!isSingleFile && !element.getManager().isInProject(element));
myPsiElement = element;
myHelpId = ObjectUtils.chooseNotNull(handler.getHelpId(), HelpID.FIND_OTHER_USAGES);
init();
}
示例10: getData
import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
public void getData(MavenGeneralSettings data) {
final String resolvedMavenHome = resolveMavenHome(data.getMavenHome());
final String mavenHome = ObjectUtils.chooseNotNull(resolvedMavenHome, data.getMavenHome());
mavenHomeField.setText(mavenHome != null ? FileUtil.toSystemIndependentName(mavenHome): null);
mavenHomeField.addCurrentTextToHistory();
updateMavenVersionLabel();
userSettingsFileOverrider.reset(data.getUserSettingsFile());
localRepositoryOverrider.reset(data.getLocalRepository());
}
示例11: findPresetHttpUrl
import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
@NotNull
private String findPresetHttpUrl() {
return ObjectUtils.chooseNotNull(ContainerUtil.find(myUrlsFromCommand, new Condition<String>() {
@Override
public boolean value(String url) {
String scheme = UriUtil.splitScheme(url).getFirst();
return scheme.startsWith("http");
}
}), ContainerUtil.getFirstItem(myUrlsFromCommand));
}
示例12: getMessage
import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
@Nullable
public static String getMessage(@Nullable Throwable throwable) {
return throwable != null ? ObjectUtils.chooseNotNull(throwable.getMessage(), throwable.getLocalizedMessage()) : null;
}
示例13: getRootProfileName
import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
@NotNull
public String getRootProfileName() {
return ObjectUtils.chooseNotNull(mySchemeManager.getCurrentSchemeName(), InspectionProfileImpl.DEFAULT_PROFILE_NAME);
}
示例14: substituteIcon
import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
@Nullable
@Override
public Icon substituteIcon(@NotNull Project project, @NotNull VirtualFile file) {
Icon icon = ObjectUtils.chooseNotNull(super.substituteIcon(project, file), ScratchFileType.INSTANCE.getIcon());
return LayeredIcon.create(icon, AllIcons.Actions.Scratch);
}
示例15: SvnBindException
import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
public SvnBindException(@Nullable String message, @Nullable Throwable cause) {
super(ObjectUtils.chooseNotNull(message, getMessage(cause)), cause);
init(message);
init(cause);
}