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

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

Introduction

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

Prototype

public static void resizeTo(int width, int height) 

Source Link

Usage

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

License:Open Source License

/**
 * This is the entry point method.//from w ww  . j a v  a 2s .co m
 */
public void onModuleLoad() {
    // Pointer to CSS manager. It has to go first!
    GWT.<Resources>create(Resources.class).css().ensureInjected();
    // Log messages
    String msg = "\nInitializing EMarking 3.0\n" + "Platform: " + Navigator.getPlatform() + "\n"
            + "User agent: " + Navigator.getUserAgent() + "\n" + "App name: " + Navigator.getAppName() + "\n"
            + "App code name: " + Navigator.getAppCodeName() + "\n" + "App version: "
            + Navigator.getAppVersion();

    logger.fine(msg);

    // List of errors after trying to initialize
    ArrayList<String> errors = new ArrayList<String>();

    // Get id for eMarkingWeb's DIV tag
    final String eMarkingDivId = "emarking";
    if (RootPanel.get(eMarkingDivId) == null) {
        errors.add("Can not initalize. EMarking requires an existing DIV tag with id: emarking.");
        return;
    }

    RootPanel.get(eMarkingDivId).add(new Label("Loading"));

    int draftId = 0;
    int preferredWidth = 860;
    boolean showRubric = true;
    boolean showColors = false;

    try {
        // First, if there's a URL parameter, replace the value
        if (Window.Location.getParameter("id") != null) {
            draftId = Integer.parseInt(Window.Location.getParameter("id"));
        }

        // Validate that the submission id is a positive integer
        if (draftId <= 0) {
            errors.add("Submission id must be a non negative integer.");
        }

        // Reading the image width
        float imagewidth = 0;
        if (RootPanel.get(eMarkingDivId).getElement().getAttribute("imagewidth") != null)
            imagewidth = Float.parseFloat(RootPanel.get(eMarkingDivId).getElement().getAttribute("imagewidth"));

        String cookie_width = Cookies.getCookie("emarking_width");

        if (cookie_width != null) {
            preferredWidth = Integer.parseInt(cookie_width);
        } else if (imagewidth > 0) {
            preferredWidth = (int) (imagewidth / 0.6f);
        }

        // Validate that the preferredWidth is a positive integer greater than 10
        if (preferredWidth <= 10) {
            errors.add("Preferred width should be a positive integer greater than 10.");
        }

        // Validate that the preferredWidth is a positive integer greater than 10
        if (preferredWidth <= 10) {
            errors.add("Preferred width should be a positive integer greater than 10.");
        }

        String cookie_showrubric = Cookies.getCookie("emarking_showrubric");

        if (cookie_showrubric != null) {
            showRubric = Integer.parseInt(cookie_showrubric) == 1;
        }

        String cookie_showcolors = Cookies.getCookie("emarking_showcolors");

        if (cookie_showcolors != null) {
            showColors = Integer.parseInt(cookie_showcolors) == 1;
        }

    } catch (Exception e) {
        logger.severe(e.getMessage());
        errors.add(
                "Error in HTML for eMarkingWeb can not initalize. Invalid submissionId value (must be integer).");
    }

    // Read div attribute for readonly
    String moodleurl = null;
    if (RootPanel.get(eMarkingDivId).getElement().getAttribute("moodleurl") != null)
        moodleurl = RootPanel.get(eMarkingDivId).getElement().getAttribute("moodleurl");

    logger.fine("\nShowRubric: " + showRubric + "\nShow colors:" + showColors + "\nPreferred width:"
            + preferredWidth + "\nMoodle ajax url: " + moodleurl);

    if (moodleurl == null)
        errors.add("Invalid Moodle ajax url");

    // If there are errors die with a configuration message
    if (errors.size() > 0) {
        Label errorsLabel = new Label();
        String text = "";
        for (int i = 0; i < errors.size(); i++) {
            text += "\n" + errors.get(i);
        }
        errorsLabel.setText(text);
        errorsLabel.setTitle("Fatal error while initializing eMarking-Web");

        RootPanel.get(eMarkingDivId).clear();
        RootPanel.get(eMarkingDivId).add(errorsLabel);
    } else {
        // Set eMarking's main interface submission id according to HTML
        MarkingInterface.setDraftId(draftId);

        EMarkingConfiguration.setShowRubricOnLoad(showRubric);
        EMarkingConfiguration.setColoredRubric(showColors);

        // Ajax URL in moodle
        EMarkingConfiguration.setMoodleUrl(moodleurl);

        // Automagically resize popup to use most of the window
        int width = screenWidth();
        int height = screenHeight();

        // Preferred width can not be bigger than the screen
        if (width < preferredWidth) {
            preferredWidth = width;
        }

        //  Resize the popup window and move it to the top left corner
        Window.resizeTo(preferredWidth, height);
        Window.moveTo(0, 0);

        // Initialize eMarking's interface
        markingInterface = new MarkingInterface();

        // Add eMarking to the browser
        RootPanel.get(eMarkingDivId).clear();
        RootPanel.get(eMarkingDivId).add(markingInterface);
        RootPanel.getBodyElement().focus();
    }
}

