Commit 1b96b720 authored by Alexander Diewald's avatar Alexander Diewald

Merge branch '3969' into 'master'

3969

See merge request !108
parents 6d5526a8 8edab6ab
......@@ -5,7 +5,8 @@ bin.includes = .,\
lib/org.conqat.ide.commons.gef.jar,\
lib/org.conqat.ide.commons.ui.jar,\
lib/swt-grouplayout.jar,\
res/
res/,\
icons/
jars.compile.order = .
source.. = src/,\
res/,\
......
DiagramCoordinate.java 6b00aec99054d4cd19003a72bd4e5e774ac6a641 GREEN
DiagramLayers.java 155cbb47a5f0aaa0025320ae607e6777f3a2d2e8 GREEN
DiagramViewer.java 82a70a1bb673b455ebc430bbc2cffc71ab9f3140 GREEN
DiagramViewer.java 920bb0f4ee6dd9ac6b607e44c01f04a413b2e2ed GREEN
DiagramViewerDefaultTags.java 6230763252409c60009ab8887b4ef582cf883229 GREEN
DiagramViewerFeatures.java 31e3fb61f915b0d8695005b083c47ce1c5be0b05 GREEN
DiagramViewerFeatures.java 44f5315505d76ef8cb0b61b5a37d7d2501195788 GREEN
DiagramViewerSelection.java e833f592543bc97077907d980a39b123fc4044e6 GREEN
EDragGesture.java 5cfa098d3877db11981c2750e5e103156d62fc5e GREEN
FeedbackChange.java b088fa89af648f1674f2f9c1f7f99d585ce801ca GREEN
......
......@@ -14,19 +14,23 @@ import static java.lang.Math.ceil;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.util.Objects.requireNonNull;
import static javafx.geometry.VPos.TOP;
import static javafx.scene.layout.GridPane.setHgrow;
import static javafx.scene.layout.GridPane.setVgrow;
import static javafx.scene.layout.Priority.ALWAYS;
import static javafx.scene.paint.Color.ORANGERED;
import static javafx.scene.paint.Color.grayRgb;
import static org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewerDefaultTags.LINK_TARGET_ALLOWED_TAG;
import static org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewerDefaultTags.LINK_TARGET_DENIED_TAG;
import static org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewerDefaultTags.LINK_TARGET_MAYBE_TAG;
import static org.fortiss.tooling.common.ui.javafx.util.GraphicUtils.getFXImage;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import org.fortiss.tooling.common.ui.ToolingCommonUIActivator;
import org.fortiss.tooling.common.ui.javafx.lwfxef.change.Change;
import org.fortiss.tooling.common.ui.javafx.lwfxef.change.ChangeSet;
import org.fortiss.tooling.common.ui.javafx.lwfxef.change.DefaultModelModifier;
......@@ -54,6 +58,8 @@ import javafx.scene.control.ContextMenu;
import javafx.scene.control.Label;
import javafx.scene.control.MenuItem;
import javafx.scene.control.ScrollBar;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.ScrollEvent;
import javafx.scene.layout.GridPane;
......@@ -62,6 +68,7 @@ import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
import javafx.scene.shape.Line;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Text;
/**
* This class represents the diagram viewer node, which manages the grid
......@@ -87,6 +94,12 @@ public class DiagramViewer {
private final DiagramLayers layers;
/** The viewer main pane. */
private final Pane viewerPane;
/** The help label. */
private final Label helpLabel = new Label("");
/** The help display. */
private Text helpText = null;
/** The help shadowed background. */
private final Rectangle helpShadow = new Rectangle(0, 0);
/** The mouse drag multi-selection feedback rectangle. */
private final Rectangle mouseDragRectangle = new Rectangle(0, 0);
/** The initial location where the selection rectangle was started. */
......@@ -178,12 +191,24 @@ public class DiagramViewer {
debugLabel.setLayoutY(20);
debugLabel.setTextFill(ORANGERED);
viewerPane.getChildren().add(helpLabel);
Image helpImage = getFXImage(ToolingCommonUIActivator.PLUGIN_ID, "/icons/help.png");
ImageView view = new ImageView(helpImage);
helpLabel.setGraphic(view);
helpLabel.setLayoutX(viewerPane.getWidth() - helpLabel.getWidth());
helpLabel.setLayoutY(0);
helpLabel.setOnMouseClicked(evt -> {
toggleHelp();
});
// clipping rectangle for the viewer pane
Rectangle viewerClip = new Rectangle();
viewerPane.setClip(viewerClip);
viewerPane.layoutBoundsProperty().addListener((obs, ov, nv) -> {
viewerClip.setWidth(nv.getWidth());
double width = nv.getWidth();
viewerClip.setWidth(width);
viewerClip.setHeight(nv.getHeight());
helpLabel.setLayoutX(width - helpLabel.getWidth());
});
// update the viewer content
......@@ -676,6 +701,41 @@ public class DiagramViewer {
return getLayers().getMouseState().getDragExtent();
}
/** Toggles the in-place help. */
private void toggleHelp() {
if(helpText == null) {
// enable help
String txt = features.getHelpText();
if(txt == null || "".equals(txt)) {
txt = "No in-place help available.";
}
helpText = new Text(txt);
helpText.setFill(Color.WHITE);
helpText.setLayoutY(0);
double lw = viewerPane.getWidth() - helpLabel.getWidth();
// 20% of the width with 3 pixel inset
helpText.setLayoutX(lw * .2 + 3);
helpText.setLayoutY(3);
helpText.setTextOrigin(TOP);
helpText.setWrappingWidth(lw * .8 - 6);
helpText.setOnMouseClicked(evt -> toggleHelp());
helpShadow.setX(lw * .2);
helpShadow.setY(0);
helpShadow.setWidth(lw * .8);
helpShadow.setHeight(viewerPane.getHeight());
helpShadow.setFill(grayRgb(32, .66));
helpShadow.setOnMouseClicked(evt -> toggleHelp());
viewerPane.getChildren().add(helpShadow);
viewerPane.getChildren().add(helpText);
} else {
// disable help
viewerPane.getChildren().remove(helpText);
viewerPane.getChildren().remove(helpShadow);
helpText = null;
}
}
/**
* Creates a drag controller for the given bundle, gesture, mouse location and source node also
* considering the current selection.
......
......@@ -47,6 +47,8 @@ public final class DiagramViewerFeatures {
private IndicatorType indicatorType = IndicatorType.CROSS;
/** The background color. */
private Color backgroundColor = LIGHTGRAY;
/** The help text for the diagram viewer in-place help */
private String helpText = null;
/** Constructor. */
public DiagramViewerFeatures(DiagramViewer diagramViewer) {
......@@ -280,4 +282,14 @@ public final class DiagramViewerFeatures {
public double getMaximumSpacing() {
return max(getVerticalSpacing(), getHorizontalSpacing());
}
/** Returns the help text. */
public String getHelpText() {
return helpText;
}
/** Sets help text. */
public void setHelpText(String helpText) {
this.helpText = helpText;
}
}
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