Skip to content
Snippets Groups Projects
Commit eec86681 authored by Florian Hölzl's avatar Florian Hölzl
Browse files

RED.

refs 2553
parent c9293d92
No related branches found
No related tags found
No related merge requests found
......@@ -31,13 +31,14 @@ import org.fortiss.tooling.kernel.model.constraints.IConstraintVerificationStatu
* @ConQAT.Rating YELLOW Hash: 8B7EC3F9AB4256EC702DE0CD91860C09
*/
public interface IConstraintVerifierUI {
// TODO: should not be needed if the service handles IDs internally
/**
* Returns the unique identifier of this constraint. Should match the corresponding
* {@link IConstraintVerifier}!
*/
String getID();
// TODO: remove @params
/**
* Action to take when trying to open the given constraint. <code>canOpen</code> should be
* called before to know if the status can be opened.
......
......@@ -50,7 +50,7 @@ import org.fortiss.tooling.kernel.ui.util.ConstraintsUIUtils;
import org.fortiss.tooling.kernel.utils.ConstraintsUtils;
/**
* Base class for constraint verification GUI.
* Base classes for constraint verification GUI.
*
* @author vincent
* @author $Author$
......@@ -61,7 +61,6 @@ public class ConstraintVerifierUIBases {
/** Base class for constraint verification GUI. */
public static abstract class ConstraintVerifierUIBase implements IConstraintVerifierUI {
/** {@inheritDoc} */
@Override
public boolean canOpen(ConstraintInstance constraint, IConstraintVerificationStatus status) {
......@@ -78,6 +77,7 @@ public class ConstraintVerifierUIBases {
IConstraintVerificationService.getInstance().verify(c);
IConstraintVerificationStatus currentStatus =
IConstraintVerificationUIService.getInstance().getStatus(c);
// FIXME: bit-wise AND surely not intended
if(currentStatus instanceof ErrorVerificationStatus & canOpen(c, status)) {
openStatus(c, status);
}
......@@ -92,6 +92,7 @@ public class ConstraintVerifierUIBases {
// get(0) because the size is equal to 1 by the previous test
fixes.get(0).runFix(status);
} else if(result > 1) {
// TODO: comment 'result - 2'
fixes.get(result - 2).runFix(status);
}
return true;
......@@ -107,7 +108,6 @@ public class ConstraintVerifierUIBases {
/** Dialog presenting the error/failure and the possible fix(es). */
private static class FixDialog extends MessageDialog {
/** List of possible fixes. */
List<IFix> fixes;
......@@ -118,13 +118,12 @@ public class ConstraintVerifierUIBases {
this.fixes = fixes;
}
// TODO: remove undocumented params
/**
* @param fixes
* @return 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
* fix,
* they will displayed instead horizontally (via getCustomArea).
* 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];
......@@ -196,6 +195,7 @@ public class ConstraintVerifierUIBases {
@Override
public void onOutdate(ConstraintInstance constraint) {
// By default, we just set the status to outdated
// TODO: import static
ConstraintsUtils.createOutdatedVerificationStatus(constraint);
ConstraintsUIUtils.triggerMarkersRefresh(constraint);
}
......@@ -239,6 +239,7 @@ public class ConstraintVerifierUIBases {
display.asyncExec(() -> IConstraintVerificationService.getInstance()
.cancel(constraint));
IConstraintVerificationService.getInstance().verify(constraint);
// TODO: import static
display.asyncExec(() -> ConstraintsUIUtils
.triggerMarkersRefresh(constraint));
return Status.OK_STATUS;
......
......@@ -67,6 +67,8 @@ public final class ConstraintVerificationUIService implements IConstraintVerific
private static ConstraintVerificationUIService INSTANCE = new ConstraintVerificationUIService();
/** Stores the class to handler map. */
// TODO: use Class<? extends IConstraitnVerifierUI> as first dimension
// (see TutorialUIService.instanceMap
protected final Map<String, IConstraintVerifierUI> handlerMap =
new HashMap<String, IConstraintVerifierUI>();
......@@ -202,7 +204,9 @@ public final class ConstraintVerificationUIService implements IConstraintVerific
/** {@inheritDoc} */
@Override
public void install(ConstraintInstance constraint) {
// TODO: import static
ConstraintsUIUtils.triggerMarkersRefresh(constraint);
// TODO: remember a reference for cleanup?
new ConstrainedAdapters(constraint);
}
......@@ -393,6 +397,7 @@ public final class ConstraintVerificationUIService implements IConstraintVerific
IConstraintVerificationService.getInstance()
.addMissingConstraintsInstances(top, id);
if(!addeds.isEmpty() && getFirstVerifier(id).isTimeConsuming()) {
// TODO: import static
ConstraintsUIUtils.displayTimeConsumptionWarning(id);
}
// Install notifiers for newly added constraints
......@@ -469,6 +474,7 @@ public final class ConstraintVerificationUIService implements IConstraintVerific
/** {@inheritDoc} */
@Override
public ImageDescriptor getIconImageDescriptor(String id) {
// TODO: use ConstraintInstance and call getConstraintID() internally
IConstraintVerifierUI verifier = getFirstVerifier(id);
return verifier == null ? null : verifier.getIconImageDescriptor();
}
......
......@@ -41,9 +41,13 @@ public interface IConstraintVerificationUIService {
boolean shallDisplayAsWarning(ConstraintInstance ci);
/** Returns a description for the given constraint type. */
// TODO: use ConstraintInstance and call getConstraintID() internally
// otherwise this String looks very arbitrary
String getDescription(String id);
/** Returns the image descriptor to be used as icon image. */
// TODO: use ConstraintInstance and call getConstraintID() internally
// otherwise this String looks very arbitrary
ImageDescriptor getIconImageDescriptor(String id);
/**
......@@ -59,9 +63,11 @@ public interface IConstraintVerificationUIService {
IConstraintVerificationStatus getStatus(ConstraintInstance ci);
/** Returns a list of all available constraints (through their IDs). */
// TODO: use ConstraintInstance instead of String to be consistent with above changes
Set<String> getAllConstraints();
/** Returns a list of constraints which should always be activated (through their IDs). */
// TODO: use ConstraintInstance instead of String to be consistent with above changes
Set<String> getAlwaysActivatedConstraints();
/**
......@@ -77,5 +83,8 @@ public interface IConstraintVerificationUIService {
void deactivate(String id, IConstraintInstanceContainer cstrContainer);
/** Registers the verifier UI part with the kernel. */
// TODO: change interface (see TutorialServiceUI for implementation).
// void registerTutorialUIProvider(Class<? extends IConstraintVerifier> nonUIverifier,
// Class<? extends IConstraintVerifierUI> uiVerifier)
void registerConstraintVerifierUI(IConstraintVerifierUI verifier);
}
......@@ -40,6 +40,7 @@ public interface IConstraintVerifier {
* Returns the unique identifier of this constraint. Should match the corresponding
* IConstraintVerifierUI!
*/
// TODO: should no longer be needed when the service handles IDs internally
String getID();
/** Verify the given constraint. */
......
......@@ -96,5 +96,7 @@ public interface IConstraintVerificationService {
void setConstrainedElement(ConstraintInstance constraint, IConstrained constrained, int index);
/** Registers the given verifier with the service. */
// TODO: change interface (see tutorial service for implementation. */
// void registerConstraintVerifier(Class<? extends IConstraintVerifier> verifier);
void registerConstraintVerifier(IConstraintVerifier verifier);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment