Example usage for com.google.gwt.user.client Window addResizeHandler

List of usage examples for com.google.gwt.user.client Window addResizeHandler

Introduction

In this page you can find the example usage for com.google.gwt.user.client Window addResizeHandler.

Prototype

public static HandlerRegistration addResizeHandler(ResizeHandler handler) 

Source Link

Usage

From source file:ch.unifr.pai.ice.client.ICEMain.java

License:Apache License

@Override
public void onModuleLoad() {

    if (DeviceType.getDeviceType() == DeviceType.MULTICURSOR) {

        /***************************************
         * Get the size of the browser window.
        ***************************************/
        MultiCursorController multiCursor = GWT.create(NoMultiCursorController.class);
        multiCursor.start();// ww w.j a  va  2 s. c om

        identifier = String.valueOf(new Date().getTime() / 1000);
        Window.alert("Start experiment: " + identifier);
        RootLayoutPanel.get().add(tabPanel);

        /*
         * tabPanel setup
         */

        //*****************Trainings***************************//
        //tabPanel.add(trainingCheckBoxes, "TA");
        //tabPanel.add(trainingtextEntrySepSpace1Users, "TB");  //tabPanel.add(trainingTextEntry1Space1User, "TB");
        //tabPanel.add(trainingDNdBoxes, "TC");
        //tabPanel.add(trainingLineTracking, "TD");

        //*****************Click Blobs***************************//
        //tabPanel.add(checkBoxes, "A"); 
        //tabPanel.add(checkB2u, "Click blobs 2 users"); 
        tabPanel.add(checkB4u, "Click blobs 4 users");

        //*****************Text Edit****************************//
        //tabPanel.add(textEntrySepSpace1Users, "B"); 
        //tabPanel.add(textEntrySepSpace2Users, "TE multi Space - 2 users");  
        tabPanel.add(textEntrySepSpace4Users, "TE multi Space - 4 users");

        ////******************D&D*********************************//
        //tabPanel.add(dNdBoxes, "C");
        //tabPanel.add(dNdBoxes2S, "D & D 2 spaces"); 
        tabPanel.add(dNdBoxes4S, "D & D 4 spaces");
        //tabPanel.add(dN4dropBoxes, "D & 4 D boxes"); 

        //tabPanel.add(textEntry1Space1User, "B");
        //tabPanel.add(textEntry1Space2Users, "TE 1 Space - 2 users"); 
        //tabPanel.add(textEntry1Space4Users, "TE 1 Space - 4 users");
        //tabPanel.add(lineTracking, "D");
        // tabPanel.add(lineTracking2users, "L tracking 2");
        // tabPanel.add(lineTracking4users, "L tracking 4");   

        tabPanel.selectTab(0);

        if (tabPanel.getWidget(0) instanceof RequireInitialisation) {
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                @Override
                public void execute() {
                    ((RequireInitialisation) tabPanel.getWidget(0)).initialise();
                }
            });
        }

        tabPanel.addSelectionHandler(new SelectionHandler<Integer>() {

            @Override
            public void onSelection(SelectionEvent event) {

                Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                    @Override
                    public void execute() {
                        ((RequireInitialisation) tabPanel.getWidget(tabPanel.getSelectedIndex())).initialise();
                    }
                });
            }
        });

        /*
         * re-position of the widgets on the resized window
         */
        Window.addResizeHandler(new ResizeHandler() {
            @Override
            public void onResize(ResizeEvent event) {

            }
        });

    }

    else {

        TouchPadWidget widget = GWT.create(TouchPadWidget.class);
        RootLayoutPanel.get().add(widget);
        //widget.initialize(UUID.get(), null, null);
        widget.start();
    }

}

From source file:ch.unifr.pai.twice.multipointer.client.ExtendedWebsocketControl.java

License:Apache License

@Override
public void start() {
    if (!isInIFrame()) {
        initializeCursorList();//from ww  w.j  a va 2 s.co m
        if (r != null)
            r.removeHandler();
        r = Window.addResizeHandler(this);
        UrlBuilder b = Window.Location.createUrlBuilder();
        b.setProtocol("ws");
        b.setPath("mouseControlXBrowser");
        b.setHash(null);
        String p = Window.Location.getPort();
        Integer port;
        try {
            port = p != null ? Integer.parseInt(p) : 8080;
        } catch (NumberFormatException e) {
            port = 8080;
        }
        b.setPort(port + 1);
        for (String param : Window.Location.getParameterMap().keySet()) {
            b.removeParameter(param);
        }
        websocket = createWebsocket(this, b.buildString());
        if (websocket != null)
            createOnBeforeUnloadHandler(websocket);
    }
}

