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:org.opennms.features.topology.app.internal.gwt.client.VSearchBox.java

License:Open Source License

@Override
public void onLoad() {
    m_componentHolder.clear();/*from  w  w w.  j  av a 2  s  .  co  m*/
    this.setStyleName("topology-search");
    final TextBoxBase textField = new TextBox();
    textField.setWidth("245px");
    textField.setStyleName("topology-search-box");
    textField.getElement().setAttribute("placeholder", "Search...");
    textField.setFocus(true);
    RemoteSuggestOracle oracle = new RemoteSuggestOracle();

    m_suggestBox = new SuggestBox(oracle, textField);

    m_suggestBox.addSelectionHandler(new SelectionHandler<SuggestOracle.Suggestion>() {
        @Override
        public void onSelection(SelectionEvent<SuggestOracle.Suggestion> event) {
            SearchSuggestion selectedItem = (SearchSuggestion) event.getSelectedItem();
            textField.setText("");
            m_connector.addToFocus(selectedItem);
        }
    });

    if (m_isMultiValued) {
        m_suggestBox.setStyleName("multivalue");
    }

    m_suggestBox.addStyleName("wideTextField");
    m_suggestBox.addSelectionHandler(this);
    m_suggestBox.addKeyUpHandler(this);

    m_componentHolder.setWidth("245px");
    m_componentHolder.add(m_suggestBox);

    if (m_focusedContainer == null) {
        m_focusedContainer = new VerticalPanel();
        m_scrollContainer = new FlowPanel();
        m_scrollContainer.add(m_focusedContainer);

    }

    m_focusedContainer.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    m_focusedContainer.setTitle("Focused Vertices");
    m_componentHolder.add(m_scrollContainer);

    Timer timer = new Timer() {

        @Override
        public void run() {
            updateScrollPanelSize();
        }
    };

    timer.schedule(1000);

    m_windowResizeRegistration = Window.addResizeHandler(new ResizeHandler() {
        @Override
        public void onResize(ResizeEvent event) {
            updateScrollPanelSize();
        }
    });

}

From source file:org.openremote.app.client.widget.AbstractAppPanel.java

License:Open Source License

public AbstractAppPanel(UiBinder<PopupPanel, AbstractAppPanel> binder) {
    this.popupPanel = binder.createAndBindUi(this);

    popupPanel.getElement().getStyle().setOverflow(Style.Overflow.AUTO);

    popupPanel.setGlassStyleName("or-PopupPanelGlass");

    popupPanel.addAttachHandler(event -> {
        if (event.isAttached()) {
            windowHandlerRegistration = Window.addResizeHandler(e -> {
                if (isOpen()) {
                    open();//  w ww.j  a v  a  2  s.  c  o  m
                }
            });
            if (openCloseConsumer != null) {
                openCloseConsumer.accept(true);
            }
        } else if (windowHandlerRegistration != null) {
            windowHandlerRegistration.removeHandler();
            windowHandlerRegistration = null;
        }
    });

    popupPanel.addCloseHandler(event -> {
        if (openCloseConsumer != null) {
            openCloseConsumer.accept(false);
        }
        if (target != null) {
            popupPanel.removeAutoHidePartner(target.getElement());
        }
    });

}

From source file:org.openremote.client.shell.floweditor.FlowEditorPresenter.java

License:Open Source License

