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:com.eas.widgets.boxes.DecoratorBox.java

public DecoratorBox(HasValue<T> aDecorated) {
    super();/*w  w w  .  ja v a2  s . c  om*/
    decorated = aDecorated;
    if (decorated instanceof HasValue<?>) {
        decorated.addValueChangeHandler(new ValueChangeHandler<T>() {

            @Override
            public void onValueChange(ValueChangeEvent<T> event) {
                setClearButtonVisible(nullable && event.getValue() != null);
            }
        });
    }
    if (decorated instanceof HasDecorations) {
        HasWidgets container = ((HasDecorations) decorated).getContainer();
        ((Widget) container).addStyleName("decorator");
        container.add(selectButton);
        container.add(clearButton);
        initWidget((Widget) decorated);
    } else {
        CommonResources.INSTANCE.commons().ensureInjected();
        ((Widget) decorated).getElement().addClassName(CommonResources.INSTANCE.commons().borderSized());
        Style style = ((Widget) decorated).getElement().getStyle();
        style.setMargin(0, Style.Unit.PX);
        style.setPosition(Style.Position.ABSOLUTE);
        style.setDisplay(Style.Display.INLINE_BLOCK);
        style.setLeft(0, Style.Unit.PX);
        style.setTop(0, Style.Unit.PX);
        style.setHeight(100, Style.Unit.PCT);
        style.setWidth(100, Style.Unit.PCT);
        style.setOutlineStyle(Style.OutlineStyle.NONE);
        FlowPanel panel = new FlowPanel();
        panel.addStyleName("decorator");
        initWidget(panel);
        panel.add((Widget) decorated);
        panel.add(selectButton);
        panel.add(clearButton);
    }

    ((Widget) decorated).addStyleName("decorator-content");

    selectButton.getElement().addClassName("decorator-select");
    selectButton.getElement().getStyle().setDisplay(Style.Display.NONE);
    selectButton.getElement().getStyle().setHeight(100, Style.Unit.PCT);
    selectButton.getElement().getStyle().setPosition(Style.Position.RELATIVE);
    clearButton.getElement().addClassName("decorator-clear");
    clearButton.getElement().getStyle().setDisplay(Style.Display.NONE);
    clearButton.getElement().getStyle().setHeight(100, Style.Unit.PCT);
    clearButton.getElement().getStyle().setPosition(Style.Position.RELATIVE);

    selectButton.addDomHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            selectValue();
        }
    }, ClickEvent.getType());
    clearButton.addDomHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            clearValue();
            setFocus(true);
        }
    }, ClickEvent.getType());
    organizeButtonsContent();

    getElement().<XElement>cast().addResizingTransitionEnd(this);

    if (decorated instanceof HasValue<?>) {
        changeValueHandler = decorated.addValueChangeHandler(new ValueChangeHandler<T>() {

            @Override
            public void onValueChange(ValueChangeEvent<T> event) {
                fireValueChangeEvent();
            }
        });
    }

    if (decorated instanceof HasKeyDownHandlers) {
        keyDownHandler = ((HasKeyDownHandlers) decorated).addKeyDownHandler(new KeyDownHandler() {

            @Override
            public void onKeyDown(KeyDownEvent event) {
                KeyDownEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this);
            }
        });
    }
    if (decorated instanceof HasKeyUpHandlers) {
        keyUpHandler = ((HasKeyUpHandlers) decorated).addKeyUpHandler(new KeyUpHandler() {

            @Override
            public void onKeyUp(KeyUpEvent event) {
                KeyUpEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this);
            }
        });
    }
    if (decorated instanceof HasKeyPressHandlers) {
        keyPressHandler = ((HasKeyPressHandlers) decorated).addKeyPressHandler(new KeyPressHandler() {

            @Override
            public void onKeyPress(KeyPressEvent event) {
                KeyPressEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this);
            }
        });
    }
    if (decorated instanceof HasFocusHandlers) {
        focusHandler = ((HasFocusHandlers) decorated).addFocusHandler(new FocusHandler() {

            @Override
            public void onFocus(FocusEvent event) {
                FocusEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this);
            }

        });
    }
    if (decorated instanceof HasBlurHandlers) {
        blurHandler = ((HasBlurHandlers) decorated).addBlurHandler(new BlurHandler() {

            @Override
            public void onBlur(BlurEvent event) {
                BlurEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this);
            }

        });
    }

}

From source file:com.eas.widgets.boxes.SpinnerBox.java

