Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(688)

Unified Diff: editor/tools/plugins/com.xored.glance.ui/src/com/xored/glance/ui/controls/text/styled/StyledTextBlock.java

Issue 17431004: New UI for Find command: find-as-you-type. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: editor/tools/plugins/com.xored.glance.ui/src/com/xored/glance/ui/controls/text/styled/StyledTextBlock.java
===================================================================
--- editor/tools/plugins/com.xored.glance.ui/src/com/xored/glance/ui/controls/text/styled/StyledTextBlock.java (revision 0)
+++ editor/tools/plugins/com.xored.glance.ui/src/com/xored/glance/ui/controls/text/styled/StyledTextBlock.java (revision 0)
@@ -0,0 +1,55 @@
+/**
+ *
+ */
+package com.xored.glance.ui.controls.text.styled;
+
+import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.swt.custom.ExtendedModifyEvent;
+import org.eclipse.swt.custom.ExtendedModifyListener;
+import org.eclipse.swt.custom.StyledText;
+
+import com.xored.glance.ui.sources.ITextBlock;
+import com.xored.glance.ui.sources.ITextBlockListener;
+import com.xored.glance.ui.sources.TextChangedEvent;
+
+/**
+ * @author Yuri Strot
+ */
+public class StyledTextBlock implements ITextBlock, ExtendedModifyListener {
+
+ public StyledTextBlock(StyledText text) {
+ this.text = text;
+ listeners = new ListenerList();
+ text.addExtendedModifyListener(this);
+ }
+
+ public String getText() {
+ return text.getText();
+ }
+
+ public void addTextBlockListener(ITextBlockListener listener) {
+ listeners.add(listener);
+ }
+
+ public void removeTextBlockListener(ITextBlockListener listener) {
+ listeners.remove(listener);
+ }
+
+ public void modifyText(ExtendedModifyEvent event) {
+ Object[] objects = listeners.getListeners();
+ TextChangedEvent textEvent = new TextChangedEvent(event.start, event.length, event.replacedText);
+ for (Object object : objects) {
+ ITextBlockListener listener = (ITextBlockListener) object;
+ listener.textChanged(textEvent);
+ }
+ }
+
+ public int compareTo(ITextBlock o) {
+ //style text support only one text block
+ return 0;
+ }
+
+ private StyledText text;
+ private ListenerList listeners;
+
+}

Powered by Google App Engine
This is Rietveld 408576698