Search in sources :

Example 1 with ClientRuntimeError

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);
            }
        });
    });
}
Also used : CopySelectionSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.CopySelectionSessionCommand) ClearStatesSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.ClearStatesSessionCommand) ValidationUtils(org.kie.workbench.common.stunner.core.validation.impl.ValidationUtils) StunnerProjectClientConstants(org.kie.workbench.common.stunner.project.client.resources.i18n.StunnerProjectClientConstants) ChangeTitleWidgetEvent(org.uberfire.client.workbench.events.ChangeTitleWidgetEvent) ClientResourceType(org.uberfire.client.workbench.type.ClientResourceType) PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) AbstractClientFullSession(org.kie.workbench.common.stunner.core.client.session.impl.AbstractClientFullSession) KieEditorView(org.kie.workbench.common.widgets.metadata.client.KieEditorView) SessionPresenter(org.kie.workbench.common.stunner.client.widgets.presenters.session.SessionPresenter) ClientTranslationService(org.kie.workbench.common.stunner.core.client.i18n.ClientTranslationService) SessionCommandFactory(org.kie.workbench.common.stunner.core.client.session.command.impl.SessionCommandFactory) DiagramElementViolation(org.kie.workbench.common.stunner.core.validation.DiagramElementViolation) ProjectDiagram(org.kie.workbench.common.stunner.project.diagram.ProjectDiagram) ProjectMessagesListener(org.kie.workbench.common.stunner.project.client.screens.ProjectMessagesListener) Map(java.util.Map) Observes(javax.enterprise.event.Observes) PlaceGainFocusEvent(org.uberfire.client.workbench.events.PlaceGainFocusEvent) IsWidget(com.google.gwt.user.client.ui.IsWidget) UberView(org.uberfire.client.mvp.UberView) ClientFullSession(org.kie.workbench.common.stunner.core.client.session.ClientFullSession) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) ExportToPdfSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.ExportToPdfSessionCommand) OnSessionErrorEvent(org.kie.workbench.common.stunner.core.client.session.event.OnSessionErrorEvent) Collection(java.util.Collection) Violation(org.kie.workbench.common.stunner.core.validation.Violation) ClientProjectDiagramService(org.kie.workbench.common.stunner.project.client.service.ClientProjectDiagramService) YesNoCancelPopup(org.uberfire.ext.widgets.common.client.common.popups.YesNoCancelPopup) Menus(org.uberfire.workbench.model.menu.Menus) ClearSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.ClearSessionCommand) ClientSession(org.kie.workbench.common.stunner.core.client.session.ClientSession) Logger(java.util.logging.Logger) DeleteSelectionSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.DeleteSelectionSessionCommand) PlaceRequest(org.uberfire.mvp.PlaceRequest) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Objects(java.util.Objects) LogConfiguration(com.google.gwt.logging.client.LogConfiguration) PasteSelectionSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.PasteSelectionSessionCommand) RedoSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.RedoSessionCommand) CutSelectionSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.CutSelectionSessionCommand) KieEditor(org.kie.workbench.common.widgets.metadata.client.KieEditor) ObservablePath(org.uberfire.backend.vfs.ObservablePath) UndoSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.UndoSessionCommand) ExportToPngSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.ExportToPngSessionCommand) PostConstruct(javax.annotation.PostConstruct) ExportToBpmnSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.ExportToBpmnSessionCommand) ValidateSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.ValidateSessionCommand) CanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler) ErrorPopupPresenter(org.uberfire.client.workbench.widgets.common.ErrorPopupPresenter) HashMap(java.util.HashMap) SavePopUpPresenter(org.uberfire.ext.editor.commons.client.file.popups.SavePopUpPresenter) PlaceManager(org.uberfire.client.mvp.PlaceManager) VisitGraphSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.VisitGraphSessionCommand) Shape(org.kie.workbench.common.stunner.core.client.shape.Shape) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) Inject(javax.inject.Inject) AbstractPlaceEvent(org.uberfire.client.workbench.events.AbstractPlaceEvent) MenuItem(org.uberfire.workbench.model.menu.MenuItem) ClientSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) DiagramClientErrorHandler(org.kie.workbench.common.stunner.core.client.error.DiagramClientErrorHandler) CommonConstants(org.kie.workbench.common.widgets.client.resources.i18n.CommonConstants) SessionPresenterFactory(org.kie.workbench.common.stunner.client.widgets.presenters.session.SessionPresenterFactory) AbstractClientReadOnlySession(org.kie.workbench.common.stunner.core.client.session.impl.AbstractClientReadOnlySession) SessionManager(org.kie.workbench.common.stunner.core.client.api.SessionManager) ServiceCallback(org.kie.workbench.common.stunner.core.client.service.ServiceCallback) Command(org.uberfire.mvp.Command) FINE(java.util.logging.Level.FINE) Event(javax.enterprise.event.Event) PlaceHiddenEvent(org.uberfire.client.workbench.events.PlaceHiddenEvent) OnDiagramFocusEvent(org.kie.workbench.common.stunner.project.client.editor.event.OnDiagramFocusEvent) ExportToJpgSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.ExportToJpgSessionCommand) HashUtil(org.kie.workbench.common.stunner.core.util.HashUtil) OnDiagramLoseFocusEvent(org.kie.workbench.common.stunner.project.client.editor.event.OnDiagramLoseFocusEvent) FileMenuBuilder(org.kie.workbench.common.widgets.client.menu.FileMenuBuilder) SwitchGridSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.impl.SwitchGridSessionCommand) AbstractClientFullSession(org.kie.workbench.common.stunner.core.client.session.impl.AbstractClientFullSession) ClientFullSession(org.kie.workbench.common.stunner.core.client.session.ClientFullSession) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) AbstractClientFullSession(org.kie.workbench.common.stunner.core.client.session.impl.AbstractClientFullSession) SessionPresenter(org.kie.workbench.common.stunner.client.widgets.presenters.session.SessionPresenter) ProjectDiagram(org.kie.workbench.common.stunner.project.diagram.ProjectDiagram) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram)

