Search in sources :

Example 1 with Resource

use of org.eclipse.sapphire.Resource in project liferay-ide by liferay.

the class CustomJspsBindingImpl method resource.

@Override
@SuppressWarnings("unchecked")
protected Resource resource(Object obj) {
    Element element = property().element();
    Resource resource = element.resource();
    return new CustomJspResource(resource, (ObjectValue<String>) obj);
}
Also used : Element(org.eclipse.sapphire.Element) IResource(org.eclipse.core.resources.IResource) Resource(org.eclipse.sapphire.Resource)

Example 2 with Resource

use of org.eclipse.sapphire.Resource in project liferay-ide by liferay.

the class WorkflowMetadataBindingImpl method readUnderlyingObject.

@Override
protected Object readUnderlyingObject() {
    WorkflowNodeMetadataObject metadataObject = null;
    Element element = property().element();
    Resource resource = element.resource();
    XmlResource xmlResource = resource.adapt(XmlResource.class);
    XmlElement xmlElement = xmlResource.getXmlElement();
    XmlElement metadataElement = xmlElement.getChildElement("metadata", false);
    if (metadataElement != null) {
        String metadata = metadataElement.getChildNodeText("");
        if (!CoreUtil.empty(metadata)) {
            metadataObject = new WorkflowNodeMetadataObject(metadata.trim());
        }
    }
    if (metadataObject == null) {
        metadataObject = new WorkflowNodeMetadataObject();
    }
    if (!metadataObject.equals(_underlyingObject)) {
        _underlyingObject = metadataObject;
    }
    return _underlyingObject;
}
Also used : XmlResource(org.eclipse.sapphire.modeling.xml.XmlResource) Element(org.eclipse.sapphire.Element) XmlElement(org.eclipse.sapphire.modeling.xml.XmlElement) XmlResource(org.eclipse.sapphire.modeling.xml.XmlResource) Resource(org.eclipse.sapphire.Resource) XmlElement(org.eclipse.sapphire.modeling.xml.XmlElement)

Example 3 with Resource

use of org.eclipse.sapphire.Resource in project liferay-ide by liferay.

the class WorkflowMetadataBindingImpl method createResource.

@Override
protected Resource createResource(Object obj) {
    Element element = property().element();
    Resource resource = element.resource();
    XmlResource xmlResource = resource.adapt(XmlResource.class);
    return new WorkflowNodeMetadataResource((WorkflowNodeMetadataObject) obj, xmlResource);
}
Also used : XmlResource(org.eclipse.sapphire.modeling.xml.XmlResource) Element(org.eclipse.sapphire.Element) XmlElement(org.eclipse.sapphire.modeling.xml.XmlElement) XmlResource(org.eclipse.sapphire.modeling.xml.XmlResource) Resource(org.eclipse.sapphire.Resource)

Example 4 with Resource

use of org.eclipse.sapphire.Resource in project liferay-ide by liferay.

the class WorkflowNodeMetadataResource method createBinding.

@Override
protected PropertyBinding createBinding(Property property) {
    PropertyBinding binding = null;
    PropertyDef def = property.definition();
    if (WorkflowNodeMetadata.PROP_TERMINAL.equals(def)) {
        binding = new ValuePropertyBinding() {

            @Override
            public String read() {
                return Boolean.toString(WorkflowNodeMetadataResource.this._metadata.isTerminal());
            }

            @Override
            public void write(String value) {
                WorkflowNodeMetadataResource.this._metadata.setTerminal(Boolean.parseBoolean(value));
                saveMetadata();
            }
        };
    } else if (WorkflowNodeMetadata.PROP_POSITION.equals(def)) {
        binding = new ElementPropertyBinding() {

            @Override
            public Resource read() {
                return new PositionResource(WorkflowNodeMetadataResource.this._metadata.getNodeLocation(), WorkflowNodeMetadataResource.this);
            }

            @Override
            public ElementType type(Resource resource) {
                return Position.TYPE;
            }
        };
    } else if (WorkflowNodeMetadata.PROP_TRANSITIONS_METADATA.equals(def)) {
        binding = new LayeredListPropertyBinding() {

            @Override
            public void remove(Resource resource) {
                TransitionMetadataResource transitionMetaResource = (TransitionMetadataResource) resource;
                List<TransitionMetadataObject> transitionMetadataObject = WorkflowNodeMetadataResource.this._metadata.getTransitionsMetadata();
                transitionMetadataObject.remove(transitionMetaResource.getMetadata());
                saveMetadata();
            }

            @Override
            public ElementType type(Resource resource) {
                return TransitionMetadata.TYPE;
            }

            @Override
            protected Object insertUnderlyingObject(ElementType type, int position) {
                TransitionMetadataObject newTransitionMeta = new TransitionMetadataObject();
                List<TransitionMetadataObject> transitionMetadataObject = WorkflowNodeMetadataResource.this._metadata.getTransitionsMetadata();
                transitionMetadataObject.add(position, newTransitionMeta);
                saveMetadata();
                return newTransitionMeta;
            }

            @Override
            protected List<?> readUnderlyingList() {
                return WorkflowNodeMetadataResource.this._metadata.getTransitionsMetadata();
            }

            @Override
            protected Resource resource(Object obj) {
                return new TransitionMetadataResource((TransitionMetadataObject) obj, WorkflowNodeMetadataResource.this);
            }
        };
    }
    if (binding != null) {
        binding.init(property);
    }
    return binding;
}
Also used : ElementType(org.eclipse.sapphire.ElementType) PropertyDef(org.eclipse.sapphire.PropertyDef) XmlResource(org.eclipse.sapphire.modeling.xml.XmlResource) Resource(org.eclipse.sapphire.Resource) ElementPropertyBinding(org.eclipse.sapphire.modeling.ElementPropertyBinding) LayeredListPropertyBinding(org.eclipse.sapphire.LayeredListPropertyBinding) ValuePropertyBinding(org.eclipse.sapphire.ValuePropertyBinding) ElementPropertyBinding(org.eclipse.sapphire.modeling.ElementPropertyBinding) PropertyBinding(org.eclipse.sapphire.PropertyBinding) LayeredListPropertyBinding(org.eclipse.sapphire.LayeredListPropertyBinding) ValuePropertyBinding(org.eclipse.sapphire.ValuePropertyBinding) List(java.util.List)

