use of org.eclipse.sapphire.ElementHandle 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;
}
use of org.eclipse.sapphire.ElementHandle in project liferay-ide by liferay.
the class EmailAddressValidationService method _getSchemaVersion.
private Version _getSchemaVersion() {
Version schemaVersion = new Version(KaleoCore.DEFAULT_KALEO_VERSION);
if (context(WorkflowDefinition.class) != null) {
WorkflowDefinition workflowDefinition = context(WorkflowDefinition.class);
Value<Version> version = workflowDefinition.getSchemaVersion();
schemaVersion = version.content();
} else if (context(NewNodeOp.class) != null) {
NewNodeOp newNodeOp = context(NewNodeOp.class);
ElementHandle<WorkflowDefinition> workflowDef = newNodeOp.getWorkflowDefinition();
WorkflowDefinition workflowDefinition = workflowDef.content();
Value<Version> version = workflowDefinition.getSchemaVersion();
schemaVersion = version.content();
} else if (context(NewWorkflowDefinitionOp.class) != null) {
NewWorkflowDefinitionOp newWorkflowDenitionOp = context(NewWorkflowDefinitionOp.class);
ReferenceValue<String, IProject> opProject = newWorkflowDenitionOp.getProject();
IProject project = opProject.target();
ILiferayProject liferayProj = LiferayCore.create(project);
ILiferayPortal portal = liferayProj.adapt(ILiferayPortal.class);
if (portal != null) {
schemaVersion = new Version(portal.getVersion());
}
}
return schemaVersion;
}
Aggregations