use of org.eclipse.sapphire.PropertyBinding 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;
}
use of org.eclipse.sapphire.PropertyBinding in project liferay-ide by liferay.
the class PositionResource method createBinding.
@Override
protected PropertyBinding createBinding(Property property) {
PropertyBinding binding = null;
PropertyDef def = property.definition();
if (Position.PROP_X.equals(def) || ConnectionBendpoint.PROP_X.equals(def) || Position.PROP_Y.equals(def) || ConnectionBendpoint.PROP_Y.equals(def)) {
binding = new ValuePropertyBinding() {
@Override
public String read() {
String retval = null;
if (PositionResource.this._point != null) {
if (Position.PROP_X.equals(def) || ConnectionBendpoint.PROP_X.equals(def)) {
retval = Integer.toString(PositionResource.this._point.getX());
} else if (Position.PROP_Y.equals(def) || ConnectionBendpoint.PROP_Y.equals(def)) {
retval = Integer.toString(PositionResource.this._point.getY());
}
}
return retval;
}
@Override
public void write(String value) {
if (PositionResource.this._point == null) {
PositionResource.this._point = new Point();
}
if (Position.PROP_X.equals(def) || ConnectionBendpoint.PROP_X.equals(def)) {
PositionResource.this._point.setX(Integer.parseInt(value));
} else if (Position.PROP_Y.equals(def) || ConnectionBendpoint.PROP_Y.equals(def)) {
PositionResource.this._point.setY(Integer.parseInt(value));
}
if (Position.PROP_X.equals(def) || Position.PROP_Y.equals(def)) {
WorkflowNodeMetadataResource metadataResource = parent().adapt(WorkflowNodeMetadataResource.class);
WorkflowNodeMetadataObject parentMetadata = metadataResource.getMetadata();
parentMetadata.setNodeLocation(PositionResource.this._point);
}
WorkflowNodeMetadataResource metadataResource = parent().adapt(WorkflowNodeMetadataResource.class);
metadataResource.saveMetadata();
}
};
}
if (binding != null) {
binding.init(property);
}
return binding;
}
use of org.eclipse.sapphire.PropertyBinding 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;
}
use of org.eclipse.sapphire.PropertyBinding in project liferay-ide by liferay.
the class RelationshipResource method createBinding.
@Override
protected PropertyBinding createBinding(Property property) {
PropertyBinding binding = null;
if (Relationship.PROP_FROM_ENTITY.equals(property.definition())) {
binding = new ValuePropertyBinding() {
@Override
public String read() {
return RelationshipResource.this._relationshipObject.getFromName();
}
@Override
public void write(String value) {
RelationshipResource.this._relationshipObject.setFromName(value);
_persistRelationship();
}
};
} else if (Relationship.PROP_TO_ENTITY.equals(property.definition())) {
binding = new ValuePropertyBinding() {
@Override
public String read() {
return RelationshipResource.this._relationshipObject.getToName();
}
@Override
public void write(String value) {
RelationshipResource.this._relationshipObject.setToName(value);
_persistRelationship();
}
};
}
if (binding != null) {
binding.init(property);
}
return binding;
}
use of org.eclipse.sapphire.PropertyBinding 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;
}
Aggregations