diff options
author | Christoph Caks | 2016-08-18 15:55:29 +0000 |
---|---|---|
committer | Christoph Caks | 2016-08-18 15:55:29 +0000 |
commit | 199d24a40f0fc93990ac3d65ffe0f69010ad54e4 (patch) | |
tree | f5c81f56c64d870df82b1a3190f33e519ee540db /bundles/code/org.eclipse.fx.text/src/org/eclipse/fx | |
parent | e0656be05b414fbe86204357543490a1dbdd608e (diff) | |
download | org.eclipse.efxclipse-199d24a40f0fc93990ac3d65ffe0f69010ad54e4.tar.gz org.eclipse.efxclipse-199d24a40f0fc93990ac3d65ffe0f69010ad54e4.tar.xz org.eclipse.efxclipse-199d24a40f0fc93990ac3d65ffe0f69010ad54e4.zip |
fixes #6
refs #5
Diffstat (limited to 'bundles/code/org.eclipse.fx.text/src/org/eclipse/fx')
4 files changed, 154 insertions, 11 deletions
diff --git a/bundles/code/org.eclipse.fx.text/src/org/eclipse/fx/text/hover/HTMLHoverInfo.java b/bundles/code/org.eclipse.fx.text/src/org/eclipse/fx/text/hover/HTMLHoverInfo.java deleted file mode 100644 index 512b5ecf6..000000000 --- a/bundles/code/org.eclipse.fx.text/src/org/eclipse/fx/text/hover/HTMLHoverInfo.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.eclipse.fx.text.hover; - -import org.eclipse.jface.text.IRegion; - -public class HTMLHoverInfo extends HoverInfo { - - public HTMLHoverInfo(HoverInfoType type, IRegion region, CharSequence html, Object hoverModel) { - super(type, region, html, hoverModel); - } - -} diff --git a/bundles/code/org.eclipse.fx.text/src/org/eclipse/fx/text/hover/HoverInfo.java b/bundles/code/org.eclipse.fx.text/src/org/eclipse/fx/text/hover/HoverInfo.java index 56e296105..931c66c39 100644 --- a/bundles/code/org.eclipse.fx.text/src/org/eclipse/fx/text/hover/HoverInfo.java +++ b/bundles/code/org.eclipse.fx.text/src/org/eclipse/fx/text/hover/HoverInfo.java @@ -11,6 +11,7 @@ public class HoverInfo { private final CharSequence hoverContent; + @Deprecated public HoverInfo(HoverInfoType type, IRegion region, String hoverText, Object hoverModel) { this.type = type; this.region = region; diff --git a/bundles/code/org.eclipse.fx.text/src/org/eclipse/fx/text/hover/HtmlString.java b/bundles/code/org.eclipse.fx.text/src/org/eclipse/fx/text/hover/HtmlString.java new file mode 100644 index 000000000..86c498158 --- /dev/null +++ b/bundles/code/org.eclipse.fx.text/src/org/eclipse/fx/text/hover/HtmlString.java @@ -0,0 +1,78 @@ +package org.eclipse.fx.text.hover; + +import java.util.ArrayList; +import java.util.List; + +import javafx.event.Event; +import javafx.event.EventHandler; +import javafx.event.EventType; + +public class HtmlString implements CharSequence { + + private List<EventHandler<LinkActionEvent>> linkActionHandlers = new ArrayList<>(); + private List<EventHandler<LinkActionEvent>> linkContextHandlers = new ArrayList<>(); + + public final <T extends Event> void addEventHandler( + final EventType<T> eventType, + final EventHandler<? super T> eventHandler) { + if (eventType == LinkActionEvent.LINK_ACTION) { + linkActionHandlers.add((EventHandler<LinkActionEvent>)eventHandler); + } + else if (eventType == LinkActionEvent.LINK_CONTEXT) { + linkContextHandlers.add((EventHandler<LinkActionEvent>)eventHandler); + } + } + + public final <T extends Event> void removeEventHandler( + final EventType<T> eventType, + final EventHandler<? super T> eventHandler) { + if (eventType == LinkActionEvent.LINK_ACTION) { + linkActionHandlers.remove(eventHandler); + } + else if (eventType == LinkActionEvent.LINK_CONTEXT) { + linkContextHandlers.remove(eventHandler); + } + } + + public final void fireEvent(Event event) { + if (event instanceof LinkActionEvent) { + if (event.getEventType() == LinkActionEvent.LINK_ACTION) { + for (EventHandler<LinkActionEvent> h : linkActionHandlers) { + h.handle((LinkActionEvent)event); + } + } + else if (event.getEventType() == LinkActionEvent.LINK_CONTEXT) { + for (EventHandler<LinkActionEvent> h : linkContextHandlers) { + h.handle((LinkActionEvent)event); + } + } + } + } + + private String html; + + public HtmlString(String html) { + this.html = html; + } + + @Override + public int length() { + return html.length(); + } + + @Override + public char charAt(int index) { + return html.charAt(index); + } + + @Override + public CharSequence subSequence(int start, int end) { + return html.subSequence(start, end); + } + + @Override + public String toString() { + return html; + } + +} diff --git a/bundles/code/org.eclipse.fx.text/src/org/eclipse/fx/text/hover/LinkActionEvent.java b/bundles/code/org.eclipse.fx.text/src/org/eclipse/fx/text/hover/LinkActionEvent.java new file mode 100644 index 000000000..3ed37325c --- /dev/null +++ b/bundles/code/org.eclipse.fx.text/src/org/eclipse/fx/text/hover/LinkActionEvent.java @@ -0,0 +1,75 @@ +package org.eclipse.fx.text.hover; + +import javafx.event.Event; +import javafx.event.EventTarget; +import javafx.event.EventType; + +/** + * An {@link Event} representing some type of action. This event type is widely + * used to represent a variety of things, such as when a {@link javafx.scene.control.Button} + * has been fired, when a {@link javafx.animation.KeyFrame} has finished, and other + * such usages. + * @since JavaFX 2.0 + */ + public class LinkActionEvent extends Event { + + private static final long serialVersionUID = 20121107L; + + public static final EventType<LinkActionEvent> LINK = + new EventType<LinkActionEvent>(Event.ANY, "LINK"); + + public static final EventType<LinkActionEvent> LINK_ACTION = + new EventType<LinkActionEvent>(LINK, "LINK_ACTION"); + + public static final EventType<LinkActionEvent> LINK_CONTEXT = + new EventType<LinkActionEvent>(LINK, "LINK_CONTEXT"); + + + private String linkTarget; + + private double screenX; + private double screenY; + + public LinkActionEvent(EventType<LinkActionEvent> type, String linkTarget, double screenX, double screenY) { + super(type); + this.linkTarget = linkTarget; + this.screenX = screenX; + this.screenY = screenY; + } + + /** + * Construct a new {@code ActionEvent} with the specified event source and target. + * If the source or target is set to {@code null}, it is replaced by the + * {@code NULL_SOURCE_TARGET} value. All ActionEvents have their type set to + * {@code ACTION}. + * + * @param source the event source which sent the event + * @param target the event target to associate with the event + */ + public LinkActionEvent(Object source, EventTarget target, EventType<LinkActionEvent> type) { + super(source, target, type); + } + + @Override + public LinkActionEvent copyFor(Object newSource, EventTarget newTarget) { + return (LinkActionEvent) super.copyFor(newSource, newTarget); + } + + @Override + public EventType<? extends LinkActionEvent> getEventType() { + return (EventType<? extends LinkActionEvent>) super.getEventType(); + } + + public String getLinkTarget() { + return linkTarget; + } + + public double getScreenX() { + return screenX; + } + + public double getScreenY() { + return screenY; + } + + }
\ No newline at end of file |