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 (11)
Showing
with 4 additions and 2848 deletions
......@@ -17,7 +17,6 @@ Export-Package: org.fortiss.tooling.base.ui,
org.fortiss.tooling.base.ui.annotation.view,
org.fortiss.tooling.base.ui.annotation.view.generic,
org.fortiss.tooling.base.ui.annotation.view.generic.filter,
org.fortiss.tooling.base.ui.compose,
org.fortiss.tooling.base.ui.contentprovider,
org.fortiss.tooling.base.ui.dialog,
org.fortiss.tooling.base.ui.dnd.gef,
......
ConstraintBasedProcessCompositor.java 6b98bc9c8096ff6553ffc49040a0919dadb20bae GREEN
/*-------------------------------------------------------------------------+
| Copyright 2011 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.ui.compose;
import static org.eclipse.emf.ecore.util.EcoreUtil.delete;
import static org.fortiss.tooling.base.ui.utils.ConstraintsBaseUIUtils.deactivateConfiguration;
import static org.fortiss.tooling.base.utils.ConstraintsBaseUtils.getDefaultConfig;
import static org.fortiss.tooling.base.utils.ConstraintsBaseUtils.isDefaultConfiguration;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.base.model.element.ConstraintConfiguration;
import org.fortiss.tooling.base.model.element.IConstraintBasedProcess;
import org.fortiss.tooling.kernel.extension.IElementCompositor;
import org.fortiss.tooling.kernel.extension.data.IElementCompositionContext;
import org.fortiss.tooling.kernel.extension.data.Prototype;
import org.fortiss.tooling.kernel.model.IProjectRootElement;
import org.fortiss.tooling.kernel.model.constraints.IConstraintInstanceContainer;
/**
* {@link IElementCompositor} implementation for the {@link IProjectRootElement} s.
*
* @author hoelzl
*/
public class ConstraintBasedProcessCompositor<CBP extends IConstraintBasedProcess>
implements IElementCompositor<CBP> {
/** {@inheritDoc} */
@Override
public boolean canCompose(CBP container, EObject contained,
IElementCompositionContext context) {
return contained instanceof ConstraintConfiguration;
}
/** {@inheritDoc} */
@Override
public boolean compose(CBP container, EObject contained, IElementCompositionContext context) {
ConstraintConfiguration config = (ConstraintConfiguration)contained;
Stream<ConstraintConfiguration> configNamesStream = container.getConfigurations().stream();
List<String> existingNames =
configNamesStream.map(c -> c.getName()).collect(Collectors.toList());
String name = config.getName();
while(existingNames.contains(name)) {
name += " bis";
}
config.setName(name);
container.getConfigurations().add(config);
return true;
}
/** {@inheritDoc} */
@Override
public boolean canComposePrototype(Prototype prototype) {
// As of now constraint configurations should never be added by prototype.
return false;
}
/** {@inheritDoc} */
@Override
public boolean canDecompose(EObject contained) {
return contained instanceof ConstraintConfiguration &&
!isDefaultConfiguration((ConstraintConfiguration)contained);
}
/** {@inheritDoc} */
@Override
public boolean decompose(EObject contained) {
if(contained.eContainer() instanceof IConstraintBasedProcess) {
IConstraintBasedProcess cbdp = (IConstraintBasedProcess)contained.eContainer();
if(contained.equals(cbdp.getCurrentObjective())) {
ConstraintConfiguration defaultConfig = getDefaultConfig(cbdp);
cbdp.setCurrentObjective(defaultConfig);
if(cbdp.eContainer() instanceof IConstraintInstanceContainer) {
IConstraintInstanceContainer cstrContainer =
(IConstraintInstanceContainer)cbdp.eContainer();
deactivateConfiguration((ConstraintConfiguration)contained, cstrContainer,
defaultConfig);
}
}
}
delete(contained);
return true;
}
}
/*-------------------------------------------------------------------------+
| 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.ui.editor;
import static org.eclipse.jface.resource.FontDescriptor.createFrom;
import org.eclipse.jface.resource.FontDescriptor;
import org.eclipse.jface.viewers.StyledString.Styler;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.TextStyle;
import org.eclipse.swt.widgets.Display;
import org.fortiss.tooling.base.model.element.ConstraintConfiguration;
import org.fortiss.tooling.kernel.extension.IConstraint;
// TODO Refactor together with ConstraintBasedProcessEditor and provide a dedicated perspective (see #3189)
/**
* This class is a helper class that provides, 1) the colors for the constraint groups,
* 2) manage the references between the constraint configurations and
* 3) manages the tree manipulation that is used to visualize the constraintsGroups,
* constraintConfigurations and constraints.
*
* @author abid
*
*/
public class ConstraintBasedProcessEditorHelper {
/** Color Array for at least seven groups. */
private static int[] colorArray =
{SWT.COLOR_DARK_GREEN, SWT.COLOR_DARK_BLUE, SWT.COLOR_DARK_YELLOW, SWT.COLOR_BLACK,
SWT.COLOR_DARK_RED, SWT.COLOR_GREEN, SWT.COLOR_CYAN};
/** Counter for the colorArray */
private static int colorCtr = 0;
/** Reference to a constraint configuration. */
private static class WithContextualConfiguration {
/** Contextual constraint configuration. */
ConstraintConfiguration config;
/** Constructor. */
public WithContextualConfiguration(ConstraintConfiguration config) {
this.config = config;
}
}
/** Constraint accompanied with a configuration providing the context. */
public static class ConstraintWithContextualConfiguration extends WithContextualConfiguration {
/** Constraint. */
/* package */Class<? extends IConstraint> cstr;
/** Constructor. */
public ConstraintWithContextualConfiguration(Class<? extends IConstraint> cstr,
ConstraintConfiguration config) {
super(config);
this.cstr = cstr;
}
}
/**
* Configuration accompanied with another configuration providing the context.
* Intent is that the contained configuration is a dependency of the context one.
*/
public static class ConfigurationRefWithContextualConfiguration
extends WithContextualConfiguration {
/** Constraint. */
/* package */ConstraintConfiguration target;
/** Constructor. */
public ConfigurationRefWithContextualConfiguration(ConstraintConfiguration configRef,
ConstraintConfiguration config) {
super(config);
this.target = configRef;
}
/** {@inheritDoc} */
@Override
public boolean equals(Object obj) {
if(obj instanceof ConfigurationRefWithContextualConfiguration) {
// current target name
String currentTargetName = this.target.getName();
// contextualRef Target of the configuration
String configRefTrgtObjName =
((ConfigurationRefWithContextualConfiguration)obj).target.getName();
// current configuration
String currentConfigName = this.config.getName();
// contextualRef Object of the configuration
String configRefObjName =
((ConfigurationRefWithContextualConfiguration)obj).config.getName();
return currentTargetName.equalsIgnoreCase(configRefTrgtObjName) &&
currentConfigName.equalsIgnoreCase(configRefObjName);
}
return false;
}
/** {@inheritDoc} */
@Override
public int hashCode() {
return target.hashCode();
}
}
/** Class to manipulate and store parent of elements. */
public static class TreeStructureNode {
/** Parent object variable. */
/* package */Object parent;
/** Data object variable. */
/* package */Object data;
/** Constructor. */
public TreeStructureNode(Object parent, Object children) {
this.parent = parent;
this.data = children;
}
/** {@inheritDoc} */
@Override
public boolean equals(Object obj) {
if(obj instanceof TreeStructureNode) {
// the current tree node to be compared with
String currentStructureNode = this.data.toString();
// the tree node to be checked
String treeStructureNode = ((TreeStructureNode)obj).data.toString();
// parent of the current tree node
String currentParentNode = this.parent.toString();
// parent of the object that needs to be checked
String objectParentNode = ((TreeStructureNode)obj).parent.toString();
return currentStructureNode.equalsIgnoreCase(treeStructureNode) &&
currentParentNode.equalsIgnoreCase(objectParentNode);
}
return false;
}
/** {@inheritDoc} */
@Override
public int hashCode() {
return parent.hashCode();
}
}
/** Styler class to create colored bold labels for constraint group name. */
public static class NormalFontStyler extends Styler {
/** Counter to keep track of currently used color in color array. */
private int colorIndex = 0;
/** Constructor. */
public NormalFontStyler() {
this.colorIndex = colorCtr;
}
/** {@inheritDoc} */
@Override
public void applyStyles(final TextStyle textStyle) {
FontDescriptor boldDescriptor = createFrom(new FontData()).setStyle(SWT.BOLD);
Font boldFont = boldDescriptor.createFont(Display.getCurrent());
textStyle.font = boldFont;
textStyle.foreground = Display.getCurrent().getSystemColor(colorArray[colorIndex]);
}
}
/** Styler class to create red color labels. */
public static class RedFontStyler extends Styler {
/** {@inheritDoc} */
@Override
public void applyStyles(final TextStyle textStyle) {
FontDescriptor boldDescriptor = createFrom(new FontData()).setStyle(SWT.BOLD);
Font boldFont = boldDescriptor.createFont(Display.getCurrent());
textStyle.font = boldFont;
textStyle.foreground = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_RED);
}
}
/** Styler class to create green color labels. */
public static class GreenFontStyler extends Styler {
/** {@inheritDoc} */
@Override
public void applyStyles(final TextStyle textStyle) {
FontDescriptor boldDescriptor = createFrom(new FontData()).setStyle(SWT.BOLD);
Font boldFont = boldDescriptor.createFont(Display.getCurrent());
textStyle.font = boldFont;
textStyle.foreground = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GREEN);
}
}
/**
* This function is responsible for updating the color of the constraints groups as they are
* added by updating the color counter (i.e., ColorCtr)
*
* @param groupSize
* is the size of the constraints groups
*/
public static void adjustColorIndex(int groupSize) {
colorCtr++;
colorCtr %= groupSize;
}
}
/*-------------------------------------------------------------------------+
| Copyright 2016 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.ui.utils;
import static org.fortiss.tooling.base.utils.ConstraintsBaseUtils.getActiveConstraintsTransitively;
import static org.fortiss.tooling.base.utils.ConstraintsBaseUtils.removeFromConstraintInstanceContainer;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.util.EContentAdapter;
import org.fortiss.tooling.base.model.base.ConstraintBasedProcess;
import org.fortiss.tooling.base.model.element.ConstraintConfiguration;
import org.fortiss.tooling.base.model.element.IConstraintBasedProcess;
import org.fortiss.tooling.kernel.extension.IConstraint;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.model.constraints.IConstrained;
import org.fortiss.tooling.kernel.model.constraints.IConstraintInstanceContainer;
import org.fortiss.tooling.kernel.model.constraints.IConstraintInstanceStatus;
import org.fortiss.tooling.kernel.service.IConstraintService;
import org.fortiss.tooling.kernel.service.IPersistencyService;
import org.fortiss.tooling.kernel.service.listener.IPersistencyServiceListener;
import org.fortiss.tooling.kernel.ui.service.IConstraintUIService;
import org.fortiss.tooling.kernel.utils.EcoreUtils;
/**
* Utility methods related to constraints.
*
* @author aravantinos
*/
public class ConstraintsBaseUIUtils {
/** Factorized behaviour. */
public static void doActivateAll(IConstraintInstanceContainer cstrContainer,
IConstraintBasedProcess cbdProcess) {
// First activate the constraints which should always be activated
for(Class<? extends IConstraint> cstrClass : IConstraintUIService.getInstance()
.getAlwaysActivatedConstraints()) {
IConstraintUIService.getInstance().activate(cstrClass, cstrContainer);
}
// Then activate the constraints of the current objective
ConstraintConfiguration currentObj = cbdProcess.getCurrentObjective();
if(currentObj != null) {
List<Class<? extends IConstraint>> activeCstrs =
getActiveConstraintsTransitively(currentObj, null);
for(Class<? extends IConstraint> cstrClass : activeCstrs) {
IConstraintUIService.getInstance().activate(cstrClass, cstrContainer);
}
}
}
/**
* Activates all constraints which are active in the given configuration, potentially adding new
* constraint instances to the provided container.
*/
public static void activateConfiguration(ConstraintConfiguration config,
IConstraintInstanceContainer cstrContainer) {
for(Class<? extends IConstraint> cstr : getActiveConstraintsTransitively(config, null)) {
IConstraintUIService.getInstance().activate(cstr, cstrContainer);
}
}
/**
* Activates all constraints which are active in the given configuration
* (non-transitively).
*/
public static void activateOneConfiguration(ConstraintConfiguration config,
IConstraintInstanceContainer cstrContainer) {
List<Class<? extends IConstraint>> configConstraints = new ArrayList<>();
for(String name : config.getActiveConstraints()) {
configConstraints.add(IConstraintService.getInstance().getConstraintByName(name));
}
for(Class<? extends IConstraint> cstr : configConstraints) {
IConstraintUIService.getInstance().activate(cstr, cstrContainer);
}
}
/**
* Deactivates all constraints which are active in the given configuration, if they are not
* still active in the provided context.
*/
public static void deactivateConfiguration(ConstraintConfiguration config,
IConstraintInstanceContainer cstrContainer, ConstraintConfiguration context) {
List<Class<? extends IConstraint>> stillActiveConstraints =
getActiveConstraintsTransitively(context, config);
for(Class<? extends IConstraint> cstr : getActiveConstraintsTransitively(config, null)) {
if(!stillActiveConstraints.contains(cstr)) {
IConstraintUIService.getInstance().deactivate(cstr, cstrContainer);
}
}
}
/**
* Deactivates all constraints which are active in the given configuration
*/
public static void deactivateConfiguration(ConstraintConfiguration config,
IConstraintInstanceContainer cstrContainer) {
for(Class<? extends IConstraint> cstr : getActiveConstraintsTransitively(config, null)) {
IConstraintUIService.getInstance().deactivate(cstr, cstrContainer);
}
}
/**
* Deactivates all constraints which are active in the given configuration
* (non-transitively).
*/
public static void deactivateOneConfiguration(ConstraintConfiguration config,
IConstraintInstanceContainer cstrContainer) {
List<Class<? extends IConstraint>> configConstraints = new ArrayList<>();
for(String name : config.getActiveConstraints()) {
configConstraints.add(IConstraintService.getInstance().getConstraintByName(name));
}
for(Class<? extends IConstraint> cstr : configConstraints) {
IConstraintUIService.getInstance().deactivate(cstr, cstrContainer);
}
}
/**
* Factorized behavior to install the various listeners necessary for constraints.
* This made in a generic manner so that the client only needs to give a function providing
* access to a {@link ConstraintBasedProcess} given a {@link ITopLevelElement}. The rest is for
* free.
*/
public static class ConstraintBasedProcessAwareActivator {
/**
* Function to access a {@link ConstraintBasedProcess} given a {@link ITopLevelElement}.
* Project-dependent.
*/
private Function<ITopLevelElement, ConstraintBasedProcess> getConstraintBasedProcess;
/** Constructor. */
public ConstraintBasedProcessAwareActivator(
Function<ITopLevelElement, ConstraintBasedProcess> getConstraintBasedProcess) {
this.getConstraintBasedProcess = getConstraintBasedProcess;
}
/** Start the kernel. */
public void start() {
for(ITopLevelElement top : IPersistencyService.getInstance().getTopLevelElements()) {
installListener(top);
activateAllConstraints(top);
}
IPersistencyService.getInstance()
.addTopLevelElementListener(new ConstraintBasedDevelopmentProcessListener());
}
/** Go through all constraints in <code>top</code> and (re-)activates them. */
private void activateAllConstraints(ITopLevelElement top) {
ConstraintBasedProcess cbp = getConstraintBasedProcess.apply(top);
if(cbp != null) {
IConstraintInstanceContainer cic = cbp.getConstraintInstanceContainer();
try {
doActivateAll(cic, cbp);
// The only case where the activation above can trigger a model change is if it
// is discovered that constraints shall be added.
// This should not happen in most cases: the constraint was normally active when
// the project was left and therefore the constraint should already be present.
// However there is a case where this is not the case: when AF3 developers added
// a new constraint and start then AF3 for the first time; then the constraint
// has to be added (sort of migration of the model actually). In such a case the
// line above will trigger an exception because not run in a command. That is
// the whole reason for the catch block thereafter.
// Note that we do not run the activation directly in a command because we do
// not want to mark the model as dirty for nothing.
} catch(IllegalStateException e) {
top.runAsCommand(() -> doActivateAll(cic, cbp));
}
}
}
/**
* Install the listener triggering activation of constraints for the given top level
* element.
* Returns the installed listener.
*/
private void installListener(ITopLevelElement top) {
ConstraintBasedProcess cbp = getConstraintBasedProcess.apply(top);
if(cbp == null) {
return;
}
IConstraintInstanceContainer cic = cbp.getConstraintInstanceContainer();
EContentAdapter listener = new EContentAdapter() {
private boolean isAlreadyAddingMissingConstraints = false;
/** {@inheritDoc} */
@Override
public void notifyChanged(Notification notification) {
super.notifyChanged(notification);
if(isTouch(notification) || isAlreadyAddingMissingConstraints) {
return;
}
// Do not react to change of status.
if(notification.getNewValue() instanceof IConstraintInstanceStatus) {
return;
}
if(notification.getEventType() == Notification.REMOVE &&
notification.getOldValue() instanceof IConstrained) {
IConstrained constrained = (IConstrained)notification.getOldValue();
removeFromConstraintInstanceContainer(constrained);
}
isAlreadyAddingMissingConstraints = true;
IConstraintUIService.getInstance().addMissingConstraintInstances(cic);
isAlreadyAddingMissingConstraints = false;
}
};
top.getRootModelElement().eAdapters().add(listener);
}
/**
* Listener to (re)activate constraints when the project changes.
* Typically to install adequate constraints when a new element was added to the project.
*/
private class ConstraintBasedDevelopmentProcessListener
implements IPersistencyServiceListener {
/** {@inheritDoc} */
@Override
public void topLevelElementLoaded(ITopLevelElement element) {
// ignore
}
/** {@inheritDoc} */
@Override
public void topLevelElementAdded(ITopLevelElement element) {
installListener(element);
}
/** {@inheritDoc} */
@Override
public void topLevelElementContentChanged(ITopLevelElement element) {
// Not our concern.
}
/** {@inheritDoc} */
@Override
public void topLevelElementRemoved(ITopLevelElement element) {
// Not our concern
}
}
/**
* @param notification
* @return true if <code>notification</code> is not relevant and should be skipped
*/
private static boolean isTouch(Notification notification) {
// Notifications which do not notify about a model change.
if(notification.isTouch()) {
return true;
}
// Notifications initiated by the the AF3 kernel which are only GUI related.
if(notification.getEventType() == EcoreUtils.KERNEL_EMF_EVENT_TYPE_COUNT) {
return true;
}
return false;
}
}
}
base.ecore 598ac2f27293be7344b762471a3570f45e63950d GREEN
base.ecore 6ba521f3458eaf64fc3ee0359e236c9a1201d259 YELLOW
......@@ -181,26 +181,6 @@
<eGenericType eTypeParameter="#//element/IDerivedAnnotation/T"/>
</eOperations>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="IConstraintBasedProcess" abstract="true"
interface="true">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Marker interface for metaclasses to describe constraint-based development processes.&#xD;&#xA;&#xD;&#xA;TODO (refs #3469) Clarify relation to constraint metaclasses in tooling.kernel."/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EReference" name="currentObjective" eType="#//element/ConstraintConfiguration"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="constraintInstanceContainer"
eType="ecore:EClass platform:/resource/org.fortiss.tooling.kernel/model/kernel.ecore#//constraints/IConstraintInstanceContainer"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="configurations" upperBound="-1"
eType="#//element/ConstraintConfiguration" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="ConstraintConfiguration" eSuperTypes="platform:/resource/org.fortiss.tooling.kernel/model/kernel.ecore#//INamedElement">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Hierarchical description of constraint configuration.&#xD;&#xA;&#xD;&#xA;TODO (refs #3469): Clarify relation to constraint metaclasses in tooling.kernel."/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="activeConstraints" upperBound="-1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="includedConfigurations"
upperBound="-1" eType="#//element/ConstraintConfiguration"/>
</eClassifiers>
</eSubpackages>
<eSubpackages name="layout" nsURI="http://www.fortiss.org/tooling/base/model/layout"
nsPrefix="org-fortiss-tooling-base-model-layout">
......@@ -478,16 +458,6 @@
<eTypeArguments eTypeParameter="#//base/DerivedAnnotationBase/T"/>
</eGenericSuperTypes>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="ConstraintInstanceContainer" eSuperTypes="platform:/resource/org.fortiss.tooling.kernel/model/kernel.ecore#//constraints/IConstraintInstanceContainer">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="@deprecated Currently unused. TODO (refs #3469) Caveat: Base class is defined in tooling.kernel."/>
</eAnnotations>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="ConstraintBasedProcess" eSuperTypes="#//element/IConstraintBasedProcess">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Base class for {@link IConstraintBasedProcess}es.&#xD;&#xA;&#xD;&#xA;TODO (refs #3469): Clarify relation to constraint metaclasses in tooling.kernel."/>
</eAnnotations>
</eClassifiers>
</eSubpackages>
<eSubpackages name="visualization" nsURI="http://www.fortiss.org/tooling/base/model/visualization"
nsPrefix="org-fortiss-tooling-base-model-visualization">
......
......@@ -58,18 +58,6 @@
<genOperations ecoreOperation="base.ecore#//element/IDerivedAnnotation/isUserAnnotatedValuePreferred"/>
<genOperations ecoreOperation="base.ecore#//element/IDerivedAnnotation/getUserAnnotatedValue"/>
</genClasses>
<genClasses image="false" ecoreClass="base.ecore#//element/IConstraintBasedProcess">
<genFeatures notify="false" createChild="false" propertySortChoices="true"
ecoreFeature="ecore:EReference base.ecore#//element/IConstraintBasedProcess/currentObjective"/>
<genFeatures notify="false" createChild="false" propertySortChoices="true"
ecoreFeature="ecore:EReference base.ecore#//element/IConstraintBasedProcess/constraintInstanceContainer"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference base.ecore#//element/IConstraintBasedProcess/configurations"/>
</genClasses>
<genClasses image="false" ecoreClass="base.ecore#//element/ConstraintConfiguration">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute base.ecore#//element/ConstraintConfiguration/activeConstraints"/>
<genFeatures notify="false" createChild="false" propertySortChoices="true"
ecoreFeature="ecore:EReference base.ecore#//element/ConstraintConfiguration/includedConfigurations"/>
</genClasses>
</nestedGenPackages>
<nestedGenPackages prefix="Layout" basePackage="org.fortiss.tooling.base.model"
disposableProviderFactory="true" ecorePackage="base.ecore#//layout">
......@@ -172,8 +160,6 @@
<genOperations ecoreOperation="base.ecore#//base/DerivedAnnotationBase/getUserAnnotatedValue"
body="return null;"/>
</genClasses>
<genClasses ecoreClass="base.ecore#//base/ConstraintInstanceContainer"/>
<genClasses ecoreClass="base.ecore#//base/ConstraintBasedProcess"/>
</nestedGenPackages>
<nestedGenPackages prefix="Visualization" basePackage="org.fortiss.tooling.base.model"
disposableProviderFactory="true" ecorePackage="base.ecore#//visualization">
......
/*-------------------------------------------------------------------------+
| Copyright 2011 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.eclipse.emf.ecore.util.EcoreUtil.delete;
import static org.fortiss.tooling.base.utils.ConstraintsBaseUtils.removeFromConstraintInstanceContainer;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.kernel.extension.IElementCompositor;
import org.fortiss.tooling.kernel.extension.data.IElementCompositionContext;
import org.fortiss.tooling.kernel.extension.data.Prototype;
import org.fortiss.tooling.kernel.model.constraints.ConstraintInstance;
import org.fortiss.tooling.kernel.model.constraints.IConstraintInstanceContainer;
/**
* {@link IElementCompositor} implementation for {@link IConstraintInstanceContainer}s.
*
* @author hoelzl
*/
public class ConstraintInstanceContainerCompositor<CIC extends IConstraintInstanceContainer>
implements IElementCompositor<CIC> {
/** {@inheritDoc} */
@Override
public boolean canCompose(CIC container, EObject contained,
IElementCompositionContext context) {
return contained instanceof ConstraintInstance;
}
/** {@inheritDoc} */
@Override
public boolean compose(CIC container, EObject contained, IElementCompositionContext context) {
ConstraintInstance c = (ConstraintInstance)contained;
container.getConstraintInstances().add(c);
return true;
}
/** {@inheritDoc} */
@Override
public boolean canComposePrototype(Prototype prototype) {
// As of now constraints should never be added by prototype.
return false;
}
/** {@inheritDoc} */
@Override
public boolean canDecompose(EObject contained) {
return contained instanceof ConstraintInstance;
}
/** {@inheritDoc} */
@Override
public boolean decompose(EObject contained) {
removeFromConstraintInstanceContainer((ConstraintInstance)contained);
delete(contained);
return true;
}
}
/*-------------------------------------------------------------------------+
| Copyright 2016 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.utils;
import static org.fortiss.tooling.kernel.utils.ConstraintsUtils.getConstraintInstanceContainer;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.common.util.EList;
import org.fortiss.tooling.base.model.element.ConstraintConfiguration;
import org.fortiss.tooling.base.model.element.ElementFactory;
import org.fortiss.tooling.base.model.element.IConstraintBasedProcess;
import org.fortiss.tooling.kernel.extension.IConstraint;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.model.constraints.ConstraintInstance;
import org.fortiss.tooling.kernel.model.constraints.IConstrained;
import org.fortiss.tooling.kernel.model.constraints.IConstraintInstanceContainer;
import org.fortiss.tooling.kernel.service.IConstraintService;
import org.fortiss.tooling.kernel.service.IPersistencyService;
/**
* Utils for constraints.
*
* @author aravantinos
*/
public class ConstraintsBaseUtils {
/** Name of the default configuration. */
public static final String DEFAULT_CONFIGURATION_NAME = "Default configuration";
/** Removes constraints on <code>c</code> from <code>container</code>. */
public static void removeFromConstraintInstanceContainer(IConstrained c) {
EList<ConstraintInstance> toRemove = c.getConstraintInstances();
if(toRemove.isEmpty()) {
// Then there is nothing to do
return;
}
// get(0) because we just checked that the list is not empty, and because the assumption is
// made that the constraint instance container is the same for all the instances in the
// list.
IConstraintInstanceContainer container = getConstraintInstanceContainer(toRemove.get(0));
container.getConstraintInstances().removeAll(toRemove);
for(ConstraintInstance constraint : toRemove) {
for(IConstrained constrained : constraint.getConstraineds()) {
// c needs to be treated separately to avoid concurrent modifications
if(constrained != null && !constrained.equals(c)) {
constrained.getConstraintInstances().remove(constraint);
}
}
}
c.getConstraintInstances().clear();
}
/**
* Removes the constraint instance from its container. Also removes it from its constrained
* elements.
*/
public static void removeFromConstraintInstanceContainer(ConstraintInstance ci) {
IConstraintInstanceContainer container = getConstraintInstanceContainer(ci);
if(container != null) {
container.getConstraintInstances().remove(ci);
}
for(IConstrained cstrd : ci.getConstraineds()) {
cstrd.getConstraintInstances().remove(ci);
}
}
/**
* If <code>config</code> is not already in <code>configList</code>, adds it and its included
* configurations.
*
* <code>exception</code> allows to avoid considering one particular configuration.
* Leave <code>null</code> if irrelevant.
*/
public static void addConfigurationTransitively(List<ConstraintConfiguration> configList,
ConstraintConfiguration config, ConstraintConfiguration exception) {
if(!configList.contains(config) && !config.equals(exception)) {
configList.add(config);
for(ConstraintConfiguration subConfig : config.getIncludedConfigurations()) {
addConfigurationTransitively(configList, subConfig, exception);
}
}
}
/**
* Returns all the configurations included in <code>config</code> transitively, including
* <code>config</code> itself.
*
* <code>exception</code> allows to avoid considering one particular configuration.
* Leave <code>null</code> if irrelevant.
*/
public static List<ConstraintConfiguration> getActiveConfigurationsTransitively(
ConstraintConfiguration config, ConstraintConfiguration exception) {
List<ConstraintConfiguration> res = new ArrayList<>();
addConfigurationTransitively(res, config, exception);
return res;
}
/**
* Returns the names of all the constraints active in the given configuration.
*
* <code>exception</code> allows to avoid considering one particular configuration.
* Leave <code>null</code> if irrelevant.
*/
public static List<String> getActiveConstraintNamesTransitively(ConstraintConfiguration config,
ConstraintConfiguration exception) {
List<ConstraintConfiguration> configs =
getActiveConfigurationsTransitively(config, exception);
List<String> res = new ArrayList<>();
for(ConstraintConfiguration subConfig : configs) {
res.addAll(subConfig.getActiveConstraints());
}
return res;
}
/**
* Returns all the constraints active in the given configuration.
*
* <code>exception</code> allows to avoid considering one particular configuration.
* Leave <code>null</code> if irrelevant.
*/
public static List<Class<? extends IConstraint>> getActiveConstraintsTransitively(
ConstraintConfiguration config, ConstraintConfiguration exception) {
List<String> names = getActiveConstraintNamesTransitively(config, exception);
List<Class<? extends IConstraint>> res = new ArrayList<>();
for(String name : names) {
res.add(IConstraintService.getInstance().getConstraintByName(name));
}
return res;
}
/** True if the given configuration is the default one. */
public static boolean isDefaultConfiguration(ConstraintConfiguration c) {
return c.getName().equals(DEFAULT_CONFIGURATION_NAME);
}
/** Gets the default configuration of the given constraint-based development process. */
public static ConstraintConfiguration getDefaultConfig(IConstraintBasedProcess cbp) {
EList<ConstraintConfiguration> configs = cbp.getConfigurations();
for(ConstraintConfiguration config : configs) {
if(isDefaultConfiguration(config)) {
return config;
}
}
return null;
}
/** Adds a default configuration to the given process and returns it for information. */
public static ConstraintConfiguration addDefaultConfig(IConstraintBasedProcess cbp) {
ConstraintConfiguration newDefaultConfig =
ElementFactory.eINSTANCE.createConstraintConfiguration();
newDefaultConfig.setName(DEFAULT_CONFIGURATION_NAME);
cbp.getConfigurations().add(newDefaultConfig);
return newDefaultConfig;
}
/** Gets the default configuration if existing, or creates one otherwise. */
public static ConstraintConfiguration retrieveDefaultConfig(IConstraintBasedProcess cbp) {
ConstraintConfiguration defaultConfig = getDefaultConfig(cbp);
if(defaultConfig != null) {
return defaultConfig;
}
ITopLevelElement top = IPersistencyService.getInstance().getTopLevelElementFor(cbp);
top.runAsCommand(() -> addDefaultConfig(cbp));
return getDefaultConfig(cbp);
}
/**
* Initializes a {@link IConstraintBasedProcess}. Needs a {@link IConstraintInstanceContainer}.
*/
public static void initializeConstraintBasedProcess(IConstraintBasedProcess cbp,
IConstraintInstanceContainer cic) {
ConstraintConfiguration defaultConfig = addDefaultConfig(cbp);
cbp.setCurrentObjective(defaultConfig);
cbp.setConstraintInstanceContainer(cic);
}
}
......@@ -116,30 +116,11 @@
</propertySection>
</propertySections>
</extension>
<extension
point="org.eclipse.ui.decorators">
<decorator
class="org.fortiss.tooling.kernel.ui.internal.ConstraintLabelDecorator"
id="org.fortiss.tooling.kernel.ui.internal.ConstraintLabelDecorator"
label="Constraint Decorator"
lightweight="true"
location="BOTTOM_LEFT"
state="true">
<enablement>
<objectClass
name="org.eclipse.emf.ecore.EObject">
</objectClass>
</enablement>
</decorator>
</extension>
<extension
point="org.fortiss.tooling.kernel.ui.contextMenuContribution">
<contextMenuContribution
contributor="org.fortiss.tooling.kernel.ui.internal.views.NavigatorNewMenu">
</contextMenuContribution>
<contextMenuContribution
contributor="org.fortiss.tooling.kernel.ui.internal.views.ConstraintMenu">
</contextMenuContribution>
</extension>
<extension
point="org.eclipse.ui.perspectives">
......@@ -150,15 +131,6 @@
name="Storage">
</perspective>
</extension>
<extension
point="org.fortiss.tooling.kernel.ui.modelElementHandler">
<modelElementHandler
handler="org.fortiss.tooling.kernel.ui.extension.base.ConstraintUIBases$ConstraintHandler">
<modelElementClass
modelElementClass="org.fortiss.tooling.kernel.model.constraints.ConstraintInstance">
</modelElementClass>
</modelElementHandler>
</extension>
<extension point="org.fortiss.tooling.kernel.uiMessageHandler">
<uiMessageHandler
handler="org.fortiss.tooling.kernel.ui.extension.base.DialogMessageHandler">
......
IAllocationEditPartFactory.java 7d30a6b77cc04191fcd516260ff10d4128f7f3ad GREEN
IConstraintUI.java e2cfa44697a95333601a8df131a169aaee85e9b5 GREEN
IContextMenuContributor.java 0f09c76662c154cf52ddab61b417e82a42854162 GREEN
IContextMenuMultiSelectionContributor.java 125b31dd38009bc2095b7e6bc860e946e39f58c4 GREEN
IEditPartFactory.java 5729715847f553d95a5bad4a9211c7e6f458badd GREEN
......
/*-------------------------------------------------------------------------+
| Copyright 2015 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.kernel.ui.extension;
import java.util.List;
import org.eclipse.jface.resource.ImageDescriptor;
import org.fortiss.tooling.kernel.model.constraints.ConstraintInstance;
import org.fortiss.tooling.kernel.model.constraints.IConstraintInstanceStatus;
import org.fortiss.tooling.kernel.ui.service.IConstraintUIService.IFix;
/**
* Interface for the GUI of constraints.
*
* @author aravantinos
*/
public interface IConstraintUI {
/**
* Action to take when trying to open the given constraint instance. <code>canOpen</code> should
* be called before in order to know if the status can be opened.
*
* @return true if the constraint instance could indeed be open, false if it needs further
* handling.
*/
public boolean openStatus(ConstraintInstance ci, IConstraintInstanceStatus s);
/** True if the constraint instance can be open. */
boolean canOpen(ConstraintInstance ci, IConstraintInstanceStatus s);
/** Method to execute when a constraint instance gets outdated. */
public void onOutdate(ConstraintInstance ci);
/**
* Returns a short user-friendly description for the current status of the constraint instance.
*/
public String getMessage(ConstraintInstance ci, IConstraintInstanceStatus s);
/**
* Returns a list of possible automatic fixes for the given constraint instance. A constraint
* instance should be candidate to fixing if its status is anything but successful or outdated.
*/
List<IFix> fixes(ConstraintInstance ci, IConstraintInstanceStatus s);
/**
* Set to <code>true</code> if you want that a failure of your constraint be displayed as a
* warning rather than as an error.
*/
public boolean displayAsWarning();
/** Gets a general description for the constraint type. */
String getDescription();
/**
* Same as <code>getDescription</code> but allows to make use of additional instance-specific
* information.
*/
public String getDescription(ConstraintInstance ci);
/** Returns the image descriptor to be used as icon image. */
public ImageDescriptor getIconImageDescriptor();
/**
* Way for the constraint to indicate that the verification is often time consuming.
* This triggers a few goodies:
* - wait 1s before triggering the constraint autocheck (if relevant)
* - display a warning popup in case of first trigger of the verification
* TODO(2703) make instead an event "onActivate" in order to allow customization. For instance
* one could check if Z3 is present or not.
*/
public boolean isTimeConsuming();
/**
* True if this constraint shall be always activated (and therefore the user shall not be
* offered the possibility to control whether the constraint is active or not).
*/
public boolean shouldBeManuallyActivated();
}
ConstraintUIBases.java 3676a600e0866091db9798763c6eee97eec5b55b GREEN
ContextMenuSubMenuContributorBase.java 6275d96fe8690d9d4744bcbaef3c7d14ba8e30ff GREEN
DialogMessageHandler.java 8714da09a777c8557de0a5c48ff68c340f9fa91d GREEN
EObjectActionBase.java 4ef9f8be59e64d4838acc9e268d418ba5d94fa1a GREEN
......
/*-------------------------------------------------------------------------+
| Copyright 2015 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.kernel.ui.extension.base;
import static org.fortiss.tooling.kernel.ui.util.ConstraintsUIUtils.triggerMarkersRefresh;
import static org.fortiss.tooling.kernel.utils.ConstraintsUtils.createOutdatedStatus;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Shell;
import org.fortiss.tooling.kernel.model.constraints.ConstraintInstance;
import org.fortiss.tooling.kernel.model.constraints.ErrorConstraintInstanceStatus;
import org.fortiss.tooling.kernel.model.constraints.FailedConstraintInstanceStatus;
import org.fortiss.tooling.kernel.model.constraints.IConstraintInstanceStatus;
import org.fortiss.tooling.kernel.model.constraints.OutdatedConstraintInstanceStatus;
import org.fortiss.tooling.kernel.service.IConstraintService;
import org.fortiss.tooling.kernel.ui.extension.IConstraintUI;
import org.fortiss.tooling.kernel.ui.service.IConstraintUIService;
import org.fortiss.tooling.kernel.ui.service.IConstraintUIService.IFix;
import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
/**
* Base classes for constraint verification GUI.
*
* @author aravantinos
*/
public class ConstraintUIBases {
/** Base class for constraint verification GUI. */
public static abstract class ConstraintUIBase implements IConstraintUI {
/** {@inheritDoc} */
@Override
public boolean canOpen(ConstraintInstance ci, IConstraintInstanceStatus status) {
return status instanceof OutdatedConstraintInstanceStatus;
}
/** {@inheritDoc} */
@Override
public String getDescription(ConstraintInstance ci) {
return this.getDescription();
}
/** {@inheritDoc} */
@Override
public List<IFix> fixes(ConstraintInstance ci, IConstraintInstanceStatus status) {
// No fix by default, it is however strongly recommended to override in order to improve
// user experience.
return new ArrayList<IFix>();
}
/** {@inheritDoc} */
@Override
public boolean openStatus(ConstraintInstance ci, IConstraintInstanceStatus status) {
if(!canOpen(ci, status)) {
return false;
}
if(status instanceof OutdatedConstraintInstanceStatus) {
IConstraintService.getInstance().verify(ci);
IConstraintInstanceStatus currentStatus =
IConstraintUIService.getInstance().getStatus(ci);
if(currentStatus instanceof ErrorConstraintInstanceStatus && canOpen(ci, status)) {
openStatus(ci, currentStatus);
}
return true;
}
if(status instanceof FailedConstraintInstanceStatus ||
status instanceof ErrorConstraintInstanceStatus) {
List<IFix> fixes = IConstraintUIService.getInstance().fixes(ci);
Shell shell = Display.getCurrent().getActiveShell();
int result = new FixDialog(shell, status, getMessage(ci, status), fixes).open();
if(fixes.size() == 1 && result == 0) {
// get(0) because the size is equal to 1 by the previous test
fixes.get(0).runFix(status);
} else if(result > 1) {
// In this case, result = 0 iff the dialog was cancelled, 1 iff the dialog was
// OK, or any number greater than 1 to select a given fix, hence the result-2
// below.
fixes.get(result - 2).runFix(status);
}
return true;
}
return false;
}
/** {@inheritDoc} */
@Override
public boolean isTimeConsuming() {
return false;
}
/** Dialog presenting the error/failure and the possible fix(es). */
private static class FixDialog extends MessageDialog {
/** List of possible fixes. */
List<IFix> fixes;
/** Constructor. */
public FixDialog(Shell parentShell, IConstraintInstanceStatus s, String msg,
List<IFix> fixes) {
super(parentShell, getTitle(s), null, msg, getIconType(s), getButtons(fixes), 1);
this.fixes = fixes;
}
/**
* Returns the buttons to display: "OK" is always displayed. In addition, if there is
* only one fix, we provide one button for this fix. If there is more than one
* possible fixes, they will displayed instead horizontally (via getCustomArea).
*/
private static String[] getButtons(List<IFix> fixes) {
String[] res = new String[fixes.size() == 1 ? 2 : 1];
if(fixes.size() == 1) {
// get(0) because the size is equal to 1 by the previous test
res[0] = "Fix: " + fixes.get(0).getDescription();
}
res[res.length - 1] = "OK";
return res;
}
/** Returns the icon type corresponding to <code>s</code>. */
private static String getTitle(IConstraintInstanceStatus s) {
if(s instanceof FailedConstraintInstanceStatus) {
return "Verification of constraint failed";
}
return "Error during constraint verification";
}
/** Returns the icon type corresponding to <code>s</code>. */
private static int getIconType(IConstraintInstanceStatus s) {
return s instanceof FailedConstraintInstanceStatus ? MessageDialog.WARNING : ERROR;
}
/** {@inheritDoc} */
@Override
protected Control createCustomArea(Composite parent) {
if(fixes.size() <= 1) {
return null;
}
Group buttonGroup = new Group(parent, SWT.NONE);
buttonGroup.setLayout(new GridLayout());
buttonGroup.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, true, false));
buttonGroup.setText("Possible fixes");
for(IFix fix : fixes) {
Button button = new Button(buttonGroup, SWT.None);
button.setText(fix.getDescription());
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
buttonPressed(fixes.indexOf(fix) + 1);
}
});
}
// Does not matter what we return as long as it's not null
return buttonGroup;
}
}
/** {@inheritDoc} */
@Override
public String getMessage(ConstraintInstance ci, IConstraintInstanceStatus status) {
IConstraintInstanceStatus s = IConstraintUIService.getInstance().getStatus(ci);
// Default message. Inheriting classes SHOULD specialize.
String name = IModelElementHandlerService.getInstance().getName(s.getConstraint());
String pre = s instanceof ErrorConstraintInstanceStatus ? "Error while checking"
: "Unsatisfied";
return pre + " constraint" + (name == null ? "." : ": \"" + name + "\"");
}
/** {@inheritDoc} */
@Override
public void onOutdate(ConstraintInstance ci) {
// By default, we just set the status to outdated
createOutdatedStatus(ci);
}
/** {@inheritDoc} */
@Override
public boolean shouldBeManuallyActivated() {
return false;
}
/** {@inheritDoc} */
@Override
public boolean displayAsWarning() {
// By default, constraints failures are displayed as error not as warnings
return false;
}
/** {@inheritDoc} */
@Override
public ImageDescriptor getIconImageDescriptor() {
return null;
}
}
/**
* Base class for constraint verifier UIs which automatically trigger a new check when the
* constraint gets outdated.
*/
public static abstract class ConstraintUIBaseAutocheck extends ConstraintUIBase {
/** {@inheritDoc} */
@Override
public void onOutdate(ConstraintInstance ci) {
Display display = Display.getDefault();
String name = "Verifying " + ConstraintUIBaseAutocheck.this.getDescription();
Job latestJob = new Job(name) {
/** {@inheritDoc} */
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
display.asyncExec(() -> IConstraintService.getInstance().cancel(ci));
IConstraintService.getInstance().verify(ci);
display.asyncExec(() -> triggerMarkersRefresh(ci));
return Status.OK_STATUS;
} catch(IllegalArgumentException e) {
// This sort of exception might happen, not sure why, but we *in no case*
// want to throw an error message to the user in case of some failure
// resulting of a constraint check which he did not explicitly triggered
return Status.CANCEL_STATUS;
}
}
};
// If the constraint is considered time consuming, we wait 1s before starting the job
// because user modifications can go faster than the check.
latestJob.schedule(isTimeConsuming() ? 1000 : 0);
}
/** {@inheritDoc} */
@Override
public boolean canOpen(ConstraintInstance ci, IConstraintInstanceStatus status) {
return false;
}
}
/** Handler for constraints. */
public static class ConstraintHandler extends ModelElementHandlerBase<ConstraintInstance> {
/** {@inheritDoc} */
@Override
public String getName(ConstraintInstance element) {
return getDescription(element);
}
/** {@inheritDoc} */
@Override
public ImageDescriptor getIconImageDescriptor() {
// This method will actually never be called
return null;
}
/** {@inheritDoc} */
@Override
public ImageDescriptor getIconImageDescriptor(ConstraintInstance element) {
return IConstraintUIService.getInstance().getIconImageDescriptor(element);
}
}
}
ActionService.java e29126b5947c9fd2f1d82bb87001b9d0ead50c3b GREEN
AllocationEditPartFactoryService.java 81bd227736013f1157ba9d0f79a9f3deefe10064 GREEN
ConstraintLabelDecorator.java ac138bfc97ea3b2f8fde0497ade915e4cd942af1 GREEN
ConstraintUIService.java 433e35bb1c9bbc628c6ee070ff45632400becf4a GREEN
ContextMenuService.java ca3c899293f25b70ce8e5f0d86ca2f9683329d81 GREEN
EditPartFactoryService.java e9180c0020f1769d9e24ef3c08f9ca5599dbc5c3 GREEN
MarkerService.java b01b7706034691683df7bbc2e7828c42574b3147 GREEN
ModelEditorBindingService.java 577f5db41abf240291434dbad6bc6b0fde1eeb2b GREEN
MarkerService.java 208f97f3ccabf0947702a17ddca23d8766a268f4 GREEN
ModelEditorBindingService.java 948fcdc298a74e366351ad8835a145af6cd238be GREEN
ModelElementHandlerService.java 07a30545ad687ff0fe13bf7a9348c41fb03e0b2c GREEN
NavigatorService.java 2b1361eac805996e22e5409dafff9707fbac3376 GREEN
ToolingKernelUIInternal.java 38903445a9084b7908716a00f41621dfb3126fca GREEN
ToolingKernelUIInternal.java a70d19883dfb315d860233156d8524cf1ac2952f GREEN
TutorialUIService.java b1d632eca91b4feb583f3930cd6ee4722dd9bfed GREEN
/*-------------------------------------------------------------------------+
| Copyright 2016 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.kernel.ui.internal;
import static org.fortiss.tooling.kernel.ui.ESharedImages.ERROR_OVERLAY;
import static org.fortiss.tooling.kernel.ui.ESharedImages.FATAL_OVERLAY;
import static org.fortiss.tooling.kernel.ui.ESharedImages.WARNING_OVERLAY;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.viewers.BaseLabelProvider;
import org.eclipse.jface.viewers.IDecoration;
import org.eclipse.jface.viewers.ILightweightLabelDecorator;
import org.fortiss.tooling.kernel.extension.data.IConstraintViolation.ESeverity;
import org.fortiss.tooling.kernel.ui.service.IMarkerService;
import org.fortiss.tooling.kernel.ui.util.ConstraintsUIUtils;
/**
* Label decorator for the {@link IMarkerService} decorations: errors, warnings, etc.
*
* @author hoelzl
*/
public final class ConstraintLabelDecorator extends BaseLabelProvider
implements ILightweightLabelDecorator {
/** {@inheritDoc} */
@Override
public void decorate(Object element, IDecoration decoration) {
if(element instanceof EObject) {
ESeverity sev =
IMarkerService.getInstance().getHighestViolationSeverity((EObject)element);
sev = ConstraintsUIUtils.augmentSeverityWithConstraintSeverity(sev, (EObject)element);
switch(sev) {
case FATAL:
decoration.addOverlay(FATAL_OVERLAY.getImageDescriptor());
break;
case ERROR:
decoration.addOverlay(ERROR_OVERLAY.getImageDescriptor());
break;
case WARNING:
decoration.addOverlay(WARNING_OVERLAY.getImageDescriptor());
break;
default:
// ignore info and debug
}
}
}
}
package org.fortiss.tooling.kernel.ui.internal;
import static java.util.Collections.emptyList;
import static org.fortiss.tooling.kernel.ui.util.ConstraintsUIUtils.displayTimeConsumptionWarning;
import static org.fortiss.tooling.kernel.ui.util.ConstraintsUIUtils.triggerMarkerRefresh;
import static org.fortiss.tooling.kernel.ui.util.ConstraintsUIUtils.triggerMarkersRefresh;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.warning;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.ENamedElement;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.util.EContentAdapter;
import org.eclipse.jface.resource.ImageDescriptor;
import org.fortiss.tooling.kernel.ToolingKernelActivator;
import org.fortiss.tooling.kernel.extension.IConstraint;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.introspection.IIntrospectionItem;
import org.fortiss.tooling.kernel.introspection.IIntrospectiveKernelService;
import org.fortiss.tooling.kernel.model.constraints.ConstraintInstance;
import org.fortiss.tooling.kernel.model.constraints.ConstraintsPackage;
import org.fortiss.tooling.kernel.model.constraints.IConstrained;
import org.fortiss.tooling.kernel.model.constraints.IConstraintInstanceContainer;
import org.fortiss.tooling.kernel.model.constraints.IConstraintInstanceStatus;
import org.fortiss.tooling.kernel.model.constraints.OutdatedConstraintInstanceStatus;
import org.fortiss.tooling.kernel.service.IConstraintService;
import org.fortiss.tooling.kernel.service.IKernelIntrospectionSystemService;
import org.fortiss.tooling.kernel.service.IPersistencyService;
import org.fortiss.tooling.kernel.ui.ToolingKernelUIActivator;
import org.fortiss.tooling.kernel.ui.extension.IConstraintUI;
import org.fortiss.tooling.kernel.ui.internal.introspection.items.ConstraintUIServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.ui.service.IConstraintUIService;
import org.fortiss.tooling.kernel.ui.util.ConstraintsUIUtils;
import org.fortiss.tooling.kernel.utils.EcoreUtils;
import org.fortiss.tooling.kernel.utils.LoggingUtils;
/**
* Implementation of {@link IConstraintUIService}.
*
* @author aravantinos
*/
public final class ConstraintUIService
implements IConstraintUIService, IIntrospectiveKernelService {
/** The singleton service instance. */
private static ConstraintUIService INSTANCE = new ConstraintUIService();
/** Stores the string to class handler map. */
protected final Map<String, Class<? extends IConstraint>> string2cstrMap =
new HashMap<String, Class<? extends IConstraint>>();
/** Stores the non-UI class to UI class handler map. */
protected final Map<Class<? extends IConstraint>, Class<? extends IConstraintUI>> cstr2cstrUIMap =
new HashMap<Class<? extends IConstraint>, Class<? extends IConstraintUI>>();
/** Stores the UI-class to instance handler map. */
protected final Map<Class<? extends IConstraintUI>, IConstraintUI> instanceMap =
new HashMap<Class<? extends IConstraintUI>, IConstraintUI>();
/** Returns the service instance. */
public static ConstraintUIService getInstance() {
return INSTANCE;
}
/** Activates logging to observe when constraints get outdated. */
private static final boolean DEBUG = false;
/** Starts the service. */
public void startService() {
IKernelIntrospectionSystemService.getInstance().registerService(this);
List<ITopLevelElement> tops = IPersistencyService.getInstance().getTopLevelElements();
for(ITopLevelElement top : tops) {
TreeIterator<EObject> tree = top.getRootModelElement().eAllContents();
while(tree.hasNext()) {
EObject next = tree.next();
if(next instanceof ConstraintInstance) {
install((ConstraintInstance)next);
}
}
}
}
/** {@inheritDoc} */
@Override
public void registerConstraintUI(Class<? extends IConstraintUI> cstrUIClass,
Class<? extends IConstraint> cstrClass) {
String name = cstrClass.getName();
if(string2cstrMap.get(name) != null) {
warning(ToolingKernelActivator.getDefault(),
"Encountered more than one registered constraint UI associated with " + name);
}
string2cstrMap.put(name, cstrClass);
cstr2cstrUIMap.put(cstrClass, cstrUIClass);
try {
instanceMap.put(cstrUIClass, cstrUIClass.getConstructor().newInstance());
} catch(InstantiationException | IllegalAccessException | IllegalArgumentException |
InvocationTargetException | NoSuchMethodException | SecurityException e) {
warning(ToolingKernelActivator.getDefault(),
"Instanciation of " + cstrUIClass.getName() + " threw an exception.");
}
}
/** Initializes the service by setting up the handler map. */
public void initializeService() {
// nothing to do here
}
/** {@inheritDoc} */
@Override
public String getIntrospectionDescription() {
return getIntrospectionLabel() +
"\n\nThis service deals with the UI aspects of constraints." +
"\n\nIt provides the following:" +
"\n- inform whether a constraint instance can be open or not," +
"\n- open the status of a constraint instance," +
"\n- \"install\" a constraint instance, i.e., sets listeners on the constrained element(s) in order" +
"\n to automatically detect when a constraint is outdated," +
"\n- inform, for a given constraint instance, whether it should display an error or a warning in case of non-satisfaction," +
"\n- provide a user-friendly short description for a constraint (useful in various automatic messages)," +
"\n- provide an icon for a given constraint (useful in the context menu)," +
"\n- give the status of a given constraint instance - taking into account whether the constraint is activated or not," +
"\n- activate a given constraint," + "\n- deactivate a given constraint," +
"\n- give the list of all available constraints," +
"\n- give the list of constraints which should always be activated - by opposition to those which should be explicitly activated by the user," +
"\n- give the list of constraints which are currently activated - by the user or automatically," +
"\n- complete a given project with instances of a given constraint if necessary." +
"\n\nThis service is \"fed\" by classes of type IConstraintUI." +
"\n\nThe class org.fortiss.tooling.kernel.ui.extension.base.ConstraintVerifierUIBaseAutocheck should" +
"\ngenerally provide a sufficient initial implementation. You are however strongly encouraged" +
"\nto extend this class to provide a better feedback to the user (e.g., with detailed errors)." +
"\n\nSee the developer wiki page \"Add a new constraint on a metamodel\"" +
" for detailed documentation on developing a new sort of constraint.";
}
/** @return the first registered constraint UI corresponding to <code>ci</code>. */
private IConstraintUI getConstraintUI(ConstraintInstance ci) {
Class<? extends IConstraint> cstr = string2cstrMap.get(ci.getConstraintName());
Class<? extends IConstraintUI> cstrUI = cstr2cstrUIMap.get(cstr);
return instanceMap.get(cstrUI);
}
/** {@inheritDoc} */
@Override
public void openStatus(ConstraintInstance ci) {
getConstraintUI(ci).openStatus(ci, getStatus(ci));
triggerMarkersRefresh(ci);
}
/** {@inheritDoc} */
@Override
public boolean canOpen(ConstraintInstance ci) {
IConstraintUI verifier = getConstraintUI(ci);
return verifier.canOpen(ci, getStatus(ci));
}
/** Map containing the adapters of each constrained element. */
Map<IConstrained, Adapter> constrainedAdapterMap = new HashMap<IConstrained, Adapter>();
/** Installed constraints, sorted by adapters. */
Map<Adapter, List<ConstraintInstance>> installedConstraintInstances = new HashMap<>();
/** {@inheritDoc} */
@Override
public void install(ConstraintInstance ci) {
triggerMarkersRefresh(ci);
for(IConstrained constrained : ci.getConstraineds()) {
Adapter currentAdapter = constrainedAdapterMap.get(constrained);
if(currentAdapter == null) {
currentAdapter = new EContentAdapter() {
@Override
public void notifyChanged(Notification notification) {
super.notifyChanged(notification);
if(isTouch(notification) || constraintRemoved(notification, constrained)) {
return;
}
List<ConstraintInstance> outdatedConstraintInstances = new ArrayList<>();
for(ConstraintInstance ci : installedConstraintInstances.get(this)) {
if(getStatus(ci) != null) {
constraintOutdated(ci, notification);
outdatedConstraintInstances.add(ci);
}
}
triggerMarkersRefresh(outdatedConstraintInstances);
}
};
constrained.eAdapters().add(currentAdapter);
constrainedAdapterMap.put(constrained, currentAdapter);
installedConstraintInstances.put(currentAdapter, new ArrayList<>());
}
installedConstraintInstances.get(currentAdapter).add(ci);
}
}
/**
* Checks if <code>notification</code> denotes a change entailing that <code>ci</code> is
* outdated. If so updates the status to outdated or triggers an automatic check if the
* <code>autocheck</code> field of the constraint is <code>true</code>.
*
* @return <code>true</code> iff <code>notification</code> indeed entailed that <code>ci</code>
* is outdated.
*/
private boolean constraintOutdated(ConstraintInstance ci, Notification notification) {
if(skipStatusChangeNotification(ci, notification)) {
return false;
}
if(!IConstraintService.getInstance().isUpToDate(ci)) {
if(DEBUG) {
String msg = "Constraint instance " + ci.toString() + " is outdated.";
LoggingUtils.info(ToolingKernelUIActivator.getDefault(), msg);
}
if(!IConstraintService.getInstance().isUpdating(ci)) {
IConstraintService.getInstance().markAsUpdating(ci);
getConstraintUI(ci).onOutdate(ci);
return true;
}
}
return false;
}
/**
* @return true iff <code>notification</code> denotes a change of the <code>ci</code>'s
* status.
*/
private boolean skipStatusChangeNotification(ConstraintInstance ci, Notification notification) {
String n = ConstraintsPackage.eINSTANCE.getConstraintInstance_Status().getName();
if(notification.getNotifier() != null && notification.getNotifier().equals(ci)) {
if(notification.getFeature() instanceof EReference) {
return(n.equals(((ENamedElement)notification.getFeature()).getName()));
}
}
return false;
}
/**
* @return true if the notification is a consequence of a constraint of <code>constrained</code>
* being removed.
*/
private boolean constraintRemoved(Notification notification, IConstrained constrained) {
if(notification.getEventType() != Notification.REMOVE) {
return false;
}
if(!notification.getNotifier().equals(constrained)) {
return false;
}
if(notification.getFeature() instanceof EReference) {
String name = ((ENamedElement)notification.getFeature()).getName();
if(name.equals(
ConstraintsPackage.eINSTANCE.getIConstrained_ConstraintInstances().getName())) {
Adapter cstrdAdapter = constrainedAdapterMap.get(constrained);
List<ConstraintInstance> cis = installedConstraintInstances.get(cstrdAdapter);
// To check!!! notification.getOldValue() should be the removed ConstraintInstance
cis.remove(notification.getOldValue());
if(cis.isEmpty()) {
constrained.eAdapters().remove(cstrdAdapter);
constrainedAdapterMap.remove(constrained);
}
return true;
}
}
return true;
}
/** @return true if <code>notification</code> is not relevant and should be skipped */
private static boolean isTouch(Notification notification) {
// Notifications which do not notify about a model change.
if(notification.isTouch()) {
return true;
}
// Notifications initiated by the the AF3 kernel which are only GUI related.
if(notification.getEventType() == EcoreUtils.KERNEL_EMF_EVENT_TYPE_COUNT) {
return true;
}
return false;
}
/** {@inheritDoc} */
@Override
public IIntrospectionDetailsItem getDetailsItem() {
Map<String, Class<? extends IConstraintUI>> handlerMap = new HashMap<>();
for(Entry<String, Class<? extends IConstraint>> entry : string2cstrMap.entrySet()) {
Class<? extends IConstraintUI> cstrUIClass = cstr2cstrUIMap.get(entry.getValue());
handlerMap.put(entry.getKey(), cstrUIClass);
}
return new ConstraintUIServiceIntrospectionDetailsItem(handlerMap);
}
/** {@inheritDoc} */
@Override
public String getIntrospectionLabel() {
return "Constraint UI Service";
}
/** Activated constraints per top level element. */
private static Map<ITopLevelElement, Set<Class<? extends IConstraint>>> activatedConstraints =
new HashMap<>();
/** {@inheritDoc} */
@Override
public IConstraintInstanceStatus getStatus(ConstraintInstance ci) {
ITopLevelElement top = IPersistencyService.getInstance().getTopLevelElementFor(ci);
boolean isActivated = false;
Set<Class<? extends IConstraint>> set = activatedConstraints.get(top);
if(set != null) {
for(Class<? extends IConstraint> id : set) {
if(id.getName().equals(ci.getConstraintName())) {
isActivated = true;
}
}
}
return isActivated ? ci.getStatus() : null;
}
/** {@inheritDoc} */
@Override
public Set<Class<? extends IConstraint>> getAllConstraints() {
return cstr2cstrUIMap.keySet();
}
/** {@inheritDoc} */
@Override
public Set<Class<? extends IConstraint>> getActivatedConstraints(ITopLevelElement top) {
Set<Class<? extends IConstraint>> res = activatedConstraints.get(top);
return res != null ? res : new HashSet<>();
}
/** {@inheritDoc} */
@Override
public void activate(Class<? extends IConstraint> cstrClass,
IConstraintInstanceContainer cstrContainer) {
ITopLevelElement top =
IPersistencyService.getInstance().getTopLevelElementFor(cstrContainer);
if(!activatedConstraints.containsKey(top)) {
activatedConstraints.put(top, new HashSet<>());
}
activatedConstraints.get(top).add(cstrClass);
List<ConstraintInstance> addeds =
IConstraintService.getInstance().addMissingConstraintsInstances(top, cstrClass);
IConstraintUI cstrUI = instanceMap.get(cstr2cstrUIMap.get(cstrClass));
if(!addeds.isEmpty() && cstrUI.isTimeConsuming()) {
displayTimeConsumptionWarning(cstrClass);
}
// Install notifiers for newly added constraints
for(ConstraintInstance added : addeds) {
IConstraintUIService.getInstance().install(added);
}
EList<ConstraintInstance> cstrs = cstrContainer.getConstraintInstances();
Predicate<ConstraintInstance> isID = c -> cstrClass.getName().equals(c.getConstraintName());
List<ConstraintInstance> idCstrs = cstrs.stream().filter(isID).collect(Collectors.toList());
update(idCstrs);
}
/** {@inheritDoc} */
@Override
public void addMissingConstraintInstances(IConstraintInstanceContainer cstrContainer) {
ITopLevelElement top =
IPersistencyService.getInstance().getTopLevelElementFor(cstrContainer);
List<ConstraintInstance> addeds = new ArrayList<ConstraintInstance>();
for(Class<? extends IConstraint> cstrClass : getActivatedConstraints(top)) {
addeds.addAll(IConstraintService.getInstance().addMissingConstraintsInstances(top,
cstrClass));
IConstraintService.getInstance().addMissingConstraintsInstances(top, cstrClass);
}
// Install notifiers for newly added constraints
for(ConstraintInstance added : addeds) {
IConstraintUIService.getInstance().install(added);
}
update(addeds);
}
/** Checks the constraints among the given list of constraint instances. */
private void update(List<ConstraintInstance> cis) {
// Checks all the constraints: the newly added and the already existing ones which are now
// activated.
for(ConstraintInstance ci : cis) {
// No need to check if it turns out the status is already known from a previous
// activation.
if(!IConstraintService.getInstance().isUpdating(ci) &&
(!IConstraintService.getInstance().isUpToDate(ci) ||
ci.getStatus() instanceof OutdatedConstraintInstanceStatus)) {
getConstraintUI(ci).onOutdate(ci);
}
}
ConstraintsUIUtils.triggerMarkersRefresh(cis);
}
/** {@inheritDoc} */
@Override
public void deactivate(Class<? extends IConstraint> cstrClass,
IConstraintInstanceContainer cstrContainer) {
ITopLevelElement top =
IPersistencyService.getInstance().getTopLevelElementFor(cstrContainer);
activatedConstraints.get(top).remove(cstrClass);
triggerMarkerRefresh(cstrClass, cstrContainer);
}
/** {@inheritDoc} */
@Override
public String getDescription(Class<? extends IConstraint> cstrClass) {
IConstraintUI cstrUI = instanceMap.get(cstr2cstrUIMap.get(cstrClass));
return cstrUI == null ? null : cstrUI.getDescription();
}
/** {@inheritDoc} */
@Override
public boolean showInIntrospectionNavigation() {
return true;
}
/** {@inheritDoc} */
@Override
public Collection<IIntrospectionItem> getIntrospectionItems() {
return emptyList();
}
/** {@inheritDoc} */
@Override
public ImageDescriptor getIconImageDescriptor(ConstraintInstance ci) {
Class<? extends IConstraint> cstrClass = string2cstrMap.get(ci.getConstraintName());
IConstraintUI cstrUI = instanceMap.get(cstr2cstrUIMap.get(cstrClass));
return cstrUI == null ? null : cstrUI.getIconImageDescriptor();
}
/** {@inheritDoc} */
@Override
public boolean shallDisplayAsWarning(ConstraintInstance constraint) {
return getConstraintUI(constraint).displayAsWarning();
}
/** {@inheritDoc} */
@Override
public Set<Class<? extends IConstraint>> getAlwaysActivatedConstraints() {
HashSet<Class<? extends IConstraint>> res = new HashSet<>();
for(Entry<Class<? extends IConstraint>, Class<? extends IConstraintUI>> entry : cstr2cstrUIMap
.entrySet()) {
if(!instanceMap.get(entry.getValue()).shouldBeManuallyActivated()) {
res.add(entry.getKey());
}
}
return res;
}
/** {@inheritDoc} */
@Override
public String getDescription(ConstraintInstance ci) {
Class<? extends IConstraint> cstrClass = string2cstrMap.get(ci.getConstraintName());
return instanceMap.get(cstr2cstrUIMap.get(cstrClass)).getDescription(ci);
}
/** {@inheritDoc} */
@Override
public List<IFix> fixes(ConstraintInstance ci) {
List<IFix> fixes = null;
IConstraintUI cstr = getConstraintUI(ci);
if(cstr != null) {
fixes = cstr.fixes(ci, ci.getStatus());
}
return fixes != null ? fixes : new ArrayList<IFix>();
}
}
......@@ -18,7 +18,6 @@ package org.fortiss.tooling.kernel.ui.internal;
import static java.util.Collections.emptyList;
import static java.util.Collections.sort;
import static org.fortiss.tooling.kernel.ui.ToolingKernelUIActivator.getImageDescriptor;
import static org.fortiss.tooling.kernel.ui.util.ConstraintsUIUtils.augmentSeverityWithConstraintSeverity;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.postRefreshNotification;
import java.util.ArrayList;
......@@ -41,7 +40,6 @@ import org.eclipse.ui.progress.UIJob;
import org.fortiss.tooling.kernel.extension.data.IConstraintViolation;
import org.fortiss.tooling.kernel.extension.data.IConstraintViolation.ESeverity;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.model.constraints.IConstrained;
import org.fortiss.tooling.kernel.service.IConstraintCheckerService;
import org.fortiss.tooling.kernel.service.IPersistencyService;
import org.fortiss.tooling.kernel.service.listener.IPersistencyServiceListener;
......@@ -168,9 +166,6 @@ public class MarkerService implements IMarkerService, IPersistencyServiceListene
return ESeverity.lowest();
}
ESeverity sev = getCacheEntry(top).getHighestSeverity(element);
if(element instanceof IConstrained) {
sev = augmentSeverityWithConstraintSeverity(sev, element);
}
return sev;
}
......