use of com.google.gwt.core.client.JsArrayMixed in project che by eclipse.
the class DeleteResourceManager method onConfirm.
private ConfirmCallback onConfirm(final Resource[] resources, final AsyncCallback<Void> callback) {
return new ConfirmCallback() {
@Override
public void accepted() {
if (resources == null) {
//sometimes we may occur NPE here while reading length
callback.onFailure(new IllegalStateException());
return;
}
Promise<?>[] deleteAll = new Promise<?>[resources.length];
for (int i = 0; i < resources.length; i++) {
final Resource resource = resources[i];
deleteAll[i] = resource.delete().catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify("Failed to delete '" + resource.getName() + "'", error.getMessage(), FAIL, StatusNotification.DisplayMode.FLOAT_MODE);
}
});
}
promiseProvider.all(deleteAll).then(new Operation<JsArrayMixed>() {
@Override
public void apply(JsArrayMixed arg) throws OperationException {
callback.onSuccess(null);
}
});
}
};
}
use of com.google.gwt.core.client.JsArrayMixed in project rstudio by rstudio.
the class Fold method toJs.
public static JsArray<JsArrayMixed> toJs(ArrayList<Fold> folds) {
JsArray<JsArrayMixed> results = JavaScriptObject.createArray().cast();
for (Fold f : folds) {
JsArrayMixed foldData = JavaScriptObject.createArray().cast();
foldData.set(0, f.getStartRow());
foldData.set(1, f.getStartColumn());
foldData.set(2, f.getEndRow());
foldData.set(3, f.getEndColumn());
foldData.set(4, f.getPlaceholder());
results.push(foldData);
}
return results;
}
use of com.google.gwt.core.client.JsArrayMixed in project rstudio by rstudio.
the class Fold method fromJs.
public static ArrayList<Fold> fromJs(JsArray<JsArrayMixed> folds) {
ArrayList<Fold> results = new ArrayList<Fold>();
for (int i = 0; i < folds.length(); i++) {
JsArrayMixed foldData = folds.get(i);
results.add(new Fold((int) foldData.getNumber(0), (int) foldData.getNumber(1), (int) foldData.getNumber(2), (int) foldData.getNumber(3), foldData.getString(4)));
}
return results;
}
use of com.google.gwt.core.client.JsArrayMixed in project che by eclipse.
the class DeleteResourceManager method delete.
/**
* Deletes the given resources and its descendants in the standard manner from file system.
* Method requires a confirmation from the user before resource will be removed.
*
* @param needConfirmation
* true if confirmation is need
* @param resources
* the resources to delete
* @return the {@link Promise} with void if removal has successfully completed
* @see #delete(Resource...)
*/
public Promise<Void> delete(boolean needConfirmation, Resource... resources) {
checkArgument(resources != null, "Null resource occurred");
checkArgument(resources.length > 0, "No resources were provided to remove");
final Resource[] filtered = filterDescendants(resources);
if (!needConfirmation) {
Promise<?>[] deleteAll = new Promise<?>[resources.length];
for (int i = 0; i < resources.length; i++) {
deleteAll[i] = resources[i].delete();
}
return promiseProvider.all(deleteAll).then(new Function<JsArrayMixed, Void>() {
@Override
public Void apply(JsArrayMixed arg) throws FunctionException {
return null;
}
});
}
List<Resource> projectsList = newArrayList();
for (Resource resource : filtered) {
if (resource.getResourceType() == PROJECT) {
projectsList.add(resource);
}
}
Resource[] projects = projectsList.toArray(new Resource[projectsList.size()]);
if (projectsList.isEmpty()) {
//if no project were found in nodes list
return promptUserToDelete(filtered);
} else if (projects.length < filtered.length) {
//inform user that we can't delete mixed list of the nodes
return promiseProvider.reject(JsPromiseError.create(localization.mixedProjectDeleteMessage()));
} else {
//delete only project nodes
return promptUserToDelete(projects);
}
}
use of com.google.gwt.core.client.JsArrayMixed in project rstudio by rstudio.
the class DomUtils method splice.
public static JavaScriptObject splice(JavaScriptObject array, int index, int howMany, String... elements) {
JsArrayMixed args = JavaScriptObject.createArray().cast();
args.push(index);
args.push(howMany);
for (String el : elements) args.push(el);
return spliceInternal(array, args);
}
Aggregations