public SpinnerBox(ValueBox<T> aField) {
    initWidget(container);//ww  w . java2  s.  c om
    container.getElement().getStyle().setDisplay(Style.Display.INLINE_BLOCK);
    container.getElement().getStyle().setPosition(Style.Position.RELATIVE);
    container.getElement().addClassName("spin-field");
    field = aField;
    field.setStyleName("form-control");
    field.addValueChangeHandler(new ValueChangeHandler<T>() {

        @Override
        public void onValueChange(ValueChangeEvent<T> event) {
            ValueChangeEvent.fire(SpinnerBox.this, getValue());
        }
    });
    if (field instanceof HasKeyDownHandlers) {
        ((HasKeyDownHandlers) field).addKeyDownHandler(new KeyDownHandler() {

            @Override
            public void onKeyDown(KeyDownEvent event) {
                KeyDownEvent.fireNativeEvent(event.getNativeEvent(), SpinnerBox.this);
            }
        });
    }
    if (field instanceof HasKeyUpHandlers) {
        ((HasKeyUpHandlers) field).addKeyUpHandler(new KeyUpHandler() {

            @Override
            public void onKeyUp(KeyUpEvent event) {
                KeyUpEvent.fireNativeEvent(event.getNativeEvent(), SpinnerBox.this);
            }
        });
    }
    if (field instanceof HasKeyPressHandlers) {
        ((HasKeyPressHandlers) field).addKeyPressHandler(new KeyPressHandler() {

            @Override
            public void onKeyPress(KeyPressEvent event) {
                KeyPressEvent.fireNativeEvent(event.getNativeEvent(), SpinnerBox.this);
            }
        });
    }
    if (field instanceof HasFocusHandlers) {
        ((HasFocusHandlers) field).addFocusHandler(new FocusHandler() {

            @Override
            public void onFocus(FocusEvent event) {
                FocusEvent.fireNativeEvent(event.getNativeEvent(), SpinnerBox.this);
            }

        });
    }
    if (field instanceof HasBlurHandlers) {
        ((HasBlurHandlers) field).addBlurHandler(new BlurHandler() {

            @Override
            public void onBlur(BlurEvent event) {
                BlurEvent.fireNativeEvent(event.getNativeEvent(), SpinnerBox.this);
            }

        });
    }
    left.getElement().addClassName("spin-left");
    left.getElement().getStyle().setDisplay(Style.Display.INLINE_BLOCK);
    left.getElement().getStyle().setTop(0, Style.Unit.PX);
    left.getElement().getStyle().setHeight(100, Style.Unit.PCT);
    left.getElement().getStyle().setPosition(Style.Position.RELATIVE);

    CommonResources.INSTANCE.commons().ensureInjected();

    field.getElement().getStyle().setDisplay(Style.Display.INLINE_BLOCK);
    field.getElement().getStyle().setPosition(Style.Position.ABSOLUTE);
    field.getElement().getStyle().setTop(0, Style.Unit.PX);
    field.getElement().getStyle().setHeight(100, Style.Unit.PCT);
    field.getElement().getStyle().setLeft(0, Style.Unit.PX);
    field.getElement().getStyle().setWidth(100, Style.Unit.PCT);
    field.getElement().getStyle().setMargin(0, Style.Unit.PX);
    field.getElement().getStyle().setBackgroundColor("inherit");
    field.getElement().getStyle().setColor("inherit");
    field.getElement().addClassName(CommonResources.INSTANCE.commons().borderSized());

    right.getElement().addClassName("spin-right");
    right.getElement().getStyle().setDisplay(Style.Display.INLINE_BLOCK);
    right.getElement().getStyle().setTop(0, Style.Unit.PX);
    right.getElement().getStyle().setHeight(100, Style.Unit.PCT);
    right.getElement().getStyle().setPosition(Style.Position.RELATIVE);

    CommonResources.INSTANCE.commons().ensureInjected();
    left.getElement().addClassName(CommonResources.INSTANCE.commons().unselectable());
    right.getElement().addClassName(CommonResources.INSTANCE.commons().unselectable());

    container.add(field);
    container.add(left);
    container.add(right);
    left.addDomHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            if (!isReadonly()) {
                decrement();
            }
        }
    }, ClickEvent.getType());
    right.addDomHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            if (!isReadonly()) {
                increment();
            }
        }
    }, ClickEvent.getType());
    redecorate();
    getElement().<XElement>cast().addResizingTransitionEnd(this);
}

From source file:com.edgenius.wiki.gwt.client.editor.MCELinkDialog.java

License:Open Source License

