Example usage for com.google.gwt.user.client.ui Hyperlink setText

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

Introduction

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

Prototype

public void setText(String text) 

Source Link

Usage

From source file:au.com.gworks.gwt.petstore.client.ProductCardView.java

License:Apache License

private void prepareCardBody(ItemRefInfo shelfRefInfo, String lp) {
    if (shelfRefInfo instanceof ItemInfo) {
        ItemInfo si = (ItemInfo) shelfRefInfo;
        descLbl.setText(productInfo.name + " - " + si.description);
        buildBodyFrameIfRequired();/*from w w  w.j  a v  a  2s.co m*/
        productDetails.setText(0, 1, productInfo.description);
        Hyperlink link = (Hyperlink) productDetails.getWidget(1, 1);
        if (link == null) {
            link = new Hyperlink();
            productDetails.setWidget(1, 1, link);
            link.setTitle("click here to link to this product item");
        }
        link.setText(si.id);
        link.setTargetHistoryToken(HistoryUtils.toHistoryToken("shopping", "item-id", si.id));
        //         productDetails.setText(1, 1, si.id);
        productDetails.setText(2, 1, si.stockLevel + "");
        productDetails.setText(3, 1, lp);
    }
}

From source file:com.ikon.frontend.client.widget.filebrowser.ExtendedScrollTable.java

License:Open Source License

/**
 * Sets the document to the row//from w ww  . j  a  v a 2  s . c  o m
 * 
 * Update indicates should be updated selected row otherside inserts new
 * 
 * @param doc
 * @param update
 */
public void addRow(GWTDocument doc, boolean update) {
    int col = 0;
    final int row = (update) ? getSelectedRow() : dataTable.getRowCount();
    if (update) {
        data.put(new Integer(dataTable.getText(row, colDataIndex)), doc);
    } else {
        dataTable.insertRow(row);
    }

    // Sets document object
    data.put(new Integer(dataIndexValue), doc);

    if (profileFileBrowser.isStatusVisible()) {
        if (doc.isCheckedOut()) {
            dataTable.setHTML(row, col, Util.imageItemHTML("img/icon/edit.gif"));
        } else if (doc.isLocked()) {
            dataTable.setHTML(row, col, Util.imageItemHTML("img/icon/lock.gif"));
        } else {
            dataTable.setHTML(row, col, " ");
        }

        // Subscribed is a special case, must add icon with others
        if (doc.isSubscribed()) {
            dataTable.setHTML(row, col,
                    dataTable.getHTML(row, col) + Util.imageItemHTML("img/icon/subscribed.gif"));
        }
        // Document has notes
        if (doc.isHasNotes()) {
            dataTable.setHTML(row, col, dataTable.getHTML(row, col) + Util.imageItemHTML("img/icon/note.gif"));
        }
        dataTable.getCellFormatter().setHorizontalAlignment(row, col++, HasHorizontalAlignment.ALIGN_RIGHT);

    }

    if (profileFileBrowser.isMassiveVisible()) {
        // Checkbox
        final CheckBox checkBox = new CheckBox();
        checkBox.setStyleName("okm-CheckBox");
        checkBox.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                oldMassiveSelected = massiveSelected.size();

                if (checkBox.getValue()) {
                    massiveSelected.add(new Integer(dataTable.getText(row, colDataIndex)));
                } else {
                    massiveSelected.remove(new Integer(dataTable.getText(row, colDataIndex)));
                }
            }
        });

        dataTable.setWidget(row, col, checkBox);
        dataTable.getCellFormatter().setHorizontalAlignment(row, col++, HasHorizontalAlignment.ALIGN_CENTER);
    }
    if (profileFileBrowser.isIconVisible()) {
        dataTable.setHTML(row, col, Util.mimeImageHTML(doc.getMimeType()));
        dataTable.getCellFormatter().setHorizontalAlignment(row, col++, HasHorizontalAlignment.ALIGN_CENTER);
    }
    if (profileFileBrowser.isNameVisible()) {
        dataTable.setHTML(row, col, doc.getName());
        dataTable.getCellFormatter().setHorizontalAlignment(row, col++, HasHorizontalAlignment.ALIGN_LEFT);
    }
    if (profileFileBrowser.isSizeVisible()) {
        dataTable.setHTML(row, col, Util.formatSize(doc.getActualVersion().getSize()));
        dataTable.getCellFormatter().setHorizontalAlignment(row, col++, HasHorizontalAlignment.ALIGN_CENTER);
    }
    if (profileFileBrowser.isLastModifiedVisible()) {
        DateTimeFormat dtf = DateTimeFormat.getFormat(Main.i18n("general.date.pattern"));
        dataTable.setHTML(row, col, dtf.format(doc.getLastModified()));
        dataTable.getCellFormatter().setHorizontalAlignment(row, col++, HasHorizontalAlignment.ALIGN_CENTER);
    }
    if (profileFileBrowser.isAuthorVisible()) {
        dataTable.setHTML(row, col, doc.getActualVersion().getUser().getUsername());
        dataTable.getCellFormatter().setHorizontalAlignment(row, col++, HasHorizontalAlignment.ALIGN_CENTER);
    }
    if (profileFileBrowser.isVersionVisible()) {
        Hyperlink hLink = new Hyperlink();
        hLink.setText(doc.getActualVersion().getName());
        hLink.setTitle(doc.getActualVersion().getComment());
        dataTable.setWidget(row, col, hLink);
        dataTable.getCellFormatter().setHorizontalAlignment(row, col++, HasHorizontalAlignment.ALIGN_CENTER);
    }
    if (!update) {
        dataTable.setHTML(row, colDataIndex, "" + (dataIndexValue++));
        dataTable.getCellFormatter().setVisible(row, colDataIndex, false);
    }

    for (int i = 0; i < colDataIndex; i++) {
        dataTable.getCellFormatter().addStyleName(row, i, "okm-DisableSelect");
    }
}

