Search in sources :

Example 1 with IElementType

use of org.eclipse.gmf.runtime.emf.type.core.IElementType in project tdi-studio-se by Talend.

the class BusinessViewProvider method getEdgeViewClass.

/**
     * @generated
     */
protected Class getEdgeViewClass(IAdaptable semanticAdapter, View containerView, String semanticHint) {
    IElementType elementType = getSemanticElementType(semanticAdapter);
    if (elementType != null && !BusinessElementTypes.isKnownElementType(elementType)) {
        return null;
    }
    EClass semanticType = getSemanticEClass(semanticAdapter);
    if (semanticType == null) {
        return null;
    }
    EObject semanticElement = getSemanticElement(semanticAdapter);
    int linkVID = BusinessVisualIDRegistry.getLinkWithClassVisualID(semanticElement, semanticType);
    switch(linkVID) {
        case BusinessItemRelationshipEditPart.VISUAL_ID:
            return BusinessItemRelationshipViewFactory.class;
        case DirectionalBusinessItemRelationshipEditPart.VISUAL_ID:
            return DirectionalBusinessItemRelationshipViewFactory.class;
        case BidirectionalBusinessItemRelationshipEditPart.VISUAL_ID:
            return BidirectionalBusinessItemRelationshipViewFactory.class;
    }
    return getUnrecognizedConnectorViewClass(semanticAdapter, containerView, semanticHint);
}
Also used : IElementType(org.eclipse.gmf.runtime.emf.type.core.IElementType) DirectionalBusinessItemRelationshipViewFactory(org.talend.designer.business.model.business.diagram.view.factories.DirectionalBusinessItemRelationshipViewFactory) BidirectionalBusinessItemRelationshipViewFactory(org.talend.designer.business.model.business.diagram.view.factories.BidirectionalBusinessItemRelationshipViewFactory) BusinessItemRelationshipViewFactory(org.talend.designer.business.model.business.diagram.view.factories.BusinessItemRelationshipViewFactory) DirectionalBusinessItemRelationshipViewFactory(org.talend.designer.business.model.business.diagram.view.factories.DirectionalBusinessItemRelationshipViewFactory) EClass(org.eclipse.emf.ecore.EClass) EObject(org.eclipse.emf.ecore.EObject) BidirectionalBusinessItemRelationshipViewFactory(org.talend.designer.business.model.business.diagram.view.factories.BidirectionalBusinessItemRelationshipViewFactory)

Example 2 with IElementType

use of org.eclipse.gmf.runtime.emf.type.core.IElementType in project tdi-studio-se by Talend.

the class BusinessBaseItemSemanticEditPolicy method getSemanticCommand.

/**
     * @generated
     */
protected Command getSemanticCommand(IEditCommandRequest request) {
    IEditCommandRequest completedRequest = completeRequest(request);
    Object editHelperContext = completedRequest.getEditHelperContext();
    if (editHelperContext instanceof View || (editHelperContext instanceof IEditHelperContext && ((IEditHelperContext) editHelperContext).getEObject() instanceof View)) {
        // no semantic commands are provided for pure design elements
        return null;
    }
    if (editHelperContext == null) {
        editHelperContext = ViewUtil.resolveSemanticElement((View) getHost().getModel());
    }
    IElementType elementType = ElementTypeRegistry.getInstance().getElementType(editHelperContext);
    if (elementType == ElementTypeRegistry.getInstance().getType("org.eclipse.gmf.runtime.emf.type.core.default")) {
        //$NON-NLS-1$ 
        elementType = null;
    }
    Command epCommand = getSemanticCommandSwitch(completedRequest);
    if (epCommand != null) {
        ICommand command = epCommand instanceof ICommandProxy ? ((ICommandProxy) epCommand).getICommand() : new CommandProxy(epCommand);
        completedRequest.setParameter(BusinessBaseEditHelper.EDIT_POLICY_COMMAND, command);
    }
    Command ehCommand = null;
    if (elementType != null) {
        ICommand command = elementType.getEditCommand(completedRequest);
        if (command != null) {
            if (!(command instanceof CompositeTransactionalCommand)) {
                TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
                command = new CompositeTransactionalCommand(editingDomain, null).compose(command);
            }
            ehCommand = new ICommandProxy(command);
        }
    }
    boolean shouldProceed = true;
    if (completedRequest instanceof DestroyRequest) {
        shouldProceed = shouldProceed((DestroyRequest) completedRequest);
    }
    if (shouldProceed) {
        if (completedRequest instanceof DestroyRequest) {
            TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
            Command deleteViewCommand = new ICommandProxy(new DeleteCommand(editingDomain, (View) getHost().getModel()));
            ehCommand = ehCommand == null ? deleteViewCommand : ehCommand.chain(deleteViewCommand);
        }
        return ehCommand;
    }
    return null;
}
Also used : IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) ICommandProxy(org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy) DestroyRequest(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyRequest) IEditCommandRequest(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest) View(org.eclipse.gmf.runtime.notation.View) IElementType(org.eclipse.gmf.runtime.emf.type.core.IElementType) DeleteCommand(org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand) ICommandProxy(org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy) CommandProxy(org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy) IEditHelperContext(org.eclipse.gmf.runtime.emf.type.core.IEditHelperContext) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) CompositeTransactionalCommand(org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand) ICommand(org.eclipse.gmf.runtime.common.core.command.ICommand) CompositeTransactionalCommand(org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand) UnexecutableCommand(org.eclipse.gef.commands.UnexecutableCommand) DeleteCommand(org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand) Command(org.eclipse.gef.commands.Command) ICommand(org.eclipse.gmf.runtime.common.core.command.ICommand) EObject(org.eclipse.emf.ecore.EObject)