public MCELinkDialog(final TinyMCE tiny) {
    super(tiny);//from   w ww .  j a v a 2  s.co m
    request.addCallback(this);

    this.setText(Msg.consts.insert_link());
    Label l1 = new Label(Msg.consts.link_url());
    Label l2 = new Label(Msg.consts.space());
    Label l3 = new Label(Msg.consts.page());

    FlexTable layout = new FlexTable();
    layout.setWidget(0, 0, l2);
    layout.setWidget(0, 1, spaceBox);

    layout.setWidget(1, 0, l3);
    layout.setWidget(1, 1, pageBox);

    Hr sep = new Hr();
    layout.setWidget(2, 0, sep);
    layout.getFlexCellFormatter().setColSpan(2, 0, 2);

    layout.setWidget(3, 0, l1);
    layout.setWidget(3, 1, extLinkBox);

    VerticalPanel panel = new VerticalPanel();
    panel.add(message);
    panel.add(layout);

    panel.setSize("100%", "100%");
    layout.setSize("100%", "100%");
    l1.setStyleName(Css.FORM_LABEL);
    l2.setStyleName(Css.FORM_LABEL);
    l3.setStyleName(Css.FORM_LABEL);
    sep.setStyleName(Css.SEPARATOR);
    extLinkBox.setStyleName(Css.FORM_INPUT);
    spaceBox.setStyleName(Css.FORM_INPUT);
    pageBox.setStyleName(Css.FORM_INPUT);
    this.setWidget(panel);

    //can not use spaceBox.onLostFocus() to decide when get PageList, as spaceBox is suggest box, a popup suggest box
    //will trigger the focus event, but at the moment, the space input not finish yet...
    pageBox.addFocusHandler(new FocusHandler() {
        public void onFocus(FocusEvent event) {
            String spaceUname = StringUtil.trim(spaceBox.getText());

            if (!StringUtil.equalsIgnoreCase(spaceUname, currSpaceUname)) {
                pageBox.request(spaceUname);
                currSpaceUname = spaceUname;
            }
        }

    });

    Scheduler.get().scheduleDeferred(new ScheduledCommand() {
        public void execute() {
            pageBox.setFocus(true);
        }
    });

    //initial request for current space
    //just put it as blank so that comparing with spaceBox.getText()
    currSpaceUname = "";
    pageBox.request(StringUtil.trim(tiny.getSpaceUname()));
}

From source file:com.edgenius.wiki.gwt.client.portal.PortletCreateDialog.java

License:Open Source License

