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:org.bonitasoft.console.client.view.labels.LabelStyleSelectorWidget.java

License:Open Source License

/**
 * /*from www  .j  a v  a  2  s. c  om*/
 * Default constructor.
 * 
 * @param aLabelDataSource
 * @param aLabelModel
 */
public LabelStyleSelectorWidget(final LabelDataSource aLabelDataSource, final LabelModel aLabelModel) {
    super();
    myLabelDataSource = aLabelDataSource;
    myLabelModel = aLabelModel;
    myErrorMessage = new Label();
    myErrorMessage.setStylePrimaryName(CSSClassManager.VALIDATION_ERROR_MESSAGE);
    myCreateDialogBox = createDialogBox();
    FlexTable theOuterPanel = new FlexTable();
    Label theLabel;
    DecoratorPanel theContainer;
    theLabel = new Label(TITLE_LABEL_KEY);
    theOuterPanel.setWidget(0, 0, theLabel);
    theOuterPanel.getFlexCellFormatter().setColSpan(0, 0, 4);
    //

    if (editableCSSClassName.length != readonlyCSSClassName.length
            || editableCSSClassName.length != previewCSSClassName.length) {
        Window.alert("Invalid list of CSS style definitions in class LabelStyleSelectorWidget!");
    }

    int theRow = 1;
    int theCol = 0;
    for (int i = 0; i < editableCSSClassName.length; i++) {
        theContainer = new DecoratorPanel();
        theLabel = new Label(B_CHARACTER);
        theContainer.add(theLabel);
        theContainer.setStylePrimaryName(previewCSSClassName[i] + CONTAINER_CSS_SUFFIX);
        theLabel.setStyleName(previewCSSClassName[i]);
        theLabel.addClickHandler(new StyleClickHandler(aLabelModel, editableCSSClassName[i],
                previewCSSClassName[i], readonlyCSSClassName[i]));
        theOuterPanel.setWidget(theRow, theCol, theContainer);
        // Go to a new line every 4 choices.
        if (theCol == 3) {
            theRow++;
            theCol = 0;
        } else {
            theCol++;
        }
    }

    // Add a separator.
    theRow++;
    theOuterPanel.setHTML(theRow, 0, "<HR>");
    theOuterPanel.getFlexCellFormatter().setColSpan(theRow, 0, 4);

    // Add a menu.
    theRow++;
    Label theRenameLink = new Label(constants.renameLabel());
    theRenameLink.setStylePrimaryName(CSSClassManager.LINK_LABEL);
    theOuterPanel.setWidget(theRow, 0, theRenameLink);
    theOuterPanel.getFlexCellFormatter().setColSpan(theRow, 0, 4);

    theRenameLink.addClickHandler(new ClickHandler() {
        /*
         * (non-Javadoc)
         * 
         * @see com.google.gwt.event.dom.client.ClickHandler#onClick(com.google .gwt.event.dom.client.ClickEvent)
         */
        public void onClick(final ClickEvent aClickEvent) {
            myCreateDialogBox.setPopupPositionAndShow(new PopupPanel.PositionCallback() {
                public void setPosition(int anOffsetWidth, int anOffsetHeight) {
                    int left = ((Window.getClientWidth() / 2) - (anOffsetWidth / 2));
                    int top = aClickEvent.getNativeEvent().getClientY() - (anOffsetHeight / 2);
                    myCreateDialogBox.setPopupPosition(left, top);
                }
            });
            myNewLabelName.setText(myLabelModel.getUUID().getValue());
            myNewLabelName.setFocus(true);
            LabelStyleSelectorWidget.this.hide();
        }
    });

    this.add(theOuterPanel);
    // Set the auto hide feature.
    setAutoHideEnabled(true);
}

From source file:org.bonitasoft.console.client.view.labels.MoreLabelAndCategoryListWidget.java

License:Open Source License

