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

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

Introduction

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

Prototype

public static int getClientWidth() 

Source Link

Usage

From source file:com.chinarewards.gwt.license.client.core.ui.impl.SimpleSiteManager.java

@Override
public void openDialog(final Dialog dialog, final DialogCloseListener handler) {
    // If the instanceId existing, return.
    if (openedDialogs.containsKey(dialog.getInstanceId())) {
        return;/*from   ww w .  ja v a  2 s. c  o  m*/
    }
    openedDialogs.put(dialog.getInstanceId(), dialog);
    openedDialogHandlers.put(dialog.getInstanceId(), handler);
    DialogBox dialogBox = new DialogBox();
    ScrollPanel panel = new ScrollPanel();
    panel.add(dialog.asWidget());
    dialogBox.setWidget(panel);
    dialogBox.setGlassEnabled(true);
    dialogBox.setAnimationEnabled(true);
    dialogBox.setText(dialog.getTitle());
    dialogBox.setDialog(dialog);
    // FIXME yanxin 20111130 dialogBox.setDialog(dialog);
    dialogBox.center();
    dialogBox.setPopupPosition(Window.getClientWidth() / 4, Window.getClientHeight() / 4);
    dialogBox.show();
    // Set max height for scroll panel. Deduction 30 PX for dialog title.
    // The window client should great than 30px, or it will not open dialog.
    int height = dialog.asWidget().getOffsetHeight();
    if (height > Window.getClientHeight()) {
        panel.setHeight(Window.getClientHeight() - 30 + "px");
    }
    openedDialogBoxes.put(dialog.getInstanceId(), dialogBox);
}

From source file:com.chinarewards.gwt.license.client.ui.DialogBox.java

/**
 * Creates an empty dialog box specifying its "auto-hide" property. It
 * should not be shown until its child widget has been added using
 * {@link #add(Widget)}.// w w w .j a  v  a 2s .c o m
 * 
 * @param autoHide
 *            <code>true</code> if the dialog should be automatically hidden
 *            when the user clicks outside of it
 * @param modal
 *            <code>true</code> if keyboard and mouse events for widgets not
 *            contained by the dialog should be ignored
 */
public DialogBox(boolean autoHide, boolean modal) {
    super(autoHide, modal);

    // Add the caption to the top row of the decorator panel. We need to
    // logically adopt the caption so we can catch mouse events.
    Element td = getCellElement(0, 1);
    HorizontalPanel panel = new HorizontalPanel();
    /**
     * About the icon to close the window.
     */

    //   <div class="close-wrap"><span class="box-title-sep"></span><span class="box-close" onclick="this.parentNode.parentNode.parentNode.style.display='none'"></span></div>

    cross = new Span();
    cross.setStyleName("box-close");
    CrossHandler crossHandler = new CrossHandler();
    cross.addClickHandler(crossHandler);
    cross.addMouseDownHandler(crossHandler);
    cross.addMouseOverHandler(crossHandler);
    cross.addMouseOutHandler(crossHandler);

    //      Label left = new Label("");
    //      left.setStyleName("left");
    //      Label right = new Label("");
    //      right.setStyleName("right");

    //      panel.add(left);
    panel.add(captionHtml);
    panel.add(cross);
    //      panel.add(right);
    //      panel.setCellWidth(left, "10px");
    //      panel.setCellHorizontalAlignment(left, HorizontalPanel.ALIGN_LEFT);
    panel.setCellHorizontalAlignment(captionHtml, HorizontalPanel.ALIGN_LEFT);
    panel.setCellHorizontalAlignment(cross, HorizontalPanel.ALIGN_RIGHT);
    //      panel.setCellHorizontalAlignment(right, HorizontalPanel.ALIGN_RIGHT);
    panel.setWidth("100%");

    caption.add(panel);
    DOM.appendChild(td, caption.getElement());
    adopt(caption);
    caption.setStyleName("Caption");

    // Set the style name
    setStyleName(DEFAULT_STYLENAME);

    windowWidth = Window.getClientWidth();
    clientLeft = Document.get().getBodyOffsetLeft();
    clientTop = Document.get().getBodyOffsetTop();

    MouseHandler mouseHandler = new MouseHandler();
    addDomHandler(mouseHandler, MouseDownEvent.getType());
    addDomHandler(mouseHandler, MouseUpEvent.getType());
    addDomHandler(mouseHandler, MouseMoveEvent.getType());
    addDomHandler(mouseHandler, MouseOverEvent.getType());
    addDomHandler(mouseHandler, MouseOutEvent.getType());
}

From source file:com.chinarewards.gwt.license.client.ui.MyDialogBox.java

/**
 * Creates an empty dialog box specifying its "auto-hide" property. It should
 * not be shown until its child widget has been added using
 * {@link #add(Widget)}.// ww w.  j a v a2s .com
 * 
 * @param autoHide <code>true</code> if the dialog should be automatically
 *          hidden when the user clicks outside of it
 * @param modal <code>true</code> if keyboard and mouse events for widgets not
 *          contained by the dialog should be ignored
 */
