Java 类com.intellij.util.NullableConsumer 实例源码

项目:intellij-ce-playground    文件:PythonSdkType.java   
public void showCustomCreateUI(SdkModel sdkModel, final JComponent parentComponent, final Consumer<Sdk> sdkCreatedCallback) {
  Project project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(parentComponent));
  final PointerInfo pointerInfo = MouseInfo.getPointerInfo();
  if (pointerInfo == null) return;
  final Point point = pointerInfo.getLocation();
  PythonSdkDetailsStep
    .show(project, sdkModel.getSdks(), null, parentComponent, point, new NullableConsumer<Sdk>() {
      @Override
      public void consume(@Nullable Sdk sdk) {
        if (sdk != null) {
          sdk.putUserData(SDK_CREATOR_COMPONENT_KEY, new WeakReference<Component>(parentComponent));
          sdkCreatedCallback.consume(sdk);
        }
      }
    });
}
项目:intellij-ce-playground    文件:PyCharmNewProjectStep.java   
@Override
public void consume(@Nullable ProjectSettingsStepBase base) {
  if (base == null) return;
  final DirectoryProjectGenerator generator = base.getProjectGenerator();
  final NullableConsumer<ProjectSettingsStepBase> callback = new GenerateProjectCallback();
  if (generator instanceof PythonProjectGenerator && base instanceof ProjectSpecificSettingsStep) {
    final BooleanFunction<PythonProjectGenerator> beforeProjectGenerated = ((PythonProjectGenerator)generator).
      beforeProjectGenerated(((ProjectSpecificSettingsStep)base).getSdk());
    if (beforeProjectGenerated != null) {
      final boolean result = beforeProjectGenerated.fun((PythonProjectGenerator)generator);
      if (result) {
        callback.consume(base);
      }
      else {
        Messages.showWarningDialog("Project can not be generated", "Error in Project Generation");
      }
    }
    else {
      callback.consume(base);
    }
  }
}
项目:intellij-ce-playground    文件:PythonSdkChooserCombo.java   
private void showOptions(final Project project) {
  final PyConfigurableInterpreterList interpreterList = PyConfigurableInterpreterList.getInstance(project);
  final Sdk[] sdks = interpreterList.getModel().getSdks();
  PythonSdkDetailsStep.show(project, sdks, null, this, getButton().getLocationOnScreen(), new NullableConsumer<Sdk>() {
    @Override
    public void consume(@Nullable Sdk sdk) {
      if (sdk == null) return;
      final PySdkService sdkService = PySdkService.getInstance();
      sdkService.restoreSdk(sdk);

      final ProjectSdksModel projectSdksModel = interpreterList.getModel();
      if (projectSdksModel.findSdk(sdk) == null) {
        projectSdksModel.addSdk(sdk);
        try {
          projectSdksModel.apply();
        }
        catch (ConfigurationException e) {
          LOG.error("Error adding new python interpreter " + e.getMessage());
        }
      }
      //noinspection unchecked
      getComboBox().setModel(new CollectionComboBoxModel(interpreterList.getAllPythonSdks(), sdk));
    }
  }, true);
}
项目:intellij-ce-playground    文件:ChangeListChooser.java   
public ChangeListChooser(@NotNull Project project,
                         @NotNull Collection<? extends ChangeList> changelists,
                         @Nullable ChangeList defaultSelection,
                         final String title,
                         @Nullable final String defaultName) {
  super(project, false);
  myProject = project;

  ChangeListEditHandler handler;
  for (ChangeList changelist : changelists) {
    handler = ((LocalChangeListImpl)changelist).getEditHandler();
    if (handler != null) {
      break;
    }
  }

  myPanel = new ChangeListChooserPanel(myProject, new NullableConsumer<String>() {
    public void consume(final @Nullable String errorMessage) {
      setOKActionEnabled(errorMessage == null);
      setErrorText(errorMessage);
    }
  });

  myPanel.init();
  myPanel.setChangeLists(changelists);
  myPanel.setDefaultSelection(changelists.size() <= 1 && onlyOneListInProject() ? null : defaultSelection);

  setTitle(title);
  if (defaultName != null) {
    myPanel.setDefaultName(defaultName);
  }

  init();
}
项目:intellij-ce-playground    文件:ChangeListChooserPanel.java   
public ChangeListChooserPanel(final Project project, @NotNull final NullableConsumer<String> okEnabledListener) {
  super(new BorderLayout());
  myProject = project;
  myOkEnabledListener = okEnabledListener;
  add(myPanel, BorderLayout.CENTER);

  myRbExisting.addItemListener(new ItemListener() {
    public void itemStateChanged(ItemEvent e) {
      updateEnabledItems();
    }
  });
}
项目:intellij-ce-playground    文件:ProjectSettingsStepBase.java   
public ProjectSettingsStepBase(DirectoryProjectGenerator projectGenerator,
                               NullableConsumer<ProjectSettingsStepBase> callback) {
  super();
  getTemplatePresentation().setIcon(projectGenerator.getLogo());
  getTemplatePresentation().setText(projectGenerator.getName());
  myProjectGenerator = projectGenerator;
  if (projectGenerator instanceof WebProjectTemplate) {
    ((WebProjectTemplate)projectGenerator).reset();
  }
  myCallback = callback;
  myProjectDirectory = findSequentNonExistingUntitled();
}
项目:intellij-ce-playground    文件:PythonSdkDetailsStep.java   
public static void show(final Project project,
                        final Sdk[] existingSdks,
                        @Nullable final DialogWrapper moreDialog,
                        JComponent ownerComponent, final Point popupPoint,
                        final NullableConsumer<Sdk> sdkAddedCallback) {
  show(project, existingSdks, moreDialog, ownerComponent, popupPoint, sdkAddedCallback, false);

}
项目:intellij-ce-playground    文件:PythonSdkDetailsStep.java   
public static void show(final Project project,
                        final Sdk[] existingSdks,
                        @Nullable final DialogWrapper moreDialog,
                        JComponent ownerComponent, final Point popupPoint,
                        final NullableConsumer<Sdk> sdkAddedCallback, boolean isNewProject) {
  final PythonSdkDetailsStep sdkHomesStep = new PythonSdkDetailsStep(project, moreDialog, ownerComponent, existingSdks, sdkAddedCallback);
  sdkHomesStep.setNewProject(isNewProject);
  final ListPopup popup = JBPopupFactory.getInstance().createListPopup(sdkHomesStep);
  popup.showInScreenCoordinates(ownerComponent, popupPoint);
}
项目:intellij-ce-playground    文件:PythonSdkDetailsStep.java   
public PythonSdkDetailsStep(@Nullable final Project project,
                            @Nullable final DialogWrapper moreDialog, @NotNull final Component ownerComponent,
                            @NotNull final Sdk[] existingSdks,
                            @NotNull final NullableConsumer<Sdk> sdkAddedCallback) {
  super(null, getAvailableOptions(moreDialog != null));
  myProject = project;
  myMore = moreDialog;
  myOwnerComponent = ownerComponent;
  myExistingSdks = existingSdks;
  mySdkAddedCallback = sdkAddedCallback;
}
项目:intellij-ce-playground    文件:PyCharmNewProjectStep.java   
public PyCharmNewProjectStep() {
  super("Select Project Type", true);

  final NullableConsumer<ProjectSettingsStepBase> callback = new GenerateProjectCallback();

  final PythonBaseProjectGenerator baseGenerator = new PythonBaseProjectGenerator();
  final ProjectSpecificAction action = new ProjectSpecificAction(baseGenerator, new ProjectSpecificSettingsStep(baseGenerator, callback));
  addAll(action.getChildren(null));

  final DirectoryProjectGenerator[] generators = Extensions.getExtensions(DirectoryProjectGenerator.EP_NAME);
  if (generators.length == 0) {
    action.setPopup(false);
  }
  Arrays.sort(generators, new Comparator<DirectoryProjectGenerator>() {
    @Override
    public int compare(DirectoryProjectGenerator o1, DirectoryProjectGenerator o2) {
      if (o1 instanceof PyFrameworkProjectGenerator && !(o2 instanceof PyFrameworkProjectGenerator)) return -1;
      if (!(o1 instanceof PyFrameworkProjectGenerator) && o2 instanceof PyFrameworkProjectGenerator) return 1;
      return o1.getName().compareTo(o2.getName());
    }
  });

  List<DirectoryProjectGenerator> pluginSpecificGenerators = Lists.newArrayList();
  for (DirectoryProjectGenerator generator : generators) {
    if (generator instanceof PythonProjectGenerator) {
      ProjectSpecificAction group =
        new ProjectSpecificAction(generator, new ProjectSpecificSettingsStep(generator, new PythonGenerateProjectCallback()));
      addAll(group.getChildren(null));
    }
    else
      pluginSpecificGenerators.add(generator);
  }

  if (!pluginSpecificGenerators.isEmpty()) {
    PluginSpecificProjectsStep step = new PluginSpecificProjectsStep(callback, pluginSpecificGenerators);
    addAll(step.getChildren(null));
  }
}
项目:intellij-ce-playground    文件:PluginSpecificProjectsStep.java   
public PluginSpecificProjectsStep(@NotNull final NullableConsumer<ProjectSettingsStepBase> callback,
                                  @NotNull final List<DirectoryProjectGenerator> projectGenerators) {
  super("Plugin-specific", true);
  getTemplatePresentation().setIcon(AllIcons.Nodes.PluginLogo);
  for (DirectoryProjectGenerator generator : projectGenerators) {
    ProjectSettingsStepBase step = generator instanceof CustomStepProjectGenerator ?
                                   ((ProjectSettingsStepBase)((CustomStepProjectGenerator)generator).createStep(generator, callback)) :
                                   new ProjectSpecificSettingsStep(generator, callback);

    ProjectSpecificAction action = new ProjectSpecificAction(generator, step);
    addAll(action.getChildren(null));
  }
}
项目:intellij-ce-playground    文件:PythonSdkDetailsDialog.java   
public PythonSdkDetailsDialog(Project project, NullableConsumer<Sdk> showMoreCallback, Runnable sdkSettingsWereModified) {
  super(project, true);
  myModule = null;
  mySdkSettingsWereModified = sdkSettingsWereModified;
  setTitle(PyBundle.message("sdk.details.dialog.title"));
  myShowMoreCallback = showMoreCallback;
  myProject = project;
  myInterpreterList = PyConfigurableInterpreterList.getInstance(myProject);
  myProjectSdksModel = myInterpreterList.getModel();
  init();
  updateOkButton();
}
项目:intellij-ce-playground    文件:PythonSdkDetailsDialog.java   
public PythonSdkDetailsDialog(Module module, NullableConsumer<Sdk> showMoreCallback, Runnable sdkSettingsWereModified) {
  super(module.getProject());
  myModule = module;
  mySdkSettingsWereModified = sdkSettingsWereModified;

  setTitle(PyBundle.message("sdk.details.dialog.title"));
  myShowMoreCallback = showMoreCallback;
  myProject = module.getProject();
  myInterpreterList = PyConfigurableInterpreterList.getInstance(myProject);
  myProjectSdksModel = myInterpreterList.getModel();
  init();
  updateOkButton();
}
项目:intellij-ce-playground    文件:PythonSdkDetailsDialog.java   
private void addSdk(AnActionButton button) {
  PythonSdkDetailsStep
    .show(myProject, myProjectSdksModel.getSdks(), null, myMainPanel, button.getPreferredPopupPoint().getScreenPoint(),
          new NullableConsumer<Sdk>() {
            @Override
            public void consume(Sdk sdk) {
              addCreatedSdk(sdk, true);
            }
          });
}
项目:intellij-ce-playground    文件:GradleModuleWizardStep.java   
public GradleModuleWizardStep(@NotNull GradleModuleBuilder builder, @NotNull WizardContext context) {
  myProjectOrNull = context.getProject();
  myBuilder = builder;
  myContext = context;
  myParentProjectForm = new GradleParentProjectForm(context, new NullableConsumer<ProjectData>() {
    @Override
    public void consume(@Nullable ProjectData data) {
      myParent = data;
      updateComponents();
    }
  });
  initComponents();
  loadSettings();
}
项目:intellij-ce-playground    文件:MavenProjectsManager.java   
public void evaluateEffectivePom(@NotNull final MavenProject mavenProject, @NotNull final NullableConsumer<String> consumer) {
  runWhenFullyOpen(new Runnable() {
    @Override
    public void run() {
      myResolvingProcessor.scheduleTask(new MavenProjectsProcessorTask() {
        @Override
        public void perform(Project project,
                            MavenEmbeddersManager embeddersManager,
                            MavenConsole console,
                            MavenProgressIndicator indicator)
          throws MavenProcessCanceledException {

          indicator.setText("Evaluating effective POM");

          myProjectsTree.executeWithEmbedder(mavenProject,
                                             getEmbeddersManager(),
                                             MavenEmbeddersManager.FOR_DEPENDENCIES_RESOLVE,
                                             console,
                                             indicator,
                                             new MavenProjectsTree.EmbedderTask() {
                                               @Override
                                               public void run(MavenEmbedderWrapper embedder) throws MavenProcessCanceledException {
                                                 try {
                                                   MavenExplicitProfiles profiles = mavenProject.getActivatedProfilesIds();
                                                   String res =
                                                     embedder.evaluateEffectivePom(mavenProject.getFile(), profiles.getEnabledProfiles(),
                                                                                   profiles.getDisabledProfiles());
                                                   consumer.consume(res);
                                                 }
                                                 catch (UnsupportedOperationException e) {
                                                   consumer.consume(null); // null means UnsupportedOperationException
                                                 }
                                               }
                                             });
        }
      });
    }
  });
}
项目:tools-idea    文件:ChangeListChooser.java   
public ChangeListChooser(@NotNull Project project,
                         @NotNull Collection<? extends ChangeList> changelists,
                         @Nullable ChangeList defaultSelection,
                         final String title,
                         @Nullable final String defaultName) {
  super(project, false);
  myProject = project;

  ChangeListEditHandler handler;
  for (ChangeList changelist : changelists) {
    handler = ((LocalChangeListImpl)changelist).getEditHandler();
    if (handler != null) {
      break;
    }
  }

  myPanel = new ChangeListChooserPanel(myProject, new NullableConsumer<String>() {
    public void consume(final @Nullable String errorMessage) {
      setOKActionEnabled(errorMessage == null);
      setErrorText(errorMessage);
    }
  });

  myPanel.init();
  myPanel.setChangeLists(changelists);
  myPanel.setDefaultSelection(changelists.size() <= 1 && onlyOneListInProject() ? null : defaultSelection);

  setTitle(title);
  if (defaultName != null) {
    myPanel.setDefaultName(defaultName);
  }

  init();
}
项目:tools-idea    文件:ChangeListChooserPanel.java   
public ChangeListChooserPanel(final Project project, @NotNull final NullableConsumer<String> okEnabledListener) {
  super(new BorderLayout());
  myProject = project;
  myOkEnabledListener = okEnabledListener;
  add(myPanel, BorderLayout.CENTER);

  myRbExisting.addItemListener(new ItemListener() {
    public void itemStateChanged(ItemEvent e) {
      updateEnabledItems();
    }
  });
}
项目:tools-idea    文件:SdkConfigurationUtil.java   
public static void createSdk(@Nullable final Project project,
                             final Sdk[] existingSdks,
                             final NullableConsumer<Sdk> onSdkCreatedCallBack,
                             final SdkType... sdkTypes) {
  if (sdkTypes.length == 0) {
    onSdkCreatedCallBack.consume(null);
    return;
  }
  final FileChooserDescriptor descriptor = createCompositeDescriptor(sdkTypes);
  if (SystemInfo.isMac) {
    descriptor.putUserData(PathChooserDialog.NATIVE_MAC_CHOOSER_SHOW_HIDDEN_FILES, Boolean.TRUE);
  }
  String suggestedPath = sdkTypes[0].suggestHomePath();
  VirtualFile suggestedDir = suggestedPath == null
                             ? null
                             : LocalFileSystem.getInstance().findFileByPath(FileUtil.toSystemIndependentName(suggestedPath));
  FileChooser.chooseFiles(descriptor, project, suggestedDir, new FileChooser.FileChooserConsumer() {
    @Override
    public void consume(List<VirtualFile> selectedFiles) {
      for (SdkType sdkType : sdkTypes) {
        if (sdkType.isValidSdkHome(selectedFiles.get(0).getPath())) {
          onSdkCreatedCallBack.consume(setupSdk(existingSdks, selectedFiles.get(0), sdkType, false, null, null));
          return;
        }
      }
      onSdkCreatedCallBack.consume(null);
    }

    @Override
    public void cancelled() {
      onSdkCreatedCallBack.consume(null);
    }
  });
}
项目:consulo    文件:ChangeListChooser.java   
public ChangeListChooser(@Nonnull Project project,
                         @Nonnull Collection<? extends ChangeList> changelists,
                         @Nullable ChangeList defaultSelection,
                         final String title,
                         @Nullable final String suggestedName) {
  super(project, false);
  myProject = project;

  ChangeListEditHandler handler;
  for (ChangeList changelist : changelists) {
    handler = ((LocalChangeListImpl)changelist).getEditHandler();
    if (handler != null) {
      break;
    }
  }

  myPanel = new ChangeListChooserPanel(myProject, new NullableConsumer<String>() {
    public void consume(final @Nullable String errorMessage) {
      setOKActionEnabled(errorMessage == null);
      setErrorText(errorMessage);
    }
  });

  myPanel.init();
  myPanel.setChangeLists(changelists);
  myPanel.setDefaultSelection(defaultSelection);

  setTitle(title);
  if (suggestedName != null) {
    myPanel.setSuggestedName(suggestedName);
  }

  init();
}
项目:intellij-ce-playground    文件:CustomStepProjectGenerator.java   
AbstractActionWithPanel createStep(DirectoryProjectGenerator projectGenerator,
NullableConsumer<? extends AbstractActionWithPanel> callback);
项目:intellij-ce-playground    文件:SdkConfigurationUtil.java   
public static void createSdk(@Nullable final Project project,
                             final Sdk[] existingSdks,
                             final NullableConsumer<Sdk> onSdkCreatedCallBack,
                             final boolean createIfExists,
                             final SdkType... sdkTypes) {
  if (sdkTypes.length == 0) {
    onSdkCreatedCallBack.consume(null);
    return;
  }

  FileChooserDescriptor descriptor = createCompositeDescriptor(sdkTypes);
  VirtualFile suggestedDir = getSuggestedSdkRoot(sdkTypes[0]);
  FileChooser.chooseFiles(descriptor, project, suggestedDir, new FileChooser.FileChooserConsumer() {
    @Override
    public void consume(List<VirtualFile> selectedFiles) {
      for (SdkType sdkType : sdkTypes) {
        final String path = selectedFiles.get(0).getPath();
        if (sdkType.isValidSdkHome(path)) {
          Sdk newSdk = null;
          if (!createIfExists) {
            for (Sdk sdk : existingSdks) {
              if (path.equals(sdk.getHomePath())) {
                newSdk = sdk;
                break;
              }
            }
          }
          if (newSdk == null) {
            newSdk = setupSdk(existingSdks, selectedFiles.get(0), sdkType, false, null, null);
          }
          onSdkCreatedCallBack.consume(newSdk);
          return;
        }
      }
      onSdkCreatedCallBack.consume(null);
    }

    @Override
    public void cancelled() {
      onSdkCreatedCallBack.consume(null);
    }
  });
}
项目:intellij-ce-playground    文件:SdkConfigurationUtil.java   
public static void createSdk(@Nullable final Project project,
                             final Sdk[] existingSdks,
                             final NullableConsumer<Sdk> onSdkCreatedCallBack,
                             final SdkType... sdkTypes) {
  createSdk(project, existingSdks, onSdkCreatedCallBack, true, sdkTypes);
}
项目:intellij-ce-playground    文件:PythonRemoteInterpreterManager.java   
public abstract void addRemoteSdk(Project project, Component parentComponent, Collection<Sdk> existingSdks,
NullableConsumer<Sdk> sdkCallback);
项目:intellij-ce-playground    文件:ProjectSpecificSettingsStep.java   
public ProjectSpecificSettingsStep(@NotNull final DirectoryProjectGenerator projectGenerator,
                                   @NotNull final NullableConsumer<ProjectSettingsStepBase> callback) {
  super(projectGenerator, callback);
}
项目:intellij-ce-playground    文件:GradleParentProjectForm.java   
public GradleParentProjectForm(WizardContext context, @Nullable NullableConsumer<ProjectData> consumer) {
  myProjectOrNull = context.getProject();
  myConsumer = consumer == null ? EmptyConsumer.<ProjectData>getInstance() : consumer;
  myIsVisible = !context.isCreatingNewProject() && myProjectOrNull != null && isGradleModuleExist(context);
  initComponents();
}