Example usage for com.google.gwt.user.client.ui KeyboardListener KeyboardListener

List of usage examples for com.google.gwt.user.client.ui KeyboardListener KeyboardListener

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui KeyboardListener KeyboardListener.

Prototype

KeyboardListener

Source Link

Usage

From source file:ca.upei.ic.timetable.client.FindCourseView.java

License:Apache License

public FindCourseView(FindCourseViewController controller) {
    controller_ = controller;/* ww  w  .  ja v a  2s  .  com*/

    // set up the dialog box
    dialogBox_ = new DialogBox(false, true); // autohide = false, modal = true
    dialogBox_.setAnimationEnabled(true);
    dialogBox_.setText("Find Courses...");

    // i have a horizontal panel
    HorizontalPanel filterPanel = new HorizontalPanel();
    // i have a level flex table
    levelTable_ = controller_.getLevelModel().getWidget();
    departmentTable_ = controller_.getDepartmentModel().getWidget();
    semesterTable_ = controller_.getSemesterModel().getWidget();
    startTimeWidget_ = controller_.getStartTimeModel().getWidget();

    // button panel
    HorizontalPanel buttonPanel = new HorizontalPanel();
    buttonPanel.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT);

    // i have an OK button
    final Button okButton = new Button("Search");
    okButton.addClickListener(new ClickListener() {

        public void onClick(Widget sender) {
            // search and close the dialog
            controller_.search();
            hide();
        }

    });

    okButton.addKeyboardListener(new KeyboardListener() {

        public void onKeyDown(Widget sender, char keyCode, int modifiers) {
        }

        public void onKeyPress(Widget sender, char keyCode, int modifiers) {
        }

        public void onKeyUp(Widget sender, char keyCode, int modifiers) {
            if (keyCode == KeyboardListener.KEY_ENTER) {
                okButton.click();
            }
        }

    });

    final Button cancelButton = new Button("Cancel");
    cancelButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            hide();
        }
    });

    cancelButton.addKeyboardListener(new KeyboardListener() {

        public void onKeyDown(Widget sender, char keyCode, int modifiers) {
        }

        public void onKeyPress(Widget sender, char keyCode, int modifiers) {
        }

        public void onKeyUp(Widget sender, char keyCode, int modifiers) {
            if (keyCode == KeyboardListener.KEY_ESCAPE)
                cancelButton.click();
        }

    });

    SimplePanel empty = new SimplePanel();
    empty.setWidth("230px");
    buttonPanel.add(empty);
    buttonPanel.add(cancelButton);
    buttonPanel.add(okButton);
    buttonPanel.setSpacing(5);
    buttonPanel.setWidth("485px");

    // add the panel to the dialog box
    dialogBox_.add(PanelUtils.verticalPanel(PanelUtils.horizontalPanel(
            PanelUtils.verticalPanel(PanelUtils.scrollPanel(levelTable_, 250, 180),
                    PanelUtils.scrollPanel(semesterTable_, 250, 120),
                    PanelUtils.scrollPanel(startTimeWidget_, 250, 30)),
            PanelUtils.scrollPanel(departmentTable_, 250, 320)), buttonPanel));
    dialogBox_.setPopupPosition(240, 0);
}

From source file:ca.upei.ic.timetable.client.MessageView.java

License:Apache License

public MessageView(MessageViewController controller) {
    controller_ = controller;/*www. j av a  2  s  .c  o m*/
    dialogBox_ = new DialogBox(true, true);
    dialogBox_.setText("Messages");
    dialogBox_.setAnimationEnabled(true);
    dialogBox_.hide();
    // XXX a hack to make sure the dialog display top most
    dialogBox_.getElement().getStyle().setProperty("z-index", "100");

    ScrollPanel scrolled = new ScrollPanel();
    scrolled.setPixelSize(350, 250);

    panel_ = new VerticalPanel();
    panel_.setWidth("232px");

    scrolled.add(panel_);
    Button closeButton = new Button("Close");
    closeButton.addClickListener(new ClickListener() {

        public void onClick(Widget sender) {
            dialogBox_.hide();
        }

    });

    closeButton.addKeyboardListener(new KeyboardListener() {

        public void onKeyDown(Widget sender, char keyCode, int modifiers) {
        }

        public void onKeyPress(Widget sender, char keyCode, int modifiers) {
            if (keyCode == KeyboardListener.KEY_ESCAPE)
                dialogBox_.hide();
        }

        public void onKeyUp(Widget sender, char keyCode, int modifiers) {
        }

    });

    Button clearButton = new Button("Clear");
    clearButton.addClickListener(new ClickListener() {

        public void onClick(Widget sender) {
            clearMessage();
        }

    });

    dialogBox_.setWidget(
            PanelUtils.verticalPanel(scrolled, PanelUtils.horizontalPanel(closeButton, clearButton)));
}