From source file:ch.unifr.pai.twice.multipointer.provider.client.MultiCursorController.java

License:Apache License

@Override
public void start() {

    if (!isInIFrame()) {
        initializeCursorList();/*www.j av  a 2s  .c o  m*/
        if (r != null)
            r.removeHandler();
        r = Window.addResizeHandler(this);
        EventBus eventBus = CommunicationManager.getBidirectionalEventBus();
        currentRemoteEventHandlers
                .add(eventBus.addHandler(RemoteMouseMoveEvent.TYPE, new RemoteMouseMoveEvent.Handler() {

                    @Override
                    public void onEvent(RemoteMouseMoveEvent event) {
                        MouseCursor m = getOrCreateCursor(event.getOriginatingDevice());
                        if (m != null)
                            m.move(event);
                    }
                }));
        currentRemoteEventHandlers
                .add(eventBus.addHandler(RemoteMouseDownEvent.TYPE, new RemoteMouseDownEvent.Handler() {

                    @Override
                    public void onEvent(RemoteMouseDownEvent event) {
                        MouseCursor m = getOrCreateCursor(event.getOriginatingDevice());
                        if (m != null)
                            m.down(event);
                    }
                }));
        currentRemoteEventHandlers
                .add(eventBus.addHandler(RemoteMouseUpEvent.TYPE, new RemoteMouseUpEvent.Handler() {

                    @Override
                    public void onEvent(RemoteMouseUpEvent event) {
                        MouseCursor m = getOrCreateCursor(event.getOriginatingDevice());
                        if (m != null)
                            m.up(event);
                    }
                }));

        currentRemoteEventHandlers
                .add(eventBus.addHandler(RemoteKeyDownEvent.TYPE, new RemoteKeyDownEvent.Handler() {

                    @Override
                    public void onEvent(RemoteKeyDownEvent event) {
                        MouseCursor m = getOrCreateCursor(event.getOriginatingDevice());
                        if (m != null)
                            m.keyDown(event);
                    }
                }));

        currentRemoteEventHandlers
                .add(eventBus.addHandler(RemoteKeyUpEvent.TYPE, new RemoteKeyUpEvent.Handler() {
                    @Override
                    public void onEvent(RemoteKeyUpEvent event) {
                        MouseCursor m = getOrCreateCursor(event.getOriginatingDevice());
                        if (m != null)
                            m.keyUp(event);
                    }
                }));

        currentRemoteEventHandlers
                .add(eventBus.addHandler(RemoteKeyPressEvent.TYPE, new RemoteKeyPressEvent.Handler() {
                    @Override
                    public void onEvent(RemoteKeyPressEvent event) {
                        MouseCursor m = getOrCreateCursor(event.getOriginatingDevice());
                        if (m != null)
                            m.keyPress(event);
                    }
                }));

        MouseControllerServiceAsync svc = GWT.create(MouseControllerService.class);
        svc.registerAsMPProvider(UUID.get(), new AsyncCallback<Void>() {

            @Override
            public void onFailure(Throwable caught) {
                Window.alert("Not Registered");
                // TODO Auto-generated method stub

            }

            @Override
            public void onSuccess(Void result) {
                Window.alert("Registered");
                // ((ServerPushEventBus) CommunicationManager.getBidirectionalEventBus()).sendPingEvent();
            }
        });
    }
}

From source file:cl.uai.client.MarkingInterface.java

License:Open Source License

/**
 * Loads submission data using global submission id
 *///from www. j av  a  2  s  . c  om
public void loadSubmissionData() {

    // Checks that global submission id is valid
    if (MarkingInterface.draftId <= 0)
        return;

    addLoading(false);

    // Ajax requesto to submission data
    AjaxRequest.ajaxRequest("action=getsubmission", new AsyncCallback<AjaxData>() {

        @Override
        public void onFailure(Throwable caught) {
            logger.severe("Error getting submission from Moodle!");
            logger.severe(caught.getMessage());
            Window.alert(caught.getMessage());
            finishLoading();
        }

        @Override
        public void onSuccess(AjaxData result) {
            // Parse Json values
            Map<String, String> values = AjaxRequest.getValueFromResult(result);

            // Reset submission data
            submissionData = SubmissionGradeData.createFromConfiguration(values);

            if (submissionData != null) {
                EMarkingWeb.markingInterface.loadInterface();
            } else {
                Window.alert(MarkingInterface.messages.InvalidSubmissionData());
            }

            Window.setTitle(
                    "Emarking " + submissionData.getCoursename() + " " + submissionData.getActivityname());

            if (EMarkingConfiguration.isChatEnabled()) {
                activateChat();
            }

            finishLoading();

            Window.addResizeHandler(new ResizeHandler() {
                @Override
                public void onResize(ResizeEvent event) {
                    resizeTime = new Date();
                    if (!resizeTimeout) {
                        resizeTimeout = true;
                        resizeTimer.schedule(200);
                    }
                }
            });
        }
    });
}