public PortletCreateDialog(final String key) {
    if (key == null) {
        this.setText(Msg.consts.create_widget());
    } else {/*from   ww w. j a  v a  2  s.  co m*/
        this.setText(Msg.consts.edit_widget());
    }
    this.setIcon(new Image(IconBundle.I.get().star()));

    FlexTable plinkerPanel = new FlexTable();

    pTitle.addFocusHandler(new FocusHandler() {
        public void onFocus(FocusEvent event) {
            String spaceUname = StringUtil.trim(pSpace.getText());
            if (!StringUtil.isBlank(spaceUname) && !StringUtil.equalsIgnoreCase(currSpaceUname, spaceUname)) {
                pTitle.request(spaceUname);
                currSpaceUname = spaceUname;
            }
        }

    });
    Label l1 = new Label(Msg.consts.space_uname());
    plinkerPanel.setWidget(0, 0, l1);
    plinkerPanel.setWidget(0, 1, pSpace);
    Label l2 = new Label(Msg.consts.page_title());
    plinkerPanel.setWidget(1, 0, l2);
    plinkerPanel.setWidget(1, 1, pTitle);

    FlexTable markupPanel = new FlexTable();
    Label l3 = new Label(Msg.consts.title());
    markupPanel.setWidget(0, 0, l3);
    markupPanel.setWidget(0, 1, title);
    title.setStyleName(Css.LONG_INPUT);

    Label l4 = new Label(Msg.consts.content());
    markupPanel.setWidget(1, 0, l4);
    markupPanel.setWidget(1, 1, markup);
    markup.setStyleName(Css.LONG_TEXTBOX);

    okBtn.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {

            WidgetModel widget = new WidgetModel();
            widget.key = key;
            widget.description = desc.getText();
            widget.shared = !keepPrivate.getValue();

            String error = null;
            String spaceUname = null;
            if (typeMarkup.getValue()) {
                widget.type = WidgetModel.TYPE_MARKUP_RENDER;
                widget.title = title.getText();
                widget.content = markup.getText();
                if (StringUtil.isBlank(widget.title)) {
                    error = "Title ";
                }
                if (StringUtil.isBlank(widget.content)) {
                    if (error != null)
                        error += " or Content";
                    else
                        error = "Content ";
                }
            } else {
                //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                //page link widget
                widget.type = WidgetModel.TYPE_PAGE_LINKER;
                spaceUname = StringUtil.trimToEmpty(pSpace.getText());
                widget.title = StringUtil.trimToEmpty(pTitle.getText());
                //build content - whatever spaceUname or title is correct as this widget object is saved into ValidPageAsync() and save immediately if no errors. 
                widget.content = "{include:src=" + EscapeUtil.escapeMacroParam(widget.title) + "@"
                        + EscapeUtil.escapeMacroParam(spaceUname) + "}";
                //it is bad idea if title is blank, then point to home page: it need lots hack to get back Home title etc. and in exception case, widget even can be blank title
                //this cause user have no chance to delete it anymore --- left rubbish widget on DB. 
                if (StringUtil.isBlank(widget.title)) {
                    error = "Title ";
                }
                if (StringUtil.isBlank(spaceUname)) {
                    if (error != null)
                        error += " or Space";
                    else
                        error = "Space ";
                }
            }

            if (error != null) {
                error += " can not be blank.";
                message.error(error);
                return;
            }

            okBtn.setEnabled(false);
            if (typeMarkup.getValue()) {
                //for markup content widget, create immediately
                PortalControllerAsync portalController = ControllerFactory.getPortalController();
                portalController.saveOrUpdateWidget(widget, PortletCreateDialog.this);
            } else {
                //for pagelink widget, valid from server side first, then save
                //valid if page exist or not? Valid from server side rather than just use suggest box, this is more exactly
                PageControllerAsync pageController = ControllerFactory.getPageController();
                pageController.exist(spaceUname, widget.title, new ValidPageAsync(widget));
            }

        }
    });
    Button cancelBtn = new Button(Msg.consts.cancel(), ButtonIconBundle.crossImage());
    cancelBtn.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            hidebox();
        }
    });
    typePageLinker.addClickHandler(typeChangeListener);
    typeMarkup.addClickHandler(typeChangeListener);

    getButtonBar().add(cancelBtn);
    getButtonBar().add(okBtn);

    deck.insert(plinkerPanel, PAGE_LINER_INDEX);
    deck.insert(markupPanel, MARKUP_RENDER_INDEX);

    fillPanel();

    int row = 0;
    FlexTable main = new FlexTable();
    main.getColumnFormatter().setWidth(0, "120px");

    main.setWidget(row, 0, message);
    main.getFlexCellFormatter().setColSpan(row, 0, 4);
    row++;

    Label l6 = new Label(Msg.consts.introduction());
    main.setWidget(row, 0, l6);
    main.setWidget(row, 1, desc);
    desc.setMaxLength(250);
    desc.setStyleName(Css.LONG_INPUT);
    Label l5 = new Label(Msg.consts.keep_private());
    main.setWidget(row, 2, l5);
    main.getFlexCellFormatter().setAlignment(row, 2, HasHorizontalAlignment.ALIGN_RIGHT,
            HasVerticalAlignment.ALIGN_MIDDLE);
    main.setWidget(row, 3, keepPrivate);
    row++;

    HorizontalPanel chooser = new HorizontalPanel();
    Label l7 = new Label(Msg.consts.page_linker());
    Label l8 = new Label(Msg.consts.markup_render());
    chooser.add(typePageLinker);
    chooser.add(l7);
    chooser.add(new HTML("&nbsp;&nbsp;&nbsp;"));
    chooser.add(typeMarkup);
    chooser.add(l8);
    chooser.setCellWidth(typePageLinker, "20px");
    chooser.setCellWidth(typeMarkup, "20px");
    main.setWidget(row, 0, chooser);
    main.getFlexCellFormatter().setColSpan(row, 0, 4);
    main.getFlexCellFormatter().setAlignment(row, 0, HasHorizontalAlignment.ALIGN_CENTER,
            HasVerticalAlignment.ALIGN_MIDDLE);
    row++;
    main.getFlexCellFormatter().setColSpan(row, 0, 4);
    main.getFlexCellFormatter().setHeight(row, 0, "3px");
    row++;

    main.setWidget(row, 0, deck);
    main.getFlexCellFormatter().setColSpan(row, 0, 4);
    row++;

    main.setStyleName(Css.FORM);
    title.setStyleName(Css.FORM_INPUT);
    desc.setStyleName(Css.FORM_INPUT);
    pTitle.setStyleName(Css.FORM_INPUT);
    pSpace.setStyleName(Css.FORM_INPUT);

    l1.setStyleName(Css.FORM_LABEL);
    l2.setStyleName(Css.FORM_LABEL);
    l3.setStyleName(Css.FORM_LABEL);
    l4.setStyleName(Css.FORM_LABEL);
    //      l5.setStyleName(Css.FORM_LABEL);

    l6.setStyleName(Css.FORM_LABEL);
    l7.setStyleName(Css.FORM_LABEL);
    DOM.setElementAttribute(l7.getElement(), "style", "text-align:left");
    l8.setStyleName(Css.FORM_LABEL);
    DOM.setElementAttribute(l8.getElement(), "style", "text-align:left");

    main.setSize("100%", "100%");
    deck.setSize("100%", "100%");

    VerticalPanel busyPanel = new VerticalPanel();
    busyPanel.add(busyMessage);
    busyPanel.add(busyImg);

    mainDeck.insert(main, DECK_MAIN);
    mainDeck.insert(busyPanel, DECK_BUSY);
    if (key == null)
        mainDeck.showWidget(DECK_MAIN);
    else {
        //edit, loading widget info
        mainDeck.showWidget(DECK_BUSY);
        PortalControllerAsync portalController = ControllerFactory.getPortalController();
        portalController.getWidget(key, new LoadingAsync());
    }

    this.setWidget(mainDeck);

}

