Java Reference
In-Depth Information
EcorePackage.eINSTANCE, XMLTypePackage.eINSTANCE };
localDataStore.setEPackages(ePackages);
try {
final Properties props = new Properties();
props.load( this .getClass().getResourceAsStream("/teneo.properties"));
props.setProperty(PersistenceOptions.PERSISTENCE_XML,
"/annotations.xml");
localDataStore.setProperties(props);
} catch (IOException e) {
throw new IllegalStateException(e);
}
localDataStore.getExtensionManager()
.registerExtension(EListPropertyHandler. class .getName(),
GMFEListPropertyHandler. class .getName());
localDataStore.initialize();
At this point, we need to write an action that will initialize our models and
open our diagram editor. You can add the code found in the sample class
OpenScenarioDBEditor to a wizard that enables the user to input the connec-
tion string information currently held in the teneo.properties file but for
now is used in a simple action from the main menu. This code and correspon-
ding contribution to the actionSets extension-point found in the sample proj-
ect comes from the original tutorial.
Finally, some slight changes to the diagram editor are required because it
expects to be working with file-based model resources. By overriding the fol-
lowing methods, the editor can accommodate the database resource that Teneo
provides:
@Override
public void setInput(IEditorInput input) {
try {
doSetInput(input, true);
} catch (CoreException x) {
Shell shell = getSite().getShell();
ErrorDialog.openError(shell, x.getMessage(),
x.getMessage(), x.getStatus());
}
// set the resource in the resourcetoreadonly map
final ResourceSet rs = getEditingDomain().getResourceSet();
for (Resource res : rs.getResources()) {
((AdapterFactoryEditingDomain) getEditingDomain())
.getResourceToReadOnlyMap().put(res, Boolean.FALSE);
}
}
@Override
Search WWH ::




Custom Search