Example 3 with IElementType

use of org.eclipse.gmf.runtime.emf.type.core.IElementType in project statecharts by Yakindu.

the class SheetLabelProvider method getImage.

public Image getImage(Object element) {
    element = unwrap(element);
    if (element instanceof IGraphicalEditPart) {
        EObject semanticElement = ((IGraphicalEditPart) element).resolveSemanticElement();
        if (semanticElement == null) {
            // Default images
            View view = ((IGraphicalEditPart) element).getNotationView();
            String viewType = view.getType();
            if (ViewType.NOTE.equals(viewType)) {
                return SharedImages.get(SharedImages.IMG_NOTE);
            } else if (ViewType.TEXT.equals(viewType)) {
                return SharedImages.get(SharedImages.IMG_TEXT);
            }
        } else {
            // custom images
            IElementType elementType = ElementTypeRegistry.getInstance().getElementType(semanticElement);
            Image image = DiagramActivator.getDefault().getImageRegistry().get(elementType.getIconURL().toString());
            if (image == null) {
                ImageDescriptor desc = ImageDescriptor.createFromURL(elementType.getIconURL());
                DiagramActivator.getDefault().getImageRegistry().put(elementType.getIconURL().toString(), desc.createImage());
                return DiagramActivator.getDefault().getImageRegistry().get(elementType.getIconURL().toString());
            }
            return image;
        }
    }
    return null;
}
Also used : IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) IElementType(org.eclipse.gmf.runtime.emf.type.core.IElementType) EObject(org.eclipse.emf.ecore.EObject) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) Image(org.eclipse.swt.graphics.Image) View(org.eclipse.gmf.runtime.notation.View)

Example 4 with IElementType

use of org.eclipse.gmf.runtime.emf.type.core.IElementType in project statecharts by Yakindu.

the class SheetLabelProvider method getText.

public String getText(Object element) {
    element = unwrap(element);
    if (element instanceof IGraphicalEditPart) {
        EObject semanticElement = ((IGraphicalEditPart) element).resolveSemanticElement();
        if (semanticElement == null) {
            View view = ((IGraphicalEditPart) element).getNotationView();
            return view.getType();
        } else {
            IElementType elementType = ElementTypeRegistry.getInstance().getElementType(semanticElement);
            StringBuilder builder = new StringBuilder();
            builder.append(elementType.getDisplayName());
            if (semanticElement instanceof NamedElement && ((NamedElement) semanticElement).getName() != null) {
                builder.append(' ');
                builder.append(((NamedElement) semanticElement).getName());
            }
            return builder.toString();
        }
    }
    return null;
}
Also used : IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) IElementType(org.eclipse.gmf.runtime.emf.type.core.IElementType) EObject(org.eclipse.emf.ecore.EObject) View(org.eclipse.gmf.runtime.notation.View) NamedElement(org.yakindu.base.base.NamedElement)

Example 5 with IElementType

use of org.eclipse.gmf.runtime.emf.type.core.IElementType in project tdi-studio-se by Talend.

the class BusinessViewProvider method getNodeViewClass.

/**
     * @generated
     */