From source file:com.ephesoft.dcma.gwt.core.client.ui.table.Table.java

License:Open Source License

private void update(boolean isRadioButton, int startIndex, int selectedIndexlocal) {
    selectedRowId = null;//from ww  w . j a v a  2s . c o m
    flexTable.removeAllRows();
    navBarTable.removeAllRows();
    createTableHeader(isRadioButton);
    int count = totalCount;
    int max = startIndex + visibleRecodrCount;
    if (max > count) {
        max = count;
    }
    navBar.update(startIndex, count, max);
    setNavigationBar();
    TableHeader header = tableData.getHeader();
    HeaderColumn[] columns = header.getHeaderColumns();
    String width = null;
    int rowCounter = 0;
    String radioName = String.valueOf(new Date().getTime());
    final List<Record> recordList = tableData.getRecordList();
    if (recordList != null) {
        if (!recordList.isEmpty()) {
            for (final Record record : recordList) {
                int colCounter = 0;
                for (; colCounter < columns.length; colCounter++) {
                    width = columns[colCounter].getWidth() + "%";
                    flexTable.getCellFormatter().setWidth(rowCounter, colCounter, width);
                    flexTable.setWidget(rowCounter, colCounter, record.getWidget(columns[colCounter]));
                    flexTable.getCellFormatter().setHorizontalAlignment(rowCounter, colCounter,
                            HasHorizontalAlignment.ALIGN_LEFT);
                    flexTable.getCellFormatter().setWordWrap(rowCounter, colCounter, true);
                    flexTable.getCellFormatter().addStyleName(rowCounter, colCounter, "wordWrap");
                }
                if (isRadioButton) {
                    final RadioButton radioButton = new RadioButton(radioName);
                    if (rowCounter == selectedIndexlocal) {
                        radioButton.setValue(true);
                        selectedRowId = record.getIdentifier();
                        selectedIndex = rowCounter;
                        if (null != listner && fireEventForFirstRow) {
                            listner.onRowSelected(selectedRowId);
                        }

                        scrollIntoView(
                                flexTable.getWidget(selectedIndexlocal, FIRST_COLUMN_INDEX).getElement());
                    }
                    radioButton.addClickHandler(new ClickHandler() {

                        @Override
                        public void onClick(ClickEvent arg0) {
                            clearRadioButtons();
                            radioButton.setValue(true);
                            selectedRowId = record.getIdentifier();
                            selectedIndex = recordList.indexOf(record);
                        }
                    });
                    flexTable.setWidget(rowCounter, 0, radioButton);
                    RadioButtonContainer radioButtonContainer = new RadioButtonContainer(radioButton,
                            record.getIdentifier());
                    radioButtons.put(rowCounter, radioButtonContainer);
                    flexTable.getCellFormatter().setHorizontalAlignment(rowCounter, 0,
                            HasHorizontalAlignment.ALIGN_CENTER);

                    radioButton.addFocusHandler(new FocusHandler() {

                        @Override
                        public void onFocus(FocusEvent arg0) {
                            removeSelectedRowStyleFromTable();
                            for (Integer rowId : radioButtons.keySet()) {
                                if (radioButtons.get(rowId).getRadioButton().equals(radioButton)) {
                                    selectedIndex = recordList.indexOf(record);
                                    flexTable.getRowFormatter().addStyleName(rowId,
                                            selectionStyle.rowHighlighted());
                                }
                            }
                        }
                    });
                } else {
                    RadioButtonContainer radioButtonContainer = new RadioButtonContainer(null,
                            record.getIdentifier());
                    radioButtons.put(rowCounter, radioButtonContainer);
                }
                if (rowCounter % 2 == 0) {
                    flexTable.getRowFormatter().setStyleName(rowCounter, selectionStyle.oddRow());
                } else {
                    flexTable.getRowFormatter().setStyleName(rowCounter, selectionStyle.evenRow());
                }
                rowCounter++;
                flexTable.getRowFormatter().addStyleName(selectedIndexlocal, selectionStyle.rowHighlighted());

            }
        } else {
            Label label = new Label();
            label.setWidth("100%");
            label.setText("No record found.");
            flexTable.getCellFormatter().setWidth(1, 0, "100%");
            flexTable.getFlexCellFormatter().setColSpan(1, 0, 3);
            // Record record = new Record("1");
            // tableData.getRecordList().add(record);
            flexTable.setWidget(1, 0, label);
        }

    }

}

