javax.swing.plaf.ComboBoxUI#com.intellij.util.ObjectUtil源码实例Demo

下面列出了javax.swing.plaf.ComboBoxUI#com.intellij.util.ObjectUtil 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@RequiredReadAction
@Override
public void visitElement(PsiElement element)
{
	if(element.getStartOffsetInParent() >= myStopOffset)
	{
		stopWalk(ObjectUtil.NULL);
		return;
	}

	if(element.getNode().getElementType() == CSharpPreprocessorElements.PREPROCESSOR_DIRECTIVE)
	{
		CSharpBuilderWrapper.processState(myState, () -> myVariables, it -> {
			myVariables.clear();
			myVariables.addAll(it);
		}, element.getNode().getChars());
	}

	super.visitElement(element);
}
 
@Nonnull
@RequiredReadAction
public static DotNetTypeRef resolveTypeForParameter(CSharpLambdaExpressionImpl target, int parameterIndex)
{
	CSharpLambdaResolveResult leftTypeRef = resolveLeftLambdaTypeRef(target);
	if(leftTypeRef == null)
	{
		return DotNetTypeRef.ERROR_TYPE;
	}

	if(leftTypeRef == CSharpUndefinedLambdaResolveResult.INSTANCE)
	{
		return DotNetTypeRef.UNKNOWN_TYPE;
	}
	DotNetTypeRef[] leftTypeParameters = leftTypeRef.getParameterTypeRefs();
	DotNetTypeRef typeRef = ArrayUtil2.safeGet(leftTypeParameters, parameterIndex);
	return ObjectUtil.notNull(typeRef, DotNetTypeRef.ERROR_TYPE);
}
 
@Nonnull
@Override
@RequiredReadAction
public PsiElement[] getEntryPointElements()
{
	final List<DotNetTypeDeclaration> typeDeclarations = new ArrayList<DotNetTypeDeclaration>();
	Collection<DotNetLikeMethodDeclaration> methods = MethodIndex.getInstance().get("Main", getProject(), GlobalSearchScope.moduleScope(getModule()));
	for(DotNetLikeMethodDeclaration method : methods)
	{
		if(method instanceof CSharpMethodDeclaration && DotNetRunUtil.isEntryPoint((DotNetMethodDeclaration) method))
		{
			Module moduleForPsiElement = ModuleUtilCore.findModuleForPsiElement(method);
			// scope is broken?
			if(!getModule().equals(moduleForPsiElement))
			{
				continue;
			}
			ContainerUtil.addIfNotNull(typeDeclarations, ObjectUtil.tryCast(method.getParent(), DotNetTypeDeclaration.class));
		}
	}
	return ContainerUtil.toArray(typeDeclarations, DotNetTypeDeclaration.ARRAY_FACTORY);
}
 
源代码4 项目: consulo-csharp   文件: CS1106.java
@RequiredReadAction
@Nullable
@Override
public HighlightInfoFactory checkImpl(@Nonnull CSharpLanguageVersion languageVersion, @Nonnull CSharpHighlightContext highlightContext, @Nonnull CSharpMethodDeclaration element)
{
	DotNetParameter[] parameters = element.getParameters();
	if(parameters.length > 0 && parameters[0].hasModifier(CSharpModifier.THIS))
	{
		PsiElement parent = element.getParent();
		if(parent instanceof CSharpTypeDeclaration)
		{
			DotNetTypeDeclaration type = CSharpCompositeTypeDeclaration.selectCompositeOrSelfType((DotNetTypeDeclaration) parent);

			if(type.getGenericParametersCount() > 0 || !type.hasModifier(DotNetModifier.STATIC))
			{
				return newBuilder(ObjectUtil.notNull(element.getNameIdentifier(), element), formatElement(element));
			}
		}
	}
	return super.checkImpl(languageVersion, highlightContext, element);
}
 