From source file:cc.alcina.framework.gwt.client.gwittir.widget.PasswordTextBox.java

License:Apache License

/** Creates a new instance of TextBox */
@SuppressWarnings("unchecked")
public PasswordTextBox(final boolean updateOnKeypress) {
    final PasswordTextBox instance = this;
    old = base.getText();/*w w w  .  j  av  a 2s . c  o m*/
    this.setComparator(SimpleComparator.INSTANCE);
    if (updateOnKeypress) {
        this.addKeyboardListener(new KeyboardListener() {
            public void onKeyDown(Widget sender, char keyCode, int modifiers) {
            }

            public void onKeyPress(Widget sender, char keyCode, int modifiers) {
                changes.firePropertyChange("value", old, getValue());
                old = (String) getValue();
            }

            public void onKeyUp(Widget sender, char keyCode, int modifiers) {
            }
        });
    } else {
        this.addKeyboardListener(new KeyboardListener() {
            public void onKeyDown(Widget sender, char keyCode, int modifiers) {
            }

            public void onKeyPress(Widget sender, char keyCode, int modifiers) {
                if (keyCode == KeyboardListener.KEY_ENTER) {
                    setFocus(false);
                    setFocus(true);
                }
            }

            public void onKeyUp(Widget sender, char keyCode, int modifiers) {
            }
        });
    }
    this.base.addChangeListener(new ChangeListener() {
        public void onChange(Widget sender) {
            changes.firePropertyChange("value", old, getValue());
            old = (String) getValue();
            changeListeners.fireChange(instance);
        }
    });
    super.initWidget(this.base);
}

From source file:cc.alcina.framework.gwt.client.gwittir.widget.TextArea.java

License:Apache License

/** Creates a new instance of TextBox */
public TextArea(final boolean updateOnKeypress) {
    final TextArea instance = this;
    old = base.getText();//from   ww w.  j  a v a  2  s .c  o  m
    this.setComparator(SimpleComparator.INSTANCE);
    if (updateOnKeypress) {
        this.addKeyboardListener(new KeyboardListener() {
            @Override
            public void onKeyDown(Widget sender, char keyCode, int modifiers) {
            }

            @Override
            public void onKeyPress(Widget sender, char keyCode, int modifiers) {
                changes.firePropertyChange("value", old, getValue());
                old = (String) getValue();
            }

            @Override
            public void onKeyUp(Widget sender, char keyCode, int modifiers) {
            }
        });
    } else {
    }
    this.base.addValueChangeHandler(new ValueChangeHandler<String>() {
        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            changes.firePropertyChange("value", old, getValue());
            old = (String) getValue();
            changeListeners.fireChange(instance);
        }
    });
    this.base.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            changes.firePropertyChange("value", old, getValue());
            old = (String) getValue();
            changeListeners.fireChange(instance);
        }
    });
    this.base.addChangeListener(new ChangeListener() {
        @Override
        public void onChange(Widget sender) {
            changes.firePropertyChange("value", old, getValue());
            old = (String) getValue();
            changeListeners.fireChange(instance);
        }
    });
    super.initWidget(this.base);
}

From source file:cc.alcina.framework.gwt.client.gwittir.widget.TextBox.java

License:Open Source License