public MyDialogBox(boolean autoHide, boolean modal) {
    super(autoHide, modal);

    // Add the caption to the top row of the decorator panel. We need to
    // logically adopt the caption so we can catch mouse events.
    Element td = getCellElement(0, 1);
    DOM.appendChild(td, caption.getElement());
    adopt(caption);
    caption.setStyleName("Caption2");

    // Set the style name
    setStyleName(DEFAULT_STYLENAME);

    windowWidth = Window.getClientWidth();
    clientLeft = Document.get().getBodyOffsetLeft();
    clientTop = Document.get().getBodyOffsetTop();
}

From source file:com.claudiushauptmann.gwt.maps.gxt.client.MarkerGXTController.java

License:Apache License

/**
 * Updates the tip position. This method is called by its base class when
 * the mouse moves and the tip position has to be updated.
 */// w w w .  j ava 2  s  . c o m
@Override
protected void updateTipPosition() {
    if (currentTip != null) {
        int x = mapMenuController.getCurrentMousePosition().getX() + 20;
        int y = mapMenuController.getCurrentMousePosition().getY() + 20;

        int width = currentTip.getWidth();
        int height = currentTip.getHeight();

        if ((x + width) > Window.getClientWidth() + Window.getScrollLeft() - 10) {
            x = mapMenuController.getCurrentMousePosition().getX() - 20 - width;
        }
        if ((y + height) > Window.getClientHeight() + Window.getScrollTop() - 10) {
            y = mapMenuController.getCurrentMousePosition().getY() - 20 - height;
        }

        currentTip.setPosition(x, y);
    }
}

From source file:com.databasepreservation.visualization.shared.client.widgets.Toast.java

/**
 * Start showing popup//from   w ww . jav  a 2s .c  o m
 */
public void start() {
    setPopupPositionAndShow(new PositionCallback() {

        public void setPosition(int offsetWidth, int offsetHeight) {
            int slotOffset = 0;
            for (int i = 0; i < slotNumber; i++) {
                if (slots[i] != null) {
                    slotOffset += slots[i].getOffsetHeight() + PADDING;
                }
            }
            Toast.this.setPopupPosition(Window.getClientWidth() - offsetWidth - PADDING,
                    Window.getScrollTop() + PADDING + slotOffset);
        }

    });

    hideTimer.schedule(HIDE_DELAY_MS);

}

From source file:com.dimdim.conference.ui.common.client.util.DimdimPopupsLayoutManager.java

License:Open Source License

public void repositionPopups() {
    if (this.lastKnownWidth == 0) {
        this.lastKnownWidth = Window.getClientWidth();
    }/* w  w  w  . j  a  v a 2  s  . c  om*/
    if (this.lastKnownHeight == 0) {
        this.lastKnownHeight = Window.getClientHeight();
    }
    //   Setup the available slots arrangement.
    this.analyzeScreen();
    //   Now move the popups around.
    this.rearrangePopups();
}

From source file:com.dimdim.conference.ui.common.client.util.DmGlassPanel.java

License:Open Source License

public DmGlassPanel(ModalDialog modalDialog) {
    this.modalDialog = modalDialog;

    Label l = new Label(" ");
    add(basePanel);//w w  w. j  av a2s  . co m
    l.addClickListener(this);
    basePanel.add(scrollPanel);
    scrollPanel.add(l);

    basePanel.setSize(Window.getClientWidth() + "px", Window.getClientHeight() + "px");
    scrollPanel.setSize(Window.getClientWidth() + "px", Window.getClientHeight() + "px");
    basePanel.setStyleName("common-glass-panel");
    basePanel.setCellHorizontalAlignment(l, HorizontalPanel.ALIGN_CENTER);
    basePanel.setCellVerticalAlignment(l, VerticalPanel.ALIGN_MIDDLE);
    this.setPopupPosition(0, 0);
}

From source file:com.dimdim.conference.ui.common.client.util.DmGlassPanel2.java

License:Open Source License

public DmGlassPanel2(NonModalPopupPanel popup) {
    this.popup = popup;

    Label l = new Label(" ");
    add(basePanel);//from www. ja v a 2  s .c  om
    l.addClickListener(this);
    basePanel.add(scrollPanel);
    scrollPanel.add(l);

    basePanel.setSize(Window.getClientWidth() + "px", Window.getClientHeight() + "px");
    l.setSize(Window.getClientWidth() + "px", Window.getClientHeight() + "px");
    scrollPanel.setSize(Window.getClientWidth() + "px", Window.getClientHeight() + "px");
    basePanel.setStyleName("common-glass-panel-2");
    basePanel.setCellHorizontalAlignment(l, HorizontalPanel.ALIGN_CENTER);
    basePanel.setCellVerticalAlignment(l, VerticalPanel.ALIGN_MIDDLE);
    this.setPopupPosition(0, 0);
}