From source file:com.openkm.frontend.client.widget.filebrowser.ExtendedScrollTable.java

License:Open Source License

/**
 * Sets the document to the row//from w w  w.j  av a  2 s .c  om
 * 
 * Update indicates should be updated selected row otherside inserts new
 */
public void addRow(GWTDocument doc, boolean update) {
    int col = 0;
    final int row = (update) ? getSelectedRow() : dataTable.getRowCount();

    if (update) {
        data.put(new Integer(dataTable.getText(row, colDataIndex)), doc);
    } else {
        dataTable.insertRow(row);
    }

    // Sets document object
    data.put(new Integer(dataIndexValue), doc);

    if (profileFileBrowser.isStatusVisible()) {
        if (doc.isCheckedOut()) {
            dataTable.setHTML(row, col, Util.imageItemHTML("img/icon/edit.gif"));
        } else if (doc.isLocked()) {
            dataTable.setHTML(row, col, Util.imageItemHTML("img/icon/lock.gif"));
        } else {
            dataTable.setHTML(row, col, "&nbsp;");
        }

        // Subscribed is a special case, must add icon with others
        if (doc.isSubscribed()) {
            dataTable.setHTML(row, col,
                    dataTable.getHTML(row, col) + Util.imageItemHTML("img/icon/subscribed.gif"));
        }

        // Document has notes
        if (doc.isHasNotes()) {
            dataTable.setHTML(row, col, dataTable.getHTML(row, col) + Util.imageItemHTML("img/icon/note.gif"));
        }

        // Document encrypted
        if (doc.getCipherName() != null && !doc.getCipherName().equals("")) {
            dataTable.setHTML(row, col,
                    dataTable.getHTML(row, col) + Util.imageItemHTML("img/icon/actions/crypt.png"));
        }

        // Document signed
        if (doc.isSigned()) {
            dataTable.setHTML(row, col,
                    dataTable.getHTML(row, col) + Util.imageItemHTML("img/icon/actions/digital_signature.png"));
        }

        dataTable.getCellFormatter().setHorizontalAlignment(row, col++, HasHorizontalAlignment.ALIGN_RIGHT);
    }

    if (profileFileBrowser.isMassiveVisible()) {
        // Checkbox
        final CheckBox checkBox = new CheckBox();
        checkBox.setStyleName("okm-CheckBox");
        checkBox.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                oldMassiveSelected = massiveSelected.size();

                if (checkBox.getValue()) {
                    massiveSelected.add(new Integer(dataTable.getText(row, colDataIndex)));
                } else {
                    massiveSelected.remove(new Integer(dataTable.getText(row, colDataIndex)));
                }
                evaluateMergePdf(); // Only when document checkbox is changed ( only document can be merged )
            }
        });

        dataTable.setWidget(row, col, checkBox);
        dataTable.getCellFormatter().setHorizontalAlignment(row, col++, HasHorizontalAlignment.ALIGN_CENTER);
    }

    if (profileFileBrowser.isIconVisible()) {
        dataTable.setHTML(row, col, Util.mimeImageHTML(doc.getMimeType()));
        dataTable.getCellFormatter().setHorizontalAlignment(row, col++, HasHorizontalAlignment.ALIGN_CENTER);
    }

    if (profileFileBrowser.isNameVisible()) {
        dataTable.setHTML(row, col, doc.getName());
        dataTable.getCellFormatter().setHorizontalAlignment(row, col++, HasHorizontalAlignment.ALIGN_LEFT);
    }

    if (profileFileBrowser.isSizeVisible()) {
        dataTable.setHTML(row, col, Util.formatSize(doc.getActualVersion().getSize()));
        dataTable.getCellFormatter().setHorizontalAlignment(row, col++, HasHorizontalAlignment.ALIGN_CENTER);
    }

    if (profileFileBrowser.isLastModifiedVisible()) {
        DateTimeFormat dtf = DateTimeFormat.getFormat(Main.i18n("general.date.pattern"));
        dataTable.setHTML(row, col, dtf.format(doc.getLastModified()));
        dataTable.getCellFormatter().setHorizontalAlignment(row, col++, HasHorizontalAlignment.ALIGN_CENTER);
    }

    if (profileFileBrowser.isAuthorVisible()) {
        dataTable.setHTML(row, col, doc.getActualVersion().getUser().getUsername());
        dataTable.getCellFormatter().setHorizontalAlignment(row, col++, HasHorizontalAlignment.ALIGN_CENTER);
    }

    if (profileFileBrowser.isVersionVisible()) {
        Hyperlink hLink = new Hyperlink();
        hLink.setText(doc.getActualVersion().getName());
        hLink.setTitle(doc.getActualVersion().getComment());
        dataTable.setWidget(row, col, hLink);
        dataTable.getCellFormatter().setHorizontalAlignment(row, col++, HasHorizontalAlignment.ALIGN_CENTER);
    }

    if (!update) {
        dataTable.setHTML(row, colDataIndex, "" + (dataIndexValue++));
        dataTable.getCellFormatter().setVisible(row, colDataIndex, false);
    }

    for (int i = 0; i < colDataIndex; i++) {
        dataTable.getCellFormatter().addStyleName(row, i, "okm-DisableSelect");
    }
}

