Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 Tools » Problem when programatically deleting diagram file
Problem when programatically deleting diagram file [message #625635] Wed, 26 May 2010 12:30
Niels Brouwers is currently offline Niels Brouwers
Messages: 67
Registered: July 2009
Hi all,

I would like to request for help to solve one annoying problem. Let me begin by first describing what I am trying to achieve.

We customized the UML 2.0 class diagram and UML 2.0 activity diagram to suite domain specific needs. The customized class diagram contains for example a stereotyped UML component. This component contains one or many UML Packages, each containing one stereotyped activity. The activity provides a behavior specification for one of the operations that is owned by one of the interfaces provided by the stereotyped component. Each activity is edited using the customized activity diagram.

Currently, I am creating a wizard to remove behavior specifications (activities) from the model (including the package which contains the activity). Furthermore, the wizard allows the user to specify whether the customized activity diagram should be deleted as well (as the diagram will contain nodes not corresponding to any model element). The wizard is shown by a pop-up action defined on the EditPart of the component. So the user can right-click on the component, invoke the action and the wizard pops-up.

Now, the annoying problem is this: when the user selects the diagram to be deleted along with the activity element, clicking the finish button on the wizard results in the correct behavior (i.e. activity, references to the activity and the diagram get deleted), but has the annoying side-affect that the customized class diagram from which the wizard was started closes! This requires the user to re-open the diagram, which obviously is very inconvenient.

Does anyone have an idea why the customized class diagram gets closed? Please see the code enclosed below.

Thank you in advance for your effort.

Kind regards,
Niels Brouwers.


public boolean performFinish() {

org.eclipse.uml2.uml.Package pack = null;

// resolve package to be removed from the model
String packageName = "la_" + selectLogicalActionBehaviorPage.getLogicalActionBehaviorName ();
pack = resolvePackage(myComponent, packageName);
if (pack == null) {
// Package could not be resolved
return false;

ResourceSet resourceSet = pack.eResource().getResourceSet();

// remove logical action diagram if required
if (removalOptionsPage.removeLogicalActionDiagram()) {
deleteLogicalActionDiagrams(pack, resourceSet);

// remove the package from the model

// save all the editors as changes to the uml model seem to be made after the editor is saved.
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().saveAllEditors(false);

// Apparently all went OK, so return true.
return true;


private void deleteLogicalActionDiagrams(org.eclipse.uml2.uml.Package pack, ResourceSet resourceSet) {
if (myProject != null) {
for (final IFile diagramFile : findAllLogicalActionDiagrams(myProject)) {
if (getRootModelElement(diagramFile.getFullPath().toString(), resourceSet) == pack) {
// pack is the root element of the diagram, so delete the diagram file
WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
protected void execute(IProgressMonitor monitor)
throws CoreException, InvocationTargetException,
InterruptedException {
diagramFile.delete(false, monitor);
try {
getContainer().run(false, false, operation);
} catch (InvocationTargetException e) {
} catch (InterruptedException e) {

Kind regards,
Niels Brouwers.
Previous Topic:Problem when programatically deleting diagram file
Next Topic:UML2 Tools and Helios
Goto Forum:

Current Time: Tue Sep 02 21:27:34 GMT 2014

Powered by FUDForum. Page generated in 0.05041 seconds