public MoreLabelAndCategoryListWidget(LabelDataSource aLabelDataSource,
        CategoryDataSource aCategoryDataSource) {
    super();//from w w w  . j  a  v a2 s.c om
    myLabelDataSource = aLabelDataSource;
    myCategoryDataSource = aCategoryDataSource;
    // Listen to changes in the list of system label.
    myLabelDataSource.addModelChangeListener(LabelDataSource.SYSTEM_LABEL_LIST_PROPERTY, this);
    myLabelDataSource.addModelChangeListener(LabelDataSource.USER_LABEL_LIST_PROPERTY, this);
    myLabelDataSource.addModelChangeListener(LabelDataSource.CONFIGURATION_PROPERTY, this);
    myCategoryDataSource.addModelChangeListener(CategoryDataSource.VISIBLE_CATEGORIES_LIST_PROPERTY, this);
    myCategoryDataSource.addModelChangeListener(CategoryDataSource.ITEM_CREATED_PROPERTY, this);
    myCategoryDataSource.addModelChangeListener(CategoryDataSource.ITEM_DELETED_PROPERTY, this);

    myOuterPanel.setOpen(false);

    myNewLabelLink.setStylePrimaryName(CSSClassManager.LINK_LABEL);
    myNewLabelLink.addClickHandler(new ClickHandler() {
        /*
         * (non-Javadoc)
         * 
         * @see com.google.gwt.event.dom.client.ClickHandler#onClick(com.google
         * .gwt.event.dom.client.ClickEvent)
         */
        public void onClick(final ClickEvent aClickEvent) {
            myCreateDialogBox.setPopupPositionAndShow(new PopupPanel.PositionCallback() {
                public void setPosition(int anOffsetWidth, int anOffsetHeight) {
                    int left = ((Window.getClientWidth() / 2) - (anOffsetWidth / 2));
                    int top = aClickEvent.getNativeEvent().getClientY() - (anOffsetHeight / 2);
                    myCreateDialogBox.setPopupPosition(left, top);
                }
            });
            myNewLabelName.setFocus(true);
        }
    });

    myManageLabelsLink.setStylePrimaryName(CSSClassManager.LINK_LABEL);

    myOuterPanel.add(myContentPanel);
    myOuterPanel.setStylePrimaryName("label_list_more_menu");

    this.initWidget(myOuterPanel);
    buildLabelWidgetsMaps();

    myLabelDataSource.getConfiguration(new AsyncHandler<LabelsConfiguration>() {

        public void handleFailure(Throwable aT) {
            update();
        }

        public void handleSuccess(LabelsConfiguration aResult) {
            myConfiguration = new LabelsConfiguration();
            myConfiguration.setCustomLabelsEnabled(aResult.isCustomLabelsEnabled());
            myConfiguration.setStarEnabled(aResult.isStarEnabled());
            update();
        }
    });

}

From source file:org.bonitasoft.console.client.view.steps.StepActionWidget.java

License:Open Source License

protected void showAssignToManyPopup() {
    final Set<UserUUID> theBunchOfCandidates = myStep.getAssign();

    myCandidates.clear();/* w w  w.  j  a  v a2 s . c o m*/

    for (UserUUID theUUID : theBunchOfCandidates) {
        myCandidates.addItem(theUUID.getValue());
    }

    // If the userdatasource is empty try to reload data to get completion
    // feature available.
    if (myUserDataSource.getSize() == 0) {
        myUserDataSource.reload();
    }

    myAssignToManyPopup.setPopupPositionAndShow(new PopupPanel.PositionCallback() {
        public void setPosition(int anOffsetWidth, int anOffsetHeight) {
            int left = ((Window.getClientWidth() / 2) - (anOffsetWidth / 2));
            int top = myMenuBar.getAbsoluteTop();
            myAssignToManyPopup.setPopupPosition(left, top);
        }
    });
}

From source file:org.cleanlogic.cesiumjs4gwt.showcase.basic.ShowSourceButton.java

License:Apache License

