use of org.eclipse.che.ide.rest.AsyncRequestCallback in project che by eclipse.
the class AntPagePresenter method getEstimateProjectCallback.
public AsyncRequestCallback<Map<String, List<String>>> getEstimateProjectCallback() {
return new AsyncRequestCallback<Map<String, List<String>>>(new StringMapListUnmarshaller()) {
@Override
protected void onSuccess(Map<String, List<String>> result) {
List<String> srcFolder = result.get(AntAttributes.SOURCE_FOLDER);
srcFolder = srcFolder != null && !srcFolder.isEmpty() ? srcFolder : Arrays.asList(AntAttributes.DEF_SRC_PATH);
setAttribute(AntAttributes.SOURCE_FOLDER, srcFolder);
List<String> testSrcFolder = result.get(AntAttributes.TEST_SOURCE_FOLDER);
testSrcFolder = testSrcFolder != null && !testSrcFolder.isEmpty() ? testSrcFolder : Arrays.asList(AntAttributes.DEF_TEST_SRC_PATH);
setAttribute(AntAttributes.TEST_SOURCE_FOLDER, testSrcFolder);
}
@Override
protected void onFailure(Throwable exception) {
Log.error(getClass(), exception.getMessage());
}
};
}
use of org.eclipse.che.ide.rest.AsyncRequestCallback in project che by eclipse.
the class MainPagePresenter method loadImporters.
private void loadImporters() {
final Map<String, Set<ProjectImporterDescriptor>> importersByCategory = new LinkedHashMap<>();
final Unmarshallable<ProjectImporterData> unmarshaller = dtoUnmarshallerFactory.newUnmarshaller(ProjectImporterData.class);
AsyncRequestCallback<ProjectImporterData> callback = new AsyncRequestCallback<ProjectImporterData>(unmarshaller) {
@Override
protected void onSuccess(ProjectImporterData data) {
List<ProjectImporterDescriptor> result = data.getImporters();
String defaultImporterId = data.getConfiguration().get(DEFAULT_PROJECT_IMPORTER);
Iterator<ProjectImporterDescriptor> itr = result.iterator();
while (itr.hasNext()) {
ProjectImporterDescriptor importer = itr.next();
if (importer.getId().equals(defaultImporterId)) {
Set<ProjectImporterDescriptor> importersSet = new LinkedHashSet<>();
importersSet.add(importer);
importersByCategory.put(importer.getCategory(), importersSet);
itr.remove();
}
}
ProjectImporterDescriptor defaultImporter = null;
for (ProjectImporterDescriptor importer : result) {
if (importer.isInternal() || importer.getCategory() == null || importWizardRegistry.getWizardRegistrar(importer.getId()) == null) {
continue;
}
if (importersByCategory.containsKey(importer.getCategory())) {
importersByCategory.get(importer.getCategory()).add(importer);
} else {
Set<ProjectImporterDescriptor> importersSet = new LinkedHashSet<>();
importersSet.add(importer);
importersByCategory.put(importer.getCategory(), importersSet);
}
if (importer.getId().equals(defaultImporterId)) {
defaultImporter = importer;
}
}
setImporters(defaultImporter);
}
private void setImporters(final ProjectImporterDescriptor defaultImporter) {
new Timer() {
@Override
public void run() {
view.setImporters(importersByCategory);
view.selectImporter(defaultImporter != null ? defaultImporter : importersByCategory.get(importersByCategory.keySet().iterator().next()).iterator().next());
}
}.schedule(300);
}
@Override
protected void onFailure(Throwable exception) {
notificationManager.notify(locale.failedToImportProject(), FAIL, FLOAT_MODE);
}
};
projectImportersService.getProjectImporters(appContext.getDevMachine(), callback);
}
Aggregations