//Originally tried this in post-init, but auto-update then gets called
//before this happens
//Grab the compilationunit and add
Resource r = Utility.getModel(getDiagram());
CompilationUnit compUnit = null;
for (EObject e : r.getContents()) {
if (e instanceof CompilationUnit) {
compUnit = (CompilationUnit) e;
}
}
//If compUnit is null create a new one
if (compUnit == null) {
compUnit =
ContainersFactory.eINSTANCE.createCompilationUnit();
r.getContents().add(compUnit);
}
//Check that the compilationunit has a package, if not add one.
eu.admire.dispel.containers.Package p = null;
if (compUnit.getPackages().size() > 0) {
p = compUnit.getPackages().get(0);
} else {
p = ContainersFactory.eINSTANCE.createPackage();
p.setName("eu.admire.test");
List<String> namespaces = new ArrayList<String>();
namespaces.add("eu");
namespaces.add("admire");
namespaces.add("test");
p.getNamespaces().addAll(namespaces);
compUnit.getPackages().add(p);
}
final eu.admire.dispel.containers.Package pck = p;
getDiagramEditor().getEditingDomain().getCommandStack().execute(
new RecordingCommand(getDiagramEditor().getEditingDomain(),