Example usage for com.google.gwt.event.dom.client FocusHandler FocusHandler

List of usage examples for com.google.gwt.event.dom.client FocusHandler FocusHandler

Introduction

In this page you can find the example usage for com.google.gwt.event.dom.client FocusHandler FocusHandler.

Prototype

FocusHandler

Source Link

Usage

From source file:org.kuali.student.common.ui.client.widgets.KSTextArea.java

License:Educational Community License

/**
 * This method sets the default style for the text area and text area events.
 *//*ww w .  j  a  v a 2 s.co  m*/
private void setupDefaultStyle() {
    addStyleName("KS-Textarea");

    this.addBlurHandler(new BlurHandler() {
        public void onBlur(BlurEvent event) {
            KSTextArea.this.removeStyleName("KS-Textarea-Focus");

        }
    });

    this.addFocusHandler(new FocusHandler() {
        public void onFocus(FocusEvent event) {
            KSTextArea.this.addStyleName("KS-Textarea-Focus");

        }
    });

    this.addMouseOverHandler(new MouseOverHandler() {
        public void onMouseOver(MouseOverEvent event) {
            KSTextArea.this.addStyleName("KS-Textarea-Hover");

        }
    });

    this.addMouseOutHandler(new MouseOutHandler() {

        public void onMouseOut(MouseOutEvent event) {
            KSTextArea.this.removeStyleName("KS-Textarea-Hover");

        }

    });

}

From source file:org.kuali.student.common.ui.client.widgets.KSTextArea.java

License:Educational Community License

@Override
public void setWatermarkText(String text) {
    if (!hasWatermark) {
        hasWatermark = true;/*from ww  w .ja  v a  2  s .c o  m*/
        watermarkText = text;
        if (getText() == null || getText().isEmpty()) {
            addStyleName("watermark-text");
            KSTextArea.super.setText(watermarkText);
            watermarkShowing = true;
        }

        this.addFocusHandler(new FocusHandler() {

            @Override
            public void onFocus(FocusEvent event) {
                if (watermarkShowing) {
                    removeStyleName("watermark-text");
                    KSTextArea.super.setText("");
                    watermarkShowing = false;
                }
            }
        });

        this.addBlurHandler(new BlurHandler() {

            @Override
            public void onBlur(BlurEvent event) {
                if (getText() == null || getText().isEmpty()) {
                    addStyleName("watermark-text");
                    KSTextArea.super.setText(watermarkText);
                    watermarkShowing = true;
                }
            }
        });
    } else {
        watermarkText = text;
        if (getText() == null || getText().isEmpty()) {
            addStyleName("watermark-text");
            KSTextArea.super.setText(watermarkText);
            watermarkShowing = true;
        }
    }
}

From source file:org.kuali.student.common.ui.client.widgets.KSTextBox.java

License:Educational Community License

/**
 * This method sets the default style for the text box and text box events.
 *
 *//*  w  ww . j  av  a2s.  c  o m*/
private void setupDefaultStyle() {
    addStyleName("KS-Textbox");

    this.addBlurHandler(new BlurHandler() {
        public void onBlur(BlurEvent event) {
            KSTextBox.this.removeStyleName("KS-Textbox-Focus");

        }
    });

    this.addFocusHandler(new FocusHandler() {
        public void onFocus(FocusEvent event) {
            KSTextBox.this.addStyleName("KS-Textbox-Focus");

        }
    });

    this.addMouseOverHandler(new MouseOverHandler() {
        public void onMouseOver(MouseOverEvent event) {
            KSTextBox.this.addStyleName("KS-Textbox-Hover");

        }
    });

    this.addMouseOutHandler(new MouseOutHandler() {

        public void onMouseOut(MouseOutEvent event) {
            KSTextBox.this.removeStyleName("KS-Textbox-Hover");

        }

    });

}

From source file:org.kuali.student.common.ui.client.widgets.KSTextBox.java

License:Educational Community License