/** Creates a new instance of TextBox */
public TextBox(final boolean updateOnKeypress) {
    final TextBox instance = this;
    old = base.getText();/*w  w w  . ja  v  a  2 s  . c o  m*/
    if (updateOnKeypress) {
        this.addKeyboardListener(new KeyboardListener() {
            boolean scheduled = false;

            @Override
            public void onKeyDown(Widget sender, char keyCode, int modifiers) {
            }

            @Override
            public void onKeyPress(Widget sender, char keyCode, int modifiers) {
                refresh();
            }

            @Override
            public void onKeyUp(Widget sender, char keyCode, int modifiers) {
                refresh();
            }

            private void refresh() {
                if (!scheduled) {
                    Scheduler.get().scheduleDeferred(new ScheduledCommand() {
                        @Override
                        public void execute() {
                            changes.firePropertyChange("value", old, getValue());
                            old = (String) getValue();
                            scheduled = false;
                        }
                    });
                    scheduled = true;
                }
            }
        });
    } else {
        this.addKeyboardListener(new KeyboardListener() {
            @Override
            public void onKeyDown(Widget sender, char keyCode, int modifiers) {
            }

            @Override
            public void onKeyPress(Widget sender, char keyCode, int modifiers) {
                if (keyCode == KeyCodes.KEY_ENTER) {
                    setFocus(false);
                    setFocus(true);
                }
            }

            @Override
            public void onKeyUp(Widget sender, char keyCode, int modifiers) {
            }
        });
    }
    this.base.addChangeListener(new ChangeListener() {
        @Override
        public void onChange(Widget sender) {
            changes.firePropertyChange("value", old, getValue());
            old = (String) getValue();
            changeListeners.fireChange(instance);
        }
    });
    this.base.addValueChangeHandler(new ValueChangeHandler<String>() {
        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            changes.firePropertyChange("value", old, getValue());
            old = (String) getValue();
            changeListeners.fireChange(instance);
        }
    });
    this.base.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (old == null && getValue() == null) {
                // don't want a non-change change fired here (invalid
                // validation)
            } else {
                changes.firePropertyChange("value", old, getValue());
            }
            old = (String) getValue();
            changeListeners.fireChange(instance);
        }
    });
    super.initWidget(this.base);
}

From source file:ch.heftix.mailxel.client.OrgTextArea.java

License:Open Source License

public OrgTextArea() {

    KeyboardListener kl = new KeyboardListener() {

        Duration sinceEscapePressed = null;

        public void onKeyDown(Widget sender, char keyCode, int modifiers) {
            if (keyCode == KeyboardListener.KEY_ESCAPE) {
                sinceEscapePressed = new Duration();
            }//from w w w  .  j av  a  2 s.  c om
        }

        public void onKeyUp(Widget sender, char keyCode, int modifiers) {
        }

        public void onKeyPress(Widget sender, char keyCode, int modifiers) {
            if ('q' == keyCode) {
                // System.out.println(sinceEscapePressed.elapsedMillis());
                if (null != sinceEscapePressed && (sinceEscapePressed.elapsedMillis() < 300)) {
                    // format region
                    TextArea ta = (TextArea) sender;
                    String text = ta.getText();
                    int pos = ta.getCursorPos();
                    int len = ta.getSelectionLength();
                    String replacement = om.prefixSelection(text, "> ", pos, len);
                    ta.setText(replacement);
                    cancelKey();
                }
            }
        }

    };

    addKeyboardListener(kl);

}

From source file:com.anzsoft.client.ui.UserIndicator.java

License:Open Source License