Example 5 with Resource

use of org.eclipse.sapphire.Resource in project liferay-ide by liferay.

the class TransitionMetadataResource method createBinding.

@Override
protected PropertyBinding createBinding(Property property) {
    PropertyBinding binding = null;
    PropertyDef def = property.definition();
    if (TransitionMetadata.PROP_NAME.equals(def)) {
        binding = new ValuePropertyBinding() {

            @Override
            public String read() {
                return TransitionMetadataResource.this._metadata.getName();
            }

            @Override
            public void write(String value) {
                TransitionMetadataResource.this._metadata.setName(value);
                WorkflowNodeMetadataResource wfNodeMetadataResource = parent().adapt(WorkflowNodeMetadataResource.class);
                wfNodeMetadataResource.saveMetadata();
            }
        };
    } else if (TransitionMetadata.PROP_LABEL_LOCATION.equals(def)) {
        binding = new LayeredElementBindingImpl() {

            @Override
            public ElementType type(Resource resource) {
                return Position.TYPE;
            }

            @Override
            protected Resource createResource(Object obj) {
                return new LabelPositionResource((Point) obj, TransitionMetadataResource.this);
            }

            @Override
            protected Object readUnderlyingObject() {
                return TransitionMetadataResource.this._metadata.getLabelPosition();
            }
        };
    } else if (TransitionMetadata.PROP_BENDPOINTS.equals(def)) {
        binding = new LayeredListPropertyBinding() {

            @Override
            public void remove(Resource resource) {
                if (resource instanceof PositionResource) {
                    List<Point> bendPoints = TransitionMetadataResource.this._metadata.getBendpoints();
                    bendPoints.remove(((PositionResource) resource).getPoint());
                    WorkflowNodeMetadataResource wfNodeMetadataResource = parent().adapt(WorkflowNodeMetadataResource.class);
                    wfNodeMetadataResource.saveMetadata();
                }
            }

            @Override
            public ElementType type(Resource resource) {
                return ConnectionBendpoint.TYPE;
            }

            @Override
            protected Object insertUnderlyingObject(ElementType type, int position) {
                Point newBendpoint = new Point();
                List<Point> bendPoints = TransitionMetadataResource.this._metadata.getBendpoints();
                bendPoints.add(position, newBendpoint);
                WorkflowNodeMetadataResource wfNodeMetadataResource = parent().adapt(WorkflowNodeMetadataResource.class);
                wfNodeMetadataResource.saveMetadata();
                return newBendpoint;
            }

            @Override
            protected List<?> readUnderlyingList() {
                return TransitionMetadataResource.this._metadata.getBendpoints();
            }

            @Override
            protected Resource resource(Object obj) {
                return new PositionResource((Point) obj, TransitionMetadataResource.this);
            }
        };
    }
    if (binding != null) {
        binding.init(property);
    }
    return binding;
}
Also used : ElementType(org.eclipse.sapphire.ElementType) PropertyDef(org.eclipse.sapphire.PropertyDef) Resource(org.eclipse.sapphire.Resource) ConnectionBendpoint(com.liferay.ide.kaleo.core.model.ConnectionBendpoint) LayeredListPropertyBinding(org.eclipse.sapphire.LayeredListPropertyBinding) PropertyBinding(org.eclipse.sapphire.PropertyBinding) ValuePropertyBinding(org.eclipse.sapphire.ValuePropertyBinding) LayeredListPropertyBinding(org.eclipse.sapphire.LayeredListPropertyBinding) LayeredElementBindingImpl(org.eclipse.sapphire.modeling.LayeredElementBindingImpl) ValuePropertyBinding(org.eclipse.sapphire.ValuePropertyBinding) List(java.util.List)

Aggregations

Resource (org.eclipse.sapphire.Resource)7 Element (org.eclipse.sapphire.Element)5 XmlResource (org.eclipse.sapphire.modeling.xml.XmlResource)3 List (java.util.List)2 Matcher (java.util.regex.Matcher)2 ElementType (org.eclipse.sapphire.ElementType)2 LayeredListPropertyBinding (org.eclipse.sapphire.LayeredListPropertyBinding)2 PropertyBinding (org.eclipse.sapphire.PropertyBinding)2 PropertyDef (org.eclipse.sapphire.PropertyDef)2 ValuePropertyBinding (org.eclipse.sapphire.ValuePropertyBinding)2 RootXmlResource (org.eclipse.sapphire.modeling.xml.RootXmlResource)2 XmlElement (org.eclipse.sapphire.modeling.xml.XmlElement)2 Document (org.w3c.dom.Document)2 ConnectionBendpoint (com.liferay.ide.kaleo.core.model.ConnectionBendpoint)1 IResource (org.eclipse.core.resources.IResource)1 ElementPropertyBinding (org.eclipse.sapphire.modeling.ElementPropertyBinding)1 LayeredElementBindingImpl (org.eclipse.sapphire.modeling.LayeredElementBindingImpl)1 Node (org.w3c.dom.Node)1