blob: 733ffbb10e6e111fea65147dcfd78e49cd43aab8 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2011 Red Hat, Inc.
* All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*
* @author Bob Brodt
******************************************************************************/
/*******************************************************************************
* Copyright (c) 2011 Red Hat, Inc.
* All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.features;
import org.eclipse.bpmn2.modeler.core.features.activity.task.AddTaskFeature;
import org.eclipse.bpmn2.modeler.core.utils.GraphicsUtil;
import org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.model.Task;
import org.eclipse.bpmn2.modeler.ui.ImageProvider;
import org.eclipse.bpmn2.modeler.ui.features.activity.task.CustomTaskFeatureContainer;
import org.eclipse.graphiti.features.IAddFeature;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.IAddContext;
import org.eclipse.graphiti.features.context.IContext;
import org.eclipse.graphiti.mm.algorithms.Image;
import org.eclipse.graphiti.mm.algorithms.RoundedRectangle;
import org.eclipse.graphiti.services.Graphiti;
import org.eclipse.graphiti.services.IGaService;
public class EmailTaskFeatureContainer extends CustomTaskFeatureContainer {
@Override
public Object getApplyObject(IContext context) {
if (context instanceof IAddContext) {
Object obj = ((IAddContext)context).getNewObject();
if (obj instanceof Task) {
Task task = (Task)obj;
String taskName = task.getTaskName();
String myName = (String)customTaskDescriptor.getProperty("taskName");
if (taskName!=null && myName!=null && taskName.equals(myName))
return obj;
}
}
return super.getApplyObject(context);
}
@Override
public IAddFeature getAddFeature(IFeatureProvider fp) {
return new AddTaskFeature(fp) {
@Override
protected void decorateActivityRectangle(RoundedRectangle rect) {
IGaService service = Graphiti.getGaService();
Image img = service.createImage(rect, ImageProvider.IMG_16_SEND_TASK);
service.setLocationAndSize(img, 2, 2, GraphicsUtil.TASK_IMAGE_SIZE, GraphicsUtil.TASK_IMAGE_SIZE);
}
};
}
}