public UserIndicator(final String nick) {
    createStatusMenu();/*from  www  . ja v a 2s .  c om*/
    setWidth("100%");
    setCellPadding(0);
    setCellSpacing(0);
    setStyleName("indicator");
    FlexCellFormatter formatter = getFlexCellFormatter();

    // Setup the links cell
    /*
    linksPanel = new HorizontalPanel();
    setWidget(0, 0, linksPanel);
    formatter.setStyleName(0, 0, "indicator-links");
    formatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    formatter.setColSpan(0, 0, 2);
    */

    // Setup the title cell
    setTitleWidget(null);
    formatter.setStyleName(0, 0, "indicator-title");

    getRowFormatter().setVerticalAlign(0, HasVerticalAlignment.ALIGN_TOP);
    getRowFormatter().setVerticalAlign(1, HasVerticalAlignment.ALIGN_TOP);

    final ChatIcons icons = ChatIcons.App.getInstance();
    statusImg = new Image();
    statusImg.setWidth("16px");
    statusImg.setHeight("16px");
    icons.online().applyTo(statusImg);

    avatarImg = new Image("images/default_avatar.png");
    avatarImg.setWidth("32px");
    avatarImg.setHeight("32px");
    avatarImg.setStyleName("handler");
    avatarImg.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            JabberApp.instance().showInfoSelf();
        }

    });

    nickName = new Label(nick);
    nickName.setDirection(Direction.LTR);
    nickName.setWidth("100%");

    statusLabel = new Label();
    statusLabel.setStyleName("status_label");
    statusLabel.setWidth("100%");

    statusEditor = new TextBox();
    statusEditor.setVisible(false);
    statusEditor.setWidth("100%");

    statusButton = new Button();
    statusButton.setMenu(statusMenu);
    statusButton.setStyleName("Status-Menu-Button");

    //statusMenuLabel = new Label();
    //statusMenuLabel.setStyleName("status_menu_label");

    //addLink(new HTML("<a href=\"http://samespace.anzsoft.com\">SameSpace</a>"));
    // Add the title and some images to the title bar
    HorizontalPanel titlePanel = new HorizontalPanel();
    titlePanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    titlePanel.setWidth("100%");
    titlePanel.setSpacing(3);

    VerticalPanel statusPanel = new VerticalPanel();
    statusPanel.setWidth("100%");
    statusPanel.add(nickName);

    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.setWidth("100%");
    hPanel.setSpacing(2);
    hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
    hPanel.add(statusLabel);
    hPanel.add(statusEditor);
    hPanel.add(statusButton);

    statusPanel.add(hPanel);

    titlePanel.add(statusImg);
    titlePanel.add(statusPanel);
    titlePanel.add(avatarImg);

    titlePanel.setCellWidth(statusImg, "20px");
    titlePanel.setCellWidth(statusPanel, "100%");
    titlePanel.setCellWidth(avatarImg, "32px");
    setTitleWidget(titlePanel);

    JabberApp.instance().getSession().getUser().addUserListener(new XmppUserListener() {
        public void onPresenceChanged(XmppPresence presence) {
            String show = new String("");
            PresenceShow presenceShow = presence.getShow();
            if (presenceShow != null)
                show = presenceShow.toString();
            String statusString = presence.getStatus();
            int priority = presence.getPriority();
            boolean avaiable = true;
            String type = presence.getType();
            if (type != null && !type.isEmpty()) {
                if (type.equalsIgnoreCase("unavailable"))
                    avaiable = false;
            }
            status = new XmppContactStatus(show, statusString, priority, avaiable);
            statusLabel.setText(status.status());
            iconFromStatus(status).applyTo(statusImg);
        }
    });

    statusLabel.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            statusLabel.setVisible(false);
            statusEditor.setVisible(true);
            statusEditor.setText(statusLabel.getText());
        }

    });

    statusEditor.addKeyboardListener(new KeyboardListener() {

        public void onKeyDown(Widget sender, char keyCode, int modifiers) {

        }

        public void onKeyPress(Widget sender, char keyCode, int modifiers) {

        }

        public void onKeyUp(Widget sender, char keyCode, int modifiers) {
            if (keyCode == 13)
                doneChangeStatusString();
        }

    });

    statusEditor.addFocusListener(new FocusListener() {
        public void onFocus(Widget sender) {
        }

        public void onLostFocus(Widget sender) {
            doneChangeStatusString();
        }

    });

    XmppVCardFactory.instance().addVCardListener(new VCardListener() {
        public void onVCard(XmppID jid, XmppVCard vcard) {
            if (jid.toStringNoResource().equalsIgnoreCase(JabberApp.instance().getJid().toStringNoResource())) {
                if (!vcard.nickName().isEmpty())
                    nickName.setText(vcard.fullName());
                else if (!vcard.fullName().isEmpty())
                    nickName.setText(vcard.fullName());
                String photoData = vcard.photo();
                if (!photoData.isEmpty() && !GXT.isIE) {
                    ImageElement imgEl = avatarImg.getElement().cast();
                    imgEl.removeAttribute("src");
                    imgEl.setSrc("data:image;base64," + photoData);
                }

            }
        }

    });
}

From source file:com.google.mobile.trippy.web.client.view.SearchBarView.java

License:Apache License

