use of org.eclipse.sapphire.ui.forms.swt.SapphireWizard in project liferay-ide by liferay.
the class ChangeTaskAssignmentsActionHandler method run.
@Override
protected Object run(Presentation context) {
Task task = _task(context);
ChangeTaskAssignmentsOp op = ChangeTaskAssignmentsOp.TYPE.instantiate();
for (WorkflowNode node : task.nearest(WorkflowDefinition.class).getDiagramNodes()) {
Assignable assignable = node.nearest(Assignable.class);
if (assignable != null) {
for (Role role : assignable.getRoles()) {
String name = role.getName().content(false);
if (!isNullOrEmpty(name)) {
ElementList<RoleName> roleName = op.getRoleNames();
roleName.insert().setName(name);
}
}
}
}
User existingUser = task.getUser().content(false);
ElementList<Role> existingRoles = task.getRoles();
ElementList<ResourceAction> existingActions = task.getResourceActions();
Scriptable scriptedAssignment = task.getScriptedAssignment().content(false);
if (existingUser != null) {
op.getImpliedUser().copy(existingUser);
} else if (ListUtil.isNotEmpty(existingRoles)) {
op.getImpliedRole().copy(existingRoles.get(0));
for (Role role : existingRoles) {
Role newRole = op.getRoles().insert();
newRole.copy(role);
Boolean autoCreate = role.getAutoCreate().content(false);
if (autoCreate != null) {
newRole.setAutoCreate(role.getAutoCreate().content());
}
}
} else if (ListUtil.isNotEmpty(existingActions)) {
for (ResourceAction action : existingActions) {
ElementList<ResourceAction> resourceActions = op.getResourceActions();
ResourceAction resourceAction = resourceActions.insert();
resourceAction.copy(action);
}
} else if (scriptedAssignment != null) {
ElementHandle<Scriptable> scriptable = op.getScriptedAssignment();
Scriptable content = scriptable.content(true);
content.copy(scriptedAssignment);
}
DefinitionLoader loader = DefinitionLoader.context(NewWorkflowDefinitionWizard.class);
DefinitionLoader loaderSdef = loader.sdef("WorkflowDefinitionWizards");
SapphireWizard<ChangeTaskAssignmentsOp> wizard = new SapphireWizard<>(op, loaderSdef.wizard("changeTaskAssignmentsWizard"));
int returnCode = new WizardDialog(((SwtPresentation) context).shell(), wizard).open();
if (returnCode == IDialogConstants.OK_ID) {
KaleoModelUtil.changeTaskAssignments(_task(context), op);
}
return null;
}
Aggregations