@Override
public void setWatermarkText(String text) {
    if (!hasWatermark) {
        hasWatermark = true;/*from w  w  w  . j  a  va 2  s .co m*/
        watermarkText = text;
        if (getText() == null || getText().isEmpty()) {
            addStyleName("watermark-text");
            super.setText(watermarkText);
            watermarkShowing = true;
        }

        this.addFocusHandler(new FocusHandler() {

            @Override
            public void onFocus(FocusEvent event) {
                if (watermarkShowing) {
                    removeStyleName("watermark-text");
                    KSTextBox.super.setText("");
                    watermarkShowing = false;
                }
            }
        });

        this.addBlurHandler(new BlurHandler() {

            @Override
            public void onBlur(BlurEvent event) {
                if (getText() == null || getText().isEmpty()) {
                    addStyleName("watermark-text");
                    KSTextBox.super.setText(watermarkText);
                    watermarkShowing = true;
                }
            }
        });
    } else {
        watermarkText = text;
        if (getText() == null || getText().isEmpty()) {
            addStyleName("watermark-text");
            KSTextBox.super.setText(watermarkText);
            watermarkShowing = true;
        }
    }
}

From source file:org.obiba.opal.web.gwt.app.client.ui.SuggestListBox.java

License:Open Source License

public SuggestListBox(SuggestOracle oracle) {
    this.oracle = oracle;
    addStyleName("obiba-SuggestListBox");

    content = new FlowPanel();

    closeables = new CloseableList();
    content.add(closeables);/*from  w  w  w  .ja v  a2  s. co m*/
    closeables.addItemRemovedHandler(new ItemRemovedHandler() {

        @Override
        public void onItemRemoved(ListItem item) {
            textBox.setFocus(true);
        }
    });

    rebuildSuggestBox();

    addFocusHandler(new FocusHandler() {
        @Override
        public void onFocus(FocusEvent event) {
            textBox.setFocus(true);
        }
    });

    clear = new Anchor();
    clear.setVisible(false);
    clear.addStyleName("icon-remove-circle");
    clear.addStyleName("textbox-clearable-anchor");
    clear.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            closeables.clear();
            textBox.setText("");
            clear.setVisible(false);
            empty.setVisible(true);
            textBox.setFocus(false);
        }
    });
    content.add(clear);

    empty = new Anchor();
    empty.setVisible(true);
    content.add(empty);

    add(content);
}

From source file:org.olanto.TranslationText.client.QuoteWidget.java

License:Open Source License

private void createSourceTree() {
    final String lS = langS.getItemText(langS.getSelectedIndex());
    final String lT = langT.getItemText(langT.getSelectedIndex());

    // Create the tree
    Tree staticTree = new Tree();
    String docName, longName, listElem;
    final String racine = lS + "/";
    int k, l;// ww w. j a v  a 2s.  co  m

    for (int i = 0; i < docList.size(); i++) {

        TreeItem docItem = new TreeItem();
        listElem = docList.get(i);
        k = listElem.indexOf("]");
        l = listElem.indexOf("[") + 2;
        longName = listElem.substring(l);
        docName = listElem.substring(0, k);
        if ((!GuiConstant.FILE_NAME_RIGHT) && (GuiConstant.PATH_ON)) {
            docItem.setTitle(longName.substring(3).replace("", "/"));
            docItem.setHTML(longName.substring(3).replace("", "/"));
        } else {
            docItem.setTitle(longName.substring(3).replace("", "/"));
            docItem.setHTML(docName);
        }

        //docItem.setStyleName("gwt-TreeItem");
        staticTree.addItem(docItem);
    }

    staticTree.addFocusHandler(new FocusHandler() {
        @Override
        public void onFocus(FocusEvent event) {
            Scheduler.get().scheduleDeferred(new Command() {
                @Override
                public void execute() {
                    tS.sourceTextArea.setFocus(true);
                }
            });
        }
    });
    staticTree.addMouseUpHandler(new MouseUpHandler() {
        @Override
        public void onMouseUp(MouseUpEvent event) {
            Scheduler.get().scheduleDeferred(new Command() {
                @Override
                public void execute() {
                    tS.sourceTextArea.setFocus(true);
                }
            });
        }
    });
    staticTree.addSelectionHandler(new SelectionHandler<TreeItem>() {
        @Override
        public void onSelection(SelectionEvent<TreeItem> event) {
            if (event.getSelectedItem().getText() != null) {
                setMessage("info", GuiMessageConst.MSG_51 + event.getSelectedItem().getTitle());
                lastSelected = event.getSelectedItem().getTitle();
                tS.reset();
                tS.words = Utility.getRefWords(refDoc.reftext[refIdx - 1] + " ");
                tS.queryLength = refDoc.reftext[refIdx - 1].length();
                tS.getTextContent(racine + event.getSelectedItem().getTitle().replace("/", ""), lS, lT,
                        refDoc.reftext[refIdx - 1]);
            }
        }
    });
    staticTree.setAnimationEnabled(true);
    staticTree.ensureDebugId("cwTree-staticTree");
    staticTree.setStyleName("gwt-Tree");
    // Wrap the static tree in a DecoratorPanel
    staticTreeWrapper.add(staticTree);
}

