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

Unified Diff: editor/tools/plugins/com.xored.glance.ui/src/com/xored/glance/ui/utils/UITextBlock.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/utils/UITextBlock.java
===================================================================
--- editor/tools/plugins/com.xored.glance.ui/src/com/xored/glance/ui/utils/UITextBlock.java (revision 0)
+++ editor/tools/plugins/com.xored.glance.ui/src/com/xored/glance/ui/utils/UITextBlock.java (revision 0)
@@ -0,0 +1,96 @@
+/**
+ *
+ */
+package com.xored.glance.ui.utils;
+
+import org.eclipse.core.runtime.ListenerList;
+
+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 UITextBlock implements ITextBlock, ITextBlockListener {
+
+ public UITextBlock(ITextBlock block) {
+ this.block = block;
+ text = block.getText();
+ block.addTextBlockListener(this);
+ }
+
+ public void dispose() {
+ block.removeTextBlockListener(this);
+ }
+
+ /**
+ * @return the block
+ */
+ public ITextBlock getBlock() {
+ return block;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.xored.glance.ui.sources.ITextBlock#getText()
+ */
+ public String getText() {
+ return text;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.xored.glance.ui.sources.ITextBlock#addTextBlockListener(com.xored
+ * .glance.ui.sources.ITextBlockListener)
+ */
+ public void addTextBlockListener(ITextBlockListener listener) {
+ listeners.add(listener);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.xored.glance.ui.sources.ITextBlock#removeTextBlockListener(com.xored
+ * .glance.ui.sources.ITextBlockListener)
+ */
+ public void removeTextBlockListener(ITextBlockListener listener) {
+ listeners.remove(listener);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.xored.glance.ui.sources.ITextBlockListener#textChanged(com.xored.
+ * glance.ui.sources.TextChangedEvent)
+ */
+ public void textChanged(TextChangedEvent event) {
+ text = block.getText();
+ Object[] objects = listeners.getListeners();
+ for (Object object : objects) {
+ ITextBlockListener listener = (ITextBlockListener) object;
+ listener.textChanged(event);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(ITextBlock block) {
+ return this.block.compareTo(((UITextBlock) block).block);
+ }
+
+ @Override
+ public String toString() {
+ return "UI(" + block + ")";
+ }
+
+ private ListenerList listeners = new ListenerList();
+ private ITextBlock block;
+ private String text;
+
+}

Powered by Google App Engine
This is Rietveld 408576698