One diagram editor for two child objects [message #192086] |
Wed, 11 June 2008 09:45  |
Eclipse User |
|
|
|
Originally posted by: quya01.yahoo.com
Hi, I'm new to GMF and to this forum. Please let me know if my question is
not clear.
The ecore model that I'm working on has an abstract class A that has two
subclasses B and C. I want to use the same diagram editor for instances of
both B and C. Can someone tell me is this possible ? And how to do this
please.
Thanks.
|
|
|
|
|
|
|
|
|
|
|
Re: One diagram editor for two child objects [message #193712 is a reply to message #193664] |
Thu, 19 June 2008 10:30   |
Eclipse User |
|
|
|
Hi Alex, let me explain what I'm trying to do
The initialize diagram pop up menu has been disabled. A button is used to
invoke a common open diagram method. The ViewService.createDiagram()
method returns a null diagram. Attached below is the openDiagram method:
public static void openDiagram(final UMLBelement element, final
IWorkbenchPart part, final String kind, final PreferencesHint hint) throws
Exception {
final Resource diagramResource;
IFile diagramFile = null;
TransactionalEditingDomain editingDomain =
GMFEditingDomainFactory.INSTANCE.createEditingDomain();
IFile selectedModelFile =
WorkspaceSynchronizer.getFile(element.getContaining_UMLBProj ect().eResource());
diagramResource =
editingDomain.getResourceSet().createResource(DiagramUtiliti es.getDiagramURI(element));
try {
diagramFile = WorkspaceSynchronizer.getFile(diagramResource);
} catch (WrappedException ex) {
MessageDialog.openError(part.getSite().getShell(), "Error", "diagram
file loading failed");
}
if (diagramFile.exists()) try {
IDE.openEditor(part.getSite().getPage(), diagramFile);
} catch (PartInitException e) {
MessageDialog.openError(part.getSite().getShell(), "Error", "Diagram
file loading failed");
}
else if
(part.getSite().getPage().saveEditor(part.getSite().getPage( ).getActiveEditor(),
false)) {
if (part.getSite().getPage().getActiveEditor().isDirty() == true) {
MessageDialog.openWarning(part.getSite().getShell(), "Warning", "This
diagram needs to be saved before another can be created");
return;
} else {
List<IFile> affectedFiles = new LinkedList<IFile>();
affectedFiles.add(selectedModelFile);
affectedFiles.add(diagramFile);
AbstractTransactionalCommand command = new
AbstractTransactionalCommand(editingDomain, "Initializing diagram
contents", affectedFiles) { //$NON-NLS-1$
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
IAdaptable info) throws ExecutionException {
Diagram diagram = ViewService.createDiagram(element, kind, hint);
diagramResource.getContents().add(diagram);
return CommandResult.newOKCommandResult();
}
};
OperationHistoryFactory.getOperationHistory().execute(comman d, new
NullProgressMonitor(), null);
diagramResource.save(Collections.EMPTY_MAP);
IDE.openEditor(part.getSite().getPage(), diagramFile);
}
}
}
Really looking forward your help. Thanks in advance
|
|
|
|
Powered by
FUDForum. Page generated in 0.28220 seconds