From source file:org.olanto.TranslationText.client.ResearchWidget.java

License:Open Source License

private void createSourceTree(ArrayList<String> doclist, final BitextWidget tS, final String Query) {
    final String lS = langS.getItemText(langS.getSelectedIndex());
    final String lT = langT.getItemText(langT.getSelectedIndex());
    // Create the tree
    Tree staticTree = new Tree();
    staticTree.ensureDebugId("cwTree-staticTree");
    staticTree.setStyleName("gwt-Tree");
    String docName, longName, listElem;
    final String racine = lS + "/";
    int k, l;//from  ww  w  .ja  v  a  2 s.c  o m

    for (int i = 0; i < doclist.size(); i++) {

        TreeItem docItem = new TreeItem();
        listElem = doclist.get(i);
        k = listElem.indexOf("]");
        l = listElem.indexOf("[") + 2;
        longName = listElem.substring(l);
        docName = listElem.substring(0, k);
        if ((!GuiConstant.FILE_NAME_RIGHT) && (GuiConstant.PATH_ON)) {
            docItem.setTitle(longName.substring(3).replace("", "/"));
            docItem.setHTML(longName.substring(3).replace("", "/"));
        } else {
            docItem.setTitle(longName.substring(3).replace("", "/"));
            docItem.setHTML(docName);
        }
        staticTree.addItem(docItem);
    }
    staticTree.addFocusHandler(new FocusHandler() {
        @Override
        public void onFocus(FocusEvent event) {
            Scheduler.get().scheduleDeferred(new Command() {
                @Override
                public void execute() {
                    tS.sourceTextArea.setFocus(true);
                }
            });
        }
    });
    staticTree.addMouseUpHandler(new MouseUpHandler() {
        @Override
        public void onMouseUp(MouseUpEvent event) {
            Scheduler.get().scheduleDeferred(new Command() {
                @Override
                public void execute() {
                    tS.sourceTextArea.setFocus(true);
                }
            });
        }
    });
    staticTree.addSelectionHandler(new SelectionHandler<TreeItem>() {
        @Override
        public void onSelection(SelectionEvent<TreeItem> event) {
            if (event.getSelectedItem().getText() != null) {
                setMessage("info", GuiMessageConst.MSG_51 + event.getSelectedItem().getTitle());
                lastSelected = event.getSelectedItem().getTitle();
                tS.reset();
                tS.words = MainEntryPoint.words;
                //                    Window.alert(tS.words.toString());
                tS.getTextContent(racine + event.getSelectedItem().getTitle().replace("/", ""), lS, lT,
                        Query);
            }
        }
    });
    // Wrap the static tree in a DecoratorPanel
    staticTreeWrapper.add(staticTree);
}

From source file:org.opencms.acacia.client.ui.CmsAttributeValueView.java

License:Open Source License

/**
 * Sets the value widget.<p>//from w  ww  . ja  va2 s . c  o m
 *
 * @param widget the widget
 * @param value the value
 * @param defaultValue the default attribute value
 * @param active <code>true</code> if the widget should be activated
 */
