Example usage for com.google.gwt.core.client JavaScriptException getMessage

List of usage examples for com.google.gwt.core.client JavaScriptException getMessage

Introduction

In this page you can find the example usage for com.google.gwt.core.client JavaScriptException getMessage.

Prototype

@Override
    public String getMessage() 

Source Link

Usage

From source file:cc.alcina.framework.gwt.client.util.WidgetUtils.java

License:Apache License

public static void copyTextToClipboard(String text) {
    FlowPanel fp = new FlowPanel();
    TextArea ta = new TextArea();
    ta.setSize("600px", "300px");
    ta.setText(text);/*from   ww w  .j av  a 2s  . com*/
    fp.add(ta);
    PopupPanel pp = new PopupPanel();
    pp.add(fp);
    pp.setAnimationEnabled(false);
    pp.show();
    ta.setSelectionRange(0, text.length());
    try {
        execCopy();
    } catch (JavaScriptException e) {
        pp.hide();
        if (e.getMessage().contains("NS_ERROR_XPC_NOT_ENOUGH_ARGS")) {
            Registry.impl(ClientNotifications.class)
                    .showMessage(new HTML("<div class='info'>Sorry, clipboard operations"
                            + " are disabled by Mozilla/Firefox" + " security settings. <br><br> Please see "
                            + "<a href='http://www.mozilla.org/editor/midasdemo/securityprefs.html'>"
                            + "http://www.mozilla.org/editor/midasdemo/securityprefs.html</a></div> "));
        } else {
            throw e;
        }
    }
    pp.hide();
}

From source file:client.net.sf.saxon.ce.dom.HTMLWriter.java

License:Mozilla Public License

/**
* Start of an element.//from  ww  w .j ava 2 s . co m
*/

public void startElement(int nameCode, int properties) throws XPathException {
    String localName = namePool.getLocalName(nameCode);
    String prefix = namePool.getPrefix(nameCode);
    String uri = namePool.getURI(nameCode);

    // TODO: For XML Writer it should write prefixes in a
    // way compliant with the XSLT2.0 specification - using xsl:output attributes
    Element element = null;
    if (uri != null && !uri.isEmpty()) {
        if (mode == WriteMode.XML && !prefix.equals("")) {
            element = createElementNS(document, uri, prefix + ":" + localName);

        } else {
            // no svg specific prefix now used, for compliance with HTML5
            element = createElementNS(document, uri, localName);
        }
    }

    // if there's no namespace - or no namespace support
    if (element == null) {
        element = document.createElement(localName);
    }
    // special case for html element: write to the document node
    Controller controller = pipe.getController();
    if (controller != null && controller.getApiCommand() == APIcommand.UPDATE_HTML
            && (localName.equals("html") || localName.equals("head") || localName.equals("body"))) {
        if (localName.equals("html")) {
            element = (Element) document.getFirstChild();
        } else {
            element = (Element) document.getElementsByTagName(localName.toUpperCase()).getItem(0);
            NodeList<Node> nodes = element.getChildNodes();
            for (int n = 0; n < nodes.getLength(); n++) {
                Node node = nodes.getItem(n);
                node.removeFromParent();
            }
        }
        currentNode = element;
        level++;
        return;
    }
    if (nextSibling != null && level == 0) {
        currentNode.insertBefore(element, nextSibling);
    } else {
        try {
            currentNode.appendChild(element);
        } catch (JavaScriptException err) {
            if (uri.equals(NamespaceConstant.IXSL)) {
                XPathException xpe = new XPathException(
                        "Error on adding IXSL element to the DOM, the IXSL namespace should be added to the 'extension-element-prefixes' list.");
                throw (xpe);
            } else {
                throw (new XPathException(err.getMessage()));
            }
        } catch (Exception exc) {
            XPathException xpe = new XPathException(
                    "Error on startElement in HTMLWriter for element '" + localName + "': " + exc.getMessage());
            throw (xpe);
        }
    }
    currentNode = element;
    level++;
}

From source file:client.net.sf.saxon.ce.dom.XMLDOM.java

License:Mozilla Public License

public static JavaScriptObject parseXML(String text) throws XPathException {
    try {/*  w  ww  .  j a v a  2s  . c o m*/
        return parseNativeXML(text);
    } catch (JavaScriptException je) {
        throw new XPathException("JS error in Saxon.parseXML: " + je.getMessage());
    } catch (Exception e) {
        throw new XPathException("error in Saxon.parseXML: " + e.getMessage());
    }
}

