Commit c7834450 authored by Saad bin Abid's avatar Saad bin Abid

added new files for marker view

*

Issue-Ref: 4018
Issue-Url: https://af3-developer.fortiss.org/issues/4018Signed-off-by: Saad bin Abid's avatarSaad bin Abid <abid@fortiss.org>
parent 6eab4c13
......@@ -15,6 +15,8 @@
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.ui.internal.views.ErrorViewFX;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeContentProviderBase;
......@@ -30,11 +32,8 @@ import javafx.scene.layout.BorderPane;
/**
*
* Let's say hello to the world.
*
*
*
* Controller class for the "Hello world!" view. References the FXML layout and contains all control
* Controller class for the "marker view". References the FXML layout and contains all control
*
* logic.
*
......@@ -65,41 +64,75 @@ public class ErrorViewFXLayoutController extends CompositeFXControllerBase<Node,
@FXML
private BorderPane pane;
@SuppressWarnings("javadoc")
int btnOption = 0;
/** Toggle State */
@SuppressWarnings("unused")
private Map<ESeverity, Boolean> toggleState;
/** */
List<ESeverity> SevrList = new ArrayList<ESeverity>();
/**
* @param toggleState
*/
@SuppressWarnings("unchecked")
public ErrorViewFXLayoutController(Map<ESeverity, Boolean> toggleState) {
this.toggleState = toggleState;
}
/** Called when debug checkbox is pushed. */
public void onDebugBtn() {
if(!debugBtn.isPressed()) {
btnOption = 3;
} else {
btnOption = 0;
}
initialize();
}
/** Called when info checkbox is pushed. */
public void onInfoBtn() {
if(!infoBtn.isPressed()) {
btnOption = 4;
} else {
btnOption = 0;
}
initialize();
}
/** Called when warning checkbox is pushed. */
public void onWarningBtn() {
if(!warningBtn.isPressed()) {
btnOption = 2;
} else {
btnOption = 0;
}
initialize();
}
/** Called when error checkbox is pushed. */
public void onErrorBtn() {
if(!errorBtn.isPressed()) {
btnOption = 1;
} else {
btnOption = 0;
}
initialize();
}
/** Called when fatal checkbox is pushed. */
public void onFatalBtn() {
if(!fatalBtn.isPressed()) {
btnOption = 5;
} else {
btnOption = 0;
}
initialize();
}
/** {@inheritDoc} */
@Override
public String getFXMLLocation() {
return "ErrorViewFXLayout.fxml";
......@@ -108,11 +141,47 @@ public class ErrorViewFXLayoutController extends CompositeFXControllerBase<Node,
/** {@inheritDoc} */
@Override
public void initialize() {
DynamicTreeContentProviderBase<Object> contentProvider = new MarkerViewFXContentProvider();
DynamicTreeTableUIProviderBase<Object> uiProvider = new MarkerViewFXUIProvider();
DynamicTreeTableViewer<Object> treeTable = new DynamicTreeTableViewer<Object>(new Object(),
false, 2, contentProvider, uiProvider);
// To Complete (Under Construction): Currently the can only have filtering for only one type
// of Severity
// Johannes: need suggestion/feedback to complete it also please help me with grouping the
// severities w.r.t labels
switch(btnOption) {
case 0: // for showing all the Severities
SevrList.clear();
SevrList.add(ESeverity.ERROR);
SevrList.add(ESeverity.WARNING);
SevrList.add(ESeverity.DEBUG);
SevrList.add(ESeverity.FATAL);
SevrList.add(ESeverity.INFO);
SevrList.add(ESeverity.NONE);
break;
case 1: // for showing only Error
SevrList.clear();
SevrList.add(ESeverity.ERROR);
break;
case 2: // for showing only Warning
SevrList.clear();
SevrList.add(ESeverity.WARNING);
break;
case 3: // for showing Debug
SevrList.clear();
SevrList.add(ESeverity.DEBUG);
break;
case 4: // for showing Info
SevrList.clear();
SevrList.add(ESeverity.INFO);
break;
case 5: // for showing Fatal
SevrList.clear();
SevrList.add(ESeverity.FATAL);
break;
}
DynamicTreeContentProviderBase<Object> contentProvider = new MarkerViewFXContentProvider();
DynamicTreeTableUIProviderBase<Object> uiProvider = new MarkerViewFXUIProvider(this);
DynamicTreeTableViewer<Object> treeTable =
new DynamicTreeTableViewer<Object>(SevrList, false, 2, contentProvider, uiProvider);
treeTable.addColumn("Severity", 80);
treeTable.addColumn("Element", 80);
......
......@@ -33,7 +33,7 @@ import org.fortiss.tooling.kernel.ui.service.IMarkerService;
/**
*
* Let's say hello to the world.
* JavaFX view part of the Marker View.
*
*
*
......@@ -75,7 +75,6 @@ public class ErrorViewFXViewPart extends AF3FXViewPart {
/** Called when there are error amrker updates. */
public void refresh() {
// TODO
}
/** Returns toggleState. */
......
......@@ -17,9 +17,12 @@ package org.fortiss.tooling.kernel.ui.internal.views.ErrorViewFX;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeContentProviderBase;
import org.fortiss.tooling.kernel.extension.data.IConstraintViolation;
import org.fortiss.tooling.kernel.extension.data.IConstraintViolation.ESeverity;
import org.fortiss.tooling.kernel.ui.service.IMarkerService;
/**
*
......@@ -27,24 +30,24 @@ import org.fortiss.tooling.kernel.extension.data.IConstraintViolation;
*/
public class MarkerViewFXContentProvider extends DynamicTreeContentProviderBase<Object> {
private MarkerViewFXContentProvider errorViewFXViewPart;
/**
*
*/
public MarkerViewFXContentProvider() {
// TODO Auto-generated constructor stub
}
private ErrorViewFXViewPart markerViewFXViewPart;
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
protected Collection<? extends Object> getChildren(Object parent) {
ArrayList<IConstraintViolation> result = new ArrayList<IConstraintViolation>();
if(parent instanceof IConstraintViolation) {
IConstraintViolation violation = (IConstraintViolation)parent;
result.add(violation);
public Collection<? extends Object> getChildren(Object parent) {
List<ESeverity> servList = new ArrayList<ESeverity>();
Collection<IConstraintViolation> violation_list = new ArrayList<IConstraintViolation>();
if(parent instanceof List) {
servList = (List)parent;
for(int i = 0; i < servList.size(); i++) {
violation_list.addAll(IMarkerService.getInstance()
.getAllViolationsWithSeverity((ESeverity)servList.get(i)));
}
return violation_list;
}
return result;
return null;
}
}
......@@ -19,77 +19,88 @@ import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableUIProviderBase;
import org.fortiss.tooling.kernel.extension.data.IConstraintViolation;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.model.INamedCommentedElement;
import org.fortiss.tooling.kernel.service.ICommandStackService;
import org.fortiss.tooling.kernel.service.IPersistencyService;
import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
import javafx.scene.control.ContextMenu;
/**
*
* @author abid
*/
public class MarkerViewFXUIProvider extends DynamicTreeTableUIProviderBase<Object> {
ErrorViewFXLayoutController errorViewFXLayoutController;
/**
* @param errorViewFXLayoutController
*/
public MarkerViewFXUIProvider(ErrorViewFXLayoutController errorViewFXLayoutController) {
// TODO Auto-generated constructor stub
this.errorViewFXLayoutController = errorViewFXLayoutController;
}
/** {@inheritDoc} */
@Override
public String getLabel(Object element, int column) {
/** {@inheritDoc} */
public void updateValue(Object element, int column, Object value) {
if(column == 0 && element instanceof INamedCommentedElement) {
INamedCommentedElement elem = (INamedCommentedElement)element;
ICommandStackService.getInstance().runAsCommand(elem, () -> {
elem.setComment((String)value);
});
}
}
// column for ESevertiy Type Error, Warning etc....
if(column == 0) {
return "";
// return getModelElementHandlerName(element);
/** {@inheritDoc} */
@Override
public ContextMenu createContextMenu(Object element, int col) {
if(element == null || col != 0) {
return null;
}
// column for source element
if(column == 1) {
if(element instanceof IConstraintViolation) {
IConstraintViolation<? extends EObject> violation =
(IConstraintViolation<? extends EObject>)element;
IModelElementHandlerService hs = IModelElementHandlerService.getInstance();
IModelElementHandler<EObject> handler =
hs.getModelElementHandler(violation.getSource());
if(handler != null) {
return handler.getName(violation.getSource());
} else {
return "";
}
}
// column for the Explanation Column
else if(column == 2) {
if(element instanceof IConstraintViolation) {
IConstraintViolation<? extends EObject> violation =
(IConstraintViolation<? extends EObject>)element;
return violation.getExplanation();
} else {
return "";
}
}
// column for the Project Column
else if(column == 3) {
ContextMenu menu = new ContextMenu();
return menu;
}
/** {@inheritDoc} */
@Override
public String getLabel(Object element, int col) {
if(element instanceof IConstraintViolation) {
if(element instanceof IConstraintViolation) {
switch(col) {
case 0: // Severity Column
return ((IConstraintViolation)element).getSeverity().toString();
case 1: // Element Column
IConstraintViolation<? extends EObject> violation =
(IConstraintViolation<? extends EObject>)element;
IModelElementHandlerService hs = IModelElementHandlerService.getInstance();
IModelElementHandler<EObject> handler =
hs.getModelElementHandler(violation.getSource());
if(handler != null) {
return handler.getName(violation.getSource());
}
case 2: // Explanation Column
return ((IConstraintViolation)element).getExplanation();
case 3: // Project Column
IConstraintViolation<? extends EObject> violation_prj =
(IConstraintViolation<? extends EObject>)element;
IPersistencyService ps = IPersistencyService.getInstance();
ITopLevelElement topElement = ps.getTopLevelElementFor(violation.getSource());
IModelElementHandler<EObject> handler = null;
ITopLevelElement topElement =
ps.getTopLevelElementFor(violation_prj.getSource());
IModelElementHandler<EObject> handler_prj = null;
EObject rootElement = null;
if(topElement != null) {
rootElement = topElement.getRootModelElement();
IModelElementHandlerService hs = IModelElementHandlerService.getInstance();
handler = hs.getModelElementHandler(rootElement);
IModelElementHandlerService hs_prj =
IModelElementHandlerService.getInstance();
handler_prj = hs_prj.getModelElementHandler(rootElement);
}
if(handler != null) {
return handler.getName(rootElement);
} else {
return "";
}
} else {
return "";
}
return(handler_prj != null ? handler_prj.getName(rootElement) : "");
}
}
return "";
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment