Package com.ponysdk.ui.terminal.instruction

Examples of com.ponysdk.ui.terminal.instruction.PTInstruction


    protected void executeInstruction(final PTInstruction update, final UIService uiService) {
        final JSONArray jsonArray = update.get(PROPERTY.INSTRUCTIONS).isArray();
        final List<PTInstruction> instructions = new ArrayList<PTInstruction>();
        for (int i = 0; i < jsonArray.size(); i++) {
            instructions.add(new PTInstruction(jsonArray.get(i).isObject().getJavaScriptObject()));
        }

        PTInstruction currentInstruction = null;
        try {
            for (final PTInstruction instruction : instructions) {
                currentInstruction = instruction;
                uiService.processInstruction(instruction);
            }
View Full Code Here


    }

    @Override
    public void onValueChange(final ValueChangeEvent<String> event) {
        if (event.getValue() != null && !event.getValue().isEmpty()) {
            final PTInstruction eventInstruction = new PTInstruction();
            eventInstruction.put(TYPE.KEY, TYPE.KEY_.HISTORY);
            eventInstruction.put(HISTORY.TOKEN, event.getValue());
            stackInstrution(eventInstruction);
        }
    }
View Full Code Here

    protected void addValueChangeHandler(final PTInstruction addHandler, final UIService uiService) {
        uiObject.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

            @Override
            public void onValueChange(final ValueChangeEvent<Boolean> event) {
                final PTInstruction instruction = new PTInstruction();
                instruction.setObjectID(addHandler.getObjectID());
                instruction.put(TYPE.KEY, TYPE.KEY_.EVENT);
                instruction.put(HANDLER.KEY, HANDLER.KEY_.BOOLEAN_VALUE_CHANGE_HANDLER);
                instruction.put(PROPERTY.VALUE, event.getValue());
                uiService.sendDataToServer(instruction);
            }
        });
    }
View Full Code Here

            final DatePicker picker = cast();
            picker.addShowRangeHandler(new ShowRangeHandler<Date>() {

                @Override
                public void onShowRange(final ShowRangeEvent<Date> event) {
                    final PTInstruction instruction = new PTInstruction();
                    instruction.setObjectID(addHandler.getObjectID());
                    instruction.put(TYPE.KEY, TYPE.KEY_.EVENT);
                    instruction.put(HANDLER.KEY, HANDLER.KEY_.SHOW_RANGE);
                    instruction.put(PROPERTY.START, Long.toString(event.getStart().getTime()));
                    instruction.put(PROPERTY.END, Long.toString(event.getEnd().getTime()));
                    uiService.sendDataToServer(instruction);
                }
            });
        } else {
            super.addHandler(addHandler, uiService);
View Full Code Here

            date = "";
        } else {
            date = Long.toString(event.getValue().getTime());
        }

        final PTInstruction instruction = new PTInstruction();
        instruction.setObjectID(addHandler.getObjectID());
        instruction.put(TYPE.KEY, TYPE.KEY_.EVENT);
        instruction.put(HANDLER.KEY, HANDLER.KEY_.DATE_VALUE_CHANGE_HANDLER);
        instruction.put(PROPERTY.VALUE, date);
        uiService.sendDataToServer(instruction);
    }
View Full Code Here

    // public W cast() {
    // return uiObject;
    // }

    protected void triggerMouseEvent(final PTInstruction addHandler, final Widget widget, final int domHandlerType, final UIService uiService, final MouseEvent<?> event) {
        final PTInstruction eventInstruction = buildEventInstruction(addHandler, domHandlerType);
        eventInstruction.put(PROPERTY.CLIENT_X, event.getClientX());
        eventInstruction.put(PROPERTY.CLIENT_Y, event.getClientY());
        eventInstruction.put(PROPERTY.X, event.getX());
        eventInstruction.put(PROPERTY.Y, event.getY());
        eventInstruction.put(PROPERTY.NATIVE_BUTTON, event.getNativeButton());
        eventInstruction.put(PROPERTY.SOURCE_ABSOLUTE_LEFT, widget.getAbsoluteLeft());
        eventInstruction.put(PROPERTY.SOURCE_ABSOLUTE_TOP, widget.getAbsoluteTop());
        eventInstruction.put(PROPERTY.SOURCE_OFFSET_HEIGHT, widget.getOffsetHeight());
        eventInstruction.put(PROPERTY.SOURCE_OFFSET_WIDTH, widget.getOffsetWidth());
        uiService.sendDataToServer(eventInstruction);
        preventOrStopEvent(event);
    }