From source file:com.bramosystems.oss.player.util.client.RegExp.java

License:Apache License

/**
 * Returns a RegExp instance for the specified pattern and flags.
 *
 * <p>/*from   ww w.j  a v  a2  s .  c o m*/
 * The flags can include the following:
 * <ul>
 * <li>g - performs a global match, that is all matches are found rather than stopping
 * after the first match</li>
 * <li>i - performs a match without case sensitivity</li>
 * <li>m - performs multiline matching, that is the caret (^) character and dollar sign
 * ($) match before and after new-line characters</li>
 * </ul>
 * </p>
 *
 * @param pattern the pattern of the regular expression
 * @param flags the modifiers of the expression
 * @return the RegExp instance
 * @throws RegexException if any error occurs, such as invalid flags
 */
public static final RegExp getRegExp(String pattern, String flags) throws RegexException {
    try {
        return _getRegExp(pattern, flags);
    } catch (JavaScriptException ex) {
        throw new RegexException(ex.getMessage());
    }
}

From source file:com.cgxlib.xq.client.plugins.deferred.PromiseReqBuilder.java

License:Apache License

/**
 * Using this constructor we access to some things in the xmlHttpRequest
 * which are not available in GWT, like adding progress handles or sending
 * javascript data (like forms in modern html5 file api).
 *///  ww w . jav a  2  s .  c o m
public PromiseReqBuilder(Settings settings) {
    String httpMethod = settings.getType();
    String url = settings.getUrl();
    IsProperties data = settings.getData();
    String ctype = settings.getContentType();
    Boolean isFormData = data != null && data.getDataImpl() instanceof JavaScriptObject
            && JsUtils.isFormData(data.<JavaScriptObject>getDataImpl());

    XMLHttpRequest xmlHttpRequest = XMLHttpRequest.create();
    try {
        if (settings.getUsername() != null && settings.getPassword() != null) {
            xmlHttpRequest.open(httpMethod, url, settings.getUsername(), settings.getPassword());
        } else if (settings.getUsername() != null) {
            xmlHttpRequest.open(httpMethod, url, settings.getUsername());
        } else {
            xmlHttpRequest.open(httpMethod, url);
        }
    } catch (JavaScriptException e) {
        RequestPermissionException requestPermissionException = new RequestPermissionException(url);
        requestPermissionException.initCause(new RequestException(e.getMessage()));
        onError(null, e);
        return;
    }

    JsUtils.prop(xmlHttpRequest, "onprogress", JsUtils.wrapFunction(new Function() {
        public void f() {
            JsCache p = arguments(0);
            double total = p.getDouble("total");
            double loaded = p.getDouble("loaded");
            double percent = loaded == 0 ? 0 : total == 0 ? 100 : (100 * loaded / total);
            dfd.notify(total, loaded, percent, "download");
        }
    }));

    JavaScriptObject upload = JsUtils.prop(xmlHttpRequest, "upload");
    JsUtils.prop(upload, "onprogress", JsUtils.wrapFunction(new Function() {
        public void f() {
            JsCache p = arguments(0);
            double total = p.getDouble("total");
            double loaded = p.getDouble("loaded");
            double percent = 100 * loaded / total;
            dfd.notify(total, loaded, percent, "upload");
        }
    }));

    IsProperties headers = settings.getHeaders();
    if (headers != null) {
        for (String headerKey : headers.getFieldNames()) {
            xmlHttpRequest.setRequestHeader(headerKey, String.valueOf(headers.get(headerKey)));
        }
    }

    if (data != null && !isFormData && !"GET".equalsIgnoreCase(httpMethod)) {
        xmlHttpRequest.setRequestHeader("Content-Type", ctype);
    }

    // Using xq to set credentials since this method was added in 2.5.1
    // xmlHttpRequest.setWithCredentials(true);
    JsUtils.prop(xmlHttpRequest, "withCredentials", settings.getWithCredentials());

    final Request request = createRequestVltr(xmlHttpRequest, settings.getTimeout(), this);

    xmlHttpRequest.setOnReadyStateChange(new ReadyStateChangeHandler() {
        public void onReadyStateChange(XMLHttpRequest xhr) {
            if (xhr.getReadyState() == XMLHttpRequest.DONE) {
                xhr.clearOnReadyStateChange();
                fireOnResponseReceivedVltr(request, PromiseReqBuilder.this);
            }
        }
    });

    try {
        JsUtils.runJavascriptFunction(xmlHttpRequest, "send",
                isFormData ? data.getDataImpl() : settings.getDataString());
    } catch (JavaScriptException e) {
        onError(null, e);
    }
}