From source file:co.fxl.gui.gwt.GWTDisplay.java

License:Open Source License

private GWTDisplay() {
    // GWTDisplayClientBundle.INSTANCE.css().ensureInjected();
    Display.instance(this);
    co.fxl.gui.style.impl.Style.instance();
    container = new GWTContainer<Widget>(this) {
        public void setComponent(Widget component) {
            widget = component;// w  w w  .j  a va2s.  co m
            widget.setWidth("100%");
            RootPanel.get().add(component, 0, 0);
        }
    };
    // TODO AOPC: Aspect Log.instance(new GWTLog());
    ToolbarImpl.ALLOW_ALIGN_END_FOR_FLOW_PANEL = !isSafari && !(isChrome && getBrowserVersion() <= 13);
    Window.addResizeHandler(new ResizeHandler() {
        @Override
        public void onResize(ResizeEvent event) {
            if (!scrolling) {
                RootPanel.get().setSize(width() + "px", height() + "px");
            }
            notifyResizeListeners();
        }
    });
    Log.instance().debug("User agent: " + Window.Navigator.getUserAgent());
    runtime = new RuntimeTemplate(getBrowserName(), getBrowserVersion());
    declareConstants();
    GWTFormat.setUp();
    // if (isChromeZoomActive()) {
    // Log.instance().debug(
    // "Zoom is active in Google Chrome: "
    // + Display.instance().width() + " inner-width vs "
    // + getOuterWidth() + " outer-width");
    // }
    StatusDisplay.FIX = new Fix() {

        @Override
        public void apply(IScrollPane p, boolean small) {
            ScrollPanel e = p.nativeElement();
            if (!small)
                e.getElement().getStyle().setOverflowX(Overflow.HIDDEN);
            else
                e.getElement().getStyle().setOverflowX(Overflow.AUTO);
        }
    };
    // if (Storage.isLocalStorageSupported()) {
    // register(new IServiceProvider<ILocalStorage>() {
    //
    // @Override
    // public Class<ILocalStorage> serviceType() {
    // return ILocalStorage.class;
    // }
    //
    // @Override
    // public ILocalStorage getService() {
    // return new GWTLocalStorage();
    // }
    // });
    // }
}

From source file:com.akanoo.client.views.CanvasView.java

License:Apache License

@Inject
public CanvasView(final Binder binder, Resources resources, Languages messages) {
    this.resources = resources;
    resources.canvasStyle().ensureInjected();

    this.messages = messages;

    representations = new ArrayList<CanvasView.NoteRepresentation>();

    widget = binder.createAndBindUi(this);

    scrollPanel.addAttachHandler(new AttachEvent.Handler() {

        @Override//from www.j  a  va  2 s . c o m
        public void onAttachOrDetach(AttachEvent event) {
            if (event.isAttached()) {
                updateCanvasSize();
            }
        }
    });

    Window.addResizeHandler(new ResizeHandler() {

        @Override
        public void onResize(ResizeEvent event) {
            updateCanvasSize();
        }
    });

    // create drag controller
    dragController = new PickupDragController(boundaryPanel, true);
    dragController.setBehaviorDragStartSensitivity(resources.canvasStyle().pixelSensitivity());
    dragController.setBehaviorBoundaryPanelDrop(false);

    dragController.addDragHandler(new DragHandlerAdapter() {
        @Override
        public void onDragStart(DragStartEvent event) {
            Widget note = event.getContext().draggable;
            startPosition = new Point(canvas.getWidgetLeft(note), canvas.getWidgetTop(note));

            GWT.log("Starting at: " + startPosition);

            ignoreClick = true;
        }
    });

    dropController = new AbsolutePositionDropController(canvas) {

        @Override
        public void onDrop(DragContext context) {
            super.onDrop(context);

            final Widget notePanel = context.draggable;

            Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                @Override
                public void execute() {
                    Point newPosition = new Point(canvas.getWidgetLeft(notePanel),
                            canvas.getWidgetTop(notePanel));

                    if (!newPosition.equals(startPosition)) {
                        GWT.log("Now got: " + newPosition);
                        Note note = findByNotePanel(notePanel).note;
                        getUiHandlers().moveNote(note, newPosition);
                    }

                    ignoreClick = false;

                }
            });
        }
    };

    dragController.registerDropController(dropController);

    canvasFocus.addFocusHandler(new FocusHandler() {

        @Override
        public void onFocus(FocusEvent event) {
            GWT.log("Canvas focussed!");

        }
    });

    canvasFocus.addMouseDownHandler(new MouseDownHandler() {

        @Override
        public void onMouseDown(MouseDownEvent event) {
            GWT.log("Canvas mouse down!");
            if (editing)
                ignoreNext = true;
        }
    });

    canvasFocus.addTouchStartHandler(new TouchStartHandler() {

        @Override
        public void onTouchStart(TouchStartEvent event) {
            GWT.log("Canvas touch down!");
            if (editing)
                ignoreNext = true;
        }
    });

    canvasFocus.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            canvasClick(event);
        }
    });
}

