|
|
|
Re: Automatic father creation [message #195764 is a reply to message #195070] |
Fri, 04 July 2008 09:09 |
Nicola Salvo Messages: 42 Registered: July 2009 |
Member |
|
|
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.CreationEdit Policy#getCreateCommand(org.eclipse.gmf.runtime.diagram.ui.r equests.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
|
|
|
|
Re: Automatic father creation [message #195989 is a reply to message #195936] |
Mon, 07 July 2008 16:09 |
Nicola Salvo Messages: 42 Registered: July 2009 |
Member |
|
|
Hello Alex,
I tried to close reopen the diagram, but the child element is not there.
I used a little bit the debugger, but I got no clue, so I tried a
different way:
public class ParallelTypeEditHelper extends RequestBaseEditHelper {
@Override
protected ICommand getConfigureCommand(final ConfigureRequest req) {
return new ConfigureElementCommand(req) {
protected CommandResult doExecuteWithResult(
IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
EObject element = req.getElementToConfigure();
doConfiguration(element, monitor);
return CommandResult.newOKCommandResult(element);
}
};
}
/**
*
* @param element
* @param monitor
*/
protected void doConfiguration(EObject element, IProgressMonitor
monitor) {
ParallelType pt = (ParallelType) element;
EReference parallelContainer = ModelPackage.eINSTANCE
..getParallelType_Workflow();
WorkflowType wtObj = ModelFactory.eINSTANCE.createWorkflowType();
EClass workflowClass = wtObj.eClass();
EObject condition = EMFCoreUtil.create(pt, parallelContainer,
workflowClass);
}
and now it's working. Is there any difference with the other way? I'd
like to learn better GMF, so it can be cool to understand why the other
way it's not working.
Moreover, the original title of the post was related with father, thus
inner element, creation. I have an input element and I'd like to be able
to create all the inner elements: I will try to follow to modify the
helper class, but probably it will be not enough because when I select
the tool and I move the mouse on the diagram, I got a "white cross"
probably because the command it not executable. Any suggestion?
Thank you very much for your help
Nicola
On Mon, 2008-07-07 at 09:57 +0000, Alex Shatalin wrote:
> Hello Nicola,
>
> > doDefaultElementCreation() correctly update the Domain, but the
> > workflowType node is not added on the diagram. Any idea? Cheers
> Can you see this node on diagram after reopenning (or pressing F5 on its
> container)?
>
> -----------------
> Alex Shatalin
>
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03584 seconds