use of elemental2.promise.Promise in project kie-wb-common by kiegroup.
the class KieTextEditorPresenter method makeMenuBar.
@Override
protected Promise<Void> makeMenuBar() {
if (workbenchContext.getActiveWorkspaceProject().isPresent()) {
final WorkspaceProject activeProject = workbenchContext.getActiveWorkspaceProject().get();
return projectController.canUpdateProject(activeProject).then(canUpdateProject -> {
if (canUpdateProject) {
final ParameterizedCommand<Boolean> onSave = withComments -> {
saveWithComments = withComments;
saveAction();
};
fileMenuBuilder.addSave(versionRecordManager.newSaveMenuItem(onSave)).addCopy(versionRecordManager.getCurrentPath(), getRenameValidator()).addRename(getSaveAndRename()).addDelete(versionRecordManager.getPathToLatest(), assetUpdateValidator);
}
addDownloadMenuItem(fileMenuBuilder);
fileMenuBuilder.addNewTopLevelMenu(versionRecordManager.buildMenu()).addNewTopLevelMenu(alertsButtonMenuItemBuilder.build());
return promises.resolve();
});
}
return promises.resolve();
}
use of elemental2.promise.Promise in project kie-wb-common by kiegroup.
the class AbstractProjectDiagramEditor method makeMenuBar.
@Override
protected Promise<Void> makeMenuBar() {
if (!menuBarInitialized) {
menuSessionItems.populateMenu(fileMenuBuilder);
makeAdditionalStunnerMenus(fileMenuBuilder);
if (workbenchContext.getActiveWorkspaceProject().isPresent()) {
final WorkspaceProject activeProject = workbenchContext.getActiveWorkspaceProject().get();
return projectController.canUpdateProject(activeProject).then(canUpdateProject -> {
if (canUpdateProject) {
final ParameterizedCommand<Boolean> onSave = withComments -> {
saveWithComments = withComments;
saveAction();
};
fileMenuBuilder.addSave(versionRecordManager.newSaveMenuItem(onSave)).addCopy(versionRecordManager.getCurrentPath(), assetUpdateValidator).addRename(getSaveAndRename()).addDelete(versionRecordManager.getPathToLatest(), assetUpdateValidator);
}
addDownloadMenuItem(fileMenuBuilder);
fileMenuBuilder.addNewTopLevelMenu(versionRecordManager.buildMenu()).addNewTopLevelMenu(alertsButtonMenuItemBuilder.build());
menuBarInitialized = true;
return promises.resolve();
});
}
}
return promises.resolve();
}
use of elemental2.promise.Promise in project kie-wb-common by kiegroup.
the class DMNMarshallerImportsClientHelper method loadNodes.
private Promise<List<DMNIncludedNode>> loadNodes(final Map<String, JSITDefinitions> existingDefinitions, final DMNIncludedModel model, final List<DMNIncludedNode> result) {
String filePath = "";
for (final Map.Entry<String, JSITDefinitions> entry : existingDefinitions.entrySet()) {
filePath = entry.getKey();
final JSITDefinitions definitions = Js.uncheckedCast(entry.getValue());
if (Objects.equals(model.getNamespace(), definitions.getNamespace())) {
break;
}
}
if (isEmpty(filePath)) {
return promises.resolve();
}
final String path = filePath;
return dmnImportsContentService.loadFile(path).then(content -> promises.create((success, fail) -> dmnImportsService.getDRGElements(content, new ServiceCallback<List<DRGElement>>() {
@Override
public void onSuccess(final List<DRGElement> drgElements) {
final List<DMNIncludedNode> nodes = drgElements.stream().map(node -> includedModelFactory.makeDMNIncludeNode(path, model, node)).collect(Collectors.toList());
result.addAll(nodes);
success.onInvoke(nodes);
}
@Override
public void onError(final ClientRuntimeError error) {
LOGGER.log(Level.SEVERE, error.getMessage());
fail.onInvoke(error);
}
})));
}
use of elemental2.promise.Promise in project kie-wb-common by kiegroup.
the class DataModelerScreenPresenter method makeMenuBar.
@Override
protected Promise<Void> makeMenuBar() {
if (!workbenchContext.getActiveWorkspaceProject().isPresent()) {
return promises.resolve();
}
final WorkspaceProject activeProject = workbenchContext.getActiveWorkspaceProject().get();
return projectController.canUpdateProject(activeProject).then(canUpdateProject -> {
if (canUpdateProject) {
final ParameterizedCommand<Boolean> onSave = withComments -> {
saveWithComments = withComments;
saveAction();
};
fileMenuBuilder.addSave(versionRecordManager.newSaveMenuItem(onSave)).addCopy(() -> onCopy()).addRename(() -> onSafeRename()).addDelete(() -> onSafeDelete());
}
addDownloadMenuItem(fileMenuBuilder);
fileMenuBuilder.addValidate(getValidateCommand()).addNewTopLevelMenu(versionRecordManager.buildMenu()).addNewTopLevelMenu(alertsButtonMenuItemBuilder.build());
return promises.resolve();
});
}
use of elemental2.promise.Promise in project drools-wb by kiegroup.
the class GlobalsEditorPresenter method makeMenuBar.
@Override
protected Promise<Void> makeMenuBar() {
if (workbenchContext.getActiveWorkspaceProject().isPresent()) {
final WorkspaceProject activeProject = workbenchContext.getActiveWorkspaceProject().get();
return projectController.canUpdateProject(activeProject).then(canUpdateProject -> {
if (canUpdateProject) {
final ParameterizedCommand<Boolean> onSave = withComments -> {
saveWithComments = withComments;
saveAction();
};
fileMenuBuilder.addSave(versionRecordManager.newSaveMenuItem(onSave)).addCopy(versionRecordManager.getCurrentPath(), assetUpdateValidator).addRename(getSaveAndRename()).addDelete(this::onDelete);
}
addDownloadMenuItem(fileMenuBuilder);
fileMenuBuilder.addValidate(getValidateCommand()).addNewTopLevelMenu(versionRecordManager.buildMenu()).addNewTopLevelMenu(alertsButtonMenuItemBuilder.build());
return promises.resolve();
});
}
return promises.resolve();
}
Aggregations