From source file:net.sf.mmm.client.ui.impl.gwt.widget.window.adapter.UiWidgetAdapterGwtMainWindow.java

License:Apache License

/**
 * {@inheritDoc}//  w  w w . ja  va2  s  .  co m
 */
@Override
public void setLength(LengthProperty property, Length value) {

    switch (property) {
    case HEIGHT:
        Window.resizeTo(Window.getClientWidth(), convertLength(value));
        break;
    case WIDTH:
        Window.resizeTo(convertLength(value), Window.getClientHeight());
        break;
    // TODO hohwille min/max width/height
    default:
        break;
    }
}

From source file:org.olanto.mySelfQD.client.MainEntryPoint.java

License:Open Source License

private void getPropertiesMyParse() {
    rpcM.InitPropertiesFromFile(Cookies.getCookie(CookiesNamespace.InterfaceLanguage),
            new AsyncCallback<GwtProp>() {
                @Override/*from   w  ww. ja  v a  2s  .c o  m*/
                public void onFailure(Throwable caught) {
                    Window.alert("Couldn't get properties List");
                }

                @Override
                public void onSuccess(GwtProp result) {
                    InitProperties(result);
                    if (GuiConstant.MAXIMIZE_ON) {
                        Window.moveTo(0, 0);
                        Window.resizeTo(getScreenWidth(), getScreenHeight());
                        maximize();
                    }
                    setParseWidget();
                }
            });
}

From source file:org.olanto.TranslationText.client.MainEntryPoint.java

License:Open Source License

/**
 * The entry point method, called automatically by loading a module that
 * declares an implementing class as an entry-point
 */// ww  w. j a v  a 2s.c  o m
@SuppressWarnings("static-access")
@Override
public void onModuleLoad() {
    rpcM = RpcInit.initRpc();
    getStopWdMyCat();
    if (Window.Location.getQueryString().length() == 0) {
        RootPanel.get("content").add(mainWidget);
        mainWidget.setWidth("100%");
        mainWidget.setStyleName("mainPage");
        mainWidget.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
        getCollections();
        getPropertiesMyCat();
    } else {
        final String source = Window.Location.getParameter("source");
        final String query = Window.Location.getParameter("query");
        final String lS = Window.Location.getParameter("LSrc");
        final String lT = Window.Location.getParameter("LTgt");

        rpcM.InitPropertiesFromFile("en", new AsyncCallback<GwtProp>() {
            @Override
            public void onFailure(Throwable caught) {
                Window.alert(
                        "Couldn't get properties List, problem loading the properties files. Check if all the services are started."
                                + caught.getMessage());
            }

            @Override
            public void onSuccess(GwtProp result) {
                InitProperties(result);

                //                    Window.alert(GuiConstant.show());
                //                    Window.alert(GuiMessageConst.show());
                if (GuiConstant.MAXIMIZE_ON) {
                    Window.moveTo(0, 0);
                    Window.resizeTo(getScreenWidth(), getScreenHeight());
                    maximize();
                }
                initCookies();
                if (MyCatCookies.areInterfaceMeasuresSaved() && GuiConstant.AUTO_ON) {
                    IMeasures.setMeasuresfromCookies();
                } else {
                    IMeasures.setDefaultMeasures();
                }

                final FormCallWidget FC = new FormCallWidget(source, query, lS, lT);
                RootPanel.get("call").add(FC);
                FC.pWidget.setWidth("100%");
                rpcM.getStopWords(new AsyncCallback<ArrayList<String>>() {
                    @Override
                    public void onFailure(Throwable caught) {
                        Window.alert(
                                "Warning: Could not get the list of stopwords. If the problem persists then restart the servers.");
                    }

                    @Override
                    public void onSuccess(ArrayList<String> result) {
                        FC.draWidget(result);
                    }
                });
            }
        });

    }
}

From source file:org.olanto.TranslationText.client.MainEntryPoint.java

License:Open Source License

private void getPropertiesMyCat() {
    rpcM.InitPropertiesFromFile(Cookies.getCookie(CookiesNamespace.InterfaceLanguage),
            new AsyncCallback<GwtProp>() {
                @Override//  w ww .  j  ava  2  s  .  co  m
                public void onFailure(Throwable caught) {
                    Window.alert("Warning: Could not get the list of properties: " + caught.getMessage());
                }

                @Override
                public void onSuccess(GwtProp result) {
                    InitProperties(result);

                    //                Window.alert(GuiConstant.show());
                    //                Window.alert(GuiMessageConst.show());
                    if (GuiConstant.MAXIMIZE_ON) {
                        Window.moveTo(0, 0);
                        Window.resizeTo(getScreenWidth(), getScreenHeight());
                        maximize();
                    }
                    if (!Window.Navigator.isCookieEnabled()) {
                        Window.alert(GuiMessageConst.MSG_63);
                    }
                    initCookies();
                    if (MyCatCookies.areInterfaceMeasuresSaved() && GuiConstant.AUTO_ON) {
                        IMeasures.setMeasuresfromCookies();
                    } else {
                        IMeasures.setDefaultMeasures();
                    }
                    setSettingsColMycat();
                    setSettingsColMyQuote();
                    getLanguages();
                }
            });
}