Commit 6cdc4e9f authored by Simon Barner's avatar Simon Barner

Merge branch 'master' of https://git.fortiss.org/af3/kernel.git into 3712

parents 46b00a22 2c91927f
ColumnHandle.java 8fc5f04cbb0127e5df8c7a9e3b2620502bf93716 GREEN
GenericAnnotationView.java 6d5569d9a346d5fd60d28a1c60baa9963b5a4010 GREEN
GenericAnnotationView.java 68a6eb91a4db97a58ebfacf400e73c297ab6b1a3 GREEN
......@@ -15,6 +15,7 @@
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.annotation.view.generic;
import static org.apache.commons.lang3.reflect.MethodUtils.getMatchingMethod;
import static org.fortiss.tooling.base.ui.annotation.editingsupport.EditingSupportFactory.createEditingSupport;
import static org.fortiss.tooling.base.ui.annotation.labelprovider.LabelProviderFactory.createLabelProvider;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
......@@ -298,7 +299,7 @@ public class GenericAnnotationView extends AnnotationViewPartBase {
*/
private void setTableItemHeight(Table table, int height) {
try {
Method method = table.getClass().getDeclaredMethod("setItemHeight", int.class);
Method method = getMatchingMethod(table.getClass(), "setItemHeight", int.class);
if(method != null) {
boolean accessible = method.canAccess(table);
if(method.trySetAccessible()) {
......
AutoLayoutMenu.java bca7986c209678ed937548a37db494430877d80e GREEN
AutoLayoutMenu.java 67dc2d04a6f39ec72ea640b745997baa8ff63a49 GREEN
DiagramTapeMeasure.java 72454e6fe5225dab11d3d691baad93aab7a171c0 GREEN
IAutoLayouter.java de1b11d9e202c7e23352ad85684dbf8a3fd17c7d GREEN
IAutoLayouterTapeMeasure.java df186e0ba505e0ecda211b1df76cf12f3245b47e GREEN
......
......@@ -82,8 +82,10 @@ public class AutoLayoutMenu implements IContextMenuContributor {
* outgoing {@link IConnection}.
*/
private boolean hasConnectedConnectorWithAngle(IHierarchicElement element) {
for(IConnector connector : element.getConnectors()) {
if(getAngle((ILayoutedModelElement)connector, CONNECTOR_ANGLE) != null) {
for(ILayoutedModelElement conLayouted : pickInstanceOf(ILayoutedModelElement.class,
element.getConnectors())) {
if(getAngle(conLayouted, CONNECTOR_ANGLE) != null) {
IConnector connector = (IConnector)conLayouted;
return !connector.getIncoming().isEmpty() || !connector.getOutgoing().isEmpty();
}
}
......
......@@ -37,9 +37,11 @@
</extension>
<extension point="org.fortiss.tooling.kernel.migrationProvider">
<migrationProvider migrationProvider="org.fortiss.tooling.base.migration.AddMissingAnnotationsMigrationProvider">
<objectClass objectClass="org.fortiss.tooling.base.model.element.IModelElement"/>
</migrationProvider>
<migrationProvider migrationProvider="org.fortiss.tooling.base.migration.RemoveDuplicatedAnnotationsMigrationProvider">
<objectClass objectClass="org.fortiss.tooling.kernel.extension.data.ITopLevelElement"/>
<objectClass objectClass="org.fortiss.tooling.base.model.element.IModelElement"/>
</migrationProvider>
</extension>
</plugin>
ConnectionCompositorBase.java 692689b535d7136acab2ab67a015f70809e64b6b GREEN
ConnectorCompositorBase.java 0264edd4034da7187d1dbdf35a674c7067adf3cd GREEN
ConnectorConnectionCompositorBase.java eed310a4710492b7ce3bc302c3db4e5c40f4d817 GREEN
ConnectorHierarchicElementConnectionCompositorBase.java 7a8e4acf235d5eb006c859056cce89fbb0aac05d GREEN
ConstraintInstanceContainerCompositor.java 9cb23f13c6cddba18ac7f9dcfd1afd9e7bce4d77 GREEN
......
/*-------------------------------------------------------------------------+
| Copyright 2017 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.compose;
import static org.fortiss.tooling.base.utils.RectangleLayoutUtils.layoutConnectorInRectangle;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.base.dnd.ElementDropContext;
import org.fortiss.tooling.base.model.element.IConnector;
import org.fortiss.tooling.base.model.element.IHierarchicElement;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.model.layout.Point;
import org.fortiss.tooling.kernel.extension.data.IElementCompositionContext;
import org.fortiss.tooling.kernel.extension.data.Prototype;
/**
* Compositor base class for {@link IConnector}s.
*
* @author zverlov
* @author barner
*/
public abstract class ConnectorCompositorBase<T extends IHierarchicElement & ILayoutedModelElement>
extends HierarchicElementCompositorBase<T> {
/** {@inheritDoc} */
@Override
public boolean canCompose(T container, EObject contained, IElementCompositionContext context) {
return isCorrectElementClass(contained);
}
/** {@inheritDoc} */
@Override
public boolean canComposePrototype(Prototype prototype) {
return isCorrectElementClass(prototype.getPrototype());
}
/** {@inheritDoc} */
@Override
public boolean compose(T container, EObject contained, IElementCompositionContext context) {
super.compose(container, contained, context);
if(isCorrectElementClass(contained)) {
IConnector connector = (IConnector)contained;
if(context instanceof ElementDropContext) {
final ElementDropContext ctx = (ElementDropContext)context;
Point ctxPosition = ctx.getPosition();
if(((ElementDropContext)context).isRootFigureCanvas()) {
ctxPosition.translate(ctx.getViewLocationZoomed());
}
layoutConnectorInRectangle((ILayoutedModelElement)connector, container,
ctxPosition);
}
container.getConnectors().add(connector);
return true;
}
return false;
}
/** {@inheritDoc} */
@Override
public boolean canDecompose(EObject contained) {
return isCorrectElementClass(contained);
}
/** Returns whether the given element is of an acceptable class. */
protected abstract boolean isCorrectElementClass(EObject element);
}
AddMissingAnnotationsMigrationProvider.java a3f2b3cbcd39f85e15bc998650f899f55d9f563e GREEN
RemoveDuplicatedAnnotationsMigrationProvider.java f1bdb4733d5b9c6003a2b7fee59b89240a0a3b61 GREEN
RemoveOutdatedAnnotationInstanceMigrationProvider.java 29c29f2bb7515cad1de45a30ffc185001b47a016 GREEN
/*-------------------------------------------------------------------------+
| Copyright 2019 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.migration;
import static org.fortiss.tooling.base.utils.AnnotationUtils.instantiateAnnotationsRecursive;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.xml.type.AnyType;
import org.fortiss.tooling.base.model.element.IModelElement;
import org.fortiss.tooling.kernel.extension.IMigrationProvider;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
/**
* Adds missing annotations to {@link IModelElement}s.
*
* @author diewald
*/
public class AddMissingAnnotationsMigrationProvider implements IMigrationProvider {
/** Remembers the processed {@link ITopLevelElement}s. */
private Collection<ITopLevelElement> migratedProjects = new ArrayList<>();
/** {@inheritDoc} */
@Override
public boolean needMigration(ITopLevelElement modelElement,
Map<EObject, AnyType> unknownFeatures) {
if(migratedProjects.contains(modelElement)) {
return false;
}
return true;
}
/** {@inheritDoc} */
@Override
public void migrate(ITopLevelElement modelElement, Map<EObject, AnyType> unknownFeatures) {
EObject rootElement = modelElement.getRootModelElement();
instantiateAnnotationsRecursive(rootElement);
migratedProjects.add(modelElement);
}
}
AngleUtils.java 462551eae71738ff51f92c9906bff9a21a375d2b GREEN
AnnotationUtils.java 1da750d19d92658b0bdf6bc18ceb18aa667e557b GREEN
AnnotationUtils.java d97bf564f04487c2628a4ab03f93726bc2de8678 GREEN
BaseMathUtils.java 65f6c39b641cba3c984a38f42b1bbf7dbf3287a3 GREEN
BaseModelElementUtils.java b8775b7a462efc168cf79a017aa3377a782d10f6 GREEN
ConstraintsBaseUtils.java bba938b43756ce6f35c338f6cef21c3ab5d49a9d GREEN
......
......@@ -32,6 +32,7 @@ import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.fortiss.tooling.base.ToolingBaseActivator;
import org.fortiss.tooling.base.annotation.AnnotationEntry;
......@@ -103,6 +104,16 @@ public class AnnotationUtils {
return value;
}
/**
* Predicate if for the given {@link IModelElement}, an annotation of the given {@code type} has
* been registered.
*/
public static boolean hasAnnotation(IModelElement modelElement,
Class<? extends IAnnotatedSpecification> type) {
IAnnotationValueService as = IAnnotationValueService.getInstance();
return as.getAnnotationEntry(modelElement).getSpecification(type) != null;
}
/**
* <p>
* Returns the annotation of a given {@code Class<T>} from a given {@code modelElement}. If the
......@@ -295,13 +306,16 @@ public class AnnotationUtils {
* convenient).
*
* @param element
* {@link IModelElement} for which annotations should be instantiated recursively.
* {@link EObject} for which annotations should be instantiated recursively.
*/
public static void instantiateAnnotationsRecursive(IModelElement element) {
public static void instantiateAnnotationsRecursive(EObject element) {
IAnnotationValueService as = IAnnotationValueService.getInstance();
as.instantiateAnnotations(element);
if(element instanceof IModelElement) {
as.instantiateAnnotations((IModelElement)element);
}
for(IModelElement child : getChildrenWithType(element, IModelElement.class)) {
as.instantiateAnnotations(child);
}
}
}
......@@ -5,7 +5,7 @@ ConstraintUIService.java 433e35bb1c9bbc628c6ee070ff45632400becf4a GREEN
ContextMenuService.java ca3c899293f25b70ce8e5f0d86ca2f9683329d81 GREEN
EditPartFactoryService.java e9180c0020f1769d9e24ef3c08f9ca5599dbc5c3 GREEN
MarkerService.java b01b7706034691683df7bbc2e7828c42574b3147 GREEN
ModelEditorBindingService.java 0239c01eef78854fa4abd2df90d93a2b06d60593 GREEN
ModelEditorBindingService.java 948fcdc298a74e366351ad8835a145af6cd238be GREEN
ModelElementHandlerService.java 07a30545ad687ff0fe13bf7a9348c41fb03e0b2c GREEN
NavigatorService.java 2b1361eac805996e22e5409dafff9707fbac3376 GREEN
ToolingKernelUIInternal.java 38903445a9084b7908716a00f41621dfb3126fca GREEN
......
......@@ -33,6 +33,7 @@ import org.eclipse.ui.IPartService;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.fortiss.tooling.kernel.ToolingKernelActivator;
......@@ -220,12 +221,9 @@ public class ModelEditorBindingService extends EObjectAwareServiceBase<IModelEdi
/** Closes the given editor. */
private void closeEditor(final IEditorPart editor) {
editor.getSite().getShell().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
editor.getSite().getPage().closeEditor(editor, false);
}
});
IWorkbenchPartSite editorSite = editor.getSite();
IWorkbenchPage page = editorSite.getPage();
editorSite.getShell().getDisplay().asyncExec(() -> page.closeEditor(editor, false));
}
/** {@inheritDoc} */
......
......@@ -2,7 +2,7 @@ IConnectionCompositionContext.java 6996c671d8730f77c9d87ea2c91a6f5a15082f4c GREE
IConstraintViolation.java a7aba9e6aac1a0e719b8f150804125d83d6726a6 GREEN
IElementCompositionContext.java 926c066ba90e95bd5ef3fd84db8d4f244fc085cd GREEN
ILogMessageContext.java 46c9a8875284460cace6978993690b3f12864bd9 GREEN
ITopLevelElement.java 1cb0265231c2c6afb7478a7f9e343428d7e0a913 GREEN
ITopLevelElement.java 2ad9cb67474b6506ee9a6c19bde055fa626b5876 GREEN
ITransformationContext.java f00a0ab19a410c3ae2fc6256483aeb4207a86395 GREEN
LibraryPrototype.java 1d5f99a4bc0e203590c07406a616a2ce11e20ce0 GREEN
LogMessage.java 14204ed9d51b356f50be52362247cfbbe0cbd5c7 GREEN
......
......@@ -119,11 +119,4 @@ public interface ITopLevelElement {
/** Returns the resource set. */
ResourceSet getResourceSet();
/**
* Perform saving of the model and states the last change as intended.
* Added to solve issue #2140.
*/
void doSaveAndResetLastChangeWasIntended(IProgressMonitor monitor)
throws IOException, CoreException;
}
......@@ -2,14 +2,14 @@ CommandStackService.java 957bda69b5feb91f002aed4d25ed334e92801e7e GREEN
ConnectionCompositorService.java d69a60cd7a3d06e91d24fd32b9c00125ea71e0dd GREEN
ConstraintCheckerService.java 459b5eb717598e7e8bb71a0c87e57ea85cb00e4b GREEN
ConstraintService.java 139187909523300c80a22be920329f1c9d0fb654 GREEN
DummyTopLevelElement.java 42ae59a6a89a57035644d04f9f0f2d674797642a GREEN
DummyTopLevelElement.java 8394597464707992cd053e68129bb87ce9f696db GREEN
ElementCompositorService.java 98c5d27e09881e60aa4f87c1ac0c7787cdec9f7c GREEN
LibraryPrototypeProvider.java b77eddbdca78f561ffb1233e98817be361c690ae GREEN
LibraryService.java d22671ba820466062852c15873698adf28960d94 GREEN
LoggingService.java da784259f7b456b54bf75c41ec268f64919ce78d GREEN
MigrationService.java 26d8590870f9322d4a1886fe510f9783b0efd087 GREEN
MigrationService.java 632c13563a3d69681e2a608023fcdadbe5340c4b GREEN
PersistencyService.java 103eef642c038ef63fa49b743d803aaa3fea2724 GREEN
PrototypeService.java 18c3db05ab11f189a9711bf241c3c7f35c954a9e GREEN
ToolingKernelInternal.java efd435f8c39e072fa9ec422deefff23d95607d25 GREEN
ToolingKernelInternal.java d624a5f6b237ce993e150e2b8d1b4390e3fc8f7a GREEN
TransformationService.java 3cdb86fe920158f93cd9466c6ef9697b2dd8ca7f GREEN
TutorialService.java 675d3f365ce062869f86baa3779d50687674bda0 GREEN
......@@ -186,12 +186,6 @@ final class DummyTopLevelElement implements ITopLevelElement, CommandStackListen
// ignore
}
/** {@inheritDoc} */
@Override
public void doSaveAndResetLastChangeWasIntended(IProgressMonitor monitor) {
// ignore
}
/** {@inheritDoc} */
@Override
public String getId(EObject modelElement) {
......
......@@ -16,10 +16,13 @@
package org.fortiss.tooling.kernel.internal;
import static java.util.Collections.emptyList;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.getFirstChildWithType;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.common.util.BasicEList;
......@@ -86,7 +89,12 @@ public class MigrationService extends ObjectAwareServiceBase<IMigrationProvider>
/** {@inheritDoc} */
@Override
public boolean needMigration(ITopLevelElement input, Map<EObject, AnyType> unknownFeatures) {
return getProvider(input, unknownFeatures) != null;
for(IMigrationProvider provider : getProviders(input)) {
if(provider.needMigration(input, unknownFeatures)) {
return true;
}
}
return false;
}
/** Extracts the list of feature names from a map of features. */
......@@ -105,24 +113,34 @@ public class MigrationService extends ObjectAwareServiceBase<IMigrationProvider>
/** {@inheritDoc} */
@Override
public void migrate(final ITopLevelElement input, final Map<EObject, AnyType> unknownFeatures) {
input.runAsCommand(new Runnable() {
input.runAsNonDirtyingCommand(new Runnable() {
@Override
public void run() {
IMigrationProvider provider;
while(null != (provider = getProvider(input, unknownFeatures))) {
provider.migrate(input, unknownFeatures);
for(IMigrationProvider provider : getProviders(input)) {
if(provider.needMigration(input, unknownFeatures)) {
provider.migrate(input, unknownFeatures);
}
}
if(!unknownFeatures.isEmpty()) {
error(ToolingKernelActivator.getDefault(),
input.getSaveableName() + " contains one or more unknown feature(s): " +
featuresToStrings(unknownFeatures));
}
for(IMigrationProvider provider : getProviders(input)) {
if(provider.needMigration(input, unknownFeatures)) {
error(ToolingKernelActivator.getDefault(),
"Migrating " + input.getSaveableName() + " failed: A need for " +
"migration is indicated although the migration was " +
"already performed. Please fix the migrator (or model).");
}
}
}
});
try {
input.doSaveAndResetLastChangeWasIntended(new NullProgressMonitor());
input.doSave(new NullProgressMonitor());
} catch(Exception e) {
error(ToolingKernelActivator.getDefault(), "Error during migration of model!", e);
......@@ -133,15 +151,18 @@ public class MigrationService extends ObjectAwareServiceBase<IMigrationProvider>
}
}
/** Get the suitable {@link IMigrationProvider} for the given input. */
private IMigrationProvider getProvider(ITopLevelElement input,
Map<EObject, AnyType> unknownFeatures) {
for(IMigrationProvider provider : getAllHandlers()) {
if(provider.needMigration(input, unknownFeatures)) {
return provider;
/** Get all suitable {@link IMigrationProvider} for the given input. */
private List<IMigrationProvider> getProviders(ITopLevelElement input) {
List<IMigrationProvider> providers = new ArrayList<>();
EObject migElement = input.getRootModelElement();
for(Entry<Class<?>, List<IMigrationProvider>> migEntry : handlerMap.entrySet()) {
if(getFirstChildWithType(migElement, migEntry.getKey()) != null) {
providers.addAll(migEntry.getValue());
}
}
return null;
return providers;
}
/** {@inheritDoc} */
......
......@@ -22,19 +22,22 @@ import org.fortiss.tooling.kernel.internal.storage.eclipse.EclipseResourceStorag
/**
* Implementation of the kernel initialization and startup.
*
* Initialize: Process meta information of services such that they are ready to use.
* Start: Services process information from the loaded models.
*
* @author hoelzl
*/
public final class ToolingKernelInternal {
/** Initialize the kernel services. */
public static void initializeKernel() {
printPhase("Tooling Kernel initializing ...");
EclipseResourceStorageService.getInstance().initializeService();
CommandStackService.getInstance().initializeService();
ConnectionCompositorService.getInstance().initializeService();
ConstraintCheckerService.getInstance().initializeService();
ConstraintService.getInstance().initializeService();
ElementCompositorService.getInstance().initializeService();
MigrationService.getInstance().initializeService();
EclipseResourceStorageService.getInstance().initializeService();
LibraryService.getInstance().initializeService();
LoggingService.getInstance().initializeService();
PersistencyService.getInstance().initializeService();
......@@ -47,13 +50,15 @@ public final class ToolingKernelInternal {
/** Starts the kernel services. */
public static void startKernel() {
printPhase("Tooling Kernel starting ...");
// EclipseResourceStorageService must be started first to make the loaded model available
// for the start phases of other services.
EclipseResourceStorageService.getInstance().startService();
CommandStackService.getInstance().startService();
ConnectionCompositorService.getInstance().startService();
ConstraintCheckerService.getInstance().startService();
ConstraintService.getInstance().startService();
ElementCompositorService.getInstance().startService();
MigrationService.getInstance().startService();
EclipseResourceStorageService.getInstance().startService();
LibraryService.getInstance().startService();
LoggingService.getInstance().startService();
PersistencyService.getInstance().startService();
......
AutoUndoCommandStack.java fc326adf66c6cea2354884cdc240da5f2f82689a GREEN
EMFTransactionalCommand.java ba4b5bead9768b6ce6c955b9238cd96cb722533c GREEN
EclipseResourceStorageService.java 88526c8e28906d431a31696b7a0d9b193e6db6ed GREEN
ModelContext.java 3f89919e0c06ebbc08ddb970bf6254db013dd5aa GREEN
EclipseResourceStorageService.java e29e32272286921c5e43963253902b3ba54490c7 GREEN
ModelContext.java 55de5f19c5d625f935fb8136ff72d80b3a54ff19 GREEN
NonDirtyingEMFTransactionalCommand.java d288ebe35d22442c603496b0c917fb99a8febeea GREEN
......@@ -109,14 +109,17 @@ public class EclipseResourceStorageService
private final Map<EObject, ModelContext> rootElementContexts =
new IdentityHashMap<EObject, ModelContext>();
/** Starts the storage provider. */
/** Initializes the storage provider. */
public void initializeService() {
setupLocationProviders();
searchWorkspaceForModels();
}
/** Starts the storage provider. */
public void startService() {
// Load models after the initialization phase: All model-related actions can thus rely on
// fully initialized services (e.g., all handlers are available).
searchWorkspaceForModels();
IPersistencyService.getInstance().registerModelStorageProvider(this);
// register resource change listener last, since on-disk changes
// are discovered during workspace search, thus introducing a possible
......@@ -211,9 +214,7 @@ public class EclipseResourceStorageService
} else if(changeKind == REMOVED && isLoaded(file)) {
unloadContext(file);
} else if(changeKind == CHANGED) {
if(isLoaded(file)) {
handleChange(file);
} else {
if(!isLoaded(file)) {
loadContext(file);
}
}
......@@ -258,16 +259,6 @@ public class EclipseResourceStorageService
}.schedule();
}
/** Handles a change of the given file (which is actually managed). */
private void handleChange(IFile file) {
ModelContext context = loadedContexts.get(file);
// this avoids to reload the context when itself caused the disk change
if(!context.getAndResetLastChangeWasCausedByModelContext()) {
unloadContext(file);
loadContext(file);
}
}
/** Returns whether the given file has been loaded by this manager. */
public synchronized boolean isLoaded(IFile file) {
return loadedContexts.containsKey(file);
......
......@@ -91,9 +91,6 @@ class ModelContext implements ITopLevelElement, CommandStackListener {
/** Stores the command stack listener for this context. */
private final List<CommandStackListener> listeners = new LinkedList<CommandStackListener>();
/** Flag for remembering whether the last change of the file was intended. */
private boolean lastChangeWasIntended = false;
/** The maximal ID used in this model (used to generate new IDs). */
private int maxId = -1;
......@@ -280,9 +277,6 @@ class ModelContext implements ITopLevelElement, CommandStackListener {
/** Returns whether the model is dirty (i.e. if there are unsaved changes). */
@Override
public boolean isDirty() {
if(lastChangeWasIntended) {
return false;
}
return ((BasicCommandStack)editingDomain.getCommandStack()).isSaveNeeded();
}
......@@ -320,8 +314,6 @@ class ModelContext implements ITopLevelElement, CommandStackListener {
} catch(IOException e) {
exception = e;
} finally {
// avoid reloading due to disk content change
setLastChangeWasCausedByModelContext();
monitor.worked(1);
try {
......@@ -393,33 +385,6 @@ class ModelContext implements ITopLevelElement, CommandStackListener {
return res;
}
/**
* Perform saving of the model and states the last change as intended.
* Added to solve issue #2140.
*/
@Override
public void doSaveAndResetLastChangeWasIntended(IProgressMonitor monitor)
throws IOException, CoreException {
doSave(monitor);
getAndResetLastChangeWasCausedByModelContext();
}
/**
* Returns whether the last change was caused by a save. This method has a
* side effect! The {@link #lastChangeWasIntended} flag will be reset, so
* this method should only be called once per change event.
*/
/* package */synchronized boolean getAndResetLastChangeWasCausedByModelContext() {
final boolean result = lastChangeWasIntended;
lastChangeWasIntended = false;
return result;
}
/** Sets the {@link #lastChangeWasIntended} flag to true. */
/* package */synchronized void setLastChangeWasCausedByModelContext() {
lastChangeWasIntended = true;
}
/** Runs the given runnable as a command. */
@Override
public void runAsCommand(final Runnable runnable) {
......
EMFTypeMap.java b6c39465568f0edbfbd5c90400a4f519c042d423 GREEN
EMFTypeToTypeMap.java 294abe02e7af4ad751d8760b6c6286a3c1f6d73f GREEN
EMFTypeToTypeSetMap.java 47ab03966258e7512fa990eb5d420f5787dff3eb GREEN
EMFTypeToTypeSetMap.java d131702e4f04ef8d8a2c70113dce2c628ce65c3d GREEN
TypeSet.java e18e66236b223eaf4c22037459779b421a0c2703 GREEN
......@@ -15,9 +15,53 @@
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.service.types;
import static java.util.Collections.emptyList;
import static java.util.Collections.unmodifiableCollection;
import static java.util.stream.Collectors.toList;
import java.util.Collection;
import java.util.Set;
import java.util.function.Predicate;
/** Maps a given EMF type to a {@link Set} of types. */
public class EMFTypeToTypeSetMap<S, T> extends EMFTypeMap<S, TypeSet<T>> {
// Nothing to do
/** Adds the given {@code targetType} to the mapped types of the given {@code sourceType}. */