1 | |
package org.kuali.student.common.ui.client.widgets; |
2 | |
|
3 | |
import com.google.gwt.event.dom.client.HasKeyUpHandlers; |
4 | |
import com.google.gwt.event.dom.client.KeyUpEvent; |
5 | |
import com.google.gwt.event.dom.client.KeyUpHandler; |
6 | |
import com.google.gwt.user.client.ui.HasText; |
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | 0 | public class TextLinkageHelper { |
13 | |
static String masterString; |
14 | |
public static void link(final HasText master, final HasText slave) { |
15 | 0 | masterString = master.getText(); |
16 | 0 | if (master instanceof HasKeyUpHandlers) { |
17 | 0 | HasKeyUpHandlers masterTextBox = (HasKeyUpHandlers) master; |
18 | 0 | masterTextBox.addKeyUpHandler(new KeyUpHandler() { |
19 | |
@Override |
20 | |
public void onKeyUp(KeyUpEvent event) { |
21 | 0 | if(masterString.equals(slave.getText()) |
22 | |
||"".equals(slave.getText()) ){ |
23 | 0 | masterString = master.getText(); |
24 | 0 | slave.setText(masterString); |
25 | |
} |
26 | 0 | } |
27 | |
}); |
28 | |
} |
29 | 0 | } |
30 | |
} |