public FlowEditorPresenter(View view) {
    super(view);// ww w  .j  av a2  s .  co  m

    Window.addResizeHandler(event -> onContainerResize());

    addListener(FlowEditEvent.class, event -> {
        flow = event.getFlow();
        notifyPath("flow");
        startFlowDesigner();
    });

    addListener(FlowDeletedEvent.class, event -> {
        if (event.matches(flow)) {
            flow = null;
            notifyPathNull("flow");
            stopFlowDesigner();
        }
    });

    addListener(NodeSelectedEvent.class, event -> {
        if (flowDesigner != null && flow != null) {
            Node node = flow.findNode(event.getNodeId());
            if (node != null) {
                flowDesigner.selectNodeShape(node);
            }
        }
    });

    addListener(NodeAddedEvent.class, event -> {
        if (flowDesigner != null && event.matches(flow)) {
            Node node = event.getNode();

            if (event.isTransformPosition()) {
                // Correct the position so it feels like you are dropping in the middle of the patch header
                double correctedX = Math.max(0,
                        event.getPositionX() - FlowDesignerConstants.PATCH_MIN_WIDTH / 2);
                double correctedY = Math.max(0, event.getPositionY()
                        - (PATCH_LABEL_FONT_SIZE + PATCH_TITLE_FONT_SIZE + PATCH_PADDING * 2) / 2);

                // Calculate the offset with the current transform (zoom, panning)
                // TODO If I would know maths, I could probably do this with the transform matrices
                Transform currentTransform = flowDesignerPanel.getViewport().getAbsoluteTransform();
                double x = (correctedX - currentTransform.getTranslateX())
                        * currentTransform.getInverse().getScaleX();
                double y = (correctedY - currentTransform.getTranslateY())
                        * currentTransform.getInverse().getScaleY();
                node.getEditorSettings().setPositionX(x);
                node.getEditorSettings().setPositionY(y);
            }

            LOG.debug("Adding node shape to flow designer: " + node);
            flowDesigner.addNodeShape(node);

            dispatch(new NodeSelectedEvent(node.getId()));
        }
    });

    addListener(NodeDeletedEvent.class, event -> {
        if (flowDesigner != null && event.matches(flow)) {
            Node node = event.getNode();
            LOG.debug("Removing node shape from flow designer: " + node);
            flowDesigner.deleteNodeShape(node);
        }
    });

    addListener(NodeModifiedEvent.class, event -> {
        if (flowDesigner != null && event.matches(flow)) {
            flowDesigner.updateNodeShape(event.getNode());
        }
    });

    addListener(MessageReceivedEvent.class, event -> {
        Message message = event.getMessage();
        if (flowDesigner != null && flow != null && flow.findSlot(message.getSlotId()) != null) {
            flowDesigner.handleMessage(message);
        }
    });

    addListener(MessageSendEvent.class, event -> {
        Message message = event.getMessage();
        if (flowDesigner != null && flow != null && flow.findSlot(message.getSlotId()) != null) {
            flowDesigner.handleMessage(message);
        }
    });
}

From source file:org.openremote.manager.client.widget.AbstractAppPanel.java

License:Open Source License

public AbstractAppPanel(UiBinder<PopupPanel, AbstractAppPanel> binder) {
    this.popupPanel = binder.createAndBindUi(this);
    popupPanel.setAutoHideOnHistoryEventsEnabled(true);

    popupPanel.setGlassStyleName("or-PopupPanelGlass");

    popupPanel.addCloseHandler(event -> {
        if (target != null) {
            popupPanel.removeAutoHidePartner(target.getElement());
            target = null;//ww w . j  a  v a 2  s  .co m
        }
    });

    Window.addResizeHandler(event -> {
        if (isShowing()) {
            if (target != null) {
                popupPanel.showRelativeTo(target);
            } else if (bottomRightTarget != null) {
                showBottomRightOf(bottomRightTarget, marginRight, marginBottom);
            } else if (topLeftTarget != null) {
                showTopLeftOf(topLeftTarget, marginTop, marginLeft);
            }
        }
    });
}

From source file:org.openremote.web.console.util.BrowserUtils.java

License:Open Source License

public static void initWindow() {
    //         consoleContainer = new AbsolutePanel();
    //         consoleContainer.setWidth("3000px");
    //         consoleContainer.setHeight("3000px");
    //         RootPanel.get().add(consoleContainer, 0, 0);
    //         //consoleContainer.getElement().getStyle().setPosition(Position.FIXED);
    updateWindowInfo();/*from ww  w . j a  v  a 2  s  .c om*/

    if (isMobile) {
        initMobile();
    } else {
        // Prevent scrollbars from being shown
        Window.enableScrolling(false);
    }

    // Add window resize handler
    Window.addResizeHandler(new ResizeHandler() {
        @Override
        public void onResize(ResizeEvent event) {
            doResizeAndRotate();
        }
    });
}

From source file:org.openstreetmap.beboj.client.Beboj.java

License:GNU General Public License

/**
 * Entry point method.//from www  .ja v a  2  s  .  c  o  m
 */
@Override
public void onModuleLoad() {

    Main.platformFactory = new BebojPlatformFactory();
    Main.main = new Main();
    Main.pref = new Preferences();
    Main.proj = new Mercator();
    Main.main.undoRedo = new UndoRedoHandler();

    MainUI ui = new MainUI();
    ui.getElement().setId("content-inner");

    canv = ui.canv;
    canvasView = ui.canvView;
    mapview = ui.mapview_div;
    Main.map = new MapFrame(canvasView);
    canvasView.setPresenter(Main.map.mapView);

    ui.setMapModesController(Main.map);

    final DiscreteZoomNavigationSupport nav = (DiscreteZoomNavigationSupport) Main.map.mapView.nav;
    nav.zoomTo(new LatLon(51.1254062, 1.3148010));
    nav.setZoom(16);

    Main.main.addLayer(new OsmDataLayer(new DataSet(), OsmDataLayer.createNewName(), null));

    Main.map.mapView.nav.addZoomChangeListener(new ZoomChangeListener() {
        @Override
        public void zoomChanged() {
            syncOLMap();
            debug("zoom", nav.getZoom() + "");
        }
    });

    configureDebugElements();

    RootPanel.get("content").add(ui);

    ui.leftButtons.buttons[0].onClick();
    ui.leftButtons.buttons[0].setDown(true);

    updateCanvasSize();
    Window.addResizeHandler(new ResizeHandler() {
        @Override
        public void onResize(ResizeEvent event) {
            updateCanvasSize();
            log("R");
            canvasView.repaint();
        }
    });
}

