use of org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError in project kie-wb-common by kiegroup.
the class AbstractProjectDiagramEditor method open.
@SuppressWarnings("unchecked")
protected void open(final ProjectDiagram diagram) {
showLoadingViews();
setOriginalHash(diagram.hashCode());
final Metadata metadata = diagram.getMetadata();
sessionManager.getSessionFactory(metadata, ClientFullSession.class).newSession(metadata, s -> {
final AbstractClientFullSession session = (AbstractClientFullSession) s;
presenter = sessionPresenterFactory.newPresenterEditor();
getView().setWidget(presenter.getView());
presenter.withToolbar(false).withPalette(true).displayNotifications(type -> true).open(diagram, session, new SessionPresenter.SessionPresenterCallback<AbstractClientFullSession, Diagram>() {
@Override
public void afterSessionOpened() {
}
@Override
public void afterCanvasInitialized() {
}
@Override
public void onSuccess() {
bindCommands();
updateTitle(diagram.getMetadata().getTitle());
hideLoadingViews();
setOriginalHash(getCurrentDiagramHash());
}
@Override
public void onError(final ClientRuntimeError error) {
onLoadError(error);
}
});
});
}
use of org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError in project kie-wb-common by kiegroup.
the class AbstractProjectDiagramNewResourceHandler method create.
@Override
public void create(final Package pkg, final String name, final NewResourcePresenter presenter) {
indicatorView.showBusyIndicator("Loading...");
final Path path = pkg.getPackageMainResourcesPath();
final Class<?> type = getDefinitionSetType();
final String setId = getId(type);
final String moduleName = context.getActiveModule().isPresent() ? context.getActiveModule().get().getModuleName() : "";
projectDiagramServices.create(path, name, setId, moduleName, pkg, new ServiceCallback<Path>() {
@Override
public void onSuccess(final Path path) {
indicatorView.hideBusyIndicator();
presenter.complete();
notifySuccess();
newResourceSuccessEvent.fire(new NewResourceSuccessEvent(path));
PlaceRequest place = new PathPlaceRequest(path, getEditorIdentifier());
placeManager.goTo(place);
}
@Override
public void onError(final ClientRuntimeError error) {
showError(error);
}
});
}
use of org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError in project kie-wb-common by kiegroup.
the class ProjectDiagramEditorTest method testLoadContentError.
@Test
public void testLoadContentError() {
ArgumentCaptor<ServiceCallback> callbackArgumentCaptor = forClass(ServiceCallback.class);
tested.loadContent();
verify(projectDiagramServices, times(1)).getByPath(eq(path), callbackArgumentCaptor.capture());
callbackArgumentCaptor.getValue().onError(new ClientRuntimeError(new DefinitionNotFoundException()));
verify(placeManager, times(1)).forceClosePlace(any(PathPlaceRequest.class));
ArgumentCaptor<Consumer> consumerArgumentCaptor = forClass(Consumer.class);
verify(diagramClientErrorHandler, times(1)).handleError(any(ClientRuntimeError.class), consumerArgumentCaptor.capture());
consumerArgumentCaptor.getValue().accept("error message");
verify(errorPopupPresenter, times(1)).showMessage("error message");
}
use of org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError in project kie-wb-common by kiegroup.
the class AbstractPaletteDefinitionBuilder method build.
private void build(final Metadata metadata, final Consumer<DefaultPaletteDefinition> paletteDefinitionConsumer) {
final String definitionSetId = metadata.getDefinitionSetId();
final Object definitionSet = getDefinitionManager().definitionSets().getDefinitionSetById(definitionSetId);
final Set<String> definitions = getDefinitionManager().adapters().forDefinitionSet().getDefinitions(definitionSet);
if (null != definitions) {
final Map<String, DefaultPaletteItem> items = new LinkedHashMap<>();
final Set<String> consumed = new HashSet<>(definitions);
// Once all item definitions consumed, build the resulting palette definition
// and let the consumer do its job.
final Command checkConsumedAndComplete = () -> {
if (consumed.isEmpty()) {
paletteDefinitionConsumer.accept(new DefaultPaletteDefinition(getSortedItems(items.values(), getDefaultComparator()), definitionSetId));
}
};
for (final String defId : definitions) {
consumed.remove(defId);
// Check if this concrete definition is excluded from the palette model.
if (itemFilter.test(defId)) {
clientFactoryServices.newDefinition(defId, new ServiceCallback<Object>() {
@Override
public void onSuccess(final Object definition) {
buildItem(definition, metadata, items);
checkConsumedAndComplete.execute();
}
@Override
public void onError(final ClientRuntimeError error) {
LOGGER.severe("Error while building the palette definition. " + "[Message=" + error.getMessage() + "]");
}
});
} else {
checkConsumedAndComplete.execute();
}
}
}
}
use of org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError in project kie-wb-common by kiegroup.
the class CreateConnectorAction method accept.
@SuppressWarnings("unchecked")
private void accept(final int x, final int y, final Edge<? extends ViewConnector<?>, Node> connector, final Node<? extends View<?>, Edge> sourceNode, final Node targetNode) {
if (null != targetNode) {
EdgeBuildRequestImpl buildRequest = new EdgeBuildRequestImpl(x, y, connector, sourceNode, targetNode);
edgeBuilderControl.build(buildRequest, new BuilderControl.BuildCallback() {
@Override
public void onSuccess(final String uuid) {
complete();
}
@Override
public void onError(final ClientRuntimeError error) {
error(error);
}
});
}
}
Aggregations