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.jbpm.form.builder.ng.model.client.form.editors.ServerScriptEditor.java

License:Apache License

public ServerScriptEditor(ServerTransformationFormItem item) {
    VerticalPanel panel = new VerticalPanel();
    this.item = item;
    this.editionArea.setCharacterWidth(50);
    this.editionArea.setVisibleLines(10);
    this.editionArea.setValue(item.getScriptContent());
    editionArea.addBlurHandler(new BlurHandler() {
        @Override/*from   ww w .j  ava 2s  .com*/
        public void onBlur(BlurEvent event) {
            wrapper.setValue(false);
        }
    });
    editionArea.addFocusHandler(new FocusHandler() {
        @Override
        public void onFocus(FocusEvent event) {
            wrapper.setValue(true);
        }
    });
    panel.add(this.editionArea);
    panel.add(createButtonsPanel());
    add(panel);
}

From source file:org.jbpm.form.builder.ng.model.client.form.FBFormItem.java

License:Apache License

public FBFormItem(List<FBFormEffect> formEffects) {
    this.effects.addAll(formEffects);
    addStyleName("fbFormItemThinBorder");
    EventHelper.addRightClickHandler(this, new RightClickHandler() {
        @Override//from   w  ww .  ja  v a 2 s. c om
        public void onRightClick(RightClickEvent event) {
            EffectsPopupPanel popupPanel = new EffectsPopupPanel(FBFormItem.this, true);
            if (getFormEffects() != null && !getFormEffects().isEmpty()) {
                popupPanel.setPopupPosition(event.getX(), event.getY());
                popupPanel.show();
            }
        }
    });
    EventHelper.addKeyboardCopyHandler(this, new ControlKeyHandler() {
        @Override
        public void onKeyboardControl() {
            CommonGlobals.getInstance().copy().append(FBFormItem.this).execute();
        }
    });
    EventHelper.addKeyboardCutHandler(this, new ControlKeyHandler() {
        @Override
        public void onKeyboardControl() {
            CommonGlobals.getInstance().cut().append(FBFormItem.this).execute();
        }
    });
    EventHelper.addKeyboardPasteHandler(this, new ControlKeyHandler() {
        @Override
        public void onKeyboardControl() {
            CommonGlobals.getInstance().paste().append(FBFormItem.this).execute();
        }
    });
    EventHelper.addBlurHandler(this, new BlurHandler() {
        @Override
        public void onBlur(BlurEvent event) {
            reset();
        }
    });
    EventHelper.addFocusHandler(this, new FocusHandler() {
        @Override
        public void onFocus(FocusEvent event) {
            makeEditor();
        }
    });
}

From source file:org.jbpm.formbuilder.client.tasks.TaskRow.java

License:Apache License

public TaskRow(TaskRef ioRef, boolean even) {
    this.ioRef = ioRef;
    addStyleName(even ? "even" : "odd");
    panel.add(new HTML("<strong>" + i18n.FormProcessId() + "</strong> " + ioRef.getProcessId()));
    panel.add(new HTML("<strong>" + i18n.FormTaskId() + "</strong> " + ioRef.getTaskId()));
    this.focus = addFocusHandler(new FocusHandler() {
        @Override//from   www .  j  av a  2  s .  c om
        public void onFocus(FocusEvent event) {
            showInputs();
            showOutputs();
            showMetaData();
        }
    });
    this.blur = addBlurHandler(new BlurHandler() {
        @Override
        public void onBlur(BlurEvent event) {
            hideInputs();
            hideOutputs();
            hideMetaData();
        }
    });
    add(panel);
}

From source file:org.kie.workbench.common.stunner.bpmn.client.forms.widgets.ComboBoxViewImpl.java

License:Apache License

@Override
public void init(final ComboBoxView.ComboBoxPresenter presenter,
        final ComboBoxView.ModelPresenter modelPresenter, final ValueListBox<String> listBox,
        final TextBox textBox, final String placeholder) {
    this.presenter = presenter;
    this.modelPresenter = modelPresenter;
    this.listBox = listBox;
    this.textBox = textBox;
    this.textBox.setPlaceholder(placeholder);
    textBox.setVisible(false);/*from  w w w.  j  av a 2 s  .co  m*/
    listBox.addValueChangeHandler(new ValueChangeHandler<String>() {
        @Override
        public void onValueChange(final ValueChangeEvent<String> valueChangeEvent) {
            presenter.listBoxValueChanged(valueChangeEvent.getValue());
        }
    });
    listBox.addDomHandler(new FocusHandler() {
        @Override
        public void onFocus(final FocusEvent focusEvent) {
            listBoxGotFocus();
        }
    }, FocusEvent.getType());
    textBox.addFocusHandler(new FocusHandler() {
        @Override
        public void onFocus(final FocusEvent focusEvent) {
            textBoxGotFocus();
        }
    });
    textBox.addBlurHandler(new BlurHandler() {
        @Override
        public void onBlur(final BlurEvent blurEvent) {
            // Update ListBoxValues and set model values when textBox loses focus
            textBoxLostFocus();
        }
    });
}

