diff --git a/com.incquerylabs.v4md/gradle.properties b/com.incquerylabs.v4md/gradle.properties index 990fc5c..803d866 100644 --- a/com.incquerylabs.v4md/gradle.properties +++ b/com.incquerylabs.v4md/gradle.properties @@ -1,8 +1,8 @@ version=2.2.1-SNAPSHOT buildNumber=221010 group=com.incquerylabs.v4md -viatraVersion=2.2.0 -viatraIncubationVersion=0.22.0 +viatraVersion=2.3.0-SNAPSHOT +viatraIncubationVersion=0.23.0-SNAPSHOT deployUrl = "build/maven-repository" xtextVersion=2.18.0 deployReleaseUrl=https://build.incquerylabs.com/nexus/repository/v4md-releases/ diff --git a/com.incquerylabs.v4md/src/main/com/incquerylabs/v4md/internal/MagicDrawProjectEngineContext.java b/com.incquerylabs.v4md/src/main/com/incquerylabs/v4md/internal/MagicDrawProjectEngineContext.java index d44cc69..34dd771 100644 --- a/com.incquerylabs.v4md/src/main/com/incquerylabs/v4md/internal/MagicDrawProjectEngineContext.java +++ b/com.incquerylabs.v4md/src/main/com/incquerylabs/v4md/internal/MagicDrawProjectEngineContext.java @@ -39,7 +39,7 @@ private void modelSetUpdated() { Set customNotifiers = scope.getCustomNotifiers().collect(Collectors.toSet()); Set projectRoots = scope.getProjectModels().collect(Collectors.toSet()); MagicDrawProjectNavigationHelper navigationHelper = getNavHelper(true); - Set actualModelRoots = navigationHelper.getModelRoots(); + Set actualModelRoots = navigationHelper.getModelRoots().collect(Collectors.toSet()); Set rootsToAdd = Sets.difference(projectRoots, actualModelRoots); Set rootsToRemove = Sets.difference(Sets.difference(actualModelRoots, projectRoots), customNotifiers); diff --git a/com.incquerylabs.v4md/src/main/com/incquerylabs/v4md/internal/MagicDrawProjectNavigationHelper.java b/com.incquerylabs.v4md/src/main/com/incquerylabs/v4md/internal/MagicDrawProjectNavigationHelper.java index eb0eb68..0ba07ab 100644 --- a/com.incquerylabs.v4md/src/main/com/incquerylabs/v4md/internal/MagicDrawProjectNavigationHelper.java +++ b/com.incquerylabs.v4md/src/main/com/incquerylabs/v4md/internal/MagicDrawProjectNavigationHelper.java @@ -1,22 +1,14 @@ package com.incquerylabs.v4md.internal; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; import org.apache.log4j.Logger; -import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.Notifier; import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.viatra.query.runtime.base.api.BaseIndexOptions; -import org.eclipse.viatra.query.runtime.base.api.filters.IBaseIndexObjectFilter; -import org.eclipse.viatra.query.runtime.base.api.filters.IBaseIndexResourceFilter; -import org.eclipse.viatra.query.runtime.base.core.NavigationHelperContentAdapter; import org.eclipse.viatra.query.runtime.base.core.NavigationHelperImpl; -import org.eclipse.viatra.query.runtime.base.exception.ViatraBaseException; import com.nomagic.uml2.ext.jmi.EventSupport; @@ -26,33 +18,8 @@ */ public class MagicDrawProjectNavigationHelper extends NavigationHelperImpl { - /** - * TODO this logger wrapping is a very hacky solution, but until bug - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=549955 is fixed, it is not - * possible to overwrite the message any other way - */ - private static final class WrappedLogger extends Logger { - private WrappedLogger(Logger source) { - super(source.getName()); - parent = source; - repository = source.getLoggerRepository(); - } - - @Override - public void error(Object message) { - if (message instanceof String && ((String)message).contains("This indicates some errors in underlying model representation.")) { - super.debug(message); - } else { - super.error(message); - } - } - } - - private Logger logger; - public MagicDrawProjectNavigationHelper(Notifier emfRoot, BaseIndexOptions options, EventSupport eventSupport, Logger logger) { - super(emfRoot, options, new WrappedLogger(logger)); - this.logger = logger; + super(emfRoot, options, logger); // TODO While this change helps avoiding some duplicate notifications, it causes // a regression when adding a new project usage to a local project: when the // usage is added, event firing is turned off, resulting in the added profile @@ -69,44 +36,50 @@ public MagicDrawProjectNavigationHelper(Notifier emfRoot, BaseIndexOptions optio // }; } - Set getModelRoots() { - return modelRoots; - } - public boolean isIndexed(EObject element) { - return EcoreUtil.isAncestor(modelRoots, element); + return EcoreUtil.isAncestor(getModelRoots().collect(Collectors.toSet()), element); } + @Override + public Stream getModelRoots() { + // Override is used to update visibility + return super.getModelRoots(); + } + + @Override public void removeRoot(Notifier root) { - if (!((root instanceof EObject) || (root instanceof Resource) || (root instanceof ResourceSet))) { - throw new ViatraBaseException(ViatraBaseException.INVALID_EMFROOT); - } - - if (!modelRoots.contains(root)) - return; + // Override is used to update visibility + super.removeRoot(root); + } - if (root instanceof Resource) { - IBaseIndexResourceFilter resourceFilter = getBaseIndexOptions().getResourceFilterConfiguration(); - if (resourceFilter != null && resourceFilter.isResourceFiltered((Resource) root)) - return; - } - final IBaseIndexObjectFilter objectFilter = getBaseIndexOptions().getObjectFilterConfiguration(); - if (objectFilter != null && objectFilter.isFiltered(root)) - return; + @Override + protected void logIncidentAdapterRemoval(Notifier notifier) { + // Do not report such cases in MagicDraw + } - // no veto by filters - modelRoots.remove(root); - // TODO contentAdapter.removeAdapter(root); removeAdapter is not visible here - Method method; - try { - method = contentAdapter.getClass().getMethod("removeAdaper", Notifier.class); - method.setAccessible(true); - method.invoke(contentAdapter, root); - } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - logger.fatal("Error while updating project", e); - } - notifyBaseIndexChangeListeners(); + @Override + protected void logIncidentFeatureTupleInsertion(Object value, EObject holder, Object featureKey) { + // Do not report such cases in MagicDraw + } + + @Override + protected void logIncidentFeatureTupleRemoval(Object value, EObject holder, Object featureKey) { + // Do not report such cases in MagicDraw + } + + @Override + protected void logIncidentInstanceInsertion(Object keyClass, EObject value) { + // Do not report such cases in MagicDraw + } + + @Override + protected void logIncidentInstanceRemoval(Object keyClass, EObject value) { + // Do not report such cases in MagicDraw + } + + @Override + protected void logIncidentStatRemoval(Object key) { + // Do not report such cases in MagicDraw } - } \ No newline at end of file