Search in sources :

Example 1 with AbstractViewElement

use of org.obeonetwork.dsl.cinematic.view.AbstractViewElement in project InformationSystem by ObeoNetwork.

the class AbstractViewElementItemProvider method getReferencedWidgetImage.

/**
 * @generated NOT
 */
public Object getReferencedWidgetImage(Object object) {
    AbstractViewElement abstractViewElement = (AbstractViewElement) object;
    Widget widget = abstractViewElement.getWidget();
    if (widget != null) {
        String iconStringPath = widget.getIcon();
        if (iconStringPath != null && !iconStringPath.trim().equals("")) {
            IResource iconResource = ResourcesPlugin.getWorkspace().getRoot().findMember(iconStringPath);
            if (iconResource == null) {
                // Search in plugins
                IPath iconPath = new Path(iconStringPath);
                String bundleId = iconPath.segment(0);
                Bundle bundle = Platform.getBundle(bundleId);
                if (bundle != null) {
                    IPath iconRelativePath = iconPath.removeFirstSegments(1);
                    Map<String, String> emptyMap = Collections.emptyMap();
                    URL imageURL = FileLocator.find(bundle, iconRelativePath, emptyMap);
                    if (imageURL != null) {
                        ImageDescriptor imgDesc = ImageDescriptor.createFromURL(imageURL);
                        if (imgDesc != null) {
                            return imgDesc.createImage();
                        }
                    }
                }
            } else {
                ImageDescriptor imgDesc = ImageDescriptor.createFromImageData(new ImageData(iconResource.getLocation().toString()));
                if (imgDesc != null) {
                    return imgDesc.createImage();
                }
            }
        }
    }
    return null;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) AbstractViewElement(org.obeonetwork.dsl.cinematic.view.AbstractViewElement) IPath(org.eclipse.core.runtime.IPath) Bundle(org.osgi.framework.Bundle) ImageData(org.eclipse.swt.graphics.ImageData) Widget(org.obeonetwork.dsl.cinematic.toolkits.Widget) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) IResource(org.eclipse.core.resources.IResource) URL(java.net.URL)

Example 2 with AbstractViewElement

use of org.obeonetwork.dsl.cinematic.view.AbstractViewElement in project InformationSystem by ObeoNetwork.

the class FlowsUtil method getAssociatedEvents.

public static Collection<Event> getAssociatedEvents(Flow flow) {
    Collection<Event> events = new HashSet<Event>();
    events.addAll(flow.getEvents());
    for (Flow subflow : getSubflows(flow)) {
        events.addAll(subflow.getEvents());
    }
    for (AbstractViewElement element : getAssociatedAbstractViewElements(flow)) {
        events.addAll(element.getEvents());
    }
    return events;
}
Also used : AbstractViewElement(org.obeonetwork.dsl.cinematic.view.AbstractViewElement) Event(org.obeonetwork.dsl.cinematic.Event) HashSet(java.util.HashSet) Flow(org.obeonetwork.dsl.cinematic.flow.Flow)

Example 3 with AbstractViewElement

use of org.obeonetwork.dsl.cinematic.view.AbstractViewElement in project InformationSystem by ObeoNetwork.

the class ViewContainerViewContainerPropertiesEditionComponent method updateSemanticModel.

/**
 * {@inheritDoc}
 * @see org.eclipse.emf.eef.runtime.impl.components.StandardPropertiesEditionComponent#updateSemanticModel(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
 */
