* @see org.eclipse.gef.editpolicies.LayoutEditPolicy#getCreateCommand(org.eclipse.gef.requests.CreateRequest)
*/
protected Command getCreateCommand(CreateRequest request) {
if (getHost().getModel() instanceof IWebflowState
&& request.getNewObject() instanceof IState) {
CreateStateCommand command = new CreateStateCommand();
command.setParent((IWebflowState) getHost().getModel());
command.setChild((IState) request.getNewObject());
return command;
}
else if (getHost().getModel() instanceof IInlineFlowState
&& request.getNewObject() instanceof IState) {
CreateStateCommand command = new CreateStateCommand();
command.setParent(((IInlineFlowState) getHost().getModel())
.getWebFlowState());
command.setChild((IState) request.getNewObject());
return command;
}
else if (getHost().getModel() instanceof IState
&& request.getNewObject() instanceof IActionElement) {
IActionElement ae = (IActionElement) request.getNewObject();
IState state = (IState) getHost().getModel();
if ((ae.getType() == IActionElement.ACTION_TYPE.ACTION && state instanceof IActionState)
|| (ae.getType() == IActionElement.ACTION_TYPE.RENDER_ACTION && state instanceof IViewState)
|| (ae.getType() == IActionElement.ACTION_TYPE.ENTRY_ACTION && state instanceof IState)
|| (ae.getType() == IActionElement.ACTION_TYPE.EXIT_ACTION && state instanceof ITransitionableFrom)) {
CreateActionCommand command = new CreateActionCommand();
command.setParent((IState) getHost().getModel());
command.setChild((IActionElement) request.getNewObject());
return command;
}
else {
return null;
}
}
else if (getHost().getModel() instanceof IState
&& !(getHost().getModel() instanceof IWebflowState)
&& !(getHost().getModel() instanceof IInlineFlowState)
&& request.getNewObject() instanceof IExceptionHandler) {
CreateExceptionHandlerCommand command = new CreateExceptionHandlerCommand();
command.setParent((IState) getHost().getModel());
command.setChild((IExceptionHandler) request.getNewObject());
return command;
}
else if (getHost().getModel() instanceof ISubflowState
&& request.getNewObject() instanceof IAttributeMapper) {
if (((ISubflowState) getHost().getModel()).getAttributeMapper() == null) {
CreateAttributeMapperCommand command = new CreateAttributeMapperCommand();
command.setParent((ISubflowState) getHost().getModel());
return command;
}
else {
return null;
}
}
else if (getHost().getModel() instanceof IDecisionState
&& request.getNewObject() instanceof IIf) {
CreateIfCommand command = new CreateIfCommand();
command.setParent((IDecisionState) getHost().getModel());
command.setChild((IIf) request.getNewObject());
return command;
}
else {
return null;
}