Skip to content
Snippets Groups Projects
Commit 55ce92b6 authored by Simon Barner's avatar Simon Barner
Browse files

- Delete also resources that contain references to the resource managed by the...

- Delete also resources that contain references to the resource managed by the kernel (e.g., the AF3 project)
refs 2309
parent 455be92d
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,7 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.ui.internal.actions;
import static org.eclipse.emf.ecore.util.EcoreUtil.resolveAll;
import static org.eclipse.ui.PlatformUI.getWorkbench;
import java.util.ArrayList;
......@@ -51,7 +52,7 @@ import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: A9E9C8C2E3BCE10A7BB9895700C06003
* @ConQAT.Rating YELLOW Hash: 77B414F02AC48706566ABE2730A3AABB
*/
public class DeleteAction extends EObjectActionBase<EObject> {
......@@ -136,6 +137,15 @@ public class DeleteAction extends EObjectActionBase<EObject> {
Shell sh = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
String message = "Are you sure you want to delete '" + topElement.getSaveableName() + "'?";
// Check if there are further resources that reference the resource to be deleted. If so,
// extend confirmation dialog accordingly.
resolveAll(topElement.getResourceSet());
if(topElement.getResourceSet().getResources().size() > 1) {
message +=
"\nThis will also include all models that reference '" +
topElement.getSaveableName() + "'.";
}
final MessageDialog dialog =
new MessageDialog(sh, "Confirm Delete", null, message, MessageDialog.QUESTION,
new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL}, 0) {
......
......@@ -17,6 +17,7 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.internal.storage.eclipse;
import static org.eclipse.emf.ecore.util.EcoreUtil.resolveAll;
import static org.fortiss.tooling.kernel.utils.EMFResourceUtils.buildOptionsMap;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.warning;
......@@ -42,7 +43,9 @@ import org.eclipse.emf.common.command.BasicCommandStack;
import org.eclipse.emf.common.command.CommandStack;
import org.eclipse.emf.common.command.CommandStackListener;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
......@@ -66,7 +69,7 @@ import org.fortiss.tooling.kernel.utils.UniqueIDUtils;
* @author hummel
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 5C7736A695F8552F01BF262E4D9A2475
* @ConQAT.Rating YELLOW Hash: B538E4B6DE34A393C8E9CC83A00B67AD
*/
class ModelContext implements ITopLevelElement, CommandStackListener {
......@@ -494,14 +497,39 @@ class ModelContext implements ITopLevelElement, CommandStackListener {
/** {@inheritDoc} */
@Override
public boolean delete() {
// Determine resources referenced by the resource managed by the kernel
EList<Resource> resourcesToDelete = new BasicEList<Resource>();
resolveAll(rset);
for(Resource currentResource : rset.getResources()) {
if(currentResource != resource) {
resourcesToDelete.add(currentResource);
}
}
boolean rval = true;
// First, delete resource managed by the kernel
try {
getFile().delete(false, null);
return true;
} catch(CoreException e) {
error(ToolingKernelActivator.getDefault(), "Error during deletion of model file " +
getFile().getName());
getFile().getName() + ".");
rval = false;
}
return false;
// The, delete all other resources
for(Resource currentResource : resourcesToDelete) {
try {
currentResource.delete(null);
} catch(IOException e) {
error(ToolingKernelActivator.getDefault(), "Error during deletion of model file " +
currentResource.getURI().lastSegment() + ".");
rval = false;
}
}
return rval;
}
/** {@inheritDoc} */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment