Search in sources :

Example 6 with IDomain

use of org.yakindu.sct.domain.extension.IDomain in project statecharts by Yakindu.

the class ContentProposalHandler method initProposalProvidersOnDemand.

protected void initProposalProvidersOnDemand() {
    if (proposalProviders == null && getSelectedView() != null) {
        IDomain domain = DomainRegistry.getDomain(getSelectedView().getElement());
        Injector injector = domain.getInjector(IDomain.FEATURE_EDITOR);
        injector.injectMembers(this);
    }
}
Also used : IDomain(org.yakindu.sct.domain.extension.IDomain) Injector(com.google.inject.Injector)

Example 7 with IDomain

use of org.yakindu.sct.domain.extension.IDomain in project statecharts by Yakindu.

the class DomainWizardPage method createControl.

public void createControl(Composite parent) {
    final Composite composite = new Composite(parent, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);
    GridLayoutFactory.fillDefaults().applyTo(composite);
    final Group domainSelectionGroup = new Group(composite, SWT.NONE);
    domainSelectionGroup.setText("Select the statechart domain:");
    GridLayoutFactory.fillDefaults().numColumns(2).applyTo(domainSelectionGroup);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(domainSelectionGroup);
    Label spacer = new Label(domainSelectionGroup, SWT.NONE);
    GridDataFactory.fillDefaults().span(2, 1).applyTo(spacer);
    image = new Label(domainSelectionGroup, SWT.NONE);
    GridDataFactory.fillDefaults().grab(false, false).applyTo(image);
    domainCombo = new ComboViewer(domainSelectionGroup, SWT.READ_ONLY);
    GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(domainCombo.getCombo());
    domainCombo.setContentProvider(new ArrayContentProvider());
    domainCombo.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            return ((IDomain) element).getName();
        }
    });
    domainCombo.setInput(domainDescriptors);
    description = new Label(domainSelectionGroup, SWT.WRAP);
    GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(description);
    setControl(composite);
    domainCombo.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IDomain domain = unwrap(event.getSelection());
            description.setText(domain.getDescription());
            image.setImage(asImage(domain));
            domainSelectionGroup.layout();
        }

        private Image asImage(IDomain domain) {
            ImageRegistry imageRegistry = DiagramActivator.getDefault().getImageRegistry();
            Image image = imageRegistry.get(domain.getImagePath().toString());
            if (image == null)
                imageRegistry.put(domain.getImagePath().toString(), ImageDescriptor.createFromURL(domain.getImagePath()).createImage());
            return imageRegistry.get(domain.getImagePath().toString());
        }
    });
    trySelectDefaultDomain();
    IConfigurationElement[] configurationElements = Platform.getExtensionRegistry().getConfigurationElementsFor("org.yakindu.sct.ui.wizard.create.contribution");
    if (configurationElements.length > 0) {
        Label spacer2 = new Label(domainSelectionGroup, SWT.NONE);
        GridDataFactory.fillDefaults().span(2, 1).applyTo(spacer2);
        for (IConfigurationElement iConfigurationElement : configurationElements) {
            try {
                CreationWizardContribution contribution = (CreationWizardContribution) iConfigurationElement.createExecutableExtension("class");
                contribution.toDomainWizardPage(composite);
            } catch (CoreException e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Image(org.eclipse.swt.graphics.Image) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IDomain(org.yakindu.sct.domain.extension.IDomain) ImageRegistry(org.eclipse.jface.resource.ImageRegistry) CoreException(org.eclipse.core.runtime.CoreException) ComboViewer(org.eclipse.jface.viewers.ComboViewer) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 8 with IDomain

use of org.yakindu.sct.domain.extension.IDomain in project statecharts by Yakindu.

the class StatechartPropertySection method createDomainCombo.

protected void createDomainCombo(Composite leftColumn) {
    Label label = getToolkit().createLabel(leftColumn, "Statechart domain");
    GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).applyTo(label);
    domainCombo = new ComboViewer(leftColumn);
    GridDataFactory.fillDefaults().span(1, 1).align(SWT.FILL, SWT.CENTER).applyTo(domainCombo.getCombo());
    Label spacer = getToolkit().createLabel(leftColumn, "");
    GridDataFactory.fillDefaults().applyTo(spacer);
    domainCombo.setContentProvider(new ArrayContentProvider());
    domainCombo.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            return ((IDomain) element).getName();
        }
    });
    List<IDomain> domains = DomainRegistry.getDomains();
    for (IDomain domainDescriptor : domains) {
        domainCombo.add(domainDescriptor);
    }
    if (domains.size() <= 1) {
        domainCombo.getControl().setEnabled(false);
    }
}
Also used : IDomain(org.yakindu.sct.domain.extension.IDomain) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Label(org.eclipse.swt.widgets.Label) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) EObject(org.eclipse.emf.ecore.EObject) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 9 with IDomain

use of org.yakindu.sct.domain.extension.IDomain in project statecharts by Yakindu.

the class StatechartDiagramEditor method getEditorInjector.

protected Injector getEditorInjector() {
    IDomain domain = DomainRegistry.getDomain(getDiagram().getElement());
    Injector injector = domain.getInjector(IDomain.FEATURE_EDITOR);
    return injector;
}
Also used : IDomain(org.yakindu.sct.domain.extension.IDomain) Injector(com.google.inject.Injector)

Example 10 with IDomain

use of org.yakindu.sct.domain.extension.IDomain in project statecharts by Yakindu.

the class PlugableXtextLabelEditPart method init.

private void init(String target) {
    IDomain domain = DomainRegistry.getDomain(resolveSemanticElement());
    injector = domain.getInjector(IDomain.FEATURE_EDITOR, target);
}
Also used : IDomain(org.yakindu.sct.domain.extension.IDomain)

Aggregations

IDomain (org.yakindu.sct.domain.extension.IDomain)11 Injector (com.google.inject.Injector)4 CoreException (org.eclipse.core.runtime.CoreException)2 EObject (org.eclipse.emf.ecore.EObject)2 Resource (org.eclipse.emf.ecore.resource.Resource)2 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)2 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)2 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)2 ComboViewer (org.eclipse.jface.viewers.ComboViewer)2 LabelProvider (org.eclipse.jface.viewers.LabelProvider)2 Label (org.eclipse.swt.widgets.Label)2 ITypeSystem (org.yakindu.base.types.typesystem.ITypeSystem)2 UpdateValueStrategy (org.eclipse.core.databinding.UpdateValueStrategy)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 IEMFValueProperty (org.eclipse.emf.databinding.IEMFValueProperty)1 URIConverter (org.eclipse.emf.ecore.resource.URIConverter)1 XMIResourceImpl (org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl)1 IViewerObservableValue (org.eclipse.jface.databinding.viewers.IViewerObservableValue)1 ImageRegistry (org.eclipse.jface.resource.ImageRegistry)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1