源代码5 项目: consulo-csharp   文件: CS0708.java
@RequiredReadAction
@Nullable
@Override
public HighlightInfoFactory checkImpl(@Nonnull CSharpLanguageVersion languageVersion, @Nonnull CSharpHighlightContext highlightContext, @Nonnull DotNetModifierListOwner element)
{
	PsiElement parent = element.getParent();
	if(parent instanceof DotNetTypeDeclaration && ((DotNetTypeDeclaration) parent).hasModifier(DotNetModifier.STATIC))
	{
		if(CSharpPsiUtilImpl.isTypeLikeElement(element))
		{
			return null;
		}
		if(!element.hasModifier(DotNetModifier.STATIC))
		{
			PsiElement nameIdentifier = ((PsiNameIdentifierOwner) element).getNameIdentifier();
			return newBuilder(ObjectUtil.notNull(nameIdentifier, element), formatElement(element)).addQuickFix(new AddModifierFix
					(DotNetModifier.STATIC, element));
		}
	}
	return null;
}
 
源代码6 项目: consulo   文件: UIDecorator.java
static <ARG, U extends UIDecorator> void apply(BiPredicate<U, ARG> predicate, ARG arg, Class<U> clazz) {
  for (UIDecorator decorator : UIDecorators.getDecorators()) {
    if (!decorator.isAvaliable()) {
      continue;
    }

    U u = ObjectUtil.tryCast(decorator, clazz);
    if (u == null) {
      continue;
    }

    if (predicate.test(u, arg)) {
      break;
    }
  }
}
 
源代码7 项目: consulo   文件: UIDecorator.java
@Nonnull
static <R, U extends UIDecorator> R get(Function<U, R> supplier, Class<U> clazz) {
  for (UIDecorator decorator : UIDecorators.getDecorators()) {
    if (!decorator.isAvaliable()) {
      continue;
    }

    U u = ObjectUtil.tryCast(decorator, clazz);
    if (u == null) {
      continue;
    }

    R fun = supplier.apply(u);
    if (fun != null) {
      return fun;
    }
  }
  throw new IllegalArgumentException("Null value");
}
 
源代码8 项目: consulo   文件: UIDecorator.java
@Nonnull
static <R, U extends UIDecorator> R get(Function<U, R> supplier, Class<U> clazz, @Nonnull R defaultValue) {
  for (UIDecorator decorator : UIDecorators.getDecorators()) {
    if (!decorator.isAvaliable()) {
      continue;
    }

    U u = ObjectUtil.tryCast(decorator, clazz);
    if (u == null) {
      continue;
    }

    R fun = supplier.apply(u);
    if (fun != null) {
      return fun;
    }
  }
  return defaultValue;
}
 
源代码9 项目: consulo   文件: BinaryContent.java
@Override
@SuppressWarnings({"EmptyCatchBlock"})
@Nullable
public Document getDocument() {
  if (myDocument == null) {
    if (isBinary()) return null;

    String text = null;
    try {
      Charset charset = ObjectUtil
              .notNull(myCharset, EncodingProjectManager.getInstance(myProject).getDefaultCharset());
      text = CharsetToolkit.bytesToString(myBytes, charset);
    }
    catch (IllegalCharsetNameException e) {
    }

    //  Still NULL? only if not supported or an exception was thrown.
    //  Decode a string using the truly default encoding.
    if (text == null) text = new String(myBytes);
    text = LineTokenizer.correctLineSeparators(text);

    myDocument = EditorFactory.getInstance().createDocument(text);
    myDocument.setReadOnly(true);
  }
  return myDocument;
}
 
源代码10 项目: consulo   文件: MessageDialogBuilder.java
@Messages.YesNoCancelResult
public int show() {
  String yesText = ObjectUtil.chooseNotNull(myYesText, Messages.YES_BUTTON);
  String noText = ObjectUtil.chooseNotNull(myNoText, Messages.NO_BUTTON);
  String cancelText = ObjectUtil.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;

}
 