From source file:org.kie.workbench.common.stunner.forms.client.fields.widgets.ComboBoxViewImpl.java

License:Apache License

@Override
public void init(final ComboBoxView.ComboBoxPresenter presenter,
        final ComboBoxView.ModelPresenter modelPresenter, final ValueListBox<String> listBox,
        final TextBox textBox, final String placeholder) {
    this.presenter = presenter;
    this.modelPresenter = modelPresenter;
    this.listBox = listBox;
    this.textBox = textBox;
    this.textBox.setPlaceholder(placeholder);

    textBox.setVisible(false);//  w  w w.j av  a 2 s .  c o  m
    listBox.addValueChangeHandler(new ValueChangeHandler<String>() {
        @Override
        public void onValueChange(ValueChangeEvent<String> valueChangeEvent) {
            presenter.listBoxValueChanged(valueChangeEvent.getValue());
        }
    });

    listBox.addDomHandler(new FocusHandler() {
        @Override
        public void onFocus(FocusEvent focusEvent) {
            listBoxGotFocus();
        }
    }, FocusEvent.getType());

    textBox.addFocusHandler(new FocusHandler() {
        @Override
        public void onFocus(FocusEvent focusEvent) {
            textBoxGotFocus();
        }
    });

    textBox.addBlurHandler(new BlurHandler() {
        @Override
        public void onBlur(BlurEvent blurEvent) {
            // Update ListBoxValues and set model values when textBox loses focus
            textBoxLostFocus();
        }
    });

}

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

License:Educational Community License

public void addWidget(final Widget w) {
    if (w instanceof HasBlurHandlers) {
        ((HasBlurHandlers) w).addBlurHandler(new BlurHandler() {
            @Override/*from   w ww. j ava2 s. c o  m*/
            public void onBlur(final BlurEvent event) {
                focusTrackers.put(w, false);
                queueCheckFocusState();
            }
        });
    }
    if (w instanceof HasFocusHandlers) {
        ((HasFocusHandlers) w).addFocusHandler(new FocusHandler() {
            @Override
            public void onFocus(final FocusEvent event) {
                focusTrackers.put(w, true);
                queueCheckFocusState();
            }
        });
    }
}

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

License:Educational Community License

public KSDatePickerImpl() {
    this.initWidget(dateField);
    focus.addWidget(picker);//from w  ww . jav  a  2 s.  c om
    focus.addWidget(dateField);
    //pickerWrapper.add(picker);
    popup.add(picker);

    picker.setWidth(dateField.getOffsetWidth() + "px");
    dateField.addBlurHandler(new BlurHandler() {
        public void onBlur(BlurEvent event) {
            dateField.removeStyleName("KS-Datefield-Focus");
            if (!picker.isVisible()) {
                focus.setSuppressed(false);
            }
        }
    });

    dateField.addFocusHandler(new FocusHandler() {
        public void onFocus(FocusEvent event) {
            dateField.addStyleName("KS-Datefield-Focus");
            popup.setPopupPosition(getAbsoluteLeft(), getAbsoluteTop() + dateField.getOffsetHeight());
            if (justPicked) {
                if (dateField.getText() != null) {
                    dateField.selectAll();
                }
                justPicked = false;
            } else {
                popup.show();
                DeferredCommand.addCommand(new Command() {
                    @Override
                    public void execute() {
                        focus.setSuppressed(true);
                    }
                });
            }

        }
    });

    dateField.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            popup.setPopupPosition(getAbsoluteLeft(), getAbsoluteTop() + dateField.getOffsetHeight());
            popup.show();
            //dateField.selectAll();

        }

    });

    dateField.addKeyPressHandler(new KeyPressHandler() {

        public void onKeyPress(KeyPressEvent event) {
            String validInput = "0123456789";
            if (validInput.indexOf(event.getCharCode()) == -1
                    && !isDeleteOrBackspaceKey(event.getNativeEvent().getKeyCode())) {
                event.preventDefault();
            }
        }

    });

    dateField.addKeyDownHandler(new KeyDownHandler() {

        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_TAB) {
                popup.hide();
                if (picker.getValue() != null) {
                    selectedDate = picker.getValue();
                }
            }
        }

    });

    dateField.addKeyUpHandler(new KeyUpHandler() {

        public void onKeyUp(KeyUpEvent event) {
            String dateText = dateField.getText();

            if (!isDeleteOrBackspaceKey(event.getNativeKeyCode())) {
                if (dateText.length() == 2) {
                    dateField.setText(dateText + "/");
                    String current = df.format(currentDate);
                    Date newDate = df.parse(dateField.getText() + "01" + current.substring(5));
                    picker.setCurrentMonth(newDate);
                } else if (dateText.length() == 5) {
                    dateField.setText(dateText + "/");
                    String current = df.format(currentDate);
                    Date newDate = df.parse(dateField.getText() + current.substring(6));
                    dateField.setText(df.format(newDate).substring(0, 6));
                    picker.setCurrentMonth(newDate);
                    picker.setValue(newDate, false);

                } else if (dateText.length() == 10) {
                    Date newDate = df.parse(dateField.getText());
                    picker.setCurrentMonth(newDate);
                    picker.setValue(newDate, false);
                    selectedDate = picker.getValue();
                }
            }
        }

    });

    //pickerHandlers
    picker.addValueChangeHandler(new ValueChangeHandler<Date>() {

        public void onValueChange(ValueChangeEvent<Date> event) {
            if (picker.getValue() != null) {
                dateField.setText(df.format(picker.getValue()));
                selectedDate = picker.getValue();
            }
            dateField.setFocus(true);
            popup.hide();
            justPicked = true;
            focus.setSuppressed(false);
            fireValueChangeEvent();
        }
    });

}

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

