From c523da8642c65445020315bd9f24d433e7aff29f Mon Sep 17 00:00:00 2001 From: Florian Hoelzl <hoelzl@fortiss.org> Date: Mon, 30 Jan 2012 10:39:42 +0000 Subject: [PATCH] added container to marker service refs 503 --- .../kernel/ui/internal/views/DoubleClick.java | 15 +++++++++++--- .../ui/internal/views/MarkerViewPart.java | 17 +++++++++++++--- .../base/ConstraintViolationBase.java | 20 +++++++++++++++++-- .../extension/data/IConstraintViolation.java | 8 +++++++- 4 files changed, 51 insertions(+), 9 deletions(-) diff --git a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/views/DoubleClick.java b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/views/DoubleClick.java index ff01af8df..5216ba294 100644 --- a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/views/DoubleClick.java +++ b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/views/DoubleClick.java @@ -32,9 +32,9 @@ import org.fortiss.tooling.kernel.ui.util.EObjectSelectionUtils; * @author hoelzl * @author $Author$ * @version $Rev$ - * @ConQAT.Rating GREEN Hash: 9CA90CD57A8A52498079F8A88484E68B + * @ConQAT.Rating YELLOW Hash: 720EFC814AF5BECE52D4786E4591A76D */ -final class DoubleClick implements IDoubleClickListener { +class DoubleClick implements IDoubleClickListener { /** Stores the use-raw-eobject flag. */ private final boolean useRawEObject; @@ -54,7 +54,7 @@ final class DoubleClick implements IDoubleClickListener { public void doubleClick(DoubleClickEvent event) { // delegate to the editor service if (event.getSelection() instanceof IStructuredSelection) { - EObject element = EObjectSelectionUtils.getFirstElement(event + EObject element = getDoubleClickedElement((IStructuredSelection) event .getSelection()); if (element != null) { if (!useRawEObject) { @@ -69,4 +69,13 @@ final class DoubleClick implements IDoubleClickListener { } } } + + /** + * Returns the element to be considered the target of the double click. + * Sub-classes may override. The default uses the first element of the given + * selection. + */ + protected EObject getDoubleClickedElement(IStructuredSelection selection) { + return EObjectSelectionUtils.getFirstElement(selection); + } } diff --git a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/views/MarkerViewPart.java b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/views/MarkerViewPart.java index b40ec9ff5..0528930c3 100644 --- a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/views/MarkerViewPart.java +++ b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/internal/views/MarkerViewPart.java @@ -34,6 +34,7 @@ import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.viewers.CellLabelProvider; import org.eclipse.jface.viewers.ColumnViewerToolTipSupport; +import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerCell; @@ -55,7 +56,7 @@ import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService; * @author hoelzl * @author $Author$ * @version $Rev$ - * @ConQAT.Rating GREEN Hash: 3A3C17AFE1D3C603961CA52C19450897 + * @ConQAT.Rating YELLOW Hash: 866C76878D04BE1CF9B23DC9FFEE49C8 */ public class MarkerViewPart extends ViewPart { @@ -199,7 +200,18 @@ public class MarkerViewPart extends ViewPart { ColumnViewerToolTipSupport .enableFor(gui.getProjectColumn().getViewer()); - gui.getTreeViewer().addDoubleClickListener(new DoubleClick(true)); + gui.getTreeViewer().addDoubleClickListener(new DoubleClick(true) { + /** {@inheritDoc} */ + @Override + protected EObject getDoubleClickedElement( + IStructuredSelection selection) { + if (selection.getFirstElement() instanceof IConstraintViolation) { + return ((IConstraintViolation<EObject>) selection + .getFirstElement()).getContainer(); + } + return super.getDoubleClickedElement(selection); + } + }); gui.getTreeViewer().setInput(IMarkerService.INSTANCE); createToggleActions(); @@ -266,5 +278,4 @@ public class MarkerViewPart extends ViewPart { refresh(); } } - } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/base/ConstraintViolationBase.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/base/ConstraintViolationBase.java index ff024fbdb..1d909ec8e 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/base/ConstraintViolationBase.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/base/ConstraintViolationBase.java @@ -29,7 +29,7 @@ import org.fortiss.tooling.kernel.extension.data.IConstraintViolation; * @author hoelzl * @author $Author$ * @version $Rev$ - * @ConQAT.Rating YELLOW Hash: CC17BC4ED54FFD8211F02C90443F77C8 + * @ConQAT.Rating YELLOW Hash: 1FC553699663AB6CFD50E2B4D17B5276 */ public class ConstraintViolationBase<T extends EObject> implements IConstraintViolation<T> { @@ -37,6 +37,9 @@ public class ConstraintViolationBase<T extends EObject> implements /** Stores the model element. */ private final T source; + /** Stores the container element. */ + private final EObject container; + /** Stores the explanation */ private final String explanation; @@ -45,10 +48,17 @@ public class ConstraintViolationBase<T extends EObject> implements /** Constructor. */ public ConstraintViolationBase(T source, ESeverity severity, - String explanation) { + String explanation, EObject container) { this.source = source; this.explanation = explanation; this.severity = severity; + this.container = container; + } + + /** Constructor. */ + public ConstraintViolationBase(T source, ESeverity severity, + String explanation) { + this(source, severity, explanation, source); } /** {@inheritDoc} */ @@ -57,6 +67,12 @@ public class ConstraintViolationBase<T extends EObject> implements return source; } + /** {@inheritDoc} */ + @Override + public EObject getContainer() { + return container; + } + /** {@inheritDoc} */ @Override public String getExplanation() { diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/data/IConstraintViolation.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/data/IConstraintViolation.java index d3898856c..1e239d16f 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/data/IConstraintViolation.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/data/IConstraintViolation.java @@ -37,13 +37,19 @@ import org.fortiss.tooling.kernel.extension.base.ConstraintViolationBase; * @author hoelzlf * @author $Author$ * @version $Rev$ - * @ConQAT.Rating GREEN Hash: EF654287282639CBC759ADFE6688688F + * @ConQAT.Rating YELLOW Hash: 04141B3BFD9B4AE78321DA1CE292E144 */ public interface IConstraintViolation<T extends EObject> extends IAdaptable { /** Returns the source of the constraint violation. */ T getSource(); + /** + * Returns the container object used for fixing this violation (i.e. the + * object to be opened an editor for). + */ + EObject getContainer(); + /** Returns the severity of the constraint violation. */ ESeverity getSeverity(); -- GitLab