public void updateSemanticModel(final IPropertiesEditionEvent event) {
    ViewContainer viewContainer = (ViewContainer) semanticObject;
    if (ViewViewsRepository.ViewContainer.Properties.description == event.getAffectedEditor()) {
        viewContainer.setDescription((java.lang.String) EEFConverterUtil.createFromString(EcorePackage.Literals.ESTRING, (String) event.getNewValue()));
    }
    if (ViewViewsRepository.ViewContainer.Properties.name == event.getAffectedEditor()) {
        viewContainer.setName((java.lang.String) EEFConverterUtil.createFromString(EcorePackage.Literals.ESTRING, (String) event.getNewValue()));
    }
    if (ViewViewsRepository.ViewContainer.Properties.widget == event.getAffectedEditor()) {
        if (event.getKind() == PropertiesEditionEvent.SET) {
            widgetSettings.setToReference((Widget) event.getNewValue());
        } else if (event.getKind() == PropertiesEditionEvent.ADD) {
            Widget eObject = ToolkitsFactory.eINSTANCE.createWidget();
            EObjectPropertiesEditionContext context = new EObjectPropertiesEditionContext(editingContext, this, eObject, editingContext.getAdapterFactory());
            PropertiesEditingProvider provider = (PropertiesEditingProvider) editingContext.getAdapterFactory().adapt(eObject, PropertiesEditingProvider.class);
            if (provider != null) {
                PropertiesEditingPolicy policy = provider.getPolicy(context);
                if (policy != null) {
                    policy.execute();
                }
            }
            widgetSettings.setToReference(eObject);
        }
    }
    if (ViewViewsRepository.ViewContainer.Properties.actions == event.getAffectedEditor()) {
        if (event.getKind() == PropertiesEditionEvent.ADD) {
            EReferencePropertiesEditionContext context = new EReferencePropertiesEditionContext(editingContext, this, actionsSettings, editingContext.getAdapterFactory());
            PropertiesEditingProvider provider = (PropertiesEditingProvider) editingContext.getAdapterFactory().adapt(semanticObject, PropertiesEditingProvider.class);
            if (provider != null) {
                PropertiesEditingPolicy policy = provider.getPolicy(context);
                if (policy instanceof CreateEditingPolicy) {
                    policy.execute();
                }
            }
        } else if (event.getKind() == PropertiesEditionEvent.EDIT) {
            EObjectPropertiesEditionContext context = new EObjectPropertiesEditionContext(editingContext, this, (EObject) event.getNewValue(), editingContext.getAdapterFactory());
            PropertiesEditingProvider provider = (PropertiesEditingProvider) editingContext.getAdapterFactory().adapt((EObject) event.getNewValue(), PropertiesEditingProvider.class);
            if (provider != null) {
                PropertiesEditingPolicy editionPolicy = provider.getPolicy(context);
                if (editionPolicy != null) {
                    editionPolicy.execute();
                }
            }
        } else if (event.getKind() == PropertiesEditionEvent.REMOVE) {
            actionsSettings.removeFromReference((EObject) event.getNewValue());
        } else if (event.getKind() == PropertiesEditionEvent.MOVE) {
            actionsSettings.move(event.getNewIndex(), (ViewAction) event.getNewValue());
        }
    }
    if (ViewViewsRepository.ViewContainer.Properties.events == event.getAffectedEditor()) {
        if (event.getKind() == PropertiesEditionEvent.ADD) {
            EReferencePropertiesEditionContext context = new EReferencePropertiesEditionContext(editingContext, this, eventsSettings, editingContext.getAdapterFactory());
            PropertiesEditingProvider provider = (PropertiesEditingProvider) editingContext.getAdapterFactory().adapt(semanticObject, PropertiesEditingProvider.class);
            if (provider != null) {
                PropertiesEditingPolicy policy = provider.getPolicy(context);
                if (policy instanceof CreateEditingPolicy) {
                    policy.execute();
                }
            }
        } else if (event.getKind() == PropertiesEditionEvent.EDIT) {
            EObjectPropertiesEditionContext context = new EObjectPropertiesEditionContext(editingContext, this, (EObject) event.getNewValue(), editingContext.getAdapterFactory());
            PropertiesEditingProvider provider = (PropertiesEditingProvider) editingContext.getAdapterFactory().adapt((EObject) event.getNewValue(), PropertiesEditingProvider.class);
            if (provider != null) {
                PropertiesEditingPolicy editionPolicy = provider.getPolicy(context);
                if (editionPolicy != null) {
                    editionPolicy.execute();
                }
            }
        } else if (event.getKind() == PropertiesEditionEvent.REMOVE) {
            eventsSettings.removeFromReference((EObject) event.getNewValue());
        } else if (event.getKind() == PropertiesEditionEvent.MOVE) {
            eventsSettings.move(event.getNewIndex(), (ViewEvent) event.getNewValue());
        }
    }
    if (ViewViewsRepository.ViewContainer.Properties.label == event.getAffectedEditor()) {
        viewContainer.setLabel((java.lang.String) EEFConverterUtil.createFromString(EcorePackage.Literals.ESTRING, (String) event.getNewValue()));
    }
    if (ViewViewsRepository.ViewContainer.Properties.ownedElements == event.getAffectedEditor()) {
        if (event.getKind() == PropertiesEditionEvent.ADD) {
            EReferencePropertiesEditionContext context = new EReferencePropertiesEditionContext(editingContext, this, ownedElementsSettings, editingContext.getAdapterFactory());
            PropertiesEditingProvider provider = (PropertiesEditingProvider) editingContext.getAdapterFactory().adapt(semanticObject, PropertiesEditingProvider.class);
            if (provider != null) {
                PropertiesEditingPolicy policy = provider.getPolicy(context);
                if (policy instanceof CreateEditingPolicy) {
                    policy.execute();
                }
            }
        } else if (event.getKind() == PropertiesEditionEvent.EDIT) {
            EObjectPropertiesEditionContext context = new EObjectPropertiesEditionContext(editingContext, this, (EObject) event.getNewValue(), editingContext.getAdapterFactory());
            PropertiesEditingProvider provider = (PropertiesEditingProvider) editingContext.getAdapterFactory().adapt((EObject) event.getNewValue(), PropertiesEditingProvider.class);
            if (provider != null) {
                PropertiesEditingPolicy editionPolicy = provider.getPolicy(context);
                if (editionPolicy != null) {
                    editionPolicy.execute();
                }
            }
        } else if (event.getKind() == PropertiesEditionEvent.REMOVE) {
            ownedElementsSettings.removeFromReference((EObject) event.getNewValue());
        } else if (event.getKind() == PropertiesEditionEvent.MOVE) {
            ownedElementsSettings.move(event.getNewIndex(), (AbstractViewElement) event.getNewValue());
        }
    }
}
Also used : EObjectPropertiesEditionContext(org.eclipse.emf.eef.runtime.context.impl.EObjectPropertiesEditionContext) AbstractViewElement(org.obeonetwork.dsl.cinematic.view.AbstractViewElement) PropertiesEditingProvider(org.eclipse.emf.eef.runtime.providers.PropertiesEditingProvider) ViewAction(org.obeonetwork.dsl.cinematic.view.ViewAction) EObject(org.eclipse.emf.ecore.EObject) ViewEvent(org.obeonetwork.dsl.cinematic.view.ViewEvent) Widget(org.obeonetwork.dsl.cinematic.toolkits.Widget) PropertiesEditingPolicy(org.eclipse.emf.eef.runtime.policies.PropertiesEditingPolicy) CreateEditingPolicy(org.eclipse.emf.eef.runtime.policies.impl.CreateEditingPolicy) ViewContainer(org.obeonetwork.dsl.cinematic.view.ViewContainer) EReferencePropertiesEditionContext(org.eclipse.emf.eef.runtime.context.impl.EReferencePropertiesEditionContext)

