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.opencms.acacia.client.CmsEditorBase.java

License:Open Source License

/**
 * Initializes the edit overlay to be positioned around the given element.<p>
 *
 * @param element the element//  w  w  w .jav  a  2 s .  c  om
 */
protected void initEditOverlay(Element element) {

    CmsInlineEditOverlay.removeAll();
    m_editOverlay = CmsInlineEditOverlay.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;
            CmsInlineEditOverlay.updateCurrentOverlayPosition();
        }
    });
}

From source file:org.opencms.ade.editprovider.client.CmsDirectEditEntryPoint.java

License:Open Source License

/**
 * Initializes the direct edit buttons.<p>
 *//*from  ww  w .  j  a  v  a  2s  . c om*/
public void initializeButtons() {

    List<Element> editableElements = CmsDomUtil.getElementsByClass(CLASS_NAME);
    List<CmsDirectEditButtons> editables = Lists.newArrayList();

    for (Element elem : editableElements) {
        CmsPositionBean pos = CmsDomUtil.getEditablePosition(elem);
        m_positions.put(elem.getId(), pos);
    }

    CmsEditablePositionCalculator posCalc = new CmsEditablePositionCalculator(m_positions);
    m_buttonPositions = posCalc.calculatePositions();

    for (Element elem : editableElements) {
        CmsDirectEditButtons directEdit = processEditableElement(elem);
        m_directEditButtons.put(elem.getId(), directEdit);
        editables.add(directEdit);
    }
    Window.addResizeHandler(new ResizeHandler() {

        public void onResize(ResizeEvent event) {

            repositionButtons();
        }
    });
}

From source file:org.opencms.gwt.client.ui.CmsMenuButton.java

License:Open Source License

/**
 * Opens the menu and fires the on toggle event.<p>
 *///ww w .ja v  a  2 s  .c  o m
public void openMenu() {

    m_isOpen = true;
    m_button.setDown(true);

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

        public void onResize(ResizeEvent event) {

            positionPopup();
        }
    });
}

From source file:org.opencms.gwt.client.ui.CmsPopup.java

License:Open Source License

/**
 * @see com.google.gwt.user.client.ui.PopupPanel#center()
 */// w w  w .  j  a  v  a2 s . c om
