Author: stan
Date: Thu Apr 10 20:42:56 2008
New Revision: 31451
Log:
APG-124 Workaround to add multiple LineStyleListener
Modified:
sandbox/Apogee/trunk/plugins/org.nuxeo.ecm.rcp.forms/src/org/nuxeo/ecm/rcp/forms/swt/TextFieldExt.java
Modified: sandbox/Apogee/trunk/plugins/org.nuxeo.ecm.rcp.forms/src/org/nuxeo/ecm/rcp/forms/swt/TextFieldExt.java
==============================================================================
--- sandbox/Apogee/trunk/plugins/org.nuxeo.ecm.rcp.forms/src/org/nuxeo/ecm/rcp/forms/swt/TextFieldExt.java (original)
+++ sandbox/Apogee/trunk/plugins/org.nuxeo.ecm.rcp.forms/src/org/nuxeo/ecm/rcp/forms/swt/TextFieldExt.java Thu Apr 10 20:42:56 2008
@@ -1,5 +1,7 @@
package org.nuxeo.ecm.rcp.forms.swt;
+import java.util.ArrayList;
+import java.util.Iterator;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.dialogs.Dialog;
@@ -43,6 +45,8 @@
super(field);
}
+ ArrayList<LineStyleListener> textFieldLineFieldlisteners = new ArrayList<LineStyleListener>();
+
StyledText text;
Shell tip;
@@ -86,6 +90,33 @@
});
}
+ text.addLineStyleListener(new LineStyleListener() {
+ public void lineGetStyle(LineStyleEvent event) {
+ for (Iterator<LineStyleListener> iterator = textFieldLineFieldlisteners.iterator(); iterator.hasNext();) {
+ LineStyleListener lineStyleListener = iterator.next();
+
+ StyleRange[] oldStyleRanges = event.styles;
+ lineStyleListener.lineGetStyle(event);
+ // copying old
+
+ if (event.styles != null && oldStyleRanges != null) {
+
+ StyleRange[] newStyleRanges = new StyleRange[oldStyleRanges.length
+ + event.styles.length];
+ int index = 0;
+ for (int i = 0; i < oldStyleRanges.length; i++) {
+ newStyleRanges[index++] = oldStyleRanges[i];
+ }
+ for (int i = 0; i < event.styles.length; i++) {
+ newStyleRanges[index++] = event.styles[i];
+ }
+ event.styles = newStyleRanges;
+ }
+
+ }
+ }
+ });
+
Color bgColor = RenderHelper.getBgColor(field);
Color fgColor = RenderHelper.getFgColor(field);
if (bgColor != null) {
@@ -117,6 +148,14 @@
return text;
}
+ public void addLineStyleListener(LineStyleListener listener) {
+ textFieldLineFieldlisteners.add(listener);
+ }
+
+ public void removeLineStyleListener(LineStyleListener listener) {
+ textFieldLineFieldlisteners.remove(listener);
+ }
+
@Override
protected void enableValidators() {
int minLength = 0;
@@ -137,10 +176,10 @@
}
}
if (minLength > 0 || maxLength > 0) {
- text.addLineStyleListener(new LenghtHandler(minLength, maxLength));
+ addLineStyleListener(new LenghtHandler(minLength, maxLength));
}
if (minLineLength > 0 || maxLineLength > 0) {
- text.addLineStyleListener(new LineLenghtHandler(minLineLength,
+ addLineStyleListener(new LineLenghtHandler(minLineLength,
maxLineLength, n));
}
This page is a mailing archive for one of the Nuxeo projects.
[2008/11/18] Nuxeo 5.2.M3 and Nuxeo WebEngine 1.0.RC released!
[2008/11/13] First Nuxeo Developer Day (1st Dec. 2008) - Still a few seats available[2008/11/13] First Nuxeo Survey[2008/10/08] Nuxeo 5.1.6 ReleasedCorporate News[2008/11/20] Nuxeo secures 2 million Euros and strengthens its board of directors and corporate governance
[2008/11/17] Nuxeo joins OASIS[2008/10/23] IFRA Expo 2008 Amsterdam, October 27th to 30th, Booth 9363, Hall 9[2008/10/08] Nuxeo announces the appointment of Carina Rimoli as Indirect Sales Manager