From source file:org.openxdata.designer.client.FormDesignerEntryPoint.java

/**
 * Sets up the form designer.//from w  ww.  ja va 2  s  .  co m
 */
public void onModuleLoadDeffered() {

    try {
        RootPanel rootPanel = RootPanel.get("formtoolsdesigner");
        if (rootPanel == null) {
            FormUtil.dlg.hide();
            return;
        }

        FormUtil.setupUncaughtExceptionHandler();

        FormDesignerUtil.setDesignerTitle();

        String s = FormUtil.getDivValue("allowBindEdit");
        if (s != null && (s.equals("0") || s.equals("false")))
            Context.setAllowBindEdit(false);

        FormUtil.retrieveUserDivParameters();

        Context.setOfflineModeStatus();

        // Get rid of scrollbars, and clear out the window's built-in margin,
        // because we want to take advantage of the entire client area.
        Window.enableScrolling(false);
        Window.setMargin("0" + OpenXdataConstants.UNITS);

        // Different themes use different background colors for the body
        // element, but IE only changes the background of the visible content
        // on the page instead of changing the background color of the entire
        // page. By changing the display style on the body element, we force
        // IE to redraw the background correctly.
        RootPanel.getBodyElement().getStyle().setProperty("display", "none");
        RootPanel.getBodyElement().getStyle().setProperty("display", "");

        loadLocales();

        designer = new FormDesignerWidget(true, true, true);

        // Finally, add the designer widget to the RootPanel, so that it will be displayed.
        rootPanel.add(designer);

        updateTabs();

        //If a form id has been specified in the html host page, load the form
        //with that id in the designer.
        s = FormUtil.getFormId();
        if (s != null)
            designer.loadForm(Integer.parseInt(s));

        // Call the window resized handler to get the initial sizes setup. Doing
        // this in a deferred command causes it to occur after all widgets' sizes
        // have been computed by the browser.
        Scheduler.get().scheduleDeferred(new ScheduledCommand() {
            public void execute() {
                designer.onWindowResized(Window.getClientWidth(), Window.getClientHeight());

                String id = FormUtil.getFormId();
                if (id == null || id.equals("-1"))
                    FormUtil.dlg.hide();
            }
        });

        // Hook the window resize event, so that we can adjust the UI.
        Window.addResizeHandler(this);
    } catch (Exception ex) {
        FormUtil.displayException(ex);
    }
}

From source file:org.openxdata.querybuilder.client.view.QueryBuilderView.java

public QueryBuilderView() {

    txtXform.setWidth("100%");
    txtXform.setHeight("100%");
    tabs.setWidth("100%");
    tabs.setHeight("100%");

    tabs.add(txtXform, "XForms Source");
    tabs.add(filterConditionsView, "Filter Conditions");
    tabs.add(displayFieldsView, "Display Fields");
    tabs.add(txtDefXml, "Definition XML");
    tabs.add(txtSql, "SQL");

    tabs.addSelectionHandler(this);
    initWidget(tabs);/*from   w  w w  . jav  a 2s.  co m*/

    tabs.selectTab(1);

    Window.addResizeHandler(this);

    //      This is needed for IE
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {
        public void execute() {
            onWindowResized(Window.getClientWidth(), Window.getClientHeight());
        }
    });

    txtXform.addChangeHandler(new ChangeHandler() {
        public void onChange(ChangeEvent event) {
            parseXform();
        }
    });

    txtDefXml.addChangeHandler(new ChangeHandler() {
        public void onChange(ChangeEvent event) {
            parseQueryDef();
        }
    });

    //txtXform.setText(FormUtil.formatXml(getTestXform()));
    //parseXform();

    //txtDefXml.setText(getTestQueryDef());
    //parseQueryDef();
}

From source file:org.otalo.ao.client.Messages.java

License:Apache License

