001: /*******************************************************************************
002: * Copyright (c) 2003, 2004 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Common Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/cpl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.openwfe.gpe.parts;
011:
012: import org.eclipse.draw2d.IFigure;
013: import org.eclipse.gef.EditPart;
014: import org.eclipse.gef.EditPartFactory;
015:
016: import org.openwfe.gpe.FlowImages;
017: import org.openwfe.gpe.figures.AndFigure;
018: import org.openwfe.gpe.figures.CaseFigure;
019: import org.openwfe.gpe.figures.ConcurrenceFigure;
020: import org.openwfe.gpe.figures.ConcurrentIteratorFigure;
021: import org.openwfe.gpe.figures.DefinedFigure;
022: import org.openwfe.gpe.figures.IfFigure;
023: import org.openwfe.gpe.figures.IteratorFigure;
024: import org.openwfe.gpe.figures.NotFigure;
025: import org.openwfe.gpe.figures.OrFigure;
026: import org.openwfe.gpe.figures.SequenceFigure;
027: import org.openwfe.gpe.figures.WhenFigure;
028: import org.openwfe.gpe.figures.WorkflowFigure;
029: import org.openwfe.gpe.model.ActivityDiagram;
030: import org.openwfe.gpe.model.AndComposite;
031: import org.openwfe.gpe.model.CaseComposite;
032: import org.openwfe.gpe.model.CompositeOrOneChild;
033: import org.openwfe.gpe.model.ConcurrenceComposite;
034: import org.openwfe.gpe.model.ConcurrentIteratorElement;
035: import org.openwfe.gpe.model.DefinedComposite;
036: import org.openwfe.gpe.model.DefinedElement;
037: import org.openwfe.gpe.model.EqualsElement;
038: import org.openwfe.gpe.model.FlowElement;
039: import org.openwfe.gpe.model.GreaterElement;
040: import org.openwfe.gpe.model.IfComposite;
041: import org.openwfe.gpe.model.IncElement;
042: import org.openwfe.gpe.model.IteratorElement;
043: import org.openwfe.gpe.model.LesserElement;
044: import org.openwfe.gpe.model.LogElement;
045: import org.openwfe.gpe.model.NotElement;
046: import org.openwfe.gpe.model.OrComposite;
047: import org.openwfe.gpe.model.ParticipantElement;
048: import org.openwfe.gpe.model.RestoreElement;
049: import org.openwfe.gpe.model.SaveElement;
050: import org.openwfe.gpe.model.SequenceComposite;
051: import org.openwfe.gpe.model.SetElement;
052: import org.openwfe.gpe.model.SubProcessElement;
053: import org.openwfe.gpe.model.UndefinedElement;
054: import org.openwfe.gpe.model.UnsetElement;
055: import org.openwfe.gpe.model.WhenComposite;
056: import org.openwfe.gpe.model.WorkflowElement;
057:
058: /**
059: *This class creates an EditPart corresponding to the given model
060: */
061: public class FlowElementPartFactory implements EditPartFactory {
062:
063: public EditPart createEditPart(EditPart context, Object model) {
064: EditPart part = null;
065: if (model instanceof ActivityDiagram)
066: part = new FlowElementDiagramPart(null);
067: else if (model instanceof WorkflowElement)
068: part = (EditPart) new OtherPart(new WorkflowFigure());
069: else if (model instanceof ConcurrenceComposite)
070: part = (EditPart) new ConcurrencePart(
071: new ConcurrenceFigure());
072: else if (model instanceof SequenceComposite)
073: part = (EditPart) new OtherPart(new SequenceFigure());
074: else if (model instanceof NotElement)
075: part = (EditPart) new OtherPart(new NotFigure());
076: else if (model instanceof OrComposite)
077: part = (EditPart) new OtherPart(new OrFigure());
078: else if (model instanceof AndComposite)
079: part = (EditPart) new OtherPart(new AndFigure());
080: else if (model instanceof DefinedComposite)
081: part = (EditPart) new OtherPart(new DefinedFigure());
082: else if (model instanceof CaseComposite)
083: part = (EditPart) new OtherPart(new CaseFigure());
084: else if (model instanceof WhenComposite)
085: part = (EditPart) new OtherPart(new WhenFigure());
086: else if (model instanceof IfComposite)
087: part = (EditPart) new OtherPart(new IfFigure());
088: else if (model instanceof SetElement)
089: part = new NoChildPart(FlowImages.set);
090: else if (model instanceof UnsetElement)
091: part = new NoChildPart(FlowImages.unset);
092: else if (model instanceof ParticipantElement)
093: part = new NoChildPart(FlowImages.participant);
094: else if (model instanceof IncElement)
095: part = new NoChildPart(FlowImages.inc);
096: else if (model instanceof SaveElement)
097: part = new NoChildPart(FlowImages.save);
098: else if (model instanceof RestoreElement)
099: part = new NoChildPart(FlowImages.restore);
100: else if (model instanceof EqualsElement)
101: part = new NoChildPart(FlowImages.equals);
102: else if (model instanceof GreaterElement)
103: part = new NoChildPart(FlowImages.greater);
104: else if (model instanceof LesserElement)
105: part = new NoChildPart(FlowImages.lesser);
106: else if (model instanceof DefinedElement)
107: part = new NoChildPart(FlowImages.defined);
108: else if (model instanceof UndefinedElement)
109: part = new NoChildPart(FlowImages.undefined);
110: else if (model instanceof SubProcessElement)
111: part = new NoChildPart(FlowImages.subprocess);
112: else if (model instanceof IteratorElement)
113: part = (EditPart) new OtherPart(new IteratorFigure());
114: else if (model instanceof ConcurrentIteratorElement)
115: part = (EditPart) new OtherPart(
116: new ConcurrentIteratorFigure());
117: else if (model instanceof LogElement)
118: part = new NoChildPart(FlowImages.log);
119: part.setModel(model);
120: return part;
121: }
122:
123: }
|