License:Educational Community License

private void setupDefaultStyle() {
    listBox.addStyleName("KS-Dropdown");

    listBox.addBlurHandler(new BlurHandler() {
        public void onBlur(BlurEvent event) {
            listBox.removeStyleName("KS-Dropdown-Focus");
        }/*from w w w .j  a va  2s  .  c  om*/
    });

    listBox.addFocusHandler(new FocusHandler() {
        public void onFocus(FocusEvent event) {
            listBox.addStyleName("KS-Dropdown-Focus");
        }
    });

    listBox.addMouseOverHandler(new MouseOverHandler() {
        public void onMouseOver(MouseOverEvent event) {
            listBox.addStyleName("KS-Dropdown-Hover");
        }
    });

    listBox.addMouseOutHandler(new MouseOutHandler() {
        public void onMouseOut(MouseOutEvent event) {
            listBox.removeStyleName("KS-Dropdown-Hover");
        }
    });

    listBox.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (listBox.getSelectedIndex() != -1) {
                listBox.addStyleName("KS-Dropdown-Selected");
            } else {
                listBox.removeStyleName("KS-Dropdown-Selected");
            }
        }
    });
}

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

License:Educational Community License

/**
 * This method sets the default style for the checkbox and checkbox events.
 *
 *///from   w w w  .  ja  v  a  2s.c  o m
private void setupDefaultStyle() {
    addStyleName("KS-Checkbox");

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

        }
    });

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

        }
    });

    //hover does not function fully for check boxes as is
    /*        this.addMouseOverHandler(new MouseOverHandler(){
    public void onMouseOver(MouseOverEvent event) {
        KSCheckBox.this.addStyleName(KSStyles.KS_CHECKBOX_HOVER_STYLE);
            
    }
            });
            
            this.addMouseOutHandler(new MouseOutHandler(){
            
    public void onMouseOut(MouseOutEvent event) {
        KSCheckBox.this.removeStyleName(KSStyles.KS_CHECKBOX_HOVER_STYLE);
            
    }
            
            });*/

    this.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override

        public void onValueChange(ValueChangeEvent<Boolean> event) {
            if (KSCheckBox.this.getValue()) {
                KSCheckBox.this.addStyleName("KS-Checkbox-Checked");
            } else {
                KSCheckBox.this.removeStyleName("KS-Checkbox-Checked");
                KSCheckBox.this.setFocus(false);
            }
        }
    });
}

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

License:Educational Community License

/**
 * This method sets the default style for the radio button and radio button events.
 *
 *///  w w w . ja  va 2s  . c o m
private void setupDefaultStyle() {
    addStyleName("KS-Radio");

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

        }
    });

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

        }
    });

    //hover does not function correctly on radio buttons
    /*        this.addMouseOverHandler(new MouseOverHandler(){
    public void onMouseOver(MouseOverEvent event) {
        KSRadioButton.this.addStyleName(KSStyles.KS_RADIO_HOVER_STYLE);
            
    }
            });
            
            this.addMouseOutHandler(new MouseOutHandler(){
            
    public void onMouseOut(MouseOutEvent event) {
        KSRadioButton.this.removeStyleName(KSStyles.KS_RADIO_HOVER_STYLE);
            
    }
            
            });*/

    this.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override

        public void onValueChange(ValueChangeEvent<Boolean> event) {
            if (KSRadioButton.this.getValue()) {
                KSRadioButton.this.addStyleName("KS-Radio-Selected");
            } else {
                KSRadioButton.this.removeStyleName("KS-Radio-Selected");
                KSRadioButton.this.setFocus(false);
            }

        }
    });

}