protected void showSourceCode(String sourceCode) {
    sourceCode = sourceCode.replaceAll("<", "&lt,").replace(">", "&gt;");

    final String html = "<pre class=\"brush: java; toolbar: false;\">" + sourceCode + "</pre>";
    ScrollPanel sp = new ScrollPanel();
    sp.setSize((Window.getClientWidth() * 0.6) + "px", (Window.getClientHeight() * 0.7) + "px");
    sp.add(new HTML(html));

    DialogBoxWithCloseButton dialogBox = new DialogBoxWithCloseButton(false);
    dialogBox.setWidget(sp);/*from  ww w  .  jav a2  s . c o  m*/
    dialogBox.setText(ShowcaseSearchPanel.I18N.viewSource(source));
    dialogBox.center();

    super.doFormat();
}

From source file:org.clevermore.monitor.client.servers.CertificatesPopup.java

License:Apache License

public CertificatesPopup(HashMap<String, List<Certificate>> result) {
    setAnimationEnabled(true);// ww  w .j  a  v a2s. c  o m
    setAutoHideEnabled(true);
    setModal(true);
    setSize(Window.getClientWidth() - 50 + "px", "200px");

    ft.getElement().setId("infoTable");
    ft.setCellPadding(0);
    ft.setCellSpacing(0);
    ft.setText(0, 0, "Domain");
    ft.setText(0, 1, "Certificate");
    ft.setText(0, 2, "Alert Raised");
    ft.getRowFormatter().getElement(0).setId("th");
    ft.setWidth("100%");
    fp.add(ft);
    setWidget(fp);

    center();

    int i = 1;
    for (String key : result.keySet()) {
        Label l = new Label(key);
        l.getElement().getStyle().setFontWeight(FontWeight.BOLDER);
        ft.setWidget(i, 0, l);
        ft.setText(i, 1, "");
        ft.setText(i, 2, "");
        i++;
        Log.debug("Certificate:" + result.get(key));
        for (Certificate c : result.get(key)) {
            ft.setText(i, 0, c.getCommonName());
            ft.setText(i, 1, c.toString());
            ft.setText(i, 2, "" + c.isAlertRaised());
            i++;
        }
    }
    int left = (Window.getClientWidth() - getOffsetWidth()) >> 1;
    setPopupPosition(Math.max(Window.getScrollLeft() + left, 0), 26);

}

From source file:org.clevermore.monitor.client.servers.GcHistoryPopup.java

License:Apache License

public void setText(String text) {
    textArea.setText(text);//from w w  w.  ja v  a 2  s  .  c  o m
    int left = (Window.getClientWidth() - getOffsetWidth()) >> 1;
    setPopupPosition(Math.max(Window.getScrollLeft() + left, 0), 26);
}

From source file:org.clevermore.monitor.client.servers.ServerStatsPopup.java

License:Apache License

public void loadSecondPart() {
    HorizontalPanel hp = new HorizontalPanel();
    Button threadDump = new Button("Get Thread Dump");
    hp.add(threadDump);//w  ww  .  j ava  2s  . com
    addRadioButtons(hp);
    Button close = new Button("Close");
    hp.add(close);
    close.addClickHandler(new ClickHandler() {

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

    hp.setWidth("100%");
    hp.setCellHorizontalAlignment(close, HorizontalAlignmentConstant.endOf(Direction.LTR));
    Style style = close.getElement().getStyle();
    style.setColor("orange");
    style.setFontWeight(FontWeight.BOLDER);
    fp.add(hp);
    fp.add(cpu);
    fp.add(memory);
    fp.add(memoryDetails);
    fp.add(sysLoad);
    addExtraElements(fp);
    fp.add(details);

    threadDump.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final ThreadDumpPopup tdp = new ThreadDumpPopup();
            tdp.center();

            service.getThreadDump(serverCode, new AsyncCallback<ThreadDump>() {

                @Override
                public void onSuccess(ThreadDump result) {
                    tdp.setDump(result);
                }

                @Override
                public void onFailure(Throwable caught) {
                    tdp.setText("Can't get thread dump:" + caught.getMessage());
                }
            });
        }
    });

    getMemoryStats(chunks);
    getCpuStats(chunks);

    service.getRuntimeInfo(serverCode, new AsyncCallback<RuntimeInfo>() {

        @Override
        public void onSuccess(RuntimeInfo result) {
            updateRuntimeInfo(result);
            int left = (Window.getClientWidth() - getOffsetWidth()) >> 1;
            setPopupPosition(Math.max(Window.getScrollLeft() + left, 0), 26);

        }

        @Override
        public void onFailure(Throwable caught) {
            Log.error("error while getting server cpu stats:" + caught.getMessage());

        }
    });

    getExtraData(chunks);

    RepeatingCommand refreshCommand = new RepeatingCommand() {

        @Override
        public boolean execute() {
            if (refresh) {
                getMemoryStats(chunks);
                getCpuStats(chunks);
                getExtraData(chunks);
                Log.debug("Reschedule refresh");
            }
            return refresh;
        }
    };
    Scheduler.get().scheduleFixedDelay(refreshCommand, 20000);
}

