Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • af3/kernel
  • diewald/kernel
2 results
Show changes
Commits on Source (3)
CopyAction.java cc58c9f52b8d0b8698a9905ffadff7c37976481b GREEN
CutAction.java 6e963d94aeea85676beb38489748002b6d13346a GREEN
DeleteAction.java 3a7af66b4b6de8335aea3d415400672093743e22 GREEN
DeleteAction.java c4aed864d899a4c6ae727ad0a5f438f387ee2a69 GREEN
PasteAction.java f834f26660a664f138c19d82ace7b17ecc18603f GREEN
RedoAction.java d91086533289a4175e7f5ee949b31a0edc86672a GREEN
RenameAction.java 8049a91748366eec6a7c08622eac29d97950ade2 GREEN
......
......@@ -17,11 +17,10 @@ package org.fortiss.tooling.kernel.ui.internal.actions;
import static org.eclipse.ui.PlatformUI.getWorkbench;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import static org.fortiss.tooling.kernel.utils.ResourceUtils.getIFile;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
......@@ -38,7 +37,6 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.jface.dialogs.IDialogConstants;
......@@ -58,7 +56,6 @@ import org.fortiss.tooling.kernel.ui.ToolingKernelUIActivator;
import org.fortiss.tooling.kernel.ui.extension.base.EObjectActionBase;
import org.fortiss.tooling.kernel.ui.internal.editor.ExtendableMultiPageEditor;
import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService;
import org.fortiss.tooling.kernel.utils.ResourceUtils;
/**
* The {@link DeleteAction} uses the {@link IElementCompositorService} and the
......@@ -81,12 +78,6 @@ public class DeleteAction extends EObjectActionBase<EObject> {
*/
private final ITopLevelElement topElement;
/**
* {@link URI}s of {@link Resource}s that directly or indirectly reference
* {@link #topElement}.
*/
private Collection<URI> uris = Collections.emptySet();
/** {@link Shell} used to display dialog. */
private Shell sh;
......@@ -104,23 +95,8 @@ public class DeleteAction extends EObjectActionBase<EObject> {
/** {@inheritDoc} */
@Override
protected IStatus run(IProgressMonitor progressMonitor) {
// Check if there are further resources that reference the resource to be deleted. If
// so, extend confirmation dialog accordingly.
Resource resource = topElement.getRootModelElement().eResource();
uris = ResourceUtils.getReferencingResourceURIs(resource, false, progressMonitor);
String message =
"Are you sure you want to delete '" + topElement.getSaveableName() + "'?";
if(!uris.isEmpty()) {
message +=
"\n\nNote that this model also references the following external resources:\n\n";
for(URI uri : uris) {
message += " - " + URI.decode(uri.lastSegment()) + "\n";
}
}
final MessageDialog dialog = new MessageDialog(sh, "Confirm Delete", null, message,
final MessageDialog dialog = new MessageDialog(sh, "Confirm Delete", null,
"Are you sure you want to delete '" + topElement.getSaveableName() + "'?",
MessageDialog.QUESTION,
new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL}, 0) {
@Override
......@@ -137,16 +113,13 @@ public class DeleteAction extends EObjectActionBase<EObject> {
});
if(dialog.getReturnCode() == 0) {
IContainer parent = ResourceUtils.getIFile(resource).getParent();
IContainer parent =
getIFile(topElement.getRootModelElement().eResource()).getParent();
// Close all opened views belonging to the deleted project
IModelEditorBindingService.getInstance()
.closeEditors(topElement.getRootModelElement());
for(URI externalModelURIs : uris) {
topElement.getResourceSet().createResource(externalModelURIs);
}
// Deletes the entire resource set, including its external models
topElement.delete();
......
AutoUndoCommandStack.java fc326adf66c6cea2354884cdc240da5f2f82689a GREEN
EMFTransactionalCommand.java ba4b5bead9768b6ce6c955b9238cd96cb722533c GREEN
EclipseResourceStorageService.java e917c822c53eacada70188e66215d91241a29a5c GREEN
ModelContext.java db1735834c85e7b508266f56463d011f2b72af0e GREEN
ModelContext.java efa60d240cd7bd8900685c35afcc87f56e6995fb GREEN
NonDirtyingEMFTransactionalCommand.java d288ebe35d22442c603496b0c917fb99a8febeea GREEN
......@@ -17,7 +17,6 @@ package org.fortiss.tooling.kernel.internal.storage.eclipse;
import static java.lang.Math.max;
import static org.eclipse.emf.common.util.URI.createPlatformResourceURI;
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;
......@@ -46,9 +45,7 @@ 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;
......@@ -283,7 +280,7 @@ class ModelContext implements ITopLevelElement, CommandStackListener {
/** Perform saving of the model. */
@Override
public synchronized void doSave(IProgressMonitor monitor) throws IOException, CoreException {
monitor.beginTask("Saving...", rset.getResources().size() + 2);
monitor.beginTask("Saving...", 2);
// Step 1: Validate resource managed by kernel
// Perform ID checking before safe to not produce inconsistent models
......@@ -328,22 +325,6 @@ class ModelContext implements ITopLevelElement, CommandStackListener {
}
}
// Step 3..n: Save resources not managed by kernel
for(Resource currentResource : rset.getResources()) {
if(currentResource != resource && !editingDomain.isReadOnly(currentResource) &&
!currentResource.getContents().isEmpty()) {
// do not save resources which are not contained (by a FileProject)
try {
currentResource.save(saveOptions);
} catch(IOException e) {
if(exception == null) {
exception = e;
}
} finally {
monitor.worked(1);
}
}
}
monitor.done();
if(exception == null) {
......@@ -505,39 +486,15 @@ class ModelContext implements ITopLevelElement, CommandStackListener {
@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);
} catch(CoreException e) {
String msg = "Error during deletion of model file " + getFile().getName() + ".";
error(ToolingKernelActivator.getDefault(), msg);
rval = false;
}
// The, delete all other resources
for(Resource currentResource : resourcesToDelete) {
try {
currentResource.delete(null);
} catch(IOException e) {
String msg = "Error during deletion of model file ";
msg += currentResource.getURI().lastSegment() + ".";
error(ToolingKernelActivator.getDefault(), msg);
rval = false;
}
return false;
}
return rval;
return true;
}
/** {@inheritDoc} */
......