Search in sources :

Example 1 with Value

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();
}
Also used : Value(org.eclipse.sapphire.Value) ValueProperty(org.eclipse.sapphire.ValueProperty) Property(org.eclipse.sapphire.Property) ValueProperty(org.eclipse.sapphire.ValueProperty)

Example 2 with Value

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();
                    }
                }
            }
        }
    }
}
Also used : Path(org.eclipse.sapphire.modeling.Path) Hook(com.liferay.ide.hook.core.model.Hook) Value(org.eclipse.sapphire.Value) CustomJspDir(com.liferay.ide.hook.core.model.CustomJspDir) Property(org.eclipse.sapphire.Property)

Example 3 with Value

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);
            }
        }
    }
}
Also used : Role(com.liferay.ide.kaleo.core.model.Role) AssignableOp(com.liferay.ide.kaleo.core.op.AssignableOp) RoleName(com.liferay.ide.kaleo.core.model.RoleName) Value(org.eclipse.sapphire.Value) WorkflowDefinition(com.liferay.ide.kaleo.core.model.WorkflowDefinition) ElementList(org.eclipse.sapphire.ElementList) WorkflowNode(com.liferay.ide.kaleo.core.model.WorkflowNode) Assignable(com.liferay.ide.kaleo.core.model.Assignable)

Example 4 with Value

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()));
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) Version(org.osgi.framework.Version) Element(org.eclipse.sapphire.Element) ILiferayRuntime(com.liferay.ide.server.core.ILiferayRuntime) Value(org.eclipse.sapphire.Value) Property(org.eclipse.sapphire.Property) IRuntime(org.eclipse.wst.server.core.IRuntime)

Example 5 with Value

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;
}
Also used : Path(org.eclipse.sapphire.modeling.Path) RelativePathService(org.eclipse.sapphire.services.RelativePathService) Value(org.eclipse.sapphire.Value)

Aggregations

Value (org.eclipse.sapphire.Value)8 WorkflowDefinition (com.liferay.ide.kaleo.core.model.WorkflowDefinition)3 Property (org.eclipse.sapphire.Property)3 Element (org.eclipse.sapphire.Element)2 Version (org.eclipse.sapphire.Version)2 Path (org.eclipse.sapphire.modeling.Path)2 ILiferayPortal (com.liferay.ide.core.ILiferayPortal)1 ILiferayProject (com.liferay.ide.core.ILiferayProject)1 CustomJspDir (com.liferay.ide.hook.core.model.CustomJspDir)1 Hook (com.liferay.ide.hook.core.model.Hook)1 Assignable (com.liferay.ide.kaleo.core.model.Assignable)1 Node (com.liferay.ide.kaleo.core.model.Node)1 Role (com.liferay.ide.kaleo.core.model.Role)1 RoleName (com.liferay.ide.kaleo.core.model.RoleName)1 WorkflowNode (com.liferay.ide.kaleo.core.model.WorkflowNode)1 AssignableOp (com.liferay.ide.kaleo.core.op.AssignableOp)1 NewNodeOp (com.liferay.ide.kaleo.core.op.NewNodeOp)1 NewWorkflowDefinitionOp (com.liferay.ide.kaleo.core.op.NewWorkflowDefinitionOp)1 LayoutTplElement (com.liferay.ide.layouttpl.core.model.LayoutTplElement)1 PortletColumnElement (com.liferay.ide.layouttpl.core.model.PortletColumnElement)1