From source file:org.clevermore.monitor.client.settings.SettingsPopup.java

License:Apache License

public SettingsPopup(final GeneralServiceAsync service) {
    setWidget(fp);/*from   w ww  .  ja v a 2 s.  c  o  m*/
    fp.add(ta);
    setAutoHideEnabled(false);
    setAnimationEnabled(true);
    setModal(true);
    setSize("1000px", "500px");
    setGlassEnabled(true);

    service.getSettingsXML(new AsyncCallback<String>() {

        @Override
        public void onFailure(Throwable caught) {
            ta.setText(caught.getMessage());
        }

        @Override
        public void onSuccess(String result) {
            ta.setText(result);
            int left = (Window.getClientWidth() - getOffsetWidth()) >> 1;
            setPopupPosition(Math.max(Window.getScrollLeft() + left, 0), 26);
            ta.setSize("1000px", "500px");

        }
    });

    Button save = new Button("Save");
    save.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            service.saveSettingsXML(ta.getText(), new AsyncCallback<Boolean>() {

                @Override
                public void onSuccess(Boolean result) {
                    if (result) {
                        Window.alert("Configurations saved");
                    } else {
                        Window.alert("Error saving: not clear");
                    }
                }

                @Override
                public void onFailure(Throwable caught) {
                    Window.alert("Error saving:" + caught.getMessage());
                }
            });
        }
    });

    fp.add(save);
    Button close = new Button("Close");
    close.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            hide();
        }
    });
    fp.add(close);
}

From source file:org.clevermore.monitor.client.widgets.AbstractMonitoringWidget.java

License:Apache License

@Override
protected void onAttach() {
    super.onAttach();
    Timer t = new Timer() {

        @Override/* w w  w . ja  va2  s .  co m*/
        public void run() {
            Log.debug("Monitoring widget attached:" + name);
            try {
                Style style = getElement().getStyle();
                int absoluteLeft = getAbsoluteLeft();
                if (absoluteLeft < Window.getClientWidth() / 2) {
                    style.setFloat(Float.LEFT);
                    Log.debug("Monitoring widget:" + name + " floating to left:" + absoluteLeft);
                } else {
                    style.setWidth(50, Unit.PCT);
                    style.setFloat(Float.RIGHT);
                    Log.debug("Monitoring widget:" + name + " floating to right:" + absoluteLeft);
                }
            } catch (Exception e) {
                Log.error(e.getMessage(), e);
            }

        }
    };

    t.schedule(1000);

}

From source file:org.cobogw.gwt.waveapi.gadget.client.ui.DialogBox.java

License:Apache License

/**
 * 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)}.//from w  w w  .  j  a  v a  2 s.  co  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);
    makeDialog(getElement(), "");
    caption = new CaptionImpl(getElement().getFirstChildElement().getFirstChildElement());
    body = new BodyImpl(getElement().getFirstChildElement().getNextSiblingElement());

    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());
}