From source file:com.google.code.gwt.geolocation.client.impl.GeolocationImplGears.java

License:Apache License

private void handleGearsError(PositionCallback callback, JavaScriptException jse) {
    String message = jse.getDescription();
    // Very annoying bug in Gears: Sometimes the Gears call fails with a
    // message "Null or undefined passed for required argument 1."
    boolean gearsBug = (message != null && message.indexOf("Null or undefined passed") == 0);
    handleError(callback, PositionError.create(gearsBug ? 0 : 1, message));
    if (gearsBug) {
        logMessage("Stumbled upon a Gears bug - please report to GWT Mobile WebKit project team! "
                + jse.getMessage());
    }/* w ww. j a va 2 s .  c  o  m*/
}

From source file:com.googlecode.gwtphonegap.client.plugins.childbrowser.ChildBrowserPhoneGapImpl.java

License:Apache License

@Override
public void initialize() {

    try {/*from  w  w w  .ja v  a2 s  .  c  om*/
        cb = initializeNative();
        initialized = true;
    } catch (JavaScriptException e) {
        throw new IllegalStateException("could not initialize Childbrowser plugin: " + e.getMessage());
    }

}

From source file:com.gwtpro.html5.fileapi.client.upload.UploadRequestBuilder.java

License:Apache License

/**
 * Sends a POST request based to upload a file, on the current builder
 * configuration.//from  www.  j av  a  2  s  .co m
 * 
 * @return a {@link UploadRequest} object that can be used to track the
 *         request
 * @throws RequestException
 *             if the call fails to initiate
 * @throws NullPointerException
 *             if a request callback has not been set
 */
public UploadRequest sendFile(File file) throws RequestException {
    if (this.callback == null) {
        throw new NullPointerException("callback has not been set");
    }
    XMLHttpRequest2 xmlHttpRequest = XMLHttpRequest2.create();
    final UploadRequest request = new UploadRequest(xmlHttpRequest, this.timeoutMillis, this.callback);
    // progress handler must be set before open!!!
    xmlHttpRequest.setOnUploadProgressHandler(new UploadProgressHandler() {

        @Override
        public void onProgress(int bytesUploaded) {
            UploadRequestBuilder.this.callback.onUploadProgress(request, bytesUploaded);
        }
    });
    try {
        if (this.user != null && this.password != null) {
            xmlHttpRequest.open("POST", this.url, this.user, this.password);
        } else if (this.user != null) {
            xmlHttpRequest.open("POST", this.url, this.user);
        } else {
            xmlHttpRequest.open("POST", this.url);
        }
    } catch (JavaScriptException e) {
        RequestPermissionException requestPermissionException = new RequestPermissionException(this.url);
        requestPermissionException.initCause(new RequestException(e.getMessage()));
        throw requestPermissionException;
    }
    if (this.headers != null) {
        for (Map.Entry<String, String> header : this.headers.entrySet()) {
            try {
                xmlHttpRequest.setRequestHeader(header.getKey(), header.getValue());
            } catch (JavaScriptException e) {
                throw new RequestException(e.getMessage());
            }
        }
    }
    xmlHttpRequest.setOnReadyStateChange(new ReadyStateChangeHandler() {

        public void onReadyStateChange(XMLHttpRequest xhr) {
            if (xhr.getReadyState() == XMLHttpRequest.DONE) {
                xhr.clearOnReadyStateChange();
                request.fireOnResponseReceived(UploadRequestBuilder.this.callback);
            }
        }
    });
    try {
        xmlHttpRequest.sendFile(file);
    } catch (JavaScriptException e) {
        throw new RequestException(e.getMessage());
    }
    return request;
}

From source file:com.parabay.client.gears.ResultSet.java

License:Apache License

public int size() throws DatabaseException {
    try {/*from  w  w  w  .j  a va2s. c  om*/
        return uncheckedSize();
    } catch (JavaScriptException ex) {
        throw new DatabaseException(ex.getMessage(), ex);
    }
}

From source file:com.parabay.client.gears.ResultSet.java

License:Apache License

public char getFieldAsChar(String fieldName) throws DatabaseException {
    try {//www  .  j ava  2  s  . c  om
        return uncheckedGetFieldAsChar(fieldName);
    } catch (JavaScriptException ex) {
        throw new DatabaseException(ex.getMessage(), ex);
    }
}