From source file:com.alkacon.acacia.client.EditorBase.java

License:Open Source License

/**
 * Initializes the edit overlay to be positioned around the given element.<p>
 * //from  w  w w  . ja va2 s.  c  o  m
 * @param element the element
 */
protected void initEditOverlay(Element element) {

    InlineEditOverlay.removeAll();
    m_editOverlay = InlineEditOverlay.addOverlayForElement(element);
    if (m_resizeHandlerRegistration != null) {
        m_resizeHandlerRegistration.removeHandler();
    }
    // add a handler to ensure the edit overlays get adjusted to changed window size
    m_resizeHandlerRegistration = Window.addResizeHandler(new ResizeHandler() {

        private Timer m_resizeTimer;

        public void onResize(ResizeEvent event) {

            if (m_resizeTimer == null) {
                m_resizeTimer = new Timer() {

                    @Override
                    public void run() {

                        handleResize();
                    }
                };
                m_resizeTimer.schedule(300);
            }
        }

        /**
         * Handles the window resize.<p>
         */
        void handleResize() {

            m_resizeTimer = null;
            InlineEditOverlay.updateCurrentOverlayPosition();
        }
    });
}

From source file:com.alkacon.geranium.client.ui.MenuButton.java

License:Open Source License

/**
 * Opens the menu and fires the on toggle event.<p>
 *//*  www.j  a  va  2 s. c o m*/
public void openMenu() {

    m_isOpen = true;
    setButtonDown();

    m_popup.show();
    m_popup.position();
    m_resizeRegistration = Window.addResizeHandler(new ResizeHandler() {

        public void onResize(ResizeEvent event) {

            m_popup.position();
        }
    });
}

From source file:com.alkacon.geranium.client.ui.Popup.java

License:Open Source License

/**
 * @see com.google.gwt.user.client.ui.PopupPanel#center()
 *//*from   ww w . ja  va2  s  .  co  m*/
@Override
public void center() {

    if (Position.FIXED.getCssName().equals(getElement().getStyle().getPosition())) {
        show();
        // keep position fixed, as may have been set to absolute
        setPositionFixed();
        int left = (Window.getClientWidth() - getOffsetWidth()) >> 1;
        int top = (Window.getClientHeight() - getOffsetHeight()) >> 1;
        setPopupPosition(Math.max(left, 0), Math.max(top, 0));
    } else {
        super.center();
        if (m_resizeHandlerRegistration == null) {
            m_resizeHandlerRegistration = Window.addResizeHandler(new ResizeHandler() {

                public void onResize(ResizeEvent event) {

                    m_windowWidth = event.getWidth();
                }
            });
        }
    }
}

From source file:com.alkacon.geranium.client.ui.Popup.java

License:Open Source License

/**
 * @see com.google.gwt.user.client.ui.PopupPanel#show()
 */// www.  j a v  a 2  s.  c o  m
@Override
public void show() {

    boolean fixed = Position.FIXED.getCssName().equals(getElement().getStyle().getPosition());
    super.show();
    if (fixed) {
        // keep position fixed as it may have been set to absolute
        setPositionFixed();
    }
    if (m_useAnimation) {
        FadeAnimation.fadeIn(getElement(), null, 500);
    }
    if (m_resizeHandlerRegistration == null) {
        m_resizeHandlerRegistration = Window.addResizeHandler(new ResizeHandler() {

            public void onResize(ResizeEvent event) {

                m_windowWidth = event.getWidth();
            }
        });
    }
}