public void setValueWidget(I_CmsFormEditWidget widget, String value, String defaultValue, boolean active) {

    if (m_hasValue) {
        throw new RuntimeException("Value has already been set");
    }
    m_defaultValue = defaultValue;
    m_hasValue = true;
    m_isSimpleValue = true;
    m_widget = widget;
    if (CmsAttributeHandler.hasResizeHandler() && (m_widget instanceof HasResizeHandlers)) {
        ((HasResizeHandlers) m_widget).addResizeHandler(CmsAttributeHandler.getResizeHandler());
    }
    m_widgetHolder.clear();
    m_widget.setWidgetInfo(m_label, m_help);
    if (active) {
        m_widget.setValue(value, false);
    } else {
        m_widget.setValue("", false);
    }
    m_widgetHolder.add(m_widget);
    m_widget.setName(getHandler().getAttributeName());
    m_widget.addValueChangeHandler(new ChangeHandler());
    m_widget.addFocusHandler(new FocusHandler() {

        public void onFocus(FocusEvent event) {

            CmsValueFocusHandler.getInstance().setFocus(CmsAttributeValueView.this);
            activateWidget();
        }
    });
    m_widget.setActive(active);
    if (!active) {
        addActivationHandler();
    } else {
        removeStyleName(formCss().emptyValue());
    }
    addStyleName(formCss().simpleValue());
}

From source file:org.opencms.acacia.client.widgets.CmsCalendarWidget.java

License:Open Source License

/**
 * Constructs an CmsComboWidget with the in XSD schema declared configuration.<p>
 * @param config The configuration string given from OpenCms XSD.
 *//*from   www  .ja v a  2  s .  com*/
public CmsCalendarWidget(String config) {
    m_dateBox.setAllowInvalidValue(true);

    // All composites must call initWidget() in their constructors.
    initWidget(m_dateBox);

    m_dateBox.getTextField().getTextBoxContainer()
            .addStyleName(I_CmsWidgetsLayoutBundle.INSTANCE.widgetCss().calendarStyle());
    ValueChangeHandler<Date> test = new ValueChangeHandler<Date>() {

        public void onValueChange(ValueChangeEvent<Date> arg0) {

            fireChangeEvent();

        }

    };

    m_dateBox.addValueChangeHandler(test);
    m_dateBox.addKeyPressHandler(new KeyPressHandler() {

        public void onKeyPress(KeyPressEvent arg0) {

            int keyCode = arg0.getUnicodeCharCode();
            if (keyCode == 0) {
                // Probably Firefox
                keyCode = arg0.getNativeEvent().getKeyCode();
            }
            if (keyCode == KeyCodes.KEY_ENTER) {
                fireChangeEvent();
            }

        }
    });
    m_dateBox.getTextField().addFocusHandler(new FocusHandler() {

        public void onFocus(FocusEvent event) {

            CmsDomUtil.fireFocusEvent(CmsCalendarWidget.this);
        }
    });
}

From source file:org.opencms.acacia.client.widgets.CmsCheckboxWidget.java

License:Open Source License

/**
 * Constructs an OptionalTextBox with the given caption on the check.<p>
 *//*from w ww . ja  v  a2  s .  co m*/
public CmsCheckboxWidget() {

    SimplePanel panel = new SimplePanel();
    // adds the checkbox to the panel.
    panel.add(m_checkbox);

    // Set the check box's caption, and check it by default.
    m_checkbox.setChecked(true);
    m_checkbox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        public void onValueChange(ValueChangeEvent<Boolean> event) {

            if (Boolean.parseBoolean(m_checkbox.getFormValueAsString())) {
                getParent().getElement().addClassName(I_CmsLayoutBundle.INSTANCE.form().inActive());
            } else {
                getParent().getElement().removeClassName(I_CmsLayoutBundle.INSTANCE.form().inActive());
            }
            fireChangeEvent();

        }

    });
    m_checkbox.getButton().addFocusHandler(new FocusHandler() {

        public void onFocus(FocusEvent event) {

            CmsDomUtil.fireFocusEvent(CmsCheckboxWidget.this);
        }
    });
    // All composites must call initWidget() in their constructors.
    initWidget(panel);

}