protected Class getNodeViewClass(IAdaptable semanticAdapter, View containerView, String semanticHint) {
    if (containerView == null) {
        return null;
    }
    IElementType elementType = getSemanticElementType(semanticAdapter);
    if (elementType != null && !BusinessElementTypes.isKnownElementType(elementType)) {
        return null;
    }
    EClass semanticType = getSemanticEClass(semanticAdapter);
    EObject semanticElement = getSemanticElement(semanticAdapter);
    int nodeVID = BusinessVisualIDRegistry.getNodeVisualID(containerView, semanticElement, semanticType, semanticHint);
    switch(nodeVID) {
        case ActionBusinessItemEditPart.VISUAL_ID:
            return ActionBusinessItemViewFactory.class;
        case ActionBusinessItemNameEditPart.VISUAL_ID:
            return ActionBusinessItemNameViewFactory.class;
        case TerminalBusinessItemEditPart.VISUAL_ID:
            return TerminalBusinessItemViewFactory.class;
        case TerminalBusinessItemNameEditPart.VISUAL_ID:
            return TerminalBusinessItemNameViewFactory.class;
        case DocumentBusinessItemEditPart.VISUAL_ID:
            return DocumentBusinessItemViewFactory.class;
        case DocumentBusinessItemNameEditPart.VISUAL_ID:
            return DocumentBusinessItemNameViewFactory.class;
        case DatabaseBusinessItemEditPart.VISUAL_ID:
            return DatabaseBusinessItemViewFactory.class;
        case DatabaseBusinessItemNameEditPart.VISUAL_ID:
            return DatabaseBusinessItemNameViewFactory.class;
        case ListBusinessItemEditPart.VISUAL_ID:
            return ListBusinessItemViewFactory.class;
        case ListBusinessItemNameEditPart.VISUAL_ID:
            return ListBusinessItemNameViewFactory.class;
        case DataBusinessItemEditPart.VISUAL_ID:
            return DataBusinessItemViewFactory.class;
        case DataBusinessItemNameEditPart.VISUAL_ID:
            return DataBusinessItemNameViewFactory.class;
        case InputBusinessItemEditPart.VISUAL_ID:
            return InputBusinessItemViewFactory.class;
        case InputBusinessItemNameEditPart.VISUAL_ID:
            return InputBusinessItemNameViewFactory.class;
        case DecisionBusinessItemEditPart.VISUAL_ID:
            return DecisionBusinessItemViewFactory.class;
        case DecisionBusinessItemNameEditPart.VISUAL_ID:
            return DecisionBusinessItemNameViewFactory.class;
        case ActorBusinessItemEditPart.VISUAL_ID:
            return ActorBusinessItemViewFactory.class;
        case ActorBusinessItemNameEditPart.VISUAL_ID:
            return ActorBusinessItemNameViewFactory.class;
        case EllipseBusinessItemEditPart.VISUAL_ID:
            return EllipseBusinessItemViewFactory.class;
        case EllipseBusinessItemNameEditPart.VISUAL_ID:
            return EllipseBusinessItemNameViewFactory.class;
        case GearBusinessItemEditPart.VISUAL_ID:
            return GearBusinessItemViewFactory.class;
        case GearBusinessItemNameEditPart.VISUAL_ID:
            return GearBusinessItemNameViewFactory.class;
        case BusinessItemRelationshipNameEditPart.VISUAL_ID:
            return BusinessItemRelationshipNameViewFactory.class;
        case DirectionalBusinessItemRelationshipNameEditPart.VISUAL_ID:
            return DirectionalBusinessItemRelationshipNameViewFactory.class;
        case BidirectionalBusinessItemRelationshipNameEditPart.VISUAL_ID:
            return BidirectionalBusinessItemRelationshipNameViewFactory.class;
    }
    return null;
}
Also used : DecisionBusinessItemNameViewFactory(org.talend.designer.business.model.business.diagram.view.factories.DecisionBusinessItemNameViewFactory) BidirectionalBusinessItemRelationshipNameViewFactory(org.talend.designer.business.model.business.diagram.view.factories.BidirectionalBusinessItemRelationshipNameViewFactory) EllipseBusinessItemViewFactory(org.talend.designer.business.model.business.diagram.view.factories.EllipseBusinessItemViewFactory) ListBusinessItemViewFactory(org.talend.designer.business.model.business.diagram.view.factories.ListBusinessItemViewFactory) DirectionalBusinessItemRelationshipNameViewFactory(org.talend.designer.business.model.business.diagram.view.factories.DirectionalBusinessItemRelationshipNameViewFactory) BusinessItemRelationshipNameViewFactory(org.talend.designer.business.model.business.diagram.view.factories.BusinessItemRelationshipNameViewFactory) BidirectionalBusinessItemRelationshipNameViewFactory(org.talend.designer.business.model.business.diagram.view.factories.BidirectionalBusinessItemRelationshipNameViewFactory) DatabaseBusinessItemViewFactory(org.talend.designer.business.model.business.diagram.view.factories.DatabaseBusinessItemViewFactory) ActorBusinessItemNameViewFactory(org.talend.designer.business.model.business.diagram.view.factories.ActorBusinessItemNameViewFactory) EClass(org.eclipse.emf.ecore.EClass) DocumentBusinessItemNameViewFactory(org.talend.designer.business.model.business.diagram.view.factories.DocumentBusinessItemNameViewFactory) DataBusinessItemViewFactory(org.talend.designer.business.model.business.diagram.view.factories.DataBusinessItemViewFactory) GearBusinessItemNameViewFactory(org.talend.designer.business.model.business.diagram.view.factories.GearBusinessItemNameViewFactory) EObject(org.eclipse.emf.ecore.EObject) DecisionBusinessItemViewFactory(org.talend.designer.business.model.business.diagram.view.factories.DecisionBusinessItemViewFactory) ActorBusinessItemViewFactory(org.talend.designer.business.model.business.diagram.view.factories.ActorBusinessItemViewFactory) TerminalBusinessItemViewFactory(org.talend.designer.business.model.business.diagram.view.factories.TerminalBusinessItemViewFactory) DatabaseBusinessItemNameViewFactory(org.talend.designer.business.model.business.diagram.view.factories.DatabaseBusinessItemNameViewFactory) ListBusinessItemNameViewFactory(org.talend.designer.business.model.business.diagram.view.factories.ListBusinessItemNameViewFactory) ActionBusinessItemNameViewFactory(org.talend.designer.business.model.business.diagram.view.factories.ActionBusinessItemNameViewFactory) InputBusinessItemViewFactory(org.talend.designer.business.model.business.diagram.view.factories.InputBusinessItemViewFactory) ActionBusinessItemViewFactory(org.talend.designer.business.model.business.diagram.view.factories.ActionBusinessItemViewFactory) DirectionalBusinessItemRelationshipNameViewFactory(org.talend.designer.business.model.business.diagram.view.factories.DirectionalBusinessItemRelationshipNameViewFactory) TerminalBusinessItemNameViewFactory(org.talend.designer.business.model.business.diagram.view.factories.TerminalBusinessItemNameViewFactory) DocumentBusinessItemViewFactory(org.talend.designer.business.model.business.diagram.view.factories.DocumentBusinessItemViewFactory) InputBusinessItemNameViewFactory(org.talend.designer.business.model.business.diagram.view.factories.InputBusinessItemNameViewFactory) IElementType(org.eclipse.gmf.runtime.emf.type.core.IElementType) DataBusinessItemNameViewFactory(org.talend.designer.business.model.business.diagram.view.factories.DataBusinessItemNameViewFactory) EllipseBusinessItemNameViewFactory(org.talend.designer.business.model.business.diagram.view.factories.EllipseBusinessItemNameViewFactory) GearBusinessItemViewFactory(org.talend.designer.business.model.business.diagram.view.factories.GearBusinessItemViewFactory)

