Java Code Examples for com.intellij.openapi.util.NullUtils

The following are top voted examples for showing how to use com.intellij.openapi.util.NullUtils. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: intellij   File: BlazeRunConfigurationProducer.java   View source code 5 votes vote down vote up
@Override
protected final boolean setupConfigurationFromContext(
    T configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
  if (NullUtils.hasNull(configuration, context, sourceElement)) {
    return false;
  }
  if (!validContext(context)) {
    return false;
  }
  return doSetupConfigFromContext(configuration, context, sourceElement);
}
 
Example 2
Project: intellij   File: BlazeRunConfigurationProducer.java   View source code 5 votes vote down vote up
@Override
public final boolean isConfigurationFromContext(T configuration, ConfigurationContext context) {
  if (NullUtils.hasNull(configuration, context)) {
    return false;
  }
  if (!validContext(context)) {
    return false;
  }
  return doIsConfigFromContext(configuration, context);
}
 
Example 3
Project: intellij-ce-playground   File: EditorComposite.java   View source code 4 votes vote down vote up
/**
 * @param file <code>file</code> for which composite is being constructed
 *
 * @param editors <code>edittors</code> that should be placed into the composite
 *
 * @exception java.lang.IllegalArgumentException if <code>editors</code>
 * is <code>null</code> or <code>providers</code> is <code>null</code> or <code>myEditor</code> arrays is empty
 */
EditorComposite(@NotNull final VirtualFile file,
                @NotNull final FileEditor[] editors,
                @NotNull final FileEditorManagerEx fileEditorManager) {
  myFile = file;
  myEditors = editors;
  if (NullUtils.hasNull(editors)) throw new IllegalArgumentException("Must not pass null editors in " + Arrays.asList(editors));
  myFileEditorManager = fileEditorManager;
  myInitialFileTimeStamp     = myFile.getTimeStamp();

  Disposer.register(fileEditorManager.getProject(), this);

  if(editors.length > 1){
    myTabbedPaneWrapper = createTabbedPaneWrapper(editors);
    JComponent component = myTabbedPaneWrapper.getComponent();
    myComponent = new MyComponent(component, component);
  }
  else if(editors.length==1){
    myTabbedPaneWrapper=null;
    FileEditor editor = editors[0];
    myComponent = new MyComponent(createEditorComponent(editor), editor.getPreferredFocusedComponent());
  }
  else{
    throw new IllegalArgumentException("editors array cannot be empty");
  }

  mySelectedEditor = editors[0];
  myFocusWatcher = new FocusWatcher();
  myFocusWatcher.install(myComponent);

  myFileEditorManager.addFileEditorManagerListener(new FileEditorManagerAdapter() {
    @Override
    public void selectionChanged(@NotNull final FileEditorManagerEvent event) {
      final VirtualFile oldFile = event.getOldFile();
      final VirtualFile newFile = event.getNewFile();
      if (Comparing.equal(oldFile, newFile) && Comparing.equal(getFile(), newFile)) {
        Runnable runnable = new Runnable() {
          @Override
          public void run() {
            final FileEditor oldEditor = event.getOldEditor();
            if (oldEditor != null) oldEditor.deselectNotify();
            final FileEditor newEditor = event.getNewEditor();
            if (newEditor != null) newEditor.selectNotify();
            ((FileEditorProviderManagerImpl)FileEditorProviderManager.getInstance()).providerSelected(EditorComposite.this);
            ((IdeDocumentHistoryImpl)IdeDocumentHistory.getInstance(myFileEditorManager.getProject())).onSelectionChanged();
          }
        };
        if (ApplicationManager.getApplication().isDispatchThread()) {
          CommandProcessor.getInstance().executeCommand(myFileEditorManager.getProject(), runnable, "Switch Active Editor", null);
        }
        else {
          runnable.run(); // not invoked by user
        }
      }
    }
  }, this);
}
 