From source file:com.qualogy.qafe.gwt.client.component.CellRendererHelper.java

License:Apache License

private static CellRenderer<DataContainerGVO, String> createLinkRenderer(final DataGridGVO source,
        final DataGridColumnGVO column, final String uuid, final String parent, final String targetHistoryToken,
        final HasDataGridMethods uiParent) {
    CellRenderer<DataContainerGVO, String> cellRenderer;
    cellRenderer = new CellRenderer<DataContainerGVO, String>() {
        public void renderRowValue(DataContainerGVO rowValue,
                ColumnDefinition<DataContainerGVO, String> columnDef, AbstractCellView<DataContainerGVO> view) {
            boolean alreadyRendered = false;
            String value = simpleObjectToText(columnDef.getCellValue(rowValue));
            int rowIndex = view.getRowIndex();
            String generatedId = generateIdBasedOnIndex(column, rowIndex);
            Hyperlink renderedComponent = (Hyperlink) getRenderedComponent(column, generatedId, uuid, parent);
            if (renderedComponent != null) {
                renderedComponent.setText(value);
                alreadyRendered = true;/*from  w  w  w.j  a  va  2s. c o  m*/
            } else {
                renderedComponent = new Hyperlink(value, targetHistoryToken);
            }

            view.setWidget(renderedComponent);
            CellRendererHelper.addBasicInfoToUIObject(renderedComponent, uuid, parent, source, column, rowValue,
                    rowIndex, null, alreadyRendered);
            handleCellSet(uiParent, columnDef, renderedComponent, rowValue);
        }
    };
    return cellRenderer;
}

