Search in sources :

Example 1 with ElementPropertyBinding

use of org.eclipse.sapphire.modeling.ElementPropertyBinding 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)

Aggregations

List (java.util.List)1 ElementType (org.eclipse.sapphire.ElementType)1 LayeredListPropertyBinding (org.eclipse.sapphire.LayeredListPropertyBinding)1 PropertyBinding (org.eclipse.sapphire.PropertyBinding)1 PropertyDef (org.eclipse.sapphire.PropertyDef)1 Resource (org.eclipse.sapphire.Resource)1 ValuePropertyBinding (org.eclipse.sapphire.ValuePropertyBinding)1 ElementPropertyBinding (org.eclipse.sapphire.modeling.ElementPropertyBinding)1 XmlResource (org.eclipse.sapphire.modeling.xml.XmlResource)1