use of org.obeonetwork.dsl.overview.Root in project InformationSystem by ObeoNetwork.
the class OverviewModelWizard method performFinish.
/**
* Do the work after everything is specified.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
@Override
public boolean performFinish() {
try {
// Remember the file.
//
final IFile modelFile = getModelFile();
// Do the work within an operation.
//
WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
@Override
protected void execute(IProgressMonitor progressMonitor) {
try {
// Create a resource set
//
ResourceSet resourceSet = new ResourceSetImpl();
// Get the URI of the model file.
//
URI fileURI = URI.createPlatformResourceURI(modelFile.getFullPath().toString(), true);
// Create a resource for this file.
//
Resource resource = resourceSet.createResource(fileURI);
// Add the initial model object to the contents.
//
Root rootObject = createInitialModel();
if (rootObject != null) {
resource.getContents().add(rootObject);
overviewModelDef.initModel(rootObject);
}
// Save the contents of the resource to the file system.
//
Map<Object, Object> options = new HashMap<Object, Object>();
options.put(XMLResource.OPTION_ENCODING, "UTF-8");
resource.save(options);
} catch (Exception exception) {
OverviewEditorPlugin.INSTANCE.log(exception);
} finally {
progressMonitor.done();
}
}
};
getContainer().run(false, false, operation);
// Select the new file resource in the current view.
//
IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
IWorkbenchPage page = workbenchWindow.getActivePage();
final IWorkbenchPart activePart = page.getActivePart();
if (activePart instanceof ISetSelectionTarget) {
final ISelection targetSelection = new StructuredSelection(modelFile);
getShell().getDisplay().asyncExec(new Runnable() {
public void run() {
((ISetSelectionTarget) activePart).selectReveal(targetSelection);
}
});
}
// Open an editor on the new file.
overviewModelDef.openEditor(modelFile);
return true;
} catch (Exception exception) {
OverviewEditorPlugin.INSTANCE.log(exception);
return true;
}
}
use of org.obeonetwork.dsl.overview.Root in project InformationSystem by ObeoNetwork.
the class RootItemProvider method collectNewChildDescriptors.
/**
* This adds {@link org.eclipse.emf.edit.command.CommandParameter}s
* describing the children that can be created under this object. <!--
* begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
if (object instanceof Root) {
Root root = (Root) object;
Collection<OverviewModelDef> overviewModelDefs = OverviewModelDefRegistry.getOverviewModelDefs();
if (overviewModelDefs != null) {
for (OverviewModelDef overviewModelDef : overviewModelDefs) {
if (overviewModelDef.isApplicable(root)) {
Collection<?> childDescriptors = overviewModelDef.getNewChildDescriptors(root);
if (childDescriptors != null) {
newChildDescriptors.addAll(childDescriptors);
}
}
}
}
}
}
use of org.obeonetwork.dsl.overview.Root in project InformationSystem by ObeoNetwork.
the class OverviewModelWizard method createInitialModel.
/**
* Create a new model.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
protected Root createInitialModel() {
Root newRoot = overviewFactory.createRoot();
newRoot.setCreatedOn(new Date());
return newRoot;
}
Aggregations