mirror of
https://github.com/nicobo/regexcite.git
synced 2026-05-21 11:58:14 +02:00
Handler Event gwt1.6
This commit is contained in:
parent
c05bc21914
commit
8df10a7349
|
|
@ -0,0 +1,3 @@
|
|||
#Sat May 23 00:48:42 CEST 2009
|
||||
eclipse.preferences.version=1
|
||||
gwtCompileSettings=PGd3dC1jb21waWxlLXNldHRpbmdzPjxsb2ctbGV2ZWw+SU5GTzwvbG9nLWxldmVsPjxvdXRwdXQtc3R5bGU+T0JGVVNDQVRFRDwvb3V0cHV0LXN0eWxlPjxleHRyYS1hcmdzPjwhW0NEQVRBW11dPjwvZXh0cmEtYXJncz48dm0tYXJncz48IVtDREFUQVstWG14NTEybV1dPjwvdm0tYXJncz48L2d3dC1jb21waWxlLXNldHRpbmdzPg\=\=
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
package org.dreamsoft.regexcite.client.ui;
|
||||
|
||||
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||
import com.google.gwt.user.client.Command;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.HorizontalSplitPanel;
|
||||
import com.google.gwt.user.client.ui.KeyboardListenerAdapter;
|
||||
import com.google.gwt.user.client.ui.SimplePanel;
|
||||
import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.google.gwt.user.client.ui.Tree;
|
||||
import com.google.gwt.user.client.ui.TreeItem;
|
||||
import com.google.gwt.user.client.ui.TreeListener;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
|
||||
public class AnalysePanel extends VerticalPanel {
|
||||
|
|
@ -85,19 +85,16 @@ public class AnalysePanel extends VerticalPanel {
|
|||
spanel2.setWidget(regexpTree);
|
||||
spanel2.setWidth("100%");
|
||||
|
||||
KeyboardListenerAdapter CRListener = new CarriageReturnListenerAdapter(executeCommand);
|
||||
regexpTextBox.addKeyboardListener(CRListener);
|
||||
EnterPressHandler enterPressHandler = new EnterPressHandler(executeCommand);
|
||||
regexpTextBox.addKeyPressHandler(enterPressHandler);
|
||||
|
||||
HorizontalSplitPanel hspanel = new HorizontalSplitPanel();
|
||||
hspanel.setRightWidget(spanel);
|
||||
hspanel.setLeftWidget(spanel2);
|
||||
|
||||
regexpTree.addTreeListener(new TreeListener() {
|
||||
public void onTreeItemSelected(TreeItem item) {
|
||||
detailItem(item);
|
||||
}
|
||||
|
||||
public void onTreeItemStateChanged(TreeItem item) {
|
||||
regexpTree.addSelectionHandler(new SelectionHandler<TreeItem>() {
|
||||
public void onSelection(SelectionEvent<TreeItem> event) {
|
||||
detailItem(event.getSelectedItem());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -145,26 +142,26 @@ public class AnalysePanel extends VerticalPanel {
|
|||
}
|
||||
|
||||
public native TreeItem parse(TreeItem treeItem, String re)/*-{
|
||||
var buildTree = function(node, parentNode) {
|
||||
if(node != null){
|
||||
var nodeName = ((node.value==null)?node.nodeName:node.value);
|
||||
var tmpNode = parentNode.@com.google.gwt.user.client.ui.TreeItem::addItem(Ljava/lang/String;)(nodeName);
|
||||
for(var i in node.children){
|
||||
buildTree(node.children[i], tmpNode);
|
||||
}
|
||||
tmpNode.@com.google.gwt.user.client.ui.TreeItem::setState(Z)(true);
|
||||
if (undefined != node.startIndex) {
|
||||
var tmpObj = @org.dreamsoft.regexcite.client.ui.AnalysePanel::createNodeInfo(IILjava/lang/String;Z)(node.startIndex,node.endIndex,node.nodeName,node.combineable);
|
||||
tmpNode.@com.google.gwt.user.client.ui.TreeItem::setUserObject(Ljava/lang/Object;)(tmpObj);
|
||||
}
|
||||
}
|
||||
var buildTree = function(node, parentNode) {
|
||||
if(node != null){
|
||||
var nodeName = ((node.value==null)?node.nodeName:node.value);
|
||||
var tmpNode = parentNode.@com.google.gwt.user.client.ui.TreeItem::addItem(Ljava/lang/String;)(nodeName);
|
||||
for(var i in node.children){
|
||||
buildTree(node.children[i], tmpNode);
|
||||
}
|
||||
var state = $wnd.PatternJS.parse(re);
|
||||
var v = state.getAST();
|
||||
buildTree(v, treeItem);
|
||||
tmpNode.@com.google.gwt.user.client.ui.TreeItem::setState(Z)(true);
|
||||
if (undefined != node.startIndex) {
|
||||
var tmpObj = @org.dreamsoft.regexcite.client.ui.AnalysePanel::createNodeInfo(IILjava/lang/String;Z)(node.startIndex,node.endIndex,node.nodeName,node.combineable);
|
||||
tmpNode.@com.google.gwt.user.client.ui.TreeItem::setUserObject(Ljava/lang/Object;)(tmpObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
var state = $wnd.PatternJS.parse(re);
|
||||
var v = state.getAST();
|
||||
buildTree(v, treeItem);
|
||||
|
||||
return treeItem;
|
||||
}-*/;
|
||||
return treeItem;
|
||||
}-*/;
|
||||
|
||||
public void initTest() {
|
||||
regexpTextBox.setText("([ae]+)|([lc]+)|\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}\\b");
|
||||
|
|
|
|||
|
|
@ -1,27 +0,0 @@
|
|||
package org.dreamsoft.regexcite.client.ui;
|
||||
|
||||
import com.google.gwt.user.client.Command;
|
||||
import com.google.gwt.user.client.ui.KeyboardListenerAdapter;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
public class CarriageReturnListenerAdapter extends KeyboardListenerAdapter {
|
||||
|
||||
private Command command;
|
||||
|
||||
public CarriageReturnListenerAdapter(Command command) {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public void onKeyPress(Widget sender, char keyCode, int modifiers) {
|
||||
if (keyCode == KEY_ENTER) {
|
||||
onCarriageReturnPress(sender, modifiers);
|
||||
}
|
||||
super.onKeyPress(sender, keyCode, modifiers);
|
||||
}
|
||||
|
||||
protected void onCarriageReturnPress(Widget sender, int modifiers) {
|
||||
if (command != null) {
|
||||
command.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package org.dreamsoft.regexcite.client.ui;
|
||||
|
||||
import com.google.gwt.event.dom.client.KeyCodes;
|
||||
import com.google.gwt.event.dom.client.KeyPressEvent;
|
||||
import com.google.gwt.event.dom.client.KeyPressHandler;
|
||||
import com.google.gwt.user.client.Command;
|
||||
|
||||
public class EnterPressHandler implements KeyPressHandler {
|
||||
|
||||
private Command command;
|
||||
|
||||
public EnterPressHandler(Command command) {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public void onKeyPress(KeyPressEvent event) {
|
||||
if (event.getCharCode() == KeyCodes.KEY_ENTER) {
|
||||
onEnterPress(event);
|
||||
}
|
||||
}
|
||||
|
||||
protected void onEnterPress(KeyPressEvent event) {
|
||||
if (command != null) {
|
||||
command.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,7 +7,6 @@ import com.google.gwt.user.client.Random;
|
|||
import com.google.gwt.user.client.Timer;
|
||||
import com.google.gwt.user.client.ui.DockPanel;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.KeyboardListenerAdapter;
|
||||
import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.google.gwt.user.client.ui.ToggleButton;
|
||||
|
||||
|
|
@ -89,9 +88,9 @@ public class ReplacePanel extends DockPanel {
|
|||
}
|
||||
};
|
||||
|
||||
KeyboardListenerAdapter CRListener = new CarriageReturnListenerAdapter(executeCommand);
|
||||
regexpTextBox.addKeyboardListener(CRListener);
|
||||
replaceTextBox.addKeyboardListener(CRListener);
|
||||
EnterPressHandler enterPressHandler = new EnterPressHandler(executeCommand);
|
||||
regexpTextBox.addKeyPressHandler(enterPressHandler);
|
||||
replaceTextBox.addKeyPressHandler(enterPressHandler);
|
||||
|
||||
regexpTextBox.setWidth("100%");
|
||||
final Timer autoSearchTimer = new Timer() {
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ package org.dreamsoft.regexcite.client.ui;
|
|||
import org.dreamsoft.regexcite.client.util.regex.Pattern;
|
||||
|
||||
import com.google.gwt.user.client.Command;
|
||||
import com.google.gwt.user.client.DeferredCommand;
|
||||
import com.google.gwt.user.client.Timer;
|
||||
import com.google.gwt.user.client.ui.DockPanel;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.KeyboardListenerAdapter;
|
||||
import com.google.gwt.user.client.ui.TextArea;
|
||||
import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.google.gwt.user.client.ui.ToggleButton;
|
||||
|
|
@ -101,9 +101,9 @@ public class SearchPanel extends DockPanel {
|
|||
}
|
||||
};
|
||||
|
||||
KeyboardListenerAdapter CRListener = new CarriageReturnListenerAdapter(executeCommand);
|
||||
regexpTextBox.addKeyboardListener(CRListener);
|
||||
replaceTextBox.addKeyboardListener(CRListener);
|
||||
EnterPressHandler enterPressHandler = new EnterPressHandler(executeCommand);
|
||||
regexpTextBox.addKeyPressHandler(enterPressHandler);
|
||||
replaceTextBox.addKeyPressHandler(enterPressHandler);
|
||||
|
||||
regexpTextBox.setWidth("100%");
|
||||
|
||||
|
|
@ -135,9 +135,13 @@ public class SearchPanel extends DockPanel {
|
|||
|
||||
autoSearchTimer.scheduleRepeating(1000);
|
||||
}
|
||||
|
||||
|
||||
// FIXME Why the split position change when help tab is selected?
|
||||
vspanel.setSplitPosition("200px");
|
||||
DeferredCommand.addCommand(new Command() {
|
||||
public void execute() {
|
||||
vspanel.setSplitPosition("50%");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue