Search in sources :

Example 6 with ValuePropertyBinding

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

the class LabelPositionResource method createBinding.

@Override
protected PropertyBinding createBinding(Property property) {
    PropertyBinding binding = null;
    PropertyDef def = property.definition();
    if (Position.PROP_X.equals(def) || Position.PROP_Y.equals(def)) {
        binding = new ValuePropertyBinding() {

            @Override
            public String read() {
                String retval = null;
                if (LabelPositionResource.this._point != null) {
                    if (Position.PROP_X.equals(def)) {
                        retval = Integer.toString(LabelPositionResource.this._point.getX());
                    } else if (Position.PROP_Y.equals(def)) {
                        retval = Integer.toString(LabelPositionResource.this._point.getY());
                    }
                }
                return retval;
            }

            @Override
            public void write(String value) {
                if (LabelPositionResource.this._point == null) {
                    LabelPositionResource.this._point = new Point();
                }
                if (Position.PROP_X.equals(def)) {
                    LabelPositionResource.this._point.setX(Integer.parseInt(value));
                } else if (Position.PROP_Y.equals(def)) {
                    LabelPositionResource.this._point.setY(Integer.parseInt(value));
                }
                /*
					 * if (Position.PROP_X.equals( def ) ||
					 * Position.PROP_Y.equals( def )) {
					 * WorkflowNodeMetadataObject parentMetadata =
					 * parent().adapt( WorkflowNodeMetadataResource.class
					 * ).getMetadata(); parentMetadata.setNodeLocation(
					 * LabelPositionResource.this.point ); }
					 */
                WorkflowNodeMetadataResource metadataResource = parent().adapt(WorkflowNodeMetadataResource.class);
                metadataResource.saveMetadata();
            }
        };
    }
    if (binding != null) {
        binding.init(property);
    }
    return binding;
}
Also used : PropertyBinding(org.eclipse.sapphire.PropertyBinding) ValuePropertyBinding(org.eclipse.sapphire.ValuePropertyBinding) PropertyDef(org.eclipse.sapphire.PropertyDef) ValuePropertyBinding(org.eclipse.sapphire.ValuePropertyBinding)

Aggregations

ValuePropertyBinding (org.eclipse.sapphire.ValuePropertyBinding)6 PropertyBinding (org.eclipse.sapphire.PropertyBinding)5 PropertyDef (org.eclipse.sapphire.PropertyDef)4 List (java.util.List)2 ElementType (org.eclipse.sapphire.ElementType)2 LayeredListPropertyBinding (org.eclipse.sapphire.LayeredListPropertyBinding)2 Resource (org.eclipse.sapphire.Resource)2 ConnectionBendpoint (com.liferay.ide.kaleo.core.model.ConnectionBendpoint)1 ElementPropertyBinding (org.eclipse.sapphire.modeling.ElementPropertyBinding)1 LayeredElementBindingImpl (org.eclipse.sapphire.modeling.LayeredElementBindingImpl)1 XmlResource (org.eclipse.sapphire.modeling.xml.XmlResource)1