public SearchBarView() {
    searchBox = new SuggestBox(mySuggestions);
    initWidget(uiBinder.createAndBindUi(this));
    searchBox.addSelectionHandler(new SelectionHandler<Suggestion>() {

        @Override/* w  w  w  .  ja va2 s  .  c  o m*/
        public void onSelection(SelectionEvent<Suggestion> event) {
            NativeEvent evt = Document.get().createClickEvent(1, 0, 0, 0, 0, false, false, false, false);
            searchButton.getElement().dispatchEvent(evt);
        }
    });

    searchPopUp.setWidget(this);
    searchPopUp.setGlassEnabled(true);
    searchPopUp.setStyleName(style.basePopup());
    final KeyboardListener onEnter = new KeyboardListener() {

        @Override
        public void onKeyUp(Widget sender, char keyCode, int modifiers) {
            //No-ops.
        }

        @Override
        public void onKeyPress(Widget sender, char keyCode, int modifiers) {
            if (keyCode == KeyboardListener.KEY_ENTER) {
                NativeEvent evt = Document.get().createClickEvent(1, 0, 0, 0, 0, false, false, false, false);
                searchButton.getElement().dispatchEvent(evt);
            }
        }

        @Override
        public void onKeyDown(Widget sender, char keyCode, int modifiers) {
            //No-ops.
        }
    };

    searchBox.addKeyboardListener(onEnter);
    defaultSearchText();
    loadSearchCategory();
}

From source file:com.google.mobile.trippy.web.client.view.TripListFilterView.java

License:Apache License

public TripListFilterView() {

    initWidget(uiBinder.createAndBindUi(this));
    searchPopUp.setGlassEnabled(true);//w  w  w .  j  a va  2  s  . c o m
    final KeyboardListener onEnter = new KeyboardListener() {

        @Override
        public void onKeyUp(Widget sender, char keyCode, int modifiers) {
            //No-ops.
        }

        @Override
        public void onKeyPress(Widget sender, char keyCode, int modifiers) {
            if (keyCode == KeyboardListener.KEY_ENTER) {
                NativeEvent evt = Document.get().createClickEvent(1, 0, 0, 0, 0, false, false, false, false);
                searchButton.getElement().dispatchEvent(evt);
            }
        }

        @Override
        public void onKeyDown(Widget sender, char keyCode, int modifiers) {
            //No-ops.
        }
    };
    searchBox.addKeyboardListener(onEnter);
    Window.addResizeHandler(new ResizeHandler() {

        @Override
        public void onResize(ResizeEvent event) {
            if (searchPopUp.isShowing()) {
                searchPopUp.center();
            }
        }
    });
}

From source file:com.sun.labs.aura.dbbrowser.client.query.SearchPanel.java

License:Open Source License