Example 4 with AbstractViewElement

use of org.obeonetwork.dsl.cinematic.view.AbstractViewElement in project InformationSystem by ObeoNetwork.

the class ViewContainerViewContainerPropertiesEditionComponent method initPart.

/**
 * {@inheritDoc}
 *
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject,
 *      org.eclipse.emf.ecore.resource.ResourceSet)
 */
public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
    setInitializing(true);
    if (editingPart != null && key == partKey) {
        editingPart.setContext(elt, allResource);
        final ViewContainer viewContainer = (ViewContainer) elt;
        final ViewContainerPropertiesEditionPart viewContainerPart = (ViewContainerPropertiesEditionPart) editingPart;
        // init values
        if (isAccessible(ViewViewsRepository.ViewContainer.Properties.description))
            viewContainerPart.setDescription(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, viewContainer.getDescription()));
        if (isAccessible(ViewViewsRepository.ViewContainer.Properties.name))
            viewContainerPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, viewContainer.getName()));
        if (isAccessible(ViewViewsRepository.ViewContainer.Properties.widget)) {
            // init part
            widgetSettings = new EObjectFlatComboSettings(viewContainer, ViewPackage.eINSTANCE.getAbstractViewElement_Widget());
            viewContainerPart.initWidget(widgetSettings);
            // set the button mode
            viewContainerPart.setWidgetButtonMode(ButtonsModeEnum.BROWSE);
        }
        if (isAccessible(ViewViewsRepository.ViewContainer.Properties.actions)) {
            actionsSettings = new ReferencesTableSettings(viewContainer, ViewPackage.eINSTANCE.getAbstractViewElement_Actions());
            viewContainerPart.initActions(actionsSettings);
        }
        if (isAccessible(ViewViewsRepository.ViewContainer.Properties.events)) {
            eventsSettings = new ReferencesTableSettings(viewContainer, ViewPackage.eINSTANCE.getAbstractViewElement_Events());
            viewContainerPart.initEvents(eventsSettings);
        }
        if (isAccessible(ViewViewsRepository.ViewContainer.Properties.label))
            viewContainerPart.setLabel(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, viewContainer.getLabel()));
        if (isAccessible(ViewViewsRepository.ViewContainer.Properties.ownedElements)) {
            ownedElementsSettings = new ReferencesTableSettings(viewContainer, ViewPackage.eINSTANCE.getViewContainer_OwnedElements());
            viewContainerPart.initOwnedElements(ownedElementsSettings);
        }
        if (isAccessible(ViewViewsRepository.ViewContainer.Properties.widget)) {
            viewContainerPart.addFilterToWidget(new ViewerFilter() {

                /**
                 * {@inheritDoc}
                 *
                 * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
                 */
                public boolean select(Viewer viewer, Object parentElement, Object element) {
                    // $NON-NLS-1$
                    return (element instanceof String && element.equals("")) || (element instanceof Widget);
                }
            });
        // Start of user code for additional businessfilters for widget
        // End of user code
        }
        if (isAccessible(ViewViewsRepository.ViewContainer.Properties.actions)) {
            viewContainerPart.addFilterToActions(new ViewerFilter() {

                /**
                 * {@inheritDoc}
                 *
                 * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
                 */
                public boolean select(Viewer viewer, Object parentElement, Object element) {
                    // $NON-NLS-1$
                    return (element instanceof String && element.equals("")) || (element instanceof ViewAction);
                }
            });
        // Start of user code for additional businessfilters for actions
        // End of user code
        }
        if (isAccessible(ViewViewsRepository.ViewContainer.Properties.events)) {
            viewContainerPart.addFilterToEvents(new ViewerFilter() {

                /**
                 * {@inheritDoc}
                 *
                 * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
                 */
                public boolean select(Viewer viewer, Object parentElement, Object element) {
                    // $NON-NLS-1$
                    return (element instanceof String && element.equals("")) || (element instanceof ViewEvent);
                }
            });
        // Start of user code for additional businessfilters for events
        // End of user code
        }
        if (isAccessible(ViewViewsRepository.ViewContainer.Properties.ownedElements)) {
            viewContainerPart.addFilterToOwnedElements(new ViewerFilter() {

                /**
                 * {@inheritDoc}
                 *
                 * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
                 */
                public boolean select(Viewer viewer, Object parentElement, Object element) {
                    // $NON-NLS-1$
                    return (element instanceof String && element.equals("")) || (element instanceof AbstractViewElement);
                }
            });
        // Start of user code for additional businessfilters for ownedElements
        // End of user code
        }
    // init values for referenced views
    // init filters for referenced views
    }
    setInitializing(false);
}
Also used : ViewContainerPropertiesEditionPart(org.obeonetwork.dsl.cinematic.view.parts.ViewContainerPropertiesEditionPart) ReferencesTableSettings(org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings) AbstractViewElement(org.obeonetwork.dsl.cinematic.view.AbstractViewElement) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) ViewAction(org.obeonetwork.dsl.cinematic.view.ViewAction) ViewEvent(org.obeonetwork.dsl.cinematic.view.ViewEvent) Widget(org.obeonetwork.dsl.cinematic.toolkits.Widget) Viewer(org.eclipse.jface.viewers.Viewer) EObject(org.eclipse.emf.ecore.EObject) EObjectFlatComboSettings(org.eclipse.emf.eef.runtime.ui.widgets.eobjflatcombo.EObjectFlatComboSettings) ViewContainer(org.obeonetwork.dsl.cinematic.view.ViewContainer)

