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;
}
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));
}
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);
}
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;
}
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;
}
Aggregations