源代码11 项目: consulo   文件: ActionGroupStub.java
public void initGroup(ActionGroup target, ActionManager actionManager) {
  ActionStub.copyTemplatePresentation(getTemplatePresentation(), target.getTemplatePresentation());
  target.setCanUseProjectAsDefault(isCanUseProjectAsDefault());
  target.setModuleExtensionIds(getModuleExtensionIds());

  target.setShortcutSet(getShortcutSet());

  AnAction[] children = getChildren(null, actionManager);
  if (children.length > 0) {
    DefaultActionGroup dTarget = ObjectUtil.tryCast(target, DefaultActionGroup.class);
    if(dTarget == null) {
      throw new PluginException("Action group class must extend DefaultActionGroup for the group to accept children:" + myActionClass, getPluginId());
    }

    for (AnAction action : children) {
      dTarget.addAction(action, Constraints.LAST, actionManager);
    }
  }

  if(myPopupDefinedInXml) {
    target.setPopup(isPopup());
  }
}
 
源代码12 项目: consulo   文件: TreeTable.java
@Override
protected void processKeyEvent(KeyEvent e){
  if (!myProcessCursorKeys) {
    super.processKeyEvent(e);
    return;
  }

  int keyCode = e.getKeyCode();
  final int selColumn = columnModel.getSelectionModel().getAnchorSelectionIndex();
  boolean treeHasFocus = selColumn == -1 || selColumn >= 0 && isTreeColumn(selColumn);
  boolean oneRowSelected = getSelectedRowCount() == 1;
  if(treeHasFocus && oneRowSelected && ((keyCode == KeyEvent.VK_LEFT) || (keyCode == KeyEvent.VK_RIGHT))){
    myTree._processKeyEvent(e);
    int rowToSelect = ObjectUtil.notNull(myTree.getSelectionRows())[0];
    getSelectionModel().setSelectionInterval(rowToSelect, rowToSelect);
    TableUtil.scrollSelectionToVisible(this);
  }
  else{
    super.processKeyEvent(e);
  }
}
 
源代码13 项目: consulo   文件: WizardSessionTest.java
@Test
public void testVisibleStep() {
  List<WizardStep<Object>> steps = new ArrayList<>();
  steps.add(new StepStub<>("first", true));
  steps.add(new StepStub<>("second", true));
  steps.add(new StepStub<>("third", false));
  steps.add(new StepStub<>("fourth", true));

  WizardSession<Object> session = new WizardSession<>(ObjectUtil.NULL, steps);

  assertTrue(session.hasNext());

  assertEquals(session.next().toString(), "first");
  assertEquals(session.next().toString(), "second");
  assertEquals(session.next().toString(), "fourth");


  WizardStep<Object> prev = session.prev();

  assertEquals(prev.toString(), "second");
}
 
源代码14 项目: consulo   文件: LoginAction.java
@RequiredUIAccess
@Override
public void update(@Nonnull AnActionEvent e) {
  if (!EarlyAccessProgramManager.is(ServiceAuthEarlyAccessProgramDescriptor.class)) {
    e.getPresentation().setEnabledAndVisible(false);
    return;
  }

  ServiceAuthConfiguration configuration = ServiceAuthConfiguration.getInstance();

  Presentation presentation = e.getPresentation();

  String email = configuration.getEmail();
  if (email == null) {
    presentation.setText("Logged as anonymous");
    presentation.setIcon(AllIcons.Actions.LoginAvator);
  }
  else {
    presentation.setText("Logged as '" + email + "'");

    Image userIcon = configuration.getUserIcon();
    presentation.setIcon(ObjectUtil.notNull(userIcon, AllIcons.Actions.LoginAvator));
  }
}
 
源代码15 项目: consulo   文件: ApplicationDefaultStoreCache.java
@Nullable
public Element findDefaultStoreElement(@Nonnull Class<?> clazz, @Nonnull String path) {
  Object result = myUrlCache.computeIfAbsent(Pair.create(clazz.getClassLoader(), path), pair -> {
    URL resource = pair.getFirst().getResource(pair.getSecond());

    if(resource != null) {
      try {
        Document document = JDOMUtil.loadDocument(resource);
        Element rootElement = document.getRootElement();
        rootElement.detach();
        return rootElement;
      }
      catch (JDOMException | IOException e) {
        throw new RuntimeException(e);
      }
    }

    return ObjectUtil.NULL;
  });

  return result == ObjectUtil.NULL ? null : (Element)result;
}
 