From source file:de.lilawelt.zmachine.client.offline.OfflineMenuImplReal.java

License:Open Source License

public void showGames() {
    if (showing) {
        return;//from ww  w  .j  a  va2 s.  c  om
    }

    showing = true;

    p.remove(statusLabel);

    Label title = new Label("Available games:");
    p.add(title, DockPanel.NORTH);

    HTMLTable h = new FlexTable();
    h.setText(0, 0, "Game Name:");

    p.add(h, DockPanel.NORTH);

    try {
        Database db = f.createDatabase();
        db.open("textadventure-saves");

        ResultSet rs = db.execute("Select gamename, gameuid from offlinegames;");
        for (int i = 0; rs.isValidRow(); ++i, rs.next()) {

            final String name = rs.getFieldAsString(0);
            final String uid = rs.getFieldAsString(1);

            Hyperlink link = new Hyperlink();
            link.setText(rs.getFieldAsString(0));
            link.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    Machine.get().loadStory("/games/" + name + ".sto", uid);
                }
            });
            h.setWidget(i + 1, 0, link);
        }
    } catch (Exception e) {
        Window.alert("Error: " + e.getMessage());
    }

}

From source file:io.pelle.mango.client.gwt.modules.dictionary.search.DictionarySearchResultModuleUI.java

License:Open Source License

public void showResults(List<SearchResultItem> result) {

    if (resultContainer != null) {
        resultContainer.removeFromParent();
    }/*  w  ww .ja  v  a 2 s. c  om*/

    resultContainer = new Div();
    container.add(resultContainer);
    resultContainer.addStyleName(DICTIONARY_SEARCH_RESULT_PANEL_STYLE);

    if (result.size() == 0) {
        Div noSearchResults = new Div();
        noSearchResults.add(new HTML(MangoClientWeb.getInstance().getMessages().noSearchResults()));
        resultContainer.add(noSearchResults);
    } else {
        for (final SearchResultItem searchResultItem : result) {

            IDictionaryModel dictionaryModel = DictionaryModelProvider
                    .getDictionary(searchResultItem.getDictionaryId());

            Div resultItemContainer = new Div();
            resultItemContainer.addStyleName(DICTIONARY_SEARCH_RESULT_ITEM_PANEL_STYLE);

            Hyperlink title = new Hyperlink();
            title.setText(DictionaryUtil.getLabel(dictionaryModel) + ": " + searchResultItem.getLabel());

            title.addHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    DictionaryEditorModuleFactory.openEditorForId(searchResultItem.getDictionaryId(),
                            searchResultItem.getId());
                }
            }, ClickEvent.getType());

            title.addStyleName(DICTIONARY_SEARCH_RESULT_ITEM_TITLE_STYLE);
            resultItemContainer.add(title);

            SafeHtmlBuilder sb = new SafeHtmlBuilder();
            boolean first = true;

            for (Map.Entry<String, String> attributeEntry : searchResultItem.getAttributes().entrySet()) {

                Optional<IBaseControlModel> baseControlModel = DictionaryModelQuery.create(dictionaryModel)
                        .getControls().getControlModelByAttributePath(attributeEntry.getKey());

                if (baseControlModel.isPresent()) {

                    if (!first) {
                        sb.appendHtmlConstant(", ");
                    }
                    first = false;

                    sb.appendHtmlConstant(DictionaryModelUtil.getColumnLabel(baseControlModel.get()));
                    sb.appendHtmlConstant(": ");
                    HtmlUtils.highlightTexts(getModule().getSearchText(), attributeEntry.getValue(), sb);
                }
            }

            HTML text = new HTML(sb.toSafeHtml());
            text.addStyleName(DICTIONARY_SEARCH_RESULT_ITEM_TEXT_STYLE);
            resultItemContainer.add(text);

            resultContainer.add(resultItemContainer);
        }
    }
}