public SearchPanel(final TabbedQueryUI parent) {
    this.parent = parent;
    service = GWTMainEntryPoint.getDBService();
    setHeight("400px");
    setWidth("100%");
    setStylePrimaryName("db-SearchPanel");
    setSpacing(5);//from  ww w.  j  av  a2 s  .  c  om
    keySrchPanel.setSpacing(3);
    keySrchPanel.add(new Label("Item by key: "));
    keySrchPanel.add(itemKey);
    keySrchPanel.add(itemKeyBtn);

    itemKey.addKeyboardListener(new KeyboardListener() {
        public void onKeyDown(Widget arg0, char arg1, int arg2) {
        }

        public void onKeyPress(Widget w, char c, int mod) {
            if (c == KEY_ENTER) {
                itemKeyBtn.click();
            }
        }

        public void onKeyUp(Widget arg0, char arg1, int arg2) {
        }

    });

    // Listen for the button clicks
    itemKeyBtn.addClickListener(new ClickListener() {
        public void onClick(Widget w) {
            // Make remote call. Control flow will continue immediately and later
            // 'callback' will be invoked when the RPC completes.

            // Create an asynchronous callback to handle the result.
            final String srchStr = itemKey.getText();
            final AsyncCallback callback = new AsyncCallback() {
                public void onSuccess(Object result) {
                    if (result != null) {
                        parent.addResults("Key:" + srchStr, (ItemDesc[]) result);
                    } else {
                        parent.showError("Remote error!");
                    }
                }

                public void onFailure(Throwable caught) {
                    parent.showError(caught.getMessage());
                }
            };
            service.searchItemByKey(srchStr, callback);
        }
    });
    add(keySrchPanel);

    nameSrchPanel.setSpacing(3);
    nameSrchPanel.add(new Label("Item by name: "));
    nameSrchPanel.add(itemName);
    nameSrchPanel.add(itemNameBtn);

    itemName.addKeyboardListener(new KeyboardListener() {
        public void onKeyDown(Widget arg0, char arg1, int arg2) {
        }

        public void onKeyPress(Widget w, char c, int mod) {
            if (c == KEY_ENTER) {
                itemNameBtn.click();
            }
        }

        public void onKeyUp(Widget arg0, char arg1, int arg2) {
        }

    });

    // Listen for the button clicks
    itemNameBtn.addClickListener(new ClickListener() {
        public void onClick(Widget w) {
            // Make remote call. Control flow will continue immediately and later
            // 'callback' will be invoked when the RPC completes.

            // Create an asynchronous callback to handle the result.
            final String srchStr = itemName.getText();
            final AsyncCallback callback = new AsyncCallback() {
                public void onSuccess(Object result) {
                    if (result != null) {
                        parent.addResults("Name:" + srchStr, (ItemDesc[]) result);
                    } else {
                        parent.showError("Remote error!");
                    }
                }

                public void onFailure(Throwable caught) {
                    parent.showError(caught.getMessage());
                }
            };
            service.searchItemByName(srchStr, callback);
        }
    });
    add(nameSrchPanel);

    genSrchPanel.setSpacing(3);
    genSrchPanel.add(new Label("Freeform query: "));
    genSrchPanel.add(itemGen);
    genSrchPanel.add(itemGenBtn);

    itemGen.addKeyboardListener(new KeyboardListener() {

        public void onKeyDown(Widget arg0, char arg1, int arg2) {
        }

        public void onKeyPress(Widget w, char c, int mod) {
            if (c == KEY_ENTER) {
                itemGenBtn.click();
            }
        }

        public void onKeyUp(Widget arg0, char arg1, int arg2) {
        }
    });

    // Listen for the button clicks
    itemGenBtn.addClickListener(new ClickListener() {

        public void onClick(Widget w) {
            // Make remote call. Control flow will continue immediately and later
            // 'callback' will be invoked when the RPC completes.

            // Create an asynchronous callback to handle the result.
            final String srchStr = itemGen.getText();
            final AsyncCallback callback = new AsyncCallback() {

                public void onSuccess(Object result) {
                    if (result != null) {
                        parent.addResults(srchStr, (ItemDesc[]) result);
                    } else {
                        parent.showError("Remote error!");
                    }
                }

                public void onFailure(Throwable caught) {
                    parent.showError(caught.getMessage());
                }
            };
            service.searchItemByGen(srchStr, callback);
        }
    });
    add(genSrchPanel);

    fsSrchPanel.setSpacing(3);
    fsSrchPanel.add(new Label("Find similar: "));
    fsSrchPanel.add(itemFS);
    fsSrchPanel.add(itemFSBtn);

    itemFS.addKeyboardListener(new KeyboardListener() {

        public void onKeyDown(Widget arg0, char arg1, int arg2) {
        }

        public void onKeyPress(Widget w, char c, int mod) {
            if (c == KEY_ENTER) {
                itemFSBtn.click();
            }
        }

        public void onKeyUp(Widget arg0, char arg1, int arg2) {
        }
    });

    // Listen for the button clicks
    itemFSBtn.addClickListener(new ClickListener() {

        public void onClick(Widget w) {
            // Make remote call. Control flow will continue immediately and later
            // 'callback' will be invoked when the RPC completes.

            // Create an asynchronous callback to handle the result.
            final String key = itemFS.getText();
            final AsyncCallback callback = new AsyncCallback() {

                public void onSuccess(Object result) {
                    if (result != null) {
                        parent.addResults(key, (ItemDesc[]) result);
                    } else {
                        parent.showError("Remote error!");
                    }
                }

                public void onFailure(Throwable caught) {
                    parent.showError(caught.getMessage());
                }
            };
            service.findSimilar(key, callback);
        }
    });
    add(fsSrchPanel);

    testBtn.addClickListener(new ClickListener() {
        public void onClick(Widget w) {
            final AsyncCallback callback = new AsyncCallback() {

                public void onSuccess(Object result) {
                    if (result != null) {
                        parent.showAttention((AttnDesc[]) result);
                    } else {
                        parent.showError("Remote error!");
                    }
                }

                public void onFailure(Throwable caught) {
                    parent.showError(caught.getMessage());
                }
            };
            service.doTest(callback);
        }
    });
    add(testBtn);
}