源代码16 项目: consulo   文件: LocalFileSystemImpl.java
@Nonnull
@Override
public Set<WatchRequest> replaceWatchedRoots(@Nonnull Collection<WatchRequest> watchRequests,
                                             @Nullable Collection<String> recursiveRoots,
                                             @Nullable Collection<String> flatRoots) {
  recursiveRoots = ObjectUtil.notNull(recursiveRoots, Collections.emptyList());
  flatRoots = ObjectUtil.notNull(flatRoots, Collections.emptyList());

  Set<WatchRequest> result = new HashSet<>();
  synchronized (myLock) {
    boolean update = doAddRootsToWatch(recursiveRoots, flatRoots, result) |
                     doRemoveWatchedRoots(watchRequests);
    if (update) {
      myNormalizedTree = null;
      setUpFileWatcher();
    }
  }
  return result;
}
 
源代码17 项目: consulo   文件: ModuleImportProcessor.java
/**
 * Will execute module importing. Will show popup for selecting import providers if more that one, and then show import wizard
 *
 * @param project - null mean its new project creation
 * @return
 */
@RequiredUIAccess
public static <C extends ModuleImportContext> AsyncResult<Pair<C, ModuleImportProvider<C>>> showFileChooser(@Nullable Project project, @Nullable FileChooserDescriptor chooserDescriptor) {
  boolean isModuleImport = project != null;

  FileChooserDescriptor descriptor = ObjectUtil.notNull(chooserDescriptor, createAllImportDescriptor(isModuleImport));

  VirtualFile toSelect = null;
  String lastLocation = PropertiesComponent.getInstance().getValue(LAST_IMPORTED_LOCATION);
  if (lastLocation != null) {
    toSelect = LocalFileSystem.getInstance().refreshAndFindFileByPath(lastLocation);
  }

  AsyncResult<Pair<C, ModuleImportProvider<C>>> result = AsyncResult.undefined();

  AsyncResult<VirtualFile> fileChooseAsync = FileChooser.chooseFile(descriptor, project, toSelect);
  fileChooseAsync.doWhenDone((f) -> {
    PropertiesComponent.getInstance().setValue(LAST_IMPORTED_LOCATION, f.getPath());

    showImportChooser(project, f, AsyncResult.undefined());
  });

  fileChooseAsync.doWhenRejected((Runnable)result::setRejected);

  return result;
}
 
源代码18 项目: consulo   文件: DesktopToolWindowManagerImpl.java
private EditorsSplitters getSplittersToFocus() {
  WindowManagerEx windowManager = (WindowManagerEx)myWindowManager.get();

  Window activeWindow = TargetAWT.to(windowManager.getMostRecentFocusedWindow());

  if (activeWindow instanceof DesktopFloatingDecorator) {
    IdeFocusManager ideFocusManager = IdeFocusManager.findInstanceByComponent(activeWindow);
    IdeFrame lastFocusedFrame = ideFocusManager.getLastFocusedFrame();
    JComponent frameComponent = lastFocusedFrame != null ? lastFocusedFrame.getComponent() : null;
    Window lastFocusedWindow = frameComponent != null ? SwingUtilities.getWindowAncestor(frameComponent) : null;
    activeWindow = ObjectUtil.notNull(lastFocusedWindow, activeWindow);
  }

  FileEditorManagerEx fem = FileEditorManagerEx.getInstanceEx(myProject);
  EditorsSplitters splitters = activeWindow != null ? fem.getSplittersFor(activeWindow) : null;
  return splitters != null ? splitters : fem.getSplitters();
}
 