From source file:net.easysmarthouse.ui.webui.client.view.RootView.java

private void initRootPanel() {
    this.add(rootPanel);

    WelcomeLabel welcomeLabel = new WelcomeLabel(rootMessages.labelTextWelcome());
    RootPanel.get("welcome").add(welcomeLabel);

    Hyperlink logoutLink = new Hyperlink();
    logoutLink.setText(rootMessages.hyperlinkTextLogout());
    logoutLink.addDomHandler(new LogoutHandler(), ClickEvent.getType());
    RootPanel.get("logout").add(logoutLink);

    HorizontalPanel headerPanel = new HorizontalPanel();
    rootPanel.add(headerPanel);/*from  w w w  .j  a v  a2  s.c o  m*/

    tabsIndexes = new HashMap<Integer, PanelKey>();

    final Panel signalingPanel = PanelManager.addPanel(PanelKey.SIGNALING);
    tabPanel.add(signalingPanel, rootMessages.panelTabsTitleSignaling());
    tabsIndexes.put(0, PanelKey.SIGNALING);

    final Panel monitoringPanel = PanelManager.addPanel(PanelKey.MONITORING);
    tabPanel.add(monitoringPanel, rootMessages.panelTabsTitleClimate());
    tabsIndexes.put(1, PanelKey.MONITORING);

    final Panel switchingPanel = PanelManager.addPanel(PanelKey.SWITCHING);
    tabPanel.add(switchingPanel, rootMessages.panelTabsTitleLight());
    tabsIndexes.put(2, PanelKey.SWITCHING);

    final Panel devicePanel = PanelManager.addPanel(PanelKey.CAMERAS);
    tabPanel.add(devicePanel, rootMessages.panelTabsTitleCameras());
    tabsIndexes.put(3, PanelKey.CAMERAS);

    final Panel triggerPanel = PanelManager.addPanel(PanelKey.TRIGGER);
    tabPanel.add(triggerPanel, rootMessages.panelTabsTitleTriggers());
    tabsIndexes.put(4, PanelKey.TRIGGER);

    fireHistoryChange(History.getToken());

    tabPanel.addSelectionHandler(new SelectionHandler<Integer>() {
        @Override
        public void onSelection(SelectionEvent<Integer> event) {
            final Integer item = event.getSelectedItem();
            final PanelKey key = tabsIndexes.get(item);

            controller.call(new MvcEvent<PanelKey>(RootControllerAction.TAB_SELECTED, key));
        }
    });

    rootPanel.add(tabPanel);
    rootPanel.setCellHorizontalAlignment(tabPanel, HasHorizontalAlignment.ALIGN_CENTER);
}

From source file:net.europa13.taikai.web.client.ui.SidePanel.java

License:Open Source License