Aggregations

EObject (org.eclipse.emf.ecore.EObject)5 IElementType (org.eclipse.gmf.runtime.emf.type.core.IElementType)5 IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)3 View (org.eclipse.gmf.runtime.notation.View)3 EClass (org.eclipse.emf.ecore.EClass)2 TransactionalEditingDomain (org.eclipse.emf.transaction.TransactionalEditingDomain)1 Command (org.eclipse.gef.commands.Command)1 UnexecutableCommand (org.eclipse.gef.commands.UnexecutableCommand)1 ICommand (org.eclipse.gmf.runtime.common.core.command.ICommand)1 DeleteCommand (org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand)1 CommandProxy (org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy)1 ICommandProxy (org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy)1 CompositeTransactionalCommand (org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand)1 IEditHelperContext (org.eclipse.gmf.runtime.emf.type.core.IEditHelperContext)1 DestroyRequest (org.eclipse.gmf.runtime.emf.type.core.requests.DestroyRequest)1 IEditCommandRequest (org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest)1 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)1 Image (org.eclipse.swt.graphics.Image)1 ActionBusinessItemNameViewFactory (org.talend.designer.business.model.business.diagram.view.factories.ActionBusinessItemNameViewFactory)1 ActionBusinessItemViewFactory (org.talend.designer.business.model.business.diagram.view.factories.ActionBusinessItemViewFactory)1