@Override
public void center() {

    super.center();
    if (m_resizeHandlerRegistration == null) {
        m_resizeHandlerRegistration = Window.addResizeHandler(new ResizeHandler() {

            public void onResize(ResizeEvent event) {

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

From source file:org.opencms.gwt.client.ui.CmsPopup.java

License:Open Source License

/**
 * @see com.google.gwt.user.client.ui.PopupPanel#show()
 *//*from  w  ww. j a  va  2  s. c om*/
@Override
public void show() {

    super.show();
    if (m_useAnimation) {
        CmsFadeAnimation.fadeIn(getElement(), null, 500);
    }
    if (m_resizeHandlerRegistration == null) {
        m_resizeHandlerRegistration = Window.addResizeHandler(new ResizeHandler() {

            public void onResize(ResizeEvent event) {

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

From source file:org.opencms.gwt.client.ui.CmsToolbarContextButton.java

License:Open Source License

/**
 * Creates the menu and adds it to the panel.<p>
 * /* w ww .  jav a 2  s.  co  m*/
 * @param menuEntries the menu entries 
 */
public void showMenu(List<I_CmsContextMenuEntry> menuEntries) {

    if (!CmsCollectionUtil.isEmptyOrNull(menuEntries)) {
        // if there were entries found for the menu, create the menu
        m_menu = new CmsContextMenu(menuEntries, true, getPopup());
        // add the resize handler for the menu
        m_resizeRegistration = Window.addResizeHandler(m_menu);
        // set the menu as widget for the panel 
        m_menuPanel.setWidget(0, 0, m_menu);
        if (m_menuCloseHandler != null) {
            m_menuCloseHandler.removeHandler();
        }
        if (m_popupCloseHandler != null) {
            m_popupCloseHandler.removeHandler();
        }
        // add the close handler for the menu
        m_menuCloseHandler = getPopup().addCloseHandler(new CmsContextMenuHandler(m_menu));
        m_popupCloseHandler = getPopup().addCloseHandler(new CloseHandler<PopupPanel>() {

            public void onClose(CloseEvent<PopupPanel> event) {

                setActive(false);
            }
        });
        positionPopup();
    } else {
        if (m_noEntriesLabel.getParent() != null) {
            m_noEntriesLabel.removeFromParent();
        }
        m_noEntriesLabel.addStyleName(I_CmsLayoutBundle.INSTANCE.contextmenuCss().menuInfoLabel());
        m_noEntriesLabel.addStyleName(I_CmsLayoutBundle.INSTANCE.generalCss().buttonCornerAll());
        getPopup().add(m_noEntriesLabel);
        positionPopup();
    }
}

From source file:org.opencms.gwt.client.ui.contextmenu.CmsContextMenuButton.java

License:Open Source License

/**
 * Creates the menu and adds it to the panel.<p>
 *
 * @param menuEntries the menu entries//from w  w w.  ja  v a  2s .  c  o  m
 */
public void showMenu(List<I_CmsContextMenuEntry> menuEntries) {

    if (!CmsClientCollectionUtil.isEmptyOrNull(menuEntries)) {
        // if there were entries found for the menu, create the menu
        m_menu = new CmsContextMenu(menuEntries, true, getPopup());
        // add the resize handler for the menu
        m_resizeRegistration = Window.addResizeHandler(m_menu);
        // set the menu as widget for the panel
        m_menuPanel.setWidget(0, 0, m_menu);
        if (m_menuCloseHandler != null) {
            m_menuCloseHandler.removeHandler();
        }
        if (m_popupCloseHandler != null) {
            m_popupCloseHandler.removeHandler();
        }
        // add the close handler for the menu
        m_menuCloseHandler = getPopup().addCloseHandler(new CmsContextMenuCloseHandler(m_menu));
        m_popupCloseHandler = getPopup().addCloseHandler(new CloseHandler<PopupPanel>() {

            public void onClose(CloseEvent<PopupPanel> event) {

                closeMenu();
            }
        });
        m_popup.position();
    } else {
        m_menuPanel.setWidget(0, 0, m_noEntriesLabel);
        m_popup.position();
    }
}

From source file:org.opencms.ui.client.CmsBreadCrumbConnector.java

License:Open Source License

/**
 * @see com.vaadin.client.ui.AbstractComponentConnector#createWidget()
 *///from  w  w w  .  ja  v a  2 s .  c om
@Override
protected Widget createWidget() {

    HTML widget = new HTML() {

        private HandlerRegistration m_handlerReg;

        @Override
        protected void onAttach() {

            super.onAttach();
            m_handlerReg = Window.addResizeHandler(CmsBreadCrumbConnector.this);
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                public void execute() {

                    updateMaxWidth();
                }
            });
        }

        @Override
        protected void onDetach() {

            super.onDetach();
            m_handlerReg.removeHandler();
        }
    };
    widget.setStyleName(STYLE_NAME);
    return widget;
}

From source file:org.openelis.gwt.widget.ScreenWindow.java

License:Open Source License

public void init(Mode mode, boolean noBorder) {
    this.mode = mode;

    setWidget(outer);//  www .  j a  va2s . c o m
    setVisible(false);

    if (browser != null)
        zIndex = browser.index;

    if (!noBorder) {
        tlCorner.addStyleName("WindowTL");
        trCorner.addStyleName("WindowTR");
        blCorner.addStyleName("WindowBL");
        brCorner.addStyleName("WindowBR");
        leftSide.addStyleName("WindowLeft");
        rightSide.addStyleName("WindowRight");

        HorizontalPanel hp = new HorizontalPanel();
        hp.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
        titleButtonsContainer = new HorizontalPanel();
        titleButtonsContainer.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

        hp.setWidth("100%");
        titleButtonsContainer.addStyleName("Caption");
        titleButtonsContainer.setWidth("100%");

        cap.addMouseDownHandler(this);
        winLabel.setStyleName("ScreenWindowLabel");
        cap.add(winLabel);
        cap.setWidth("100%");
        cap.setHeight("100%");
        cap.setCellVerticalAlignment(winLabel, HasAlignment.ALIGN_MIDDLE);
        close.addClickHandler(this);
        close.setStyleName("CloseButton");
        collapse.addClickHandler(this);
        collapse.setStyleName("MinimizeButton");
        hp.add(tlCorner);
        titleButtonsContainer.add(cap);
        titleButtonsContainer.setCellWidth(cap, "100%");
        hp.add(titleButtonsContainer);
        hp.setCellWidth(titleButtonsContainer, "100%");

        if (mode == Mode.SCREEN || mode == Mode.LOOK_UP) {
            HorizontalPanel hp2 = new HorizontalPanel();
            hp2.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
            hp2.add(collapse);
            hp2.add(close);
            titleButtonsContainer.add(hp2);
            titleButtonsContainer.setCellHorizontalAlignment(hp2, HasAlignment.ALIGN_RIGHT);
            hp.setCellWidth(hp2, "32px");
            hp.setCellHorizontalAlignment(hp2, HasAlignment.ALIGN_RIGHT);
        }
        hp.add(trCorner);
        statusImg.addMouseOverHandler(this);
        statusImg.addMouseOutHandler(this);
        status.setStyleName("StatusBar");
        status.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

        status.add(statusImg);
        status.add(message);
        status.add(progressBar);
        progressBar.setVisible(false);
        status.setWidth("100%");

        status.setCellWidth(message, "100%");
        message.setStyleName("ScreenWindowLabel");
        outer.add(hp);

        bottomRow.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

        bottomRow.setWidth("100%");
        bottomRow.setSpacing(0);

        middleGrid.setCellPadding(0);
        middleGrid.setCellSpacing(0);
        middleGrid.getCellFormatter().addStyleName(0, 0, "WindowLeft");
        middleGrid.setWidget(0, 1, body);
        middleGrid.getCellFormatter().addStyleName(0, 2, "WindowRight");

        bottomRow.add(blCorner);
        bottomRow.add(status);
        bottomRow.add(brCorner);

        bottomRow.setCellWidth(status, "100%");

        body.addStyleName("WindowBody");

        outer.add(middleGrid);
        outer.add(bottomRow);
        outer.addStyleName("WindowPanel");
        outer.sinkEvents(Event.ONCLICK);
        outer.setWidth("auto");
    } else {
        outer.add(body);
        outer.addStyleName("WindowPanel");
        outer.sinkEvents(Event.ONCLICK);
        outer.setWidth("auto");
    }

    Window.addResizeHandler(this);
    if (browser != null) {
        browser.dragController.makeDraggable(this, cap);
        return;
    }
    if (mode == Mode.LOOK_UP || mode == Mode.DIALOG) {
        modalGlass = new AbsolutePanel();
        modalGlass.setStyleName("GlassPanel");
        modalGlass.setHeight(Window.getClientHeight() + "px");
        modalGlass.setWidth(Window.getClientWidth() + "px");

        RootPanel.get().add(modalGlass);
        RootPanel.get().setWidgetPosition(modalGlass, 0, 0);
        modalPanel = new AbsolutePanel();
        modalPanel.setStyleName("ModalPanel");
        modalPanel.setHeight(Window.getClientHeight() + "px");
        modalPanel.setWidth(Window.getClientWidth() + "px");
        modalPanel.add(this, position, position);
        RootPanel.get().add(modalPanel);
        RootPanel.get().setWidgetPosition(modalPanel, 0, 0);
        setVisible(true);
        dragController = new PickupDragController(modalPanel, true);
        dropController = new AbsolutePositionDropController(modalPanel);
        dragController.registerDropController(dropController);
        dragController.makeDraggable(this, cap);
        dragController.setBehaviorDragProxy(true);
    } else {
        RootPanel.get().add(this);
        RootPanel.get().setWidgetPosition(this, position, position);
        setVisible(true);
        dragController = new PickupDragController(RootPanel.get(), true);
        dropController = new AbsolutePositionDropController(RootPanel.get());
        dragController.registerDropController(dropController);
        dragController.makeDraggable(this, cap);
        dragController.setBehaviorDragProxy(true);
    }
}

From source file:org.openelis.gwt.widget.WindowBrowser.java

License:Open Source License

public void init(boolean size, int limit) {
    this.limit = limit;
    initWidget(browser);//from   ww  w .ja  v  a  2  s.  co m
    dragController.setBehaviorDragProxy(true);
    dragController.registerDropController(dropController);
    DOM.setStyleAttribute(browser.getElement(), "overflow", "auto");
    if (size) {
        Window.addResizeHandler(new ResizeHandler() {

            public void onResize(ResizeEvent event) {
                resize();

            }

        });
        DeferredCommand.addCommand(new Command() {
            public void execute() {
                resize();
            }
        });
    }
}