Example 5 with AbstractViewElement

use of org.obeonetwork.dsl.cinematic.view.AbstractViewElement in project InformationSystem by ObeoNetwork.

the class ViewUtil method getAssociatedAbstractViewElements.

public static Collection<AbstractViewElement> getAssociatedAbstractViewElements(ViewContainer container) {
    Collection<AbstractViewElement> elements = new ArrayList<AbstractViewElement>();
    // Add children
    for (AbstractViewElement child : container.getOwnedElements()) {
        if (child instanceof ViewElement) {
            elements.add(child);
        } else if (child instanceof ViewContainer) {
            elements.add(child);
            elements.addAll(getAssociatedAbstractViewElements((ViewContainer) child));
        } else if (child instanceof ViewContainerReference) {
            ViewContainerReference vcr = (ViewContainerReference) child;
            if (vcr.getViewContainer() != null) {
                ViewContainer refContainer = vcr.getViewContainer();
                elements.add(refContainer);
                elements.addAll(getAssociatedAbstractViewElements(refContainer));
            }
        }
    }
    return elements;
}
Also used : ViewContainerReference(org.obeonetwork.dsl.cinematic.view.ViewContainerReference) AbstractViewElement(org.obeonetwork.dsl.cinematic.view.AbstractViewElement) ArrayList(java.util.ArrayList) AbstractViewElement(org.obeonetwork.dsl.cinematic.view.AbstractViewElement) ViewElement(org.obeonetwork.dsl.cinematic.view.ViewElement) ViewContainer(org.obeonetwork.dsl.cinematic.view.ViewContainer)