From source file:com.dimdim.conference.ui.layout.client.main.NewLayout.java

License:Open Source License

public void onModuleLoad() {
    this.originalWidth = Window.getClientWidth();
    this.minimumWidth = this.originalWidth;
    if (this.minimumWidth > 1024) {
        this.minimumWidth = 1024;
    }/* w  w  w  .j  a v  a  2 s . c  o m*/
    this.originalHeight = Window.getClientHeight();
    this.minimumHeight = this.originalHeight;
    if (this.minimumHeight > 768) {
        this.minimumHeight = 768;
    }
    ConferenceGlobals.setContentWidth(Window.getClientWidth());
    ConferenceGlobals.setContentHeight(Window.getClientHeight());

    ConferenceGlobals.conferenceKey = getConfKey();
    //      lmm = new LoadingModuleMessage("Loading.....");
    //RootPanel.get("MainConsole").add(lmm);
    //      lmm.setSize(Window.getClientWidth()+"px",Window.getClientHeight()+"px");
    UIDataDictionaryManager.initManager(getWebAppName(), getConfKey(), getUserType(),
            new String[] { "dictionary", "dictionary", "dictionary", "dictionary", "dictionary" },
            new String[] { "console", "console", "console", "global_string", "session_string" }, new String[] {
                    "ui_strings", "tooltips", "default_layout", "emoticons", "user_info" + getDataCacheId() });
    UIDataDictionaryManager.getManager().readDataDictionaries(this);
}

From source file:com.dimdim.conference.ui.layout.client.main.NewLayout.java

License:Open Source License

protected void loadConsole() {
    DebugPanel.getDebugPanel().addDebugMessage("Initializing Console");
    //   Now once the environment i initialized the client model can be
    //   created which depends on it.

    //      String getEventsURL = ConferenceGlobals.webappRoot+
    //         "GetEvents.action?sessionKey="+ConferenceGlobals.sessionKey;
    String getEventsURL = ConferenceGlobals.webappRoot + "GetEvents.action?sessionKey="
            + ConferenceGlobals.sessionKey;
    String serverPingURL = ConferenceGlobals.webappRoot + "PingServer.action";
    ClientModel.createClientModel();/*from   ww  w  .  j a v a2 s  .  c  om*/
    DebugPanel.getDebugPanel().addDebugMessage("Client model creation complete");

    Window.setMargin("0px");

    try {
        UIRosterEntry currentUser = ClientModel.getClientModel().getRosterModel().getCurrentUser();
        fullPanel = new ConsoleFullPanel(this, currentUser);
        //RootPanel.get("MainConsole").remove(this.lmm);
        //RootPanel.get("MainConsole").add(fullPanel);

        //RootPanel.get("MainConsole").add(fullPanel.getTopPanel())
        //this.meetingAssistent = new MeetingAssistentDialog(this.workspaceClickListener);
    } catch (Exception e) {
        Window.alert(e.getMessage());
    }
    DebugPanel.getDebugPanel().addDebugMessage("Fetching initial data");
    ClientModel.getClientModel().getClientStateModel().addListener(this.fullPanel.getMiddlePanel());
    ClientModel.getClientModel().getRosterModel()
            .addListener(this.fullPanel.getMiddlePanel().getRosterModelListener());

    UIParams uiParams = UIParams.getUIParams();
    EventsJsonHandler eventsHandler = EventsJsonHandler.getHandler();
    eventsHandler.setEventsTracker(DebugPanel.getDebugPanel());
    gerth = new GetEventResponseTextHandler(eventsHandler, uiParams.getRegularEventPollIntervalMillis(),
            uiParams.getMaxEventPollErrors());
    gerth.setServerPingURL(serverPingURL);
    eventsReadingTimer = new JSONurlReadingTimer(getEventsURL, getConfKey(),
            uiParams.getInitialEventPollDelayMillis(), gerth);
    gerth.setServerStatusListener(this.eventsReadingTimer);
    eventsReadingTimer.start();

    Window.addWindowResizeListener(this);
    DeferredCommand.add(new Command() {
        public void execute() {
            onWindowResized(Window.getClientWidth(), Window.getClientHeight());
            continueLoading();
        }
    });

    ClientModel.getClientModel().getRosterModel().reportConsoleLoaded();

    //      ConsoleDataReader dataReader = new ConsoleDataReader(this);
    //      dataReader.readConsoleData();
    DebugPanel.getDebugPanel().addDebugMessage("Console initialization complete.");
    showConsole();

    //      linking meeting assistant dialog listener
    meetingAssistent = new MeetingAssistentDialog(fullPanel.getMiddlePanel().getLeftPanel());
    fullPanel.getTopPanel().getLinksPanel().getAssistantLabel().addClickListener(this);
}