Search in sources :

Example 1 with ScaffoldInfo

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

the class ScaffoldInfoItemProvider method getText.

/**
 * This returns the label text for the adapted class.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public String getText(Object object) {
    ScaffoldInfo info = (ScaffoldInfo) object;
    AdapterFactoryLabelProvider lp = new AdapterFactoryLabelProvider(new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE));
    String left = "<none>";
    if (info.getLeftObject() != null) {
        left = lp.getText(info.getLeftObject());
    }
    String right = "<none>";
    if (info.getRightObject() != null) {
        right = lp.getText(info.getRightObject());
    }
    String label = "[" + left + " <-> " + right + "]";
    return getString("_UI_ScaffoldInfo_type") + " " + label;
}
Also used : ScaffoldInfo(fr.gouv.mindef.safran.database.scaffold.ScaffoldInfo) AdapterFactoryLabelProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider) ComposedAdapterFactory(org.eclipse.emf.edit.provider.ComposedAdapterFactory)

Example 2 with ScaffoldInfo

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

the class AbstractTransformationTest method test.

private void test(ScaffoldType kind, String folder, Iterable<URI> additionalResources) {
    ScaffoldInfo scaffoldInfo = buildScaffoldInfo(kind, URI.createPlatformPluginURI(getModelsFolder() + folder + resourceNames.get(kind)[0], true), URI.createPlatformPluginURI(getModelsFolder() + folder + resourceNames.get(kind)[1], true), additionalResources);
    testTransformation(kind, scaffoldInfo, URI.createPlatformPluginURI(getModelsFolder() + folder + resourceNames.get(kind)[2], true));
}
Also used : ScaffoldInfo(fr.gouv.mindef.safran.database.scaffold.ScaffoldInfo)

Example 3 with ScaffoldInfo

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

the class AbstractScaffoldHandler method executeFromScaffoldModel.

protected void executeFromScaffoldModel(StructuredSelection structuredSelection) {
    ScaffoldInfo info = ScaffoldingUtils.getScaffoldInfoFromSelection(structuredSelection.getFirstElement());
    executeFromScaffoldModel(info);
}
Also used : ScaffoldInfo(fr.gouv.mindef.safran.database.scaffold.ScaffoldInfo)

Example 4 with ScaffoldInfo

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

the class AbstractScaffoldHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
    shell = HandlerUtil.getActiveShell(event);
    if (selection instanceof StructuredSelection) {
        StructuredSelection structuredSelection = (StructuredSelection) selection;
        if (structuredSelection.size() == 2) {
            ScaffoldInfo existingScaffoldInfo = getExistingScaffoldModel(structuredSelection);
            if (existingScaffoldInfo != null) {
                MessageDialog dlg = new MessageDialog(shell, "Existing scaffold model found", null, "A scaffold model already exists for these objects in file " + existingScaffoldInfo.eResource().getURI().toPlatformString(true) + "\n\nWhat do you want to do ?", MessageDialog.QUESTION_WITH_CANCEL, new String[] { "Use existing scaffold", "Create a new scaffold", "Cancel" }, 0);
                int btn = dlg.open();
                if (btn == CANCEL) {
                    return null;
                } else if (btn == CREATE_NEW_SCAFFOLD) {
                    executeScaffoldingWizard(structuredSelection);
                } else if (btn == USE_EXISTING_SCAFFOLD) {
                    executeFromScaffoldModel(existingScaffoldInfo);
                }
            } else {
                executeScaffoldingWizard(structuredSelection);
            }
        } else if (structuredSelection.size() == 1) {
            executeFromScaffoldModel(structuredSelection);
        }
    }
    return null;
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ScaffoldInfo(fr.gouv.mindef.safran.database.scaffold.ScaffoldInfo) MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Example 5 with ScaffoldInfo

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

the class AbstractScaffoldHandler method getExistingScaffoldModel.

private ScaffoldInfo getExistingScaffoldModel(StructuredSelection selection) {
    Iterator<?> iterator = selection.iterator();
    Object first = iterator.next();
    Object second = iterator.next();
    EObject firstEObject = null;
    EObject secondEObject = null;
    if (first instanceof EObject && second instanceof EObject) {
        firstEObject = (EObject) first;
        secondEObject = (EObject) second;
        Session session = SessionManager.INSTANCE.getSession(firstEObject);
        for (Resource semanticResource : session.getSemanticResources()) {
            for (EObject object : semanticResource.getContents()) {
                if (object instanceof ScaffoldInfo) {
                    ScaffoldInfo info = (ScaffoldInfo) object;
                    if ((info.getLeftObject() == firstEObject && info.getRightObject() == secondEObject) || (info.getLeftObject() == secondEObject && info.getRightObject() == firstEObject)) {
                        return info;
                    }
                }
            }
        }
    }
    return null;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) Resource(org.eclipse.emf.ecore.resource.Resource) ScaffoldInfo(fr.gouv.mindef.safran.database.scaffold.ScaffoldInfo) EObject(org.eclipse.emf.ecore.EObject) Session(org.eclipse.sirius.business.api.session.Session)

Aggregations

ScaffoldInfo (fr.gouv.mindef.safran.database.scaffold.ScaffoldInfo)11 EObject (org.eclipse.emf.ecore.EObject)7 Resource (org.eclipse.emf.ecore.resource.Resource)5 InternalEObject (org.eclipse.emf.ecore.InternalEObject)2 Transformation (fr.gouv.mindef.safran.database.transfo.Transformation)1 IFile (org.eclipse.core.resources.IFile)1 IResource (org.eclipse.core.resources.IResource)1 CDOResource (org.eclipse.emf.cdo.eresource.CDOResource)1 URI (org.eclipse.emf.common.util.URI)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 XMLResource (org.eclipse.emf.ecore.xmi.XMLResource)1 ComposedAdapterFactory (org.eclipse.emf.edit.provider.ComposedAdapterFactory)1 AdapterFactoryLabelProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider)1 RecordingCommand (org.eclipse.emf.transaction.RecordingCommand)1 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)1 ISelection (org.eclipse.jface.viewers.ISelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 Session (org.eclipse.sirius.business.api.session.Session)1 DAnalysisSessionEObject (org.eclipse.sirius.viewpoint.DAnalysisSessionEObject)1 TableContainer (org.obeonetwork.dsl.database.TableContainer)1