use of org.eclipse.sapphire.Value in project liferay-ide by liferay.
the class CustomJspValidationService method compute.
@Override
public Status compute() {
Value<?> value = (Value<?>) context(Element.class).property(context(Property.class).definition());
ValueProperty property = value.definition();
String label = property.getLabel(true, CapitalizationType.NO_CAPS, false);
if (_isValueEmpty(value)) {
String msg = NLS.bind(Msgs.nonEmptyValueRequired, label);
return Status.createErrorStatus(msg);
} else if (!_isValidPortalJsp(value) && !_isValidProjectJsp(value)) {
String msg = NLS.bind(Msgs.customJspInvalidPath, label);
return Status.createErrorStatus(msg);
}
return Status.createOkStatus();
}
use of org.eclipse.sapphire.Value in project liferay-ide by liferay.
the class CustomJspDirListener method handleTypedEvent.
@Override
protected void handleTypedEvent(PropertyContentEvent event) {
Property prop = event.property();
Hook hook = prop.element().nearest(Hook.class);
if (hook != null) {
if (CustomJspDir.PROP_VALUE.equals(prop.definition())) {
// IDE-1132, Listen the change of Property CustomJspDir, and refresh the
// Property CustomJsps.
hook.property(Hook.PROP_CUSTOM_JSPS).refresh();
} else if (Hook.PROP_CUSTOM_JSP_DIR.equals(prop.definition())) {
// IDE-1251 listen for changes to custom_jsp_dir and if it is empty initialize
// initial content @InitialValue
CustomJspDir customJspDir = hook.getCustomJspDir().content(false);
if (customJspDir != null) {
Value<Path> value = customJspDir.getValue();
if (value != null) {
Path path = value.content(false);
if (path == null) {
customJspDir.initialize();
}
}
}
}
}
}
use of org.eclipse.sapphire.Value in project liferay-ide by liferay.
the class RoleNamePossibleValuesMetaService method initIfNecessary.
protected void initIfNecessary(Object object) {
if (object instanceof WorkflowDefinition) {
for (WorkflowNode node : ((WorkflowDefinition) object).getDiagramNodes()) {
Assignable assignable = node.nearest(Assignable.class);
if (assignable != null) {
for (Role role : assignable.getRoles()) {
Value<String> roleName = role.getName();
String name = roleName.content(false);
if (!CoreUtil.isNullOrEmpty(name)) {
_originalRoleNames.add(name);
}
}
}
}
} else if (object instanceof AssignableOp) {
ElementList<RoleName> roleNames = ((AssignableOp) object).getRoleNames();
for (RoleName roleName : roleNames) {
Value<String> nameValue = roleName.getName();
String name = nameValue.content(false);
if (!CoreUtil.isNullOrEmpty(name)) {
_originalRoleNames.add(name);
}
}
}
}
use of org.eclipse.sapphire.Value 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.Value in project liferay-ide by liferay.
the class CreateDirectoryActionHandler method computeEnablementState.
@Override
protected boolean computeEnablementState() {
boolean enabled = super.computeEnablementState();
if (enabled) {
@SuppressWarnings("unchecked") Value<Path> value = (Value<Path>) getModelElement().property(property().definition());
Path path = value.content();
RelativePathService service = property().service(RelativePathService.class);
Path absolutePath = service.convertToAbsolute(path);
enabled = (absolutePath != null) && (!absolutePath.toFile().exists());
}
return enabled;
}
Aggregations