From source file:com.ephesoft.dcma.gwt.rv.client.view.TableExtractionView.java

License:Open Source License

private void setTableList(final FlexTable flexTable, final List<Row> rows, final List<Column> columnList,
        final DataTable inputDataTable, final Document inputDocument) {
    selectedDataTableName = inputDataTable.getName();
    int index = 1;
    for (Row row : rows) {
        final int presentRowNumber = index;
        if (row != null && row.getColumns() != null && row.getColumns().getColumn() != null
                && !row.getColumns().getColumn().isEmpty()) {
            final List<Column> columns = row.getColumns().getColumn();
            int index1 = 0;
            final ArrayList<Coordinates> rowCoordinates = new ArrayList<Coordinates>();
            rowCoordinates.add(row.getRowCoordinates());
            for (final Column column : columnList) {
                final int presentColumnNumber = index1;
                final Column selectedColumn = columns.get(index1);
                columnPattern = tableNameVsColumnPattern.get(inputDataTable.getName());
                List<String> alternateValuesSet = getAlternateValueSet(selectedColumn);
                MultiWordSuggestOracle oracle = setMultiWordOracle(selectedColumn.getValue(),
                        alternateValuesSet);
                final SuggestBox suggestBox = new SuggestBox(oracle);
                suggestBox.addStyleName("tableViewListBox");
                suggestBox.setWidth("100%");

                final RegExValidatableWidget<SuggestBox> validatableSuggestBox = new RegExValidatableWidget<SuggestBox>(
                        suggestBox);//from   w  w  w.  ja  va2 s .com

                if ((columnPattern != null && columnPattern.size() > index1)
                        && (!row.isMannualExtraction() || selectedColumn.isValidationRequired())) {
                    validatableSuggestBox.addValidator(new RegExValidator(validatableSuggestBox,
                            columnPattern.get(index1), suggestBox, presenter.rpcService));
                }

                suggestBox.addValueChangeHandler(new ValueChangeHandler<String>() {

                    @Override
                    public void onValueChange(final ValueChangeEvent<String> event) {
                        selectedColumn.setValue(event.getValue());
                        selectedColumn.setValid(validatableSuggestBox.validate());
                        validatableSuggestBox.toggleValidDateBox();
                    }
                });

                suggestBox.getTextBox().addFocusHandler(new FocusHandler() {

                    @Override
                    public void onFocus(FocusEvent event) {
                        TableExtractionView.this
                                .fireEvent(new ValidationFieldChangeEvent(selectedColumn, rowCoordinates));
                        if (event.getSource() instanceof TextBox) {
                            selectedTextBox = (TextBox) event.getSource();
                        }
                        selectedRowNumber = presentRowNumber;
                        selectedColumnNumber = presentColumnNumber;
                        selectedDocument = inputDocument;
                        if (selectedDataTableName != null) {
                            clearSelectedRowStyle(tableNameVsViewMap.get(selectedDataTableName));
                        }
                        if (!presenter.isManualTableExtraction()) {
                            selDataTable = inputDataTable;
                        }
                        selectedDataTableName = inputDataTable.getName();
                        addSelectedRowStyle(flexTable, rows, columnList, selectedRowNumber);
                    }
                });

                suggestBox.addSelectionHandler(new SelectionHandler<Suggestion>() {

                    @Override
                    public void onSelection(SelectionEvent<Suggestion> suggestion) {
                        String inputString = suggestion.getSelectedItem().getReplacementString();
                        setSuggestBoxEvents(selectedColumn, inputString, validatableSuggestBox);
                        ValueChangeEvent.fire(suggestBox, inputString);
                        Row currRow = rows.get(selectedRowNumber - 1);
                        Column currColumn = currRow.getColumns().getColumn().get(selectedColumnNumber);
                        List<Coordinates> coorList = new ArrayList<Coordinates>();
                        coorList.add(currRow.getRowCoordinates());
                        TableExtractionView.this
                                .fireEvent(new ValidationFieldChangeEvent(currColumn, coorList));
                    }
                });

                suggestBox.setText(selectedColumn.getValue());
                if (!selectedColumn.isValid()) {
                    validatableSuggestBox.getWidget().addStyleName("dateBoxFormatError");
                }
                if (row.isMannualExtraction()) {
                    ValueChangeEvent.fire(suggestBox, selectedColumn.getValue());
                }
                flexTable.setWidget(index, index1, validatableSuggestBox.getWidget());
                index1++;
            }
            index++;
        }
    }
}

