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

added container to marker service

refs 503
parent 32f39c68
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
}
......@@ -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();
}
}
}
......@@ -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() {
......
......@@ -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();
......
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