use of org.eclipse.sapphire.Property in project liferay-ide by liferay.
the class HierarchyBrowseActionHandler 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;
String javaType = _getClassReferenceType(property);
if (javaType != null) {
scope = SearchEngine.createHierarchyScope(JavaCore.create(project).findType(javaType));
} else {
MessageDialog.openInformation(((SwtPresentation) context).shell(), Msgs.browseImplementation, Msgs.validClassImplProperty);
return null;
}
SelectionDialog dlg = JavaUI.createTypeDialog(((SwtPresentation) context).shell(), null, scope, IJavaElementSearchConstants.CONSIDER_CLASSES, 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) {
PortletUIPlugin.logError(jme);
}
return null;
}
use of org.eclipse.sapphire.Property in project liferay-ide by liferay.
the class TransitionTargetListener method handleTypedEvent.
@Override
protected void handleTypedEvent(PropertyContentEvent event) {
Property property = event.property();
Transition transition = property.nearest(Transition.class);
if (transition != null) {
ReferenceValue<String, Node> targe = transition.getTarget();
Value<String> transitionName = transition.getName();
if ((targe.content() != null) && (transitionName.content(false) == null)) {
String targetName = targe.content();
String defaultName = targetName;
Set<String> existingNames = new HashSet<>();
CanTransition camtransition = transition.nearest(CanTransition.class);
for (Transition t : camtransition.getTransitions()) {
Value<String> tName = t.getName();
if (tName.content() != null) {
existingNames.add(tName.content());
}
}
int count = 1;
while (existingNames.contains(defaultName)) {
defaultName = targetName + "_" + count++;
}
transition.setName(defaultName);
}
}
}
use of org.eclipse.sapphire.Property in project liferay-ide by liferay.
the class LeastVersionRuntimeValidationService method compute.
@Override
protected Status compute() {
Property property = context(Element.class).property(context(Property.class).definition());
Value<?> value = (Value<?>) property;
String runtimeName = value.content().toString();
IRuntime runtime = ServerUtil.getRuntime(runtimeName);
if (runtime == null) {
return Status.createErrorStatus("Liferay runtime must be configured.");
}
ILiferayRuntime liferayRuntime = ServerUtil.getLiferayRuntime(runtime);
Version runtimeVersion = new Version(liferayRuntime.getPortalVersion());
if (CoreUtil.compareVersions(runtimeVersion, ILiferayConstants.V620) < 0) {
return Status.createErrorStatus("Liferay runtime must be greater than 6.2.0.");
} else {
return StatusBridge.create(runtime.validate(new NullProgressMonitor()));
}
}
use of org.eclipse.sapphire.Property in project liferay-ide by liferay.
the class LiferayVersionDefaultValueService method initDefaultValueService.
@Override
protected void initDefaultValueService() {
super.initDefaultValueService();
PropertyDef def = context().find(PropertyDef.class);
Property property = context(Element.class).property(def);
PossibleValuesService possibleValuesService = property.service(PossibleValuesService.class);
possibleValuesService.attach(new Listener() {
@Override
public void handle(Event event) {
_possibleValues = possibleValuesService.values();
refresh();
}
});
NewLiferayProfile profile = context(NewLiferayProfile.class);
profile.property(NewLiferayProfile.PROP_RUNTIME_NAME).attach(new FilteredListener<PropertyContentEvent>() {
@Override
protected void handleTypedEvent(PropertyContentEvent event) {
_possibleValues = possibleValuesService.values();
_runtimeVersion = null;
refresh();
}
});
_possibleValues = possibleValuesService.values();
}
use of org.eclipse.sapphire.Property in project liferay-ide by liferay.
the class HierarchyJavaTypeBrowseActionHandler method browse.
@Override
public String browse(Presentation context) {
Element element = getModelElement();
Property property = property();
IProject project = element.adapt(IProject.class);
try {
JavaTypeConstraintService typeService = property.service(JavaTypeConstraintService.class);
EnumSet<JavaTypeKind> kinds = EnumSet.noneOf(JavaTypeKind.class);
kinds.addAll(typeService.kinds());
int browseDialogStyle = IJavaElementSearchConstants.CONSIDER_ALL_TYPES;
int count = kinds.size();
if (count == 1) {
JavaTypeKind kind = kinds.iterator().next();
switch(kind) {
case CLASS:
browseDialogStyle = IJavaElementSearchConstants.CONSIDER_CLASSES;
break;
case ABSTRACT_CLASS:
browseDialogStyle = IJavaElementSearchConstants.CONSIDER_CLASSES;
break;
case INTERFACE:
browseDialogStyle = IJavaElementSearchConstants.CONSIDER_INTERFACES;
break;
case ANNOTATION:
browseDialogStyle = IJavaElementSearchConstants.CONSIDER_ANNOTATION_TYPES;
break;
case ENUM:
browseDialogStyle = IJavaElementSearchConstants.CONSIDER_ENUMS;
break;
default:
throw new IllegalStateException();
}
} else if (count == 2) {
if (kinds.contains(JavaTypeKind.CLASS) || kinds.contains(JavaTypeKind.ABSTRACT_CLASS)) {
if (kinds.contains(JavaTypeKind.INTERFACE)) {
browseDialogStyle = IJavaElementSearchConstants.CONSIDER_CLASSES_AND_INTERFACES;
} else if (kinds.contains(JavaTypeKind.ENUM)) {
browseDialogStyle = IJavaElementSearchConstants.CONSIDER_CLASSES_AND_ENUMS;
}
}
}
IJavaSearchScope scope = null;
IType type = JavaCore.create(project).findType(_typeName);
if (type != null) {
scope = SearchEngine.createHierarchyScope(type);
}
SwtPresentation swt = (SwtPresentation) context;
SelectionDialog dlg = JavaUI.createTypeDialog(swt.shell(), null, scope, browseDialogStyle, false, _filter, null);
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;
}
Aggregations