[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.modeling.gmf] Re: Automatic father creation
|
Hello Alex,
sorry for the late reply. First of all thank you for helping. I tried to
follow your advice and I dive a bit in the newsgroup. What I did so far is:
public class ParallelTypeCreateCommand extends CreateElementCommand {
.
.
@Override
protected EObject doDefaultElementCreation() {
ParallelType obj = (ParallelType) super.doDefaultElementCreation();
WorkflowType wt = ModelFactory.eINSTANCE.createWorkflowType();
obj.getWorkflow().add(wt);
return obj;
}
then I defined a new policy:
public class ParallelTypeEditPart extends ShapeNodeEditPart {
class MyCreationEditPolicy extends CreationEditPolicy {
/* (non-Javadoc)
* @see
org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy#getCreateCommand(org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest)
*/
@Override
protected Command getCreateCommand(CreateViewRequest request) {
IElementType wt = RequestElementTypes.WorkflowType_2011;
//IElementType wt2 = RequestElementTypes.WorkflowType_2008;
ICommand createElementViewCommand = ((ICommandProxy) super
.getCreateCommand(request)).getICommand();
TransactionalEditingDomain editingDomain = ((IGraphicalEditPart)
getHost())
.getEditingDomain();
CompositeTransactionalCommand cc = new CompositeTransactionalCommand(
editingDomain, DiagramUIMessages.AddCommand_Label);
cc.compose(createElementViewCommand);
PreferencesHint preferencesHint = getDiagramPreferencesHint();
CreateViewAndElementRequest req = new CreateViewAndElementRequest(
wt, preferencesHint);
Iterator descriptors = req.getViewDescriptors().iterator();
while (descriptors.hasNext()) {
CreateViewRequest.ViewDescriptor descriptor =
(CreateViewRequest.ViewDescriptor) descriptors
.next();
CreateCommand createCommand = new CreateCommand(editingDomain,
descriptor, ((View) (getHost().getModel()))
.getDiagram());
cc.compose(createCommand);
}
return new ICommandProxy(cc.reduce());
}
}
and installed it:
protected void createDefaultEditPolicies() {
installEditPolicy(EditPolicyRoles.CREATION_ROLE,
new MyCreationEditPolicy());
Using the debugger I can notice that the funtion is called and the
doDefaultElementCreation() correctly update the Domain, but the
workflowType node is not added on the diagram. Any idea?
Cheers
Nicola
Alex Shatalin wrote:
Hello Nicola,
-Parallel
--Sequence
-Parallel
-Pipeline
You can make it working by creating mapping for this diagram structure +
then modifying generated CreateParallel/SequenceCommand to create Workflow
element in addition.
As a result you'll be able to create disared diagram structure, but will
not be able to initialize diagram using existing model - additional
modification
will be required in this place.
-----------------
Alex Shatalin