Example 4
Project: intellij-ce-playground   File: ArgumentListGenerator.java   View source code 4 votes vote down vote up
public void generate(@Nullable GrClosureSignature signature,
                     @NotNull GrExpression[] exprs,
                     @NotNull GrNamedArgument[] namedArgs,
                     @NotNull GrClosableBlock[] clArgs,
                     @NotNull GroovyPsiElement context) {
  GrClosureSignatureUtil.ArgInfo<PsiElement>[] argInfos =
    signature == null ? null : GrClosureSignatureUtil.mapParametersToArguments(signature, namedArgs, exprs, clArgs, context, false, false);

  if (argInfos == null && signature != null) {
    argInfos = GrClosureSignatureUtil.mapParametersToArguments(signature, namedArgs, exprs, clArgs, context, true, true);
  }

  final PsiSubstitutor substitutor = signature == null ? PsiSubstitutor.EMPTY : signature.getSubstitutor();
  if (argInfos == null || NullUtils.hasNull(argInfos)) {
    generateSimple(exprs, namedArgs, clArgs, context, substitutor);
    return;
  }

  final GrClosureParameter[] params = signature.getParameters();

  final Project project = context.getProject();
  myBuilder.append('(');
  boolean hasCommaAtEnd = false;
  for (int i = 0; i < argInfos.length; i++) {
    GrClosureSignatureUtil.ArgInfo<PsiElement> arg = argInfos[i];
    if (arg == null) continue;
    final GrClosureParameter param = params[i];
    boolean generated = arg.isMultiArg ? generateMultiArg(arg, param, substitutor, project, context) : generateSingeArg(arg, param);
    if (generated) {
      hasCommaAtEnd = true;
      myBuilder.append(", ");
    }
  }

  if (hasCommaAtEnd) {
    myBuilder.delete(myBuilder.length() - 2, myBuilder.length());
    //myBuilder.removeFromTheEnd(2);
  }

  myBuilder.append(')');
}
 
Example 5
Project: tools-idea   File: ArgumentListGenerator.java   View source code 4 votes vote down vote up
public void generate(@Nullable GrClosureSignature signature,
                     @NotNull GrExpression[] exprs,
                     @NotNull GrNamedArgument[] namedArgs,
                     @NotNull GrClosableBlock[] clArgs,
                     @NotNull GroovyPsiElement context) {
  GrClosureSignatureUtil.ArgInfo<PsiElement>[] argInfos =
    signature == null ? null : GrClosureSignatureUtil.mapParametersToArguments(signature, namedArgs, exprs, clArgs, context, false, false);

  if (argInfos == null && signature != null) {
    argInfos = GrClosureSignatureUtil.mapParametersToArguments(signature, namedArgs, exprs, clArgs, context, true, true);
  }

  final PsiSubstitutor substitutor = signature == null ? PsiSubstitutor.EMPTY : signature.getSubstitutor();
  if (argInfos == null || NullUtils.hasNull(argInfos)) {
    generateSimple(exprs, namedArgs, clArgs, context, substitutor);
    return;
  }

  final GrClosureParameter[] params = signature.getParameters();

  final Project project = context.getProject();
  myBuilder.append('(');
  boolean hasCommaAtEnd = false;
  for (int i = 0; i < argInfos.length; i++) {
    GrClosureSignatureUtil.ArgInfo<PsiElement> arg = argInfos[i];
    if (arg == null) continue;
    final GrClosureParameter param = params[i];
    boolean generated = arg.isMultiArg ? generateMultiArg(arg, param, substitutor, project, context) : generateSingeArg(arg, param);
    if (generated) {
      hasCommaAtEnd = true;
      myBuilder.append(", ");
    }
  }

  if (hasCommaAtEnd) {
    myBuilder.delete(myBuilder.length() - 2, myBuilder.length());
    //myBuilder.removeFromTheEnd(2);
  }

  myBuilder.append(')');
}