源代码19 项目: consulo-unity3d   文件: Unity3dPackageOrderEntry.java
@Nullable
@Override
public Object getEqualObject()
{
	Unity3dRootModuleExtension extension = myModuleRootLayer.getExtension(Unity3dRootModuleExtension.class);
	if(extension == null)
	{
		return ObjectUtil.NULL;
	}
	return extension.getSdk();
}
 
源代码20 项目: consulo-unity3d   文件: Unity3dMetaManager.java
@Nullable
@RequiredReadAction
public String getGUID(@Nonnull VirtualFile virtualFile)
{
	String name = virtualFile.getName();

	VirtualFile parent = virtualFile.getParent();
	if(parent == null)
	{
		return null;
	}

	int targetId = FileBasedIndex.getFileId(virtualFile);

	Object o = myGUIDs.computeIfAbsent(targetId, integer ->
	{
		VirtualFile child = parent.findChild(name + "." + Unity3dMetaFileType.INSTANCE.getDefaultExtension());
		if(child != null)
		{
			String guid = null;
			PsiFile file = PsiManager.getInstance(myProject).findFile(child);
			if(file instanceof YAMLFile)
			{
				guid = Unity3dMetaIndexExtension.findGUIDFromFile((YAMLFile) file);
			}
			return guid == null ? ObjectUtil.NULL : guid;
		}
		return ObjectUtil.NULL;
	});
	return o instanceof String ? (String) o : null;
}
 
@RequiredReadAction
@Nullable
@Override
@SuppressWarnings("unchecked")
public CSharpElementGroup<CSharpMethodDeclaration> findExtensionMethodGroupByName(@Nonnull String name)
{
	Object o = myExtensionGroups.get(name);
	return o == ObjectUtil.NULL ? null : (CSharpElementGroup<CSharpMethodDeclaration>) o;
}
 
@RequiredReadAction
@Nonnull
@Override
public String getName()
{
	String assemblyTitle = DotNetAssemblyUtil.getAssemblyTitle(myModule);
	return ObjectUtil.notNull(assemblyTitle, myModule.getName());
}
 
@RequiredReadAction
@Nonnull
public static DotNetTypeDeclaration selectCompositeOrSelfType(@Nonnull DotNetTypeDeclaration parent)
{
	if(parent.hasModifier(CSharpModifier.PARTIAL))
	{
		CSharpCompositeTypeDeclaration compositeType = findCompositeType((CSharpTypeDeclaration) parent);
		return ObjectUtil.notNull(compositeType, parent);
	}
	return parent;
}
 
@RequiredReadAction
@Nullable
public static CSharpCompositeTypeDeclaration findCompositeType(@Nonnull CSharpTypeDeclaration parent)
{
	Object cachedValue = CachedValuesManager.getCachedValue(parent, () -> CachedValueProvider.Result.create(findCompositeTypeImpl(parent), PsiModificationTracker
			.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT));
	return cachedValue == ObjectUtil.NULL ? null : (CSharpCompositeTypeDeclaration) cachedValue;
}
 
源代码25 项目: consulo-csharp   文件: CS0161.java
@RequiredReadAction
@Nullable
@Override
public HighlightInfoFactory checkImpl(@Nonnull CSharpLanguageVersion languageVersion, @Nonnull CSharpHighlightContext highlightContext, @Nonnull CSharpMethodDeclaration element)
{
	DotNetTypeRef returnTypeRef = element.getReturnTypeRef();
	if(DotNetTypeRefUtil.isVmQNameEqual(returnTypeRef, element, DotNetTypes.System.Void))
	{
		return null;
	}

	PsiElement codeBlock = element.getCodeBlock().getElement();
	if(codeBlock instanceof CSharpBlockStatementImpl)
	{
		DotNetStatement[] statements = ((CSharpBlockStatementImpl) codeBlock).getStatements();
		if(statements.length == 0)
		{
			return newBuilder(ObjectUtil.chooseNotNull(((CSharpBlockStatementImpl) codeBlock).getRightBrace(), getNameIdentifier(element)), formatElement(element));
		}
		else if(statements.length == 1)
		{
			DotNetStatement statement = statements[0];
			if(statement instanceof CSharpCheckedStatementImpl)
			{
				DotNetStatement[] childStatements = ((CSharpCheckedStatementImpl) statement).getStatements();
				if(childStatements.length == 0)
				{
					return newBuilder(ObjectUtil.chooseNotNull(((CSharpBlockStatementImpl) codeBlock).getRightBrace(), getNameIdentifier(element)), formatElement(element));
				}
			}
		}
	}

	return null;
}
 
