org.jbpm.designer.client.handlers.NewProcessHandler Maven / Gradle / Ivy
/*
* Copyright 2015 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jbpm.designer.client.handlers;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import com.google.gwt.user.client.ui.IsWidget;
import org.guvnor.common.services.project.model.Package;
import org.jboss.errai.common.client.api.Caller;
import org.jboss.errai.common.client.api.RemoteCallback;
import org.jbpm.designer.client.resources.i18n.DesignerEditorConstants;
import org.jbpm.designer.client.type.Bpmn2Type;
import org.jbpm.designer.service.DesignerAssetService;
import org.uberfire.ext.widgets.common.client.callbacks.DefaultErrorCallback;
import org.kie.workbench.common.widgets.client.handlers.DefaultNewResourceHandler;
import org.kie.workbench.common.widgets.client.handlers.NewResourcePresenter;
import org.uberfire.backend.vfs.Path;
import org.uberfire.client.mvp.PlaceManager;
import org.uberfire.mvp.PlaceRequest;
import org.uberfire.mvp.impl.PathPlaceRequest;
import org.uberfire.workbench.type.ResourceTypeDefinition;
@ApplicationScoped
public class NewProcessHandler extends DefaultNewResourceHandler {
@Inject
private Caller designerAssetService;
@Inject
private PlaceManager placeManager;
@Inject
private Bpmn2Type resourceType;
@Override
public String getDescription() {
return DesignerEditorConstants.INSTANCE.businessProcess();
}
@Override
public IsWidget getIcon() {
return null;
}
@Override
public ResourceTypeDefinition getResourceType() {
return resourceType;
}
@Override
public void create( final Package pkg,
final String baseFileName,
final NewResourcePresenter presenter ) {
designerAssetService.call( new RemoteCallback() {
@Override
public void callback( final Path path ) {
presenter.complete();
notifySuccess();
final PlaceRequest place = new PathPlaceRequest( path );
placeManager.goTo( place );
}
}, new DefaultErrorCallback() ).createProcess( pkg.getPackageMainResourcesPath(), buildFileName( baseFileName,
resourceType ) );
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy