Search in sources :

Example 1 with ScaffoldType

use of fr.gouv.mindef.safran.database.scaffold.ScaffoldType in project InformationSystem by ObeoNetwork.

the class AddAdditionalObjectsWizard method performFinish.

/* (non-Javadoc)
	 * @see org.eclipse.jface.wizard.Wizard#performFinish()
	 */
public boolean performFinish() {
    final Collection<EObject> newAdditionalObjects1 = additionalResourcesPage.getAdditionalObjects1();
    final Collection<EObject> newAdditionalObjects2 = additionalResourcesPage.getAdditionalObjects2();
    final boolean hasBeenModified1 = hasBeenModified(scaffoldInfo.getLeftToRightAdditionalObjects(), newAdditionalObjects1);
    final boolean hasBeenModified2 = hasBeenModified(scaffoldInfo.getRightToLeftAdditionalObjects(), newAdditionalObjects2);
    if (hasBeenModified1 || hasBeenModified2) {
        Session session = SessionManager.INSTANCE.getSession(scaffoldInfo);
        TransactionalEditingDomain editingDomain = session.getTransactionalEditingDomain();
        RecordingCommand updatingCmd = new RecordingCommand(editingDomain, "Updating additional objects") {

            @Override
            protected void doExecute() {
                if (hasBeenModified1) {
                    ScaffoldType leftToRightScaffoldType = scaffoldInfo.getLeftToRightTransformationType();
                    scaffoldInfo.clearAdditionalObjectsForTransformation(leftToRightScaffoldType);
                    for (EObject newObject : newAdditionalObjects1) {
                        scaffoldInfo.addAdditionalObjectsForTransformation(newObject, leftToRightScaffoldType);
                    }
                }
                if (hasBeenModified2) {
                    ScaffoldType rightToleftScaffoldType = scaffoldInfo.getRightToLeftTransformationType();
                    scaffoldInfo.clearAdditionalObjectsForTransformation(rightToleftScaffoldType);
                    for (EObject newObject : newAdditionalObjects2) {
                        scaffoldInfo.addAdditionalObjectsForTransformation(newObject, rightToleftScaffoldType);
                    }
                }
            }
        };
        editingDomain.getCommandStack().execute(updatingCmd);
    }
    return true;
}
Also used : ScaffoldType(fr.gouv.mindef.safran.database.scaffold.ScaffoldType) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) RecordingCommand(org.eclipse.emf.transaction.RecordingCommand) EObject(org.eclipse.emf.ecore.EObject) Session(org.eclipse.sirius.business.api.session.Session)

Example 2 with ScaffoldType

use of fr.gouv.mindef.safran.database.scaffold.ScaffoldType in project InformationSystem by ObeoNetwork.

the class SpecifyAdditionalObjects2WaysPage method createControl.

/**
 * Create contents of the wizard.
 * @param parent
 */
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    setControl(container);
    container.setLayout(new GridLayout(1, false));
    Session session = SessionManager.INSTANCE.getSession(scaffoldInfo);
    ScaffoldType scaffoldType1 = scaffoldInfo.getLeftToRightTransformationType();
    EObject target1 = scaffoldInfo.getRightObject();
    Collection<EObject> additionalObjects1 = new ArrayList<EObject>(scaffoldInfo.getLeftToRightAdditionalObjects());
    ScaffoldType scaffoldType2 = scaffoldInfo.getRightToLeftTransformationType();
    EObject target2 = scaffoldInfo.getLeftObject();
    Collection<EObject> additionalObjects2 = new ArrayList<EObject>(scaffoldInfo.getRightToLeftAdditionalObjects());
    Label lbl1 = new Label(container, SWT.NONE);
    lbl1.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    lbl1.setText(scaffoldType1.getName() + " :");
    additionalObjectsComposite1 = new AdditionalObjectsComposite(container, session, scaffoldType1, target1, additionalObjects1);
    additionalObjectsComposite1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    new Label(container, SWT.NONE);
    Label lbl2 = new Label(container, SWT.NONE);
    lbl2.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    lbl2.setText(scaffoldType2.getName() + " :");
    additionalObjectsComposite2 = new AdditionalObjectsComposite(container, session, scaffoldType2, target2, additionalObjects2);
    additionalObjectsComposite2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
}
Also used : ScaffoldType(fr.gouv.mindef.safran.database.scaffold.ScaffoldType) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) Session(org.eclipse.sirius.business.api.session.Session)

Example 3 with ScaffoldType

use of fr.gouv.mindef.safran.database.scaffold.ScaffoldType in project InformationSystem by ObeoNetwork.

the class TestInputIsScaffoldModel method test.

@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
    if (receiver instanceof StructuredSelection) {
        StructuredSelection selection = (StructuredSelection) receiver;
        if (selection.size() == 1) {
            Object element = selection.getFirstElement();
            if (args != null && args.length >= 1) {
                String kind = (String) args[0];
                ScaffoldType scaffoldType;
                if (ANY.equals(kind)) {
                    scaffoldType = null;
                } else {
                    scaffoldType = getCorrespondingScaffoldType(kind);
                }
                if (element instanceof Resource) {
                    Resource resource = (Resource) element;
                    return handleScaffoldModel(resource, scaffoldType);
                } else {
                    URI uri = getModelURI(element);
                    return handleScaffoldModel(uri, scaffoldType);
                }
            }
        }
    }
    return false;
}
Also used : ScaffoldType(fr.gouv.mindef.safran.database.scaffold.ScaffoldType) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) Resource(org.eclipse.emf.ecore.resource.Resource) EObject(org.eclipse.emf.ecore.EObject) URI(org.eclipse.emf.common.util.URI)

Example 4 with ScaffoldType

use of fr.gouv.mindef.safran.database.scaffold.ScaffoldType in project InformationSystem by ObeoNetwork.

the class TestMultipleInputIsValid method test.

@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
    if (receiver instanceof StructuredSelection) {
        StructuredSelection selection = (StructuredSelection) receiver;
        if (selection.size() == 2) {
            if (args != null && args.length >= 1) {
                String kind = (String) args[0];
                Iterator<?> iterator = selection.iterator();
                Object element1 = iterator.next();
                Object element2 = iterator.next();
                ScaffoldType scaffoldType = getCorrespondingScaffoldType(kind);
                return isSelectionValidFor(element1, element2, scaffoldType);
            }
        }
    }
    return false;
}
Also used : ScaffoldType(fr.gouv.mindef.safran.database.scaffold.ScaffoldType) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) EObject(org.eclipse.emf.ecore.EObject)

Aggregations

ScaffoldType (fr.gouv.mindef.safran.database.scaffold.ScaffoldType)4 EObject (org.eclipse.emf.ecore.EObject)4 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 Session (org.eclipse.sirius.business.api.session.Session)2 ArrayList (java.util.ArrayList)1 URI (org.eclipse.emf.common.util.URI)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 RecordingCommand (org.eclipse.emf.transaction.RecordingCommand)1 TransactionalEditingDomain (org.eclipse.emf.transaction.TransactionalEditingDomain)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1