From source file:com.ephesoft.dcma.gwt.rv.client.view.ValidatePanel.java

License:Open Source License

/**
 * @param field/*  w  w  w  . j  av  a 2s  . c  om*/
 * @param fieldNameString
 * @param sampleValueString
 * @param vWidget
 */
private void addVWidgetHandlers(final DocField field, final String fieldNameString,
        final String sampleValueString, final ValidatableWidget<SuggestionBox> vWidget) {
    vWidget.getWidget().getTextBox().addKeyUpHandler(new KeyUpHandler() {

        @Override
        public void onKeyUp(KeyUpEvent arg0) {
            if (presenter.batchDTO.getSuggestionBoxSwitchState().equals("OFF")) {
                vWidget.getWidget().hideSuggestionList();
            }
            if (arg0.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                arg0.preventDefault();
                vWidget.getWidget().hideSuggestionList();
            }
        }
    });
    vWidget.getWidget().getTextBox().addKeyDownHandler(new KeyDownHandler() {

        @Override
        public void onKeyDown(KeyDownEvent keyDownEvent) {
            if (keyDownEvent.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                keyDownEvent.preventDefault();
                vWidget.getWidget().hideSuggestionList();
            }
            switch (keyDownEvent.getNativeKeyCode()) {
            case 'b':
            case 'B':
                if (keyDownEvent.isControlKeyDown()) {
                    keyDownEvent.preventDefault();
                    boolean validateWidget = vWidget.isValidateWidget();
                    vWidget.setValidateWidget(!validateWidget);
                    ValidatePanel.this.fireEvent(new ValidationFieldChangeEvent(vWidget.validate(),
                            sampleValueString, field.getName(), vWidget.validateThroughValidators()));
                }
                break;
            default:
                break;
            }
        }
    });
    vWidget.getWidget().getTextBox().addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> arg0) {
            if (presenter.batchDTO.getFieldValueChangeScriptSwitchState().equalsIgnoreCase("ON")) {
                currentFieldSet = false;
                presenter.setScriptExecuted(true);
                presenter.setFieldValueChangeName(field.getName());
                setTimerToExecuteScript();
            }
        }

    });
    vWidget.getWidget().getTextBox().addFocusHandler(new FocusHandler() {

        @Override
        public void onFocus(FocusEvent event) {
            if (!currentFieldSet) {
                currentFieldSet = true;
                presenter.setCurrentFieldName(field.getName());
            }

            presenter.setCurrentDocumentFieldName(field.getName());

            setCurrentDocFieldWidget(field.getName());
            if (presenter.batchDTO.getSuggestionBoxSwitchState().equals("OFF")) {
                vWidget.getWidget().hideSuggestionList();
            }
            ValidatePanel.this.fireEvent(new ValidationFieldChangeEvent(field));
            ValidatePanel.this.fireEvent(new ValidationFieldChangeEvent(vWidget.validate(), sampleValueString,
                    fieldNameString, vWidget.validateThroughValidators()));

            if (presenter.isScriptExecuted()) {
                presenter.executeScriptOnFieldChange(presenter.getFieldValueChangeName());
            }
        }
    });

    vWidget.getWidget().addSelectionHandler(new SelectionHandler<Suggestion>() {

        @Override
        public void onSelection(SelectionEvent<Suggestion> arg0) {
            String inputString = arg0.getSelectedItem().getReplacementString();
            setSuggestBoxEvents(field, inputString, vWidget);
        }
    });
}

From source file:com.ephesoft.dcma.gwt.rv.client.view.ValidatePanel.java

License:Open Source License

/**
 * @param isFieldHidden/*from   ww w.  j  a  v a  2s  . co  m*/
 * @param index
 * @param field
 * @param alternateValuesSet
 * @param fieldTypeDescription
 * @param tempTextArea
 * @param isReadOnly
 * @param fieldNameString
 * @param sampleValueString
 * @return
 */
