use of org.whole.lang.ui.editparts.IEntityPart in project whole by wholeplatform.
the class GrammarBasedPartFactory method createEntityPart.
protected IEntityPart createEntityPart(IEntity entity) {
Grammar grammar = GrammarsRegistry.instance().getGrammarsFor(entity).iterator().next();
Map<String, IEntity> configurations = getConfigurations(grammar.getUri().getValue());
IEntity configuration = configurations.get(entity.wGetEntityDescriptor().getName());
if (configuration == null)
return null;
IEntityPart entityPart = null;
switch(entity.wGetEntityKind()) {
case COMPOSITE:
if (!configuration.wGetEntityDescriptor().getName().equals("CompositePart"))
throw new IllegalArgumentException();
entityPart = new CompositeEntityPart(configuration);
break;
case SIMPLE:
if (!configuration.wGetEntityDescriptor().getName().equals("SimplePart"))
throw new IllegalArgumentException();
entityPart = new SimpleEntityPart(configuration);
break;
case DATA:
if (!configuration.wGetEntityDescriptor().getName().equals("DataPart") && !configuration.wGetEntityDescriptor().getName().equals("EnumPart"))
throw new IllegalArgumentException();
entityPart = DataTypeUtils.getDataKind(entity).isEnumValue() ? new EnumEntityPart(configuration) : new DataEntityPart(configuration);
break;
}
return entityPart;
}
use of org.whole.lang.ui.editparts.IEntityPart in project whole by wholeplatform.
the class WholeFreeformLayoutEditPolicy method getCreateCommand.
protected Command getCreateCommand(CreateRequest request) {
Object newObject = request.getNewObject();
if (newObject instanceof IEntity) {
IEntity newEntity = (IEntity) newObject;
IEntityPart hostPart = (IEntityPart) getHost();
// FIXME workaround
IEntity compositeEntity = hostPart.getModelEntity().wGet(0);
if (!compositeEntity.wGetEntityDescriptor(0).isPlatformSupertypeOf(newEntity.wGetEntityDescriptor()))
return null;
Rectangle constraint = (Rectangle) getConstraintFor(request);
return getConstrainedCompositeAddCommand(newEntity, constraint);
}
return null;
}
use of org.whole.lang.ui.editparts.IEntityPart in project whole by wholeplatform.
the class WholeFlowLayoutEditPolicy method getCreateCommand.
protected Command getCreateCommand(CreateRequest request) {
Object newObject = request.getNewObject();
if (newObject instanceof IEntity) {
IEntityPart compositePart = (IEntityPart) getHost();
IEntityPart afterPart = (IEntityPart) getInsertionReference(request);
return commandFactory.create(new DnDOverCompositeRequest(PartRequest.MOVE_ADD_CHILD, compositePart, (IEntity) newObject, afterPart));
// CompositeAddCommand cmd = new CompositeAddCommand();
// cmd.setComposite(compositePart.getModelEntity());
// cmd.setNewChild((IEntity) newObject);
// cmd.setPrevChild(afterPart == null ? null : afterPart.getModelEntity());
// return cmd;
}
return UnexecutableCommand.INSTANCE;
}
use of org.whole.lang.ui.editparts.IEntityPart in project whole by wholeplatform.
the class WholeContainerEditPolicy method getOrphanChildrenCommand.
protected Command getOrphanChildrenCommand(GroupRequest req) {
GroupRequest request = (GroupRequest) req;
List<?> editParts = request.getEditParts();
CompoundCommand command = new CompoundCommand();
for (int i = 0; i < editParts.size(); i++) {
EditPart child = (EditPart) editParts.get(i);
command.add(createOrphanCommand((IEntityPart) child));
}
return command.unwrap();
}
use of org.whole.lang.ui.editparts.IEntityPart in project whole by wholeplatform.
the class XsiSimpleElementPart method removeChildVisual.
@Override
protected void removeChildVisual(EditPart childEditPart) {
super.removeChildVisual(childEditPart);
IEntity child = ((IEntityPart) childEditPart).getModelEntity();
if (EntityUtils.isComposite(child))
child.wRemoveChangeEventHandler(getRefreshChangeEventHandler());
}
Aggregations