use of org.eclipse.sapphire.ui.forms.swt.SwtPresentation in project liferay-ide by liferay.
the class ServiceTypeImplBrowseActionHandler method browse.
@Override
public String browse(Presentation context) {
Element element = getModelElement();
Property property = property();
IProject project = element.adapt(IProject.class);
try {
IJavaSearchScope scope = null;
TypeSelectionExtension extension = null;
if ("type".equals(_kind)) {
scope = SearchEngine.createJavaSearchScope(new IJavaProject[] { JavaCore.create(project) });
extension = new TypeSelectionExtension() {
@Override
public ITypeInfoFilterExtension getFilterExtension() {
return new ITypeInfoFilterExtension() {
public boolean select(ITypeInfoRequestor typeInfoRequestor) {
if (typeInfoRequestor.getPackageName().startsWith("com.liferay") && typeInfoRequestor.getTypeName().endsWith("Service")) {
return true;
}
return false;
}
};
}
};
} else if ("impl".equals(_kind)) {
String serviceType = _getServiceType(element);
if (serviceType != null) {
String wrapperType = serviceType + "Wrapper";
scope = SearchEngine.createHierarchyScope(JavaCore.create(project).findType(wrapperType));
} else {
Shell shell = ((SwtPresentation) context).shell();
MessageDialog.openInformation(shell, Msgs.serviceImplBrowse, Msgs.validServiceTypeProperty);
return null;
}
}
Shell shell = ((SwtPresentation) context).shell();
SelectionDialog dlg = JavaUI.createTypeDialog(shell, null, scope, _browseDialogStyle, false, StringPool.DOUBLE_ASTERISK, extension);
String title = property.definition().getLabel(true, CapitalizationType.TITLE_STYLE, false);
dlg.setTitle(Msgs.select + title);
if (dlg.open() == SelectionDialog.OK) {
Object[] results = dlg.getResult();
assert (results != null) && (results.length == 1);
if (results[0] instanceof IType) {
return ((IType) results[0]).getFullyQualifiedName();
}
}
} catch (JavaModelException jme) {
HookUI.logError(jme);
}
return null;
}
use of org.eclipse.sapphire.ui.forms.swt.SwtPresentation 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.ui.forms.swt.SwtPresentation in project liferay-ide by liferay.
the class SelectActiveProfilesActionHandler method run.
@Override
protected Object run(Presentation context) {
if (context instanceof SwtPresentation) {
final SwtPresentation swt = (SwtPresentation) context;
final NewLiferayPluginProjectOp op = getModelElement().nearest(NewLiferayPluginProjectOp.class);
final String previousActiveProfilesValue = op.getActiveProfilesValue().content();
// we need to rebuild the 'selected' list from what is specified in the
// 'activeProfiles' property
op.getSelectedProfiles().clear();
final String activeProfiles = op.getActiveProfilesValue().content();
if (!CoreUtil.isNullOrEmpty(activeProfiles)) {
final String[] profileIds = activeProfiles.split(",");
if (ListUtil.isNotEmpty(profileIds)) {
for (String profileId : profileIds) {
if (!CoreUtil.isNullOrEmpty(profileId)) {
boolean foundExistingProfile = false;
for (Profile profile : op.getSelectedProfiles()) {
if (profileId.equals(profile.getId().content())) {
foundExistingProfile = true;
break;
}
}
if (!foundExistingProfile) {
Profile newlySelectedProfile = op.getSelectedProfiles().insert();
newlySelectedProfile.setId(profileId);
}
}
}
}
}
final CustomSapphireDialog dialog = new CustomSapphireDialog(swt.shell(), op, DefinitionLoader.sdef(NewLiferayPluginProjectWizard.class).dialog("SelectActiveProfiles"));
dialog.setBlockOnOpen(true);
final int result = dialog.open();
if (result == SapphireDialog.CANCEL) {
// restore previous value
op.setActiveProfilesValue(previousActiveProfilesValue);
} else {
final ElementList<Profile> selectedProfiles = op.getSelectedProfiles();
NewLiferayPluginProjectOpMethods.updateActiveProfilesValue(op, selectedProfiles);
}
}
return null;
}
use of org.eclipse.sapphire.ui.forms.swt.SwtPresentation in project liferay-ide by liferay.
the class NewLiferayProfileActionHandler method run.
@Override
protected Object run(Presentation context) {
if (context instanceof SwtPresentation) {
final SwtPresentation swt = (SwtPresentation) context;
final NewLiferayPluginProjectOp op = _op(context);
final NewLiferayProfile newLiferayProfile = op.getNewLiferayProfiles().insert();
final SapphireDialog dialog = new SapphireDialog(swt.shell(), newLiferayProfile, DefinitionLoader.sdef(NewLiferayPluginProjectWizard.class).dialog("NewLiferayProfile"));
dialog.setBlockOnOpen(true);
final int result = dialog.open();
if (result == SapphireDialog.OK) {
addToActiveProfiles(op, newLiferayProfile);
} else {
op.getNewLiferayProfiles().remove(newLiferayProfile);
}
}
return null;
}
use of org.eclipse.sapphire.ui.forms.swt.SwtPresentation in project liferay-ide by liferay.
the class OpenPluginTypeDescriptionDialogAction method run.
@Override
protected Object run(Presentation context) {
if (context instanceof SwtPresentation) {
final SwtPresentation swt = (SwtPresentation) context;
final NewLiferayPluginProjectOp op = getModelElement().nearest(NewLiferayPluginProjectOp.class);
final PluginTypeDescriptionDialog dialog = new PluginTypeDescriptionDialog(swt.shell(), op, DefinitionLoader.sdef(NewLiferayPluginProjectWizard.class).dialog("PluginTypeDescription"));
dialog.setBlockOnOpen(false);
dialog.open();
}
return null;
}
Aggregations