public void registerContent(Content content, MainPanel.Subsystem subsystem, String historyToken) {

    TreeItem ti = new TreeItem(content.getTitle());
    ti.setUserObject(content);//from ww  w.ja  va 2s .c om

    Hyperlink link = new Hyperlink(content.getTitle(), historyToken);
    link.addClickListener(linkListener);
    link.addStyleName("taikaiweb-SidebarLink");

    switch (subsystem) {
    case SESSION:
        //                link = new Hyperlink("Session", historyToken);
        link.setText("Session");
        add(link, "sidebar_session");
        //                session.setUserObject(content);

        break;
    case SYSADMIN:
        add(link, "sidebar_sysadmin");
        //                sysadmin.addItem(ti);
        break;
    case ADMIN:
        add(link, "sidebar_admin");
        //                admin.addItem(ti);
        break;
    case COURT:
        add(link, "sidebar_court");
        //                court.addItem(ti);
        break;
    }

}

From source file:org.eurekastreams.web.client.ui.pages.profile.tabs.GroupProfileAboutTabPanel.java

License:Apache License

/**
 * Constructor.//from   ww w .  java  2s .  co m
 * 
 * @param group
 *            Group to display.
 */
public GroupProfileAboutTabPanel(final DomainGroupModelView group) {
    final HashMap<String, String> basicInfoTabURL = new HashMap<String, String>();
    basicInfoTabURL.put("tab", "Basic Info");

    CreateUrlRequest target = new CreateUrlRequest(Page.GROUP_SETTINGS, group.getShortName());
    target.setParameters(basicInfoTabURL);

    Panel overviewPanel = createTitledPanel("Overview");
    Panel keywordsPanel = createTitledPanel("Keywords");

    final HTML noOverview = new HTML("An overview has not been added.");
    final HTML noKeywords = new HTML("Keywords have not been added.");

    final Hyperlink overviewHyperlink = new Hyperlink();
    final Hyperlink keywordsHyperlink = new Hyperlink();
    addLeft(overviewPanel);
    addRight(keywordsPanel);

    if (group.getOverview() == null || group.getOverview().trim().isEmpty()) {
        overviewHyperlink.setText("Add an overview.");
        overviewHyperlink.setTargetHistoryToken(Session.getInstance().generateUrl(target));
        overviewHyperlink.setVisible(false);

        overviewPanel.add(overviewHyperlink);
        overviewPanel.add(noOverview);
    } else {
        HTML overview = new HTML(group.getOverview());
        overview.addStyleName(StaticResourceBundle.INSTANCE.coreCss().profileAboutOverview());
        overviewPanel.add(overview);
    }

    if (group.getCapabilities() == null || group.getCapabilities().isEmpty()) {
        keywordsHyperlink.setText("Add keywords.");
        keywordsHyperlink.setTargetHistoryToken(Session.getInstance().generateUrl(target));
        keywordsHyperlink.setVisible(false);

        keywordsPanel.add(keywordsHyperlink);
        keywordsPanel.add(noKeywords);
    } else {
        List<String> caps = group.getCapabilities();
        List<BackgroundItem> bgitems = new ArrayList<BackgroundItem>();
        for (String cap : caps) {
            bgitems.add(new BackgroundItem(cap, BackgroundItemType.NOT_SET));
        }
        keywordsPanel.add(new BackgroundItemLinksPanel("keywords", bgitems));
    }

    // Shows the appropriate "add" links for group coordinators, if necessary.
    final EventBus eventBus = Session.getInstance().getEventBus();
    eventBus.addObserver(AuthorizeUpdateGroupResponseEvent.class,
            new Observer<AuthorizeUpdateGroupResponseEvent>() {
                public void update(final AuthorizeUpdateGroupResponseEvent event) {
                    if (event.getResponse()) {
                        if (!overviewHyperlink.getText().isEmpty()) {
                            overviewHyperlink.setVisible(true);
                            noOverview.setVisible(false);
                        }

                        if (!keywordsHyperlink.getText().isEmpty()) {
                            keywordsHyperlink.setVisible(true);
                            noKeywords.setVisible(false);
                        }
                    }
                }
            });
}

