com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListenerAdapter Java Examples

The following examples show how to use com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListenerAdapter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExternalSystemRunConfiguration.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected void detachProcessImpl() {
  myTask.cancel(new ExternalSystemTaskNotificationListenerAdapter() {

    private boolean myResetGreeting = true;

    @Override
    public void onTaskOutput(@Nonnull ExternalSystemTaskId id, @Nonnull String text, boolean stdOut) {
      if (myResetGreeting) {
        notifyTextAvailable("\r", ProcessOutputTypes.SYSTEM);
        myResetGreeting = false;
      }
      notifyTextAvailable(text, stdOut ? ProcessOutputTypes.STDOUT : ProcessOutputTypes.STDERR);
    }
  });
  notifyProcessDetached();
}
 
Example #2
Source File: RNUtil.java    From react-native-console with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 执行./gradlew assembleRelease
 * @param project
 */
public static void buildAndroid(Project project) {
    GradleUtil.executeTask(project, "assembleRelease", "-Pmirror", new ExternalSystemTaskNotificationListenerAdapter() {
        @Override
        public void onTaskOutput(@NotNull ExternalSystemTaskId id, @NotNull String text, boolean stdOut) {
            super.onTaskOutput(id, text, stdOut);
        }
    });
}
 
Example #3
Source File: FreelineUtil.java    From freeline with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 执行./gradlew initFreeline
 * @param project
 */
public static void initFreeline(Project project) {
    GradleUtil.executeTask(project, "initFreeline", "-Pmirror", new ExternalSystemTaskNotificationListenerAdapter() {
        @Override
        public void onTaskOutput(@NotNull ExternalSystemTaskId id, @NotNull String text, boolean stdOut) {
            super.onTaskOutput(id, text, stdOut);
        }
    });
}
 
Example #4
Source File: UpdateAction.java    From freeline with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 更新操作
 *
 * @param newVersion
 * @param gradleBuildModels
 */
protected void updateAction(final String newVersion, final Map<GradleBuildModel,
        List<ArtifactDependencyModel>> gradleBuildModels) {
    CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
        @Override
        public void run() {
            ApplicationManager.getApplication().runWriteAction(new Runnable() {
                @Override
                public void run() {
                    for (GradleBuildModel file : gradleBuildModels.keySet()) {
                        List<ArtifactDependencyModel> models = gradleBuildModels.get(file);
                        for (ArtifactDependencyModel dependencyModel1 : models) {
                            ArtifactDependencyModelWrapper dependencyModel = new ArtifactDependencyModelWrapper(dependencyModel1);
                            if (isClasspathLibrary(dependencyModel)) {
                                dependencyModel1.setVersion(newVersion);
                            }
                            if (isDependencyLibrary(dependencyModel)) {
                                file.dependencies().remove(dependencyModel1);
                            }
                        }
                        file.applyChanges();
                    }
                    GradleUtil.executeTask(currentProject, "initFreeline", "-Pmirror", new ExternalSystemTaskNotificationListenerAdapter() {
                        @Override
                        public void onTaskOutput(@NotNull ExternalSystemTaskId id, @NotNull String text, boolean stdOut) {
                            super.onTaskOutput(id, text, stdOut);
                        }
                    });
                }
            });
        }
    });
}
 
Example #5
Source File: ExternalSystemImportingTestCase.java    From intellij-quarkus with Eclipse Public License 2.0 4 votes vote down vote up
private void doImportProject() {
  AbstractExternalSystemSettings systemSettings = ExternalSystemApiUtil.getSettings(myProject, getExternalSystemId());
  final ExternalProjectSettings projectSettings = getCurrentExternalProjectSettings();
  projectSettings.setExternalProjectPath(getProjectPath());
  //noinspection unchecked
  Set<ExternalProjectSettings> projects = ContainerUtilRt.newHashSet(systemSettings.getLinkedProjectsSettings());
  projects.remove(projectSettings);
  projects.add(projectSettings);
  //noinspection unchecked
  systemSettings.setLinkedProjectsSettings(projects);

  final Ref<Couple<String>> error = Ref.create();
  ImportSpec importSpec = createImportSpec();
  if (importSpec.getCallback() == null) {
    importSpec = new ImportSpecBuilder(importSpec).callback(new ExternalProjectRefreshCallback() {
      @Override
      public void onSuccess(@Nullable final DataNode<ProjectData> externalProject) {
        if (externalProject == null) {
          System.err.println("Got null External project after import");
          return;
        }
        ServiceManager.getService(ProjectDataManager.class).importData(externalProject, myProject, true);
        System.out.println("External project was successfully imported");
      }

      @Override
      public void onFailure(@NotNull String errorMessage, @Nullable String errorDetails) {
        error.set(Couple.of(errorMessage, errorDetails));
      }
    }).build();
  }

  ExternalSystemProgressNotificationManager notificationManager =
    ServiceManager.getService(ExternalSystemProgressNotificationManager.class);
  ExternalSystemTaskNotificationListenerAdapter listener = new ExternalSystemTaskNotificationListenerAdapter() {
    @Override
    public void onTaskOutput(@NotNull ExternalSystemTaskId id, @NotNull String text, boolean stdOut) {
      if (StringUtil.isEmptyOrSpaces(text)) return;
      (stdOut ? System.out : System.err).print(text);
    }
  };
  notificationManager.addNotificationListener(listener);
  try {
    ExternalSystemUtil.refreshProjects(importSpec);
  }
  finally {
    notificationManager.removeNotificationListener(listener);
  }

  if (!error.isNull()) {
    String failureMsg = "Import failed: " + error.get().first;
    if (StringUtil.isNotEmpty(error.get().second)) {
      failureMsg += "\nError details: \n" + error.get().second;
    }
    fail(failureMsg);
  }
}