Aggregations

AbstractViewElement (org.obeonetwork.dsl.cinematic.view.AbstractViewElement)6 EObject (org.eclipse.emf.ecore.EObject)3 Widget (org.obeonetwork.dsl.cinematic.toolkits.Widget)3 ViewContainer (org.obeonetwork.dsl.cinematic.view.ViewContainer)3 ViewEvent (org.obeonetwork.dsl.cinematic.view.ViewEvent)3 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)2 Event (org.obeonetwork.dsl.cinematic.Event)2 Flow (org.obeonetwork.dsl.cinematic.flow.Flow)2 ViewAction (org.obeonetwork.dsl.cinematic.view.ViewAction)2 HashSet (java.util.HashSet)1 IResource (org.eclipse.core.resources.IResource)1 IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1 EObjectPropertiesEditionContext (org.eclipse.emf.eef.runtime.context.impl.EObjectPropertiesEditionContext)1 EReferencePropertiesEditionContext (org.eclipse.emf.eef.runtime.context.impl.EReferencePropertiesEditionContext)1 PropertiesEditingPolicy (org.eclipse.emf.eef.runtime.policies.PropertiesEditingPolicy)1 CreateEditingPolicy (org.eclipse.emf.eef.runtime.policies.impl.CreateEditingPolicy)1 PropertiesEditingProvider (org.eclipse.emf.eef.runtime.providers.PropertiesEditingProvider)1