From source file:org.eurekastreams.web.client.ui.pages.search.GlobalSearchComposite.java

License:Apache License

/**
 * Constructor./*from  w  w  w .  j a  va2  s. c  o  m*/
 *
 * @param label
 *            the label for the uninitialized textbox.
 */
public GlobalSearchComposite(final String label) {
    searchTerm = new LabeledTextBox(label);
    resultsPanelContainer.setVisible(false);
    addStyleName(StaticResourceBundle.INSTANCE.coreCss().searchList());

    add(searchTerm);

    resultsPanelContainer
            .addStyleName(StaticResourceBundle.INSTANCE.coreCss().searchResultsAutocompleteResults());
    resultsPanelContainer
            .addStyleName(StaticResourceBundle.INSTANCE.coreCss().globalSearchResultsAutocompleteResults());

    add(resultsPanelContainer);
    resultsPanelContainer.add(resultsPanel);

    final EventBus eventBus = Session.getInstance().getEventBus();

    final GlobalSearchComposite thisClass = this;

    searchTerm.addKeyUpHandler(new KeyUpHandler() {
        public void onKeyUp(final KeyUpEvent ev) {
            if (ev.getNativeKeyCode() == KeyCodes.KEY_ENTER && !ev.isAnyModifierKeyDown()
                    && searchTerm.getText().length() > 0 && activeItem != null) {
                activeItem.getElement().dispatchEvent(
                        Document.get().createClickEvent(1, 0, 0, 0, 0, false, false, false, false));
                clearSearch();

            } else if (ev.getNativeKeyCode() == KeyCodes.KEY_DOWN && activeItem != null) {
                int activeIndex = resultsPanel.getWidgetIndex(activeItem);

                if (activeIndex + 1 < resultsPanel.getWidgetCount()) {
                    selectItem((Panel) resultsPanel.getWidget(activeIndex + 1));
                }
            } else if (ev.getNativeKeyCode() == KeyCodes.KEY_UP && activeItem != null) {
                int activeIndex = resultsPanel.getWidgetIndex(activeItem);

                if (activeIndex - 1 >= 0) {
                    selectItem((Panel) resultsPanel.getWidget(activeIndex - 1));
                }
            } else if (termLength != searchTerm.getText().length()) {
                String searchTermText = searchTerm.getText().trim();
                termLength = searchTermText.length();
                if (termLength == 0) {
                    resultsPanelContainer.setVisible(false);
                    resultsPanel.clear();
                    thisClass.removeStyleName(StaticResourceBundle.INSTANCE.coreCss().globalSearchBoxActive());
                } else {
                    GetDirectorySearchResultsRequest request = new GetDirectorySearchResultsRequest(
                            searchTermText, "", 0, 4, "global");
                    SearchResultsModel.getInstance().fetch(request, true);
                    thisClass.addStyleName(StaticResourceBundle.INSTANCE.coreCss().globalSearchBoxActive());
                }
            }
        }
    });

    searchTerm.addBlurHandler(new BlurHandler() {
        public void onBlur(final BlurEvent arg0) {
            timerFactory.runTimer(BLUR_DELAY, new TimerHandler() {
                public void run() {
                    clearSearch();
                }
            });
        }
    });

    eventBus.addObserver(GotSearchResultsResponseEvent.class, new Observer<GotSearchResultsResponseEvent>() {
        public void update(final GotSearchResultsResponseEvent event) {
            if ("global".equals(event.getCallerKey())) {
                resultsPanel.clear();
                activeItem = null;
                resultsPanelContainer.setVisible(event.getResponse().getPagedSet().size() > 0);
                String historyToken = "";

                for (ModelView result : event.getResponse().getPagedSet()) {
                    final FocusPanel itemContainer = new FocusPanel();
                    final FlowPanel itemPanel = new FlowPanel();
                    final Hyperlink name = new Hyperlink();
                    name.addStyleName(StaticResourceBundle.INSTANCE.coreCss().globalSearchItemName());
                    name.addStyleName(StaticResourceBundle.INSTANCE.coreCss().ellipsisChild());

                    if (result instanceof PersonModelView) {
                        final PersonModelView person = (PersonModelView) result;
                        itemPanel.add(AvatarLinkPanel.create(person, Size.Small, false));
                        name.setText(person.getDisplayName());
                        name.setTitle(person.getDisplayName());
                        historyToken = Session.getInstance()
                                .generateUrl(new CreateUrlRequest(Page.PEOPLE, person.getAccountId()));

                        itemContainer.addClickHandler(new ClickHandler() {
                            public void onClick(final ClickEvent event) {
                                ArrayList<String> views = new ArrayList<String>();
                                views.add(person.getAccountId());
                                eventBus.notifyObservers(
                                        new UpdateHistoryEvent(new CreateUrlRequest(Page.PEOPLE, views)));
                            }
                        });

                    } else if (result instanceof DomainGroupModelView) {
                        final DomainGroupModelView group = (DomainGroupModelView) result;
                        itemPanel.add(new AvatarLinkPanel(EntityType.GROUP, group.getShortName(),
                                group.getAvatarId(), Size.Small, false));
                        name.setText(group.getName());
                        name.setTitle(group.getName());
                        historyToken = Session.getInstance()
                                .generateUrl(new CreateUrlRequest(Page.GROUPS, group.getShortName()));

                        itemContainer.addClickHandler(new ClickHandler() {
                            public void onClick(final ClickEvent event) {
                                ArrayList<String> views = new ArrayList<String>();
                                views.add(group.getShortName());
                                eventBus.notifyObservers(
                                        new UpdateHistoryEvent(new CreateUrlRequest(Page.GROUPS, views)));
                            }
                        });
                    }

                    itemContainer.addMouseOverHandler(new MouseOverHandler() {
                        public void onMouseOver(final MouseOverEvent arg0) {
                            selectItem(itemContainer);
                        }
                    });

                    name.setTargetHistoryToken(historyToken);
                    itemPanel.add(name);

                    itemContainer.add(itemPanel);
                    resultsPanel.add(itemContainer);

                    if (activeItem == null) {
                        selectItem(itemContainer);
                    }
                }

                if (event.getResponse().getTotal() > event.getResponse().getPagedSet().size()) {
                    final FocusPanel itemContainer = new FocusPanel();
                    final FlowPanel itemPanel = new FlowPanel();

                    itemContainer
                            .addStyleName(StaticResourceBundle.INSTANCE.coreCss().searchResultsMoreButton());

                    itemPanel.add(new Label("See more results"));

                    itemContainer.addClickHandler(new ClickHandler() {
                        public void onClick(final ClickEvent event) {
                            eventBus.notifyObservers(new UpdateHistoryEvent(new CreateUrlRequest(Page.SEARCH,
                                    generateParams(searchTerm.getText()), false)));
                        }
                    });

                    itemContainer.addMouseOverHandler(new MouseOverHandler() {
                        public void onMouseOver(final MouseOverEvent arg0) {
                            selectItem(itemContainer);
                        }
                    });

                    itemContainer.add(itemPanel);
                    resultsPanel.add(itemContainer);
                }

            }
        }
    });

    eventBus.addObserver(SwitchedHistoryViewEvent.class, new Observer<SwitchedHistoryViewEvent>() {
        public void update(final SwitchedHistoryViewEvent event) {
            if (event.getPage() != Page.SEARCH) {
                searchTerm.reset();
            }
        }
    });
}