View Full Code Here

        uiService.sendDataToServer(eventInstruction);
        preventOrStopEvent(event);
    }

    protected void triggerDomEvent(final PTInstruction addHandler, final int domHandlerType, final UIService uiService, final DomEvent<?> event) {
        final PTInstruction eventInstruction = buildEventInstruction(addHandler, domHandlerType);
        uiService.sendDataToServer(eventInstruction);
        preventOrStopEvent(event);
    }
View Full Code Here

        uiService.sendDataToServer(eventInstruction);
        preventOrStopEvent(event);
    }

    private PTInstruction buildEventInstruction(final PTInstruction addHandler, final int domHandlerType) {
        final PTInstruction eventInstruction = new PTInstruction();
        eventInstruction.setObjectID(addHandler.getObjectID());
        eventInstruction.put(TYPE.KEY, TYPE.KEY_.EVENT);
        eventInstruction.put(HANDLER.KEY, HANDLER.KEY_.DOM_HANDLER);
        eventInstruction.put(PROPERTY.DOM_HANDLER_TYPE, domHandlerType);
        return eventInstruction;
    }
View Full Code Here

        return eventInstruction;
    }

    protected void triggerOnKeyPress(final PTInstruction addHandler, final int domHandlerType, final UIService uiService, final KeyPressEvent event) {

        final PTInstruction eventInstruction = buildEventInstruction(addHandler, domHandlerType);
        eventInstruction.put(PROPERTY.VALUE, event.getNativeEvent().getKeyCode());

        if (addHandler.containsKey(PROPERTY.KEY_FILTER)) {
            final JSONArray jsonArray = addHandler.get(PROPERTY.KEY_FILTER).isArray();
            for (int i = 0; i < jsonArray.size(); i++) {
                final JSONNumber keyCode = jsonArray.get(i).isNumber();
View Full Code Here

                    final TextBoxBase textBox = (TextBoxBase) widget;
                    textBox.addKeyUpHandler(new KeyUpHandler() {

                        @Override
                        public void onKeyUp(final KeyUpEvent event) {
                            final PTInstruction changeHandlerInstruction = new PTInstruction();
                            changeHandlerInstruction.setObjectID(addHandler.getObjectID());
                            changeHandlerInstruction.put(TYPE.KEY, TYPE.KEY_.EVENT);
                            changeHandlerInstruction.put(HANDLER.KEY, HANDLER.KEY_.STRING_VALUE_CHANGE_HANDLER);
                            changeHandlerInstruction.put(PROPERTY.VALUE, textBox.getText());

                            final PTInstruction eventInstruction = buildEventInstruction(addHandler, domHandlerType);
                            eventInstruction.put(PROPERTY.VALUE, event.getNativeEvent().getKeyCode());

                            if (addHandler.containsKey(PROPERTY.KEY_FILTER)) {
                                final JSONArray jsonArray = addHandler.get(PROPERTY.KEY_FILTER).isArray();
                                for (int i = 0; i < jsonArray.size(); i++) {
                                    final JSONNumber keyCode = jsonArray.get(i).isNumber();
                                    if (keyCode.doubleValue() == event.getNativeEvent().getKeyCode()) {
                                        uiService.stackInstrution(changeHandlerInstruction);
                                        uiService.stackInstrution(eventInstruction);
                                        uiService.flushEvents();
                                        break;
                                    }
                                }
                            } else {
                                uiService.stackInstrution(changeHandlerInstruction);
                                uiService.stackInstrution(eventInstruction);
                                uiService.flushEvents();
                            }
                            preventOrStopEvent(event);
                        }
                    });
                } else {
                    widget.addDomHandler(new KeyUpHandler() {

                        @Override
                        public void onKeyUp(final KeyUpEvent event) {
                            final PTInstruction eventInstruction = buildEventInstruction(addHandler, domHandlerType);
                            eventInstruction.put(PROPERTY.VALUE, event.getNativeEvent().getKeyCode());

                            if (addHandler.containsKey(PROPERTY.KEY_FILTER)) {
                                final JSONArray jsonArray = addHandler.get(PROPERTY.KEY_FILTER).isArray();
                                for (int i = 0; i < jsonArray.size(); i++) {
                                    final JSONNumber keyCode = jsonArray.get(i).isNumber();
                                    if (keyCode.doubleValue() == event.getNativeEvent().getKeyCode()) {
                                        uiService.sendDataToServer(eventInstruction);
                                        uiService.flushEvents();
                                        break;
                                    }
                                }
                            } else {
                                uiService.sendDataToServer(eventInstruction);
                                uiService.flushEvents();
                            }
                            preventOrStopEvent(event);
                        }
                    }, KeyUpEvent.getType());
                }
                break;
            case DRAG_START:
                widget.getElement().setDraggable(Element.DRAGGABLE_TRUE);
                widget.addBitlessDomHandler(new DragStartHandler() {

                    @Override
                    public void onDragStart(final DragStartEvent event) {
                        event.setData("text", Long.toString(addHandler.getObjectID()));
                        event.getDataTransfer().setDragImage(uiObject.getElement(), 10, 10);
                        triggerDomEvent(addHandler, domHandlerType, uiService, event);
                    }
                }, DragStartEvent.getType());
                break;
            case DRAG_END:
                widget.addBitlessDomHandler(new DragEndHandler() {

                    @Override
                    public void onDragEnd(final DragEndEvent event) {
                        triggerDomEvent(addHandler, domHandlerType, uiService, event);
                    }
                }, DragEndEvent.getType());
                break;
            case DRAG_ENTER:
                widget.addBitlessDomHandler(new DragEnterHandler() {

                    @Override
                    public void onDragEnter(final DragEnterEvent event) {
                        triggerDomEvent(addHandler, domHandlerType, uiService, event);
                    }
                }, DragEnterEvent.getType());
                break;
            case DRAG_LEAVE:
                widget.addBitlessDomHandler(new DragLeaveHandler() {

                    @Override
                    public void onDragLeave(final DragLeaveEvent event) {
                        triggerDomEvent(addHandler, domHandlerType, uiService, event);
                    }
                }, DragLeaveEvent.getType());
                break;
            case DROP:
                widget.addBitlessDomHandler(new DragOverHandler() {

                    @Override
                    public void onDragOver(final DragOverEvent event) {
                        // required by GWT api
                        // triggerDomEvent(addHandler, domHandlerType, uiService);
                    }
                }, DragOverEvent.getType());

                widget.addBitlessDomHandler(new DropHandler() {

                    @Override
                    public void onDrop(final DropEvent event) {
                        event.preventDefault();
                        final String dragWidgetID = event.getData("text");
                        final PTInstruction eventInstruction = buildEventInstruction(addHandler, domHandlerType);
                        if (dragWidgetID != null) eventInstruction.put(PROPERTY.DRAG_SRC, Long.parseLong(dragWidgetID));
                        uiService.sendDataToServer(eventInstruction);
                    }
                }, DropEvent.getType());
                break;
            case CONTEXT_MENU:
View Full Code Here

TOP

Related Classes of com.ponysdk.ui.terminal.instruction.PTInstruction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.