Search in sources :

Example 21 with IEntityPart

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;
}
Also used : IEntity(org.whole.lang.model.IEntity) Grammar(org.whole.lang.grammars.model.Grammar) IEntityPart(org.whole.lang.ui.editparts.IEntityPart)

Example 22 with IEntityPart

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;
}
Also used : IEntity(org.whole.lang.model.IEntity) Rectangle(org.eclipse.draw2d.geometry.Rectangle) IEntityPart(org.whole.lang.ui.editparts.IEntityPart)

Example 23 with IEntityPart

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;
}
Also used : DnDOverCompositeRequest(org.whole.lang.ui.requests.DnDOverCompositeRequest) IEntity(org.whole.lang.model.IEntity) IEntityPart(org.whole.lang.ui.editparts.IEntityPart)

Example 24 with IEntityPart

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();
}
Also used : GroupRequest(org.eclipse.gef.requests.GroupRequest) EditPart(org.eclipse.gef.EditPart) IEntityPart(org.whole.lang.ui.editparts.IEntityPart) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 25 with IEntityPart

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());
}
Also used : IEntity(org.whole.lang.model.IEntity) IEntityPart(org.whole.lang.ui.editparts.IEntityPart)

Aggregations

IEntityPart (org.whole.lang.ui.editparts.IEntityPart)49 IEntity (org.whole.lang.model.IEntity)21 IEntityPartViewer (org.whole.lang.ui.viewers.IEntityPartViewer)12 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)7 ArrayList (java.util.ArrayList)6 EditPart (org.eclipse.gef.EditPart)6 Point (org.eclipse.draw2d.geometry.Point)5 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)4 FocusEvent (org.eclipse.swt.events.FocusEvent)4 FocusListener (org.eclipse.swt.events.FocusListener)4 IBindingManager (org.whole.lang.bindings.IBindingManager)4 ActionRegistry (org.whole.lang.e4.ui.actions.ActionRegistry)4 E4KeyHandler (org.whole.lang.e4.ui.actions.E4KeyHandler)4 E4NavigationKeyHandler (org.whole.lang.e4.ui.actions.E4NavigationKeyHandler)4 IPartFocusListener (org.whole.lang.ui.editparts.IPartFocusListener)4 ITextualEntityPart (org.whole.lang.ui.editparts.ITextualEntityPart)4 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)3 ESelectionService (org.eclipse.e4.ui.workbench.modeling.ESelectionService)3