Example 2 with ClientRuntimeError

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);
        }
    });
}
Also used : Path(org.uberfire.backend.vfs.Path) PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) PlaceRequest(org.uberfire.mvp.PlaceRequest) PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) NewResourceSuccessEvent(org.kie.workbench.common.widgets.client.handlers.NewResourceSuccessEvent)

Example 3 with ClientRuntimeError

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");
}
Also used : ServiceCallback(org.kie.workbench.common.stunner.core.client.service.ServiceCallback) Consumer(java.util.function.Consumer) DefinitionNotFoundException(org.kie.workbench.common.stunner.core.definition.exception.DefinitionNotFoundException) PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) Test(org.junit.Test)

Example 4 with ClientRuntimeError

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();
            }
        }
    }
}
Also used : Command(org.uberfire.mvp.Command) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) LinkedHashMap(java.util.LinkedHashMap) HashSet(java.util.HashSet)

Example 5 with ClientRuntimeError

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);
            }
        });
    }
}
Also used : EdgeBuildRequestImpl(org.kie.workbench.common.stunner.core.client.canvas.controls.builder.request.EdgeBuildRequestImpl) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) EdgeBuilderControl(org.kie.workbench.common.stunner.core.client.canvas.controls.builder.EdgeBuilderControl) BuilderControl(org.kie.workbench.common.stunner.core.client.canvas.controls.builder.BuilderControl)

Aggregations

ClientRuntimeError (org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError)19 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)4 Test (org.junit.Test)3 CanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler)3 OnSessionErrorEvent (org.kie.workbench.common.stunner.core.client.session.event.OnSessionErrorEvent)3 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)3 PathPlaceRequest (org.uberfire.mvp.impl.PathPlaceRequest)3 Collection (java.util.Collection)2 Level (java.util.logging.Level)2 Logger (java.util.logging.Logger)2 Event (javax.enterprise.event.Event)2 Inject (javax.inject.Inject)2 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)2 CanvasSelectionEvent (org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasSelectionEvent)2 ServiceCallback (org.kie.workbench.common.stunner.core.client.service.ServiceCallback)2 CommandResult (org.kie.workbench.common.stunner.core.command.CommandResult)2 LookupManager (org.kie.workbench.common.stunner.core.lookup.LookupManager)2 DiagramLookupRequest (org.kie.workbench.common.stunner.core.lookup.diagram.DiagramLookupRequest)2 DiagramRepresentation (org.kie.workbench.common.stunner.core.lookup.diagram.DiagramRepresentation)2 Path (org.uberfire.backend.vfs.Path)2