public void loadRest() {

    topPanel = new TopPanel(line, moderator, images);
    topPanel.setWidth("100%");

    fora = new Fora(images);
    messageList = new MessageList(images);
    messageList.setWidth("100%");

    // Create the right panel, containing the email list & details.
    rightPanel.add(messageList);//  w  w  w  . j av  a  2 s  . c om
    if (!canManage()) {
        searchResultMsgList = new SearchResultMsgList();
        searchResultMsgList.setWidth("100%");
        searchResultMsgList.setVisible(false);
        rightPanel.add(searchResultMsgList);
    }

    if (line.bcastingAllowed()) {
        broadcastIface = new BroadcastInterface(images);
        bcasts = new Broadcasts(images);
        rightPanel.add(broadcastIface);
    }
    if (line.hasSMSConfig()) {
        smsList = new SMSList(images);
        smsList.setWidth("100%");
        smsIface = new SMSInterface(images);
        smss = new SMSs(images);
        rightPanel.add(smsIface);
        rightPanel.add(smsList);
    }

    shortcuts = new Shortcuts(images, fora, bcasts, smss, search);
    shortcuts.setWidth("100%");
    rightPanel.setWidth("100%");

    if (canManage()) {
        groupsIface = new ManageGroups(images);
        rightPanel.add(groupsIface);

        //showing help if its stream
        String helpHtmlStr = "<div id='help_tab' class='help-tab-right'>"
                + "<a href='http://awaaz.de/blog/2013/09/awaaz-de-streams-start-up-guide-and-glossary/' target=_blank  id='help-link'>"
                + "<span>H</span>" + "<span>E</span>" + "<span>L</span>" + "<span>P</span></a></div>";
        HTML helpHtml = new HTML(helpHtmlStr);
        RootPanel.get().add(helpHtml);
    } else {
        messageDetail = new MessageDetail();
        messageDetail.setWidth("100%");
        rightPanel.add(messageDetail);

        search = new SearchFilterPanel(searchResultMsgList);
        searchShortCut = new Shortcuts(images, null, null, null, search);
        searchShortCut.setWidth("100%");
        searchShortCut.setVisible(false);
    }

    displayForumPanel();

    // creating a loader
    loaderImage = new HTML(AbstractImagePrototype.create(images.loader()).getHTML());
    loaderImage.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    loaderImage.addStyleName("loader-img");
    showLoader(false);

    rightPanel.add(loaderImage);

    // Create a dock panel that will contain the menu bar at the top,
    // the shortcuts to the left, and the mail list & details taking the rest.
    DockPanel outer = new DockPanel();
    //DockLayoutPanel outer = new DockLayoutPanel(Unit.PCT);

    outer.add(topPanel, DockPanel.NORTH);
    outer.add(shortcuts, DockPanel.WEST);
    if (!canManage()) {
        if (searchShortCut.isVisible())
            searchShortCut.setVisible(false);
        outer.add(searchShortCut, DockPanel.WEST);
    }

    //outer.addWest(shortcuts, 100);
    outer.add(rightPanel, DockPanel.CENTER);
    //outer.add(rightPanel);
    outer.setWidth("100%");

    outer.setSpacing(4);
    outer.setCellWidth(rightPanel, "100%");

    // Hook the window resize event, so that we can adjust the UI.
    Window.addResizeHandler(this);

    // Get rid of scrollbars, and clear out the window's built-in margin,
    // because we want to take advantage of the entire client area.
    //Window.enableScrolling(false);
    Window.setMargin("0px");

    // Finally, add the outer panel to the RootPanel, so that it will be
    // displayed.
    RootPanel.get().add(outer);

    // Call the window resized handler to get the initial sizes setup. Doing
    // this in a deferred command causes it to occur after all widgets' sizes
    // have been computed by the browser.
    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
        public void execute() {
            onWindowResized(Window.getClientWidth(), Window.getClientHeight());

        }
    });

    onWindowResized(Window.getClientWidth(), Window.getClientHeight());
}

From source file:org.palaso.languageforge.client.lex.controls.ResizableWidgetCollection.java

License:Apache License

/**
 * Set whether or not resize checking is enabled. If disabled, elements will
 * still be resized on window events, but the timer will not check their
 * dimensions periodically.//from   w ww  .  j a va 2s  .  c  o  m
 * 
 * @param enabled
 *            true to enable the resize checking timer
 */
public void setResizeCheckingEnabled(boolean enabled) {
    if (enabled && !resizeCheckingEnabled) {
        resizeCheckingEnabled = true;
        if (windowHandler == null) {
            windowHandler = Window.addResizeHandler(new ResizeHandler() {
                public void onResize(ResizeEvent event) {
                    checkWidgetSize();
                }
            });
        }
        resizeCheckTimer.schedule(resizeCheckDelay);
    } else if (!enabled && resizeCheckingEnabled) {
        resizeCheckingEnabled = false;
        if (windowHandler != null) {
            windowHandler.removeHandler();
            windowHandler = null;
        }
        resizeCheckTimer.cancel();
    }
}