源代码26 项目: consulo-csharp   文件: CS1105.java
@RequiredReadAction
@Nullable
@Override
public HighlightInfoFactory checkImpl(@Nonnull CSharpLanguageVersion languageVersion, @Nonnull CSharpHighlightContext highlightContext, @Nonnull CSharpMethodDeclaration element)
{
	DotNetParameter[] parameters = element.getParameters();
	if(parameters.length > 0 && parameters[0].hasModifier(CSharpModifier.THIS))
	{
		if(!element.hasModifier(DotNetModifier.STATIC))
		{
			return newBuilder(ObjectUtil.notNull(element.getNameIdentifier(), element), formatElement(element));
		}
	}
	return null;
}
 
源代码27 项目: consulo   文件: InputValidatorEx.java
@Nonnull
static String getErrorText(@Nonnull InputValidator validator, @Nonnull String inputString, @Nonnull String defaultError) {
  if (validator instanceof InputValidatorEx) {
    return ObjectUtil.notNull(((InputValidatorEx)validator).getErrorText(inputString), defaultError);
  }
  return defaultError;
}
 
源代码28 项目: consulo   文件: MessageDialogBuilder.java
@Messages.YesNoResult
public int show() {
  String yesText = ObjectUtil.chooseNotNull(myYesText, Messages.YES_BUTTON);
  String noText = ObjectUtil.chooseNotNull(myNoText, Messages.NO_BUTTON);
  try {
    if (Messages.canShowMacSheetPanel() && !Messages.isApplicationInUnitTestOrHeadless()) {
      return MacMessages.getInstance().showYesNoDialog(myTitle, myMessage, yesText, noText, WindowManager.getInstance().suggestParentWindow(myProject), myDoNotAskOption);
    }
  } catch (Exception ignored) {}

  return Messages.showDialog(myProject, myMessage, myTitle, new String[]{yesText, noText}, 0, myIcon, myDoNotAskOption) == 0 ? Messages.YES : Messages.NO;

}
 
源代码29 项目: consulo   文件: TextComponentEmptyText.java
@Override
protected Rectangle getTextComponentBound() {
  Rectangle b = myOwner.getBounds();
  Insets insets = ObjectUtil.notNull(myOwner.getInsets(), JBUI.emptyInsets());
  Insets margin = ObjectUtil.notNull(myOwner.getMargin(), JBUI.emptyInsets());
  Insets ipad = getComponent().getIpad();
  int left = insets.left + margin.left - ipad.left;
  int right = insets.right + margin.right - ipad.right;
  int top = insets.top + margin.top - ipad.top;
  int bottom = insets.bottom + margin.bottom - ipad.bottom;
  return new Rectangle(left, top, b.width - left - right, b.height - top - bottom);
}
 
源代码30 项目: consulo   文件: FirefoxSettingsConfigurable.java
@Override
public void reset() {
  File defaultFile = FirefoxUtil.getDefaultProfileIniPath();
  myDefaultProfilesIniPath = defaultFile != null ? defaultFile.getAbsolutePath() : "";

  String path = mySettings.getProfilesIniPath();
  myProfilesIniPathField.setText(path != null ? FileUtilRt.toSystemDependentName(path) : myDefaultProfilesIniPath);
  updateProfilesList();
  myProfileCombobox.setSelectedItem(ObjectUtil.notNull(mySettings.getProfile(), myDefaultProfile));
}