private int setTextAreaTypeFields(boolean isFieldHidden, int index, final DocField field,
        List<String> alternateValuesSet, String fieldTypeDescription, ValidatableWidget<TextArea> tempTextArea,
        boolean isReadOnly, final String fieldNameString, final String sampleValueString) {
    int indexLocal = index;
    if (!isFieldHidden) {
        final ValidatableWidget<TextArea> textAreaWidget = tempTextArea;
        for (int k = 0; k < alternateValuesSet.size(); k++) {
            textAreaWidget.getWidget().setTitle(field.getName());
        }

        textAreaWidget.getWidget().addValueChangeHandler(new ValueChangeHandler<String>() {

            @Override
            public void onValueChange(ValueChangeEvent<String> arg0) {
                if (presenter.batchDTO.getFieldValueChangeScriptSwitchState().equalsIgnoreCase("ON")) {
                    currentFieldSet = false;
                    presenter.setScriptExecuted(true);
                    presenter.setFieldValueChangeName(field.getName());
                    setTimerToExecuteScript();
                }
            }

        });
        textAreaWidget.getWidget().addFocusHandler(new FocusHandler() {

            @Override
            public void onFocus(FocusEvent event) {
                if (!currentFieldSet) {
                    currentFieldSet = true;
                    setFieldAlreadySelected(true);
                    presenter.setCurrentFieldName(field.getName());
                }

                presenter.setCurrentDocumentFieldName(field.getName());

                setCurrentDocFieldWidget(field.getName());
                ValidatePanel.this.fireEvent(new ValidationFieldChangeEvent(field));
                ValidatePanel.this.fireEvent(
                        new ValidationFieldChangeEvent(true, sampleValueString, fieldNameString, true));

                if (presenter.isScriptExecuted()) {
                    presenter.executeScriptOnFieldChange(presenter.getFieldValueChangeName());
                }

            }
        });

        Label fieldLabel = null;
        if (fieldTypeDescription != null && !fieldTypeDescription.isEmpty()) {
            fieldLabel = new Label(fieldTypeDescription);
            validationTable.setWidget(indexLocal++, 0, fieldLabel);
        } else {
            fieldLabel = new Label(field.getName());
            validationTable.setWidget(indexLocal++, 0, fieldLabel);
        }
        validationTable.setWidget(indexLocal++, 0, textAreaWidget.getWidget());
        addDocFieldWidget(presenter.document.getIdentifier(), fieldLabel, field, null, null, textAreaWidget,
                isReadOnly);
    }
    return indexLocal;
}

From source file:com.ephesoft.dcma.gwt.rv.client.view.ValidatePanel.java

License:Open Source License

/**
 * @param field/*w ww  .j  av a2  s  .c  om*/
 * @param sampleValueString
 * @param listBoxWidget
 * @param vWidget
 */
private void addVWidgetHandlers(final DocField field, final String sampleValueString,
        final ValidatableWidget<ListBox> listBoxWidget, final ListBox vWidget) {
    vWidget.addFocusHandler(new FocusHandler() {

        @Override
        public void onFocus(FocusEvent event) {
            if (!currentFieldSet) {
                currentFieldSet = true;
                presenter.setCurrentFieldName(field.getName());
            }

            presenter.setCurrentDocumentFieldName(field.getName());

            setCurrentDocFieldWidget(field.getName());
            ValidatePanel.this.fireEvent(new ValidationFieldChangeEvent(field, false));

            // commented out this line to remove the overlay in case the actual value not found in drop down
            ValidatePanel.this.fireEvent(new ValidationFieldChangeEvent(listBoxWidget.validate(), null, null,
                    listBoxWidget.validateThroughValidators()));

            if (presenter.isScriptExecuted()) {
                presenter.executeScriptOnFieldChange(presenter.getFieldValueChangeName());
            }
        }
    });

    vWidget.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent arg0) {
            validateListBoxSelection(listBoxWidget);
            updateDocument(null, field.getName());
            if (presenter.batchDTO.getFieldValueChangeScriptSwitchState().equalsIgnoreCase("ON")) {
                currentFieldSet = false;
                presenter.setScriptExecuted(true);
                presenter.setFieldValueChangeName(field.getName());
                setTimerToExecuteScript();
            }
        }
    });
    vWidget.addKeyDownHandler(new KeyDownHandler() {

        @Override
        public void onKeyDown(KeyDownEvent event) {
            switch (event.getNativeKeyCode()) {
            case 'b':
            case 'B':
                if (event.isControlKeyDown()) {
                    event.preventDefault();
                    boolean validateWidget = listBoxWidget.isValidateWidget();
                    listBoxWidget.setValidateWidget(!validateWidget);
                    ValidatePanel.this.fireEvent(new ValidationFieldChangeEvent(listBoxWidget.validate(),
                            sampleValueString, field.getName(), listBoxWidget.validateThroughValidators()));
                }
                break;
            default:
                break;

            }
        }
    });
}

From source file:com.ephesoft.gxt.rv.client.widget.DocumentTree.java

License:Open Source License

private DocumentTree() {
    this.thumbnailDocumentMap = new HashMap<String, TreeItem>();
    this.addSelectionHandler();
    this.setScrollOnSelectEnabled(true);
    this.addFocusHandler(new FocusHandler() {

        @Override/* w  w  w .  j  a  v  a2  s.c om*/
        public void onFocus(final FocusEvent event) {
            event.preventDefault();
            ReviewValidateEventBus.fireEvent(new FocusInitializationEvent());
        }
    });
}