Skip to content
Snippets Groups Projects
Commit 57b5ce56 authored by Johannes Eder's avatar Johannes Eder
Browse files

<Sub-system>: <Summary>

* changed to toogle buttons
* created new fx image method
* created standard tool tip util method

Issue-Ref: 4018
Issue-Url: https://af3-developer.fortiss.org/issues/4018



Signed-off-by: default avatarJohannes Eder <eder@fortiss.org>
parent 3bf0b9d7
No related branches found
No related tags found
1 merge request!1244018 error view java fx
......@@ -26,6 +26,7 @@ import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Tooltip;
/**
* Utility methods for {@link Scene} graph.
......@@ -197,4 +198,14 @@ public final class JavaFXUtils {
}
return null;
}
/**
* Creates a tooltip with the given text, yellow background and black font. The standard tooltip
* is white font on yellow background which is hardly readable.
*/
public static Tooltip createToolTip(String description) {
Tooltip value = new Tooltip(description);
value.setStyle("-fx-background-color: yellow; -fx-text-fill: black;");
return value;
}
}
......@@ -31,6 +31,8 @@ import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
import org.fortiss.tooling.kernel.ui.service.INavigatorService;
import org.osgi.framework.BundleContext;
import javafx.scene.image.ImageView;
/**
* The activator class controls the plug-in life cycle.
*
......@@ -91,4 +93,13 @@ public class ToolingKernelUIActivator extends AbstractUIPlugin {
protected void initializeImageRegistry(ImageRegistry registry) {
ESharedImages.registerImages(registry);
}
public static ImageView getFXImage(String iconPath) {
try {
ImageView iv = new ImageView(iconPath);
return iv;
} catch(NullPointerException | IllegalArgumentException e) {
return null;
}
}
}
......@@ -17,6 +17,7 @@ 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.getFXImage;
import static org.fortiss.tooling.kernel.ui.ToolingKernelUIActivator.getImageDescriptor;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.postRefreshNotification;
......@@ -46,6 +47,8 @@ import org.fortiss.tooling.kernel.service.listener.IPersistencyServiceListener;
import org.fortiss.tooling.kernel.ui.internal.views.ErrorViewFX.ErrorViewFXLayoutController;
import org.fortiss.tooling.kernel.ui.service.IMarkerService;
import javafx.scene.image.ImageView;
/**
* This class implements the {@link IMarkerService} interface.
*
......@@ -388,6 +391,30 @@ public class MarkerService implements IMarkerService, IPersistencyServiceListene
return list;
}
/** {@inheritDoc} */
@Override
public ImageView getFXImageFor(ESeverity severity, boolean smallDecoration) {
switch(severity) {
case FATAL:
return getFXImage("icons/fatal.gif");
case ERROR:
if(smallDecoration) {
return getFXImage("icons/error_small.gif");
}
return getFXImage("icons/error.gif");
case WARNING:
if(smallDecoration) {
return getFXImage("icons/warning_small.gif");
}
return getFXImage("icons/warning.gif");
case INFO:
return getFXImage("icons/info.gif");
case DEBUG:
return getFXImage("icons/debug.gif");
}
return null;
}
/** {@inheritDoc} */
@Override
public ImageDescriptor getImageFor(ESeverity severity, boolean smallDecoration) {
......
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.ToggleButton?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<ScrollPane xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
<ScrollPane fitToHeight="true" fitToWidth="true" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
<content>
<VBox>
<children>
<HBox>
<children>
<CheckBox fx:id="errorBtn" mnemonicParsing="false" onAction="#onErrorBtn" text="Error" />
<CheckBox fx:id="infoBtn" mnemonicParsing="false" onAction="#onInfoBtn" text="Info" />
<CheckBox fx:id="debugBtn" mnemonicParsing="false" onAction="#onDebugBtn" text="Debug" />
<CheckBox fx:id="warningBtn" mnemonicParsing="false" onAction="#onWarningBtn" text="Warning" />
<CheckBox fx:id="fatalBtn" mnemonicParsing="false" onAction="#onFatalBtn" prefHeight="18.0" prefWidth="93.0" text="Fatal" />
<ToggleButton fx:id="errorBtn" mnemonicParsing="false" onAction="#onErrorBtn" text="Error" />
<ToggleButton fx:id="infoBtn" mnemonicParsing="false" onAction="#onInfoBtn" text="Info" />
<ToggleButton fx:id="debugBtn" mnemonicParsing="false" onAction="#onDebugBtn" text="Debug" />
<ToggleButton fx:id="warningBtn" mnemonicParsing="false" onAction="#onWarningBtn" text="Warning" />
<ToggleButton fx:id="fatalBtn" mnemonicParsing="false" onAction="#onFatalBtn" text="Fatal" />
</children>
</HBox>
<BorderPane fx:id="pane" prefHeight="200.0" prefWidth="200.0" />
<BorderPane fx:id="pane" />
</children>
</VBox>
</content>
......
......@@ -15,6 +15,13 @@
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.ui.internal.views.ErrorViewFX;
import static org.fortiss.tooling.common.ui.javafx.util.JavaFXUtils.createToolTip;
import static org.fortiss.tooling.kernel.extension.data.IConstraintViolation.ESeverity.DEBUG;
import static org.fortiss.tooling.kernel.extension.data.IConstraintViolation.ESeverity.ERROR;
import static org.fortiss.tooling.kernel.extension.data.IConstraintViolation.ESeverity.FATAL;
import static org.fortiss.tooling.kernel.extension.data.IConstraintViolation.ESeverity.INFO;
import static org.fortiss.tooling.kernel.extension.data.IConstraintViolation.ESeverity.WARNING;
import java.util.HashMap;
import java.util.Map;
......@@ -28,7 +35,8 @@ import org.fortiss.tooling.kernel.ui.service.IMarkerService;
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ToggleButton;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
/**
......@@ -42,19 +50,19 @@ public class ErrorViewFXLayoutController extends CompositeFXControllerBase<Node,
/** Debug Button */
@FXML
private CheckBox debugBtn;
private ToggleButton debugBtn;
/** Info Button */
@FXML
private CheckBox infoBtn;
private ToggleButton infoBtn;
/** Warning Button */
@FXML
private CheckBox warningBtn;
private ToggleButton warningBtn;
/** Error Button */
@FXML
private CheckBox errorBtn;
private ToggleButton errorBtn;
/** Fatal Button */
@FXML
private CheckBox fatalBtn;
private ToggleButton fatalBtn;
/** Border Pane for the tree table */
@FXML
private BorderPane pane;
......@@ -144,7 +152,39 @@ public class ErrorViewFXLayoutController extends CompositeFXControllerBase<Node,
treeTable.addColumn("Explanation", 80);
treeTable.addColumn("Project", 80);
// set up icons
ImageView debugImg = IMarkerService.getInstance().getFXImageFor(ESeverity.DEBUG, false);
debugBtn.setGraphic(debugImg);
debugBtn.setText("");
debugBtn.setTooltip(createToolTip(DEBUG.name()));
toggleState.put(DEBUG, false);
ImageView errorImg = IMarkerService.getInstance().getFXImageFor(ESeverity.ERROR, false);
errorBtn.setGraphic(errorImg);
errorBtn.setText("");
errorBtn.setTooltip(createToolTip(ERROR.name()));
toggleState.put(ERROR, true);
errorBtn.setSelected(true);
ImageView fatalImg = IMarkerService.getInstance().getFXImageFor(ESeverity.FATAL, false);
fatalBtn.setGraphic(fatalImg);
fatalBtn.setText("");
fatalBtn.setTooltip(createToolTip(FATAL.name()));
toggleState.put(FATAL, false);
ImageView infoImg = IMarkerService.getInstance().getFXImageFor(ESeverity.INFO, false);
infoBtn.setGraphic(infoImg);
infoBtn.setText("");
infoBtn.setTooltip(createToolTip(INFO.name()));
toggleState.put(INFO, false);
ImageView warnImg = IMarkerService.getInstance().getFXImageFor(ESeverity.WARNING, false);
warningBtn.setGraphic(warnImg);
warningBtn.setText("");
warningBtn.setTooltip(createToolTip(WARNING.name()));
toggleState.put(WARNING, true);
warningBtn.setSelected(true);
pane.setCenter(treeTable.getControl());
pane.layout();
}
}
......@@ -27,6 +27,8 @@ import org.fortiss.tooling.kernel.service.IConstraintCheckerService;
import org.fortiss.tooling.kernel.ui.internal.MarkerService;
import org.fortiss.tooling.kernel.ui.internal.views.ErrorViewFX.ErrorViewFXViewPart;
import javafx.scene.image.ImageView;
/**
* The marker service manages model element specific markers. It uses the
* {@link IConstraintCheckerService} to check constraints on the model and
......@@ -69,6 +71,9 @@ public interface IMarkerService {
*/
ImageDescriptor getImageFor(ESeverity severity, boolean smallDecoration);
/** Similar to {@link #getImageFor(ESeverity, boolean)} but for Java FX. */
ImageView getFXImageFor(ESeverity severity, boolean smallDecoration);
/**
* <p>
* Returns a shared icon appropriate for the severity. Flag indicates small sized image.
......
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