Java Code Examples for com.google.gwt.core.client.GWT#isProdMode()
The following examples show how to use
com.google.gwt.core.client.GWT#isProdMode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractJsonWriterTest.java From gwt-jackson with Apache License 2.0 | 6 votes |
public void testDoubles() { JsonWriter jsonWriter = newJsonWriter(); jsonWriter.beginArray(); jsonWriter.value( -0.0 ); jsonWriter.value( 1.0 ); jsonWriter.value( Double.MAX_VALUE ); jsonWriter.value( Double.MIN_VALUE ); jsonWriter.value( 0.0 ); jsonWriter.value( -0.5 ); jsonWriter.value( 2.2250738585072014E-308 ); jsonWriter.value( Math.PI ); jsonWriter.value( Math.E ); jsonWriter.endArray(); jsonWriter.close(); if ( GWT.isProdMode() ) { // in compiled mode, the .0 are removed, the power is written with 'e+' instead of 'E' and 'e-' instead of 'E-' and the Double // .MIN_VALUE is 5e-324 assertEquals( "[0," + "1," + "1.7976931348623157e+308," + "5e-324," + "0," + "-0.5," + "2.2250738585072014e-308," + "" + "3.141592653589793," + "2.718281828459045]", jsonWriter.getOutput() ); } else { assertEquals( "[-0.0," + "1.0," + "1.7976931348623157E308," + "4.9E-324," + "0.0," + "-0.5," + "2.2250738585072014E-308," + "" + "3.141592653589793," + "2.718281828459045]", jsonWriter.getOutput() ); } }
Example 2
Source File: DataControlsSes.java From SensorWebClient with GNU General Public License v2.0 | 6 votes |
public static String createMD5(String password) { StringBuffer buffer = new StringBuffer(); try { MessageDigest md5 = MessageDigest.getInstance("MD5"); md5.reset(); md5.update(password.getBytes()); byte[] result = md5.digest(); for (int i = 0; i < result.length; i++) { buffer.append(Integer.toHexString(0xFF & result[i])); } } catch (NoSuchAlgorithmException e) { if (!GWT.isProdMode()) { GWT.log("Error hashing password", e); } } return buffer.toString(); }
Example 3
Source File: StationSelectorMap.java From SensorWebClient with GNU General Public License v2.0 | 6 votes |
public void zoomToMarkers() { try { if (markerLayer != null) { Bounds bbox = markerLayer.getDataExtent(); if (bbox != null) { int z = map.getZoomForExtent(bbox, false); map.zoomToExtent(bbox); map.zoomTo(z); } } } catch (Exception e) { if ( !GWT.isProdMode()) { GWT.log("", e); } } }
Example 4
Source File: StationSelectorController.java From SensorWebClient with GNU General Public License v2.0 | 5 votes |
@Override public void onNewStationPositions(NewStationPositionsEvent evt) { if ( !GWT.isProdMode()) { TimeseriesParametersLookup lookup = controller.getParametersLookup(); ArrayList<Procedure> procedures = lookup.getProcedures(); int proceduresSize = procedures.size(); GWT.log("#" + proceduresSize + " new Procedures"); } controller.updateMapContent(); controller.zoomToConfiguredExtent(); controller.updateStationFilter(); }
Example 5
Source File: EventBus.java From SensorWebClient with GNU General Public License v2.0 | 5 votes |
@Override public void fireEvent(GwtEvent<?> event) { try { if (!GWT.isProdMode()) { GWT.log("Firing " + event.toDebugString()); } super.fireEvent(event); } catch (Exception e) { ExceptionHandler.handleUnexpectedException(e); } }
Example 6
Source File: ExceptionHandler.java From SensorWebClient with GNU General Public License v2.0 | 5 votes |
public static void handleUnexpectedException(Exception e) { Toaster t = Toaster.getToasterInstance(); StringBuilder sb = new StringBuilder(); sb.append("Unexpected Exception occured. Msg: \""); sb.append(e.getMessage()).append("\""); sb.append(", CausedBy: "); sb.append(e.getCause()); t.addErrorMessage(sb.toString()); if (!GWT.isProdMode()) GWT.log(sb.toString(), e); }
Example 7
Source File: ExceptionHandler.java From SensorWebClient with GNU General Public License v2.0 | 5 votes |
/** * Process exception. * * @param e * the e */ private static void logInToaster(MetaException e) { Toaster toaster = Toaster.getToasterInstance(); if (toaster == null) { Window.alert("Initialization error: no message toaster present!"); if (!GWT.isProdMode()) { GWT.log("INIT ERROR: No message toaster present!"); GWT.log(e.getMessage(), e); } return; } StringBuilder sb = new StringBuilder(); switch (e.getWeight()) { case mild: sb.append("MILD: "); break; case severe: sb.append("SEVERE: "); break; } sb.append(e.getMessage()); sb.append("\ncaused by: "); sb.append(e.getCause()); toaster.addErrorMessage(sb.toString()); if (!GWT.isProdMode()) GWT.log(e.getMessage(), e); }
Example 8
Source File: Application.java From SensorWebClient with GNU General Public License v2.0 | 5 votes |
private static void fireNewTimeRangeEvent(TimeRange timeRange) { try { DateTimeFormat formatter = DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.ISO_8601); long begin = formatter.parseStrict(timeRange.getStart()).getTime(); long end = formatter.parseStrict(timeRange.getEnd()).getTime(); Toaster.getToasterInstance().addMessage("Begin: " + timeRange.getStart()); Toaster.getToasterInstance().addMessage("End: " + timeRange.getEnd()); EventBus.getMainEventBus().fireEvent(new DatesChangedEvent(begin, end, true)); } catch (Exception e) { if ( !GWT.isProdMode()) { GWT.log("Unparsable TimeRange: " + timeRange, e); } } }
Example 9
Source File: StationSelectorController.java From SensorWebClient with GNU General Public License v2.0 | 5 votes |
@Override public void onNewFullOfferings(PropagateOfferingsFullEvent evt) { if ( !GWT.isProdMode()) { TimeseriesParametersLookup lookup = controller.getParametersLookup(); Collection<Offering> offerings = lookup.getOfferings(); int offeringsSize = offerings.size(); GWT.log("#" + offeringsSize + " new Offerings"); } }
Example 10
Source File: Editor.java From proarc with GNU General Public License v3.0 | 5 votes |
private void initLogging() { Dictionary levels = Dictionary.getDictionary("EditorLoggingConfiguration"); for (String loggerName : levels.keySet()) { String levelValue = levels.get(loggerName); try { Level level = Level.parse(levelValue); Logger logger = Logger.getLogger(loggerName); logger.setLevel(level); Logger.getLogger("").info(ClientUtils.format( "logger: '%s', levelValue: %s", loggerName, level)); } catch (IllegalArgumentException ex) { Logger.getLogger("").log(Level.SEVERE, ClientUtils.format("logger: '%s', levelValue: %s", loggerName, levelValue), ex); } } if (GWT.isProdMode()) { // XXX SmartGWT 3.0 ignores thrown exceptions in production mode. // Javascript stack traces are useless but messages can be valuable GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() { @Override public void onUncaughtException(Throwable e) { StringBuilder sb = new StringBuilder(); for (Throwable t = e; t != null; t = t.getCause()) { sb.append("* ").append(t.getClass().getName()).append(": ") .append(t.getLocalizedMessage()).append("\n"); for (StackTraceElement elm : t.getStackTrace()) { sb.append(" ").append(elm.toString()).append("\n"); } } // visible in javascript console; Window.alert is too much intrusive. LOG.log(Level.SEVERE, e.getMessage(), e); // Window.alert(sb.toString()); } }); } }
Example 11
Source File: StationSelectorController.java From SensorWebClient with GNU General Public License v2.0 | 5 votes |
@Override public void onNewPhenomenons(NewPhenomenonsEvent evt) { if ( !GWT.isProdMode()) { TimeseriesParametersLookup lookup = controller.getParametersLookup(); Collection<Phenomenon> phenomenons = lookup.getPhenomenons(); GWT.log("#" + phenomenons.size() + " new Phenomenons"); } }
Example 12
Source File: FloatJsonDeserializerTest.java From gwt-jackson with Apache License 2.0 | 5 votes |
@Override public void testDeserializeValue() { assertDeserialization( new Float( "34.10245" ), "34.10245" ); assertDeserialization( new Float( "-784.15454" ), "\"-784.15454\"" ); // the float emulation gives slightly different results => use BigDecimal for precision! if ( !GWT.isProdMode() ) { assertDeserialization( Float.MIN_VALUE, "1.4e-45" ); assertDeserialization( Float.MAX_VALUE, "3.4028235e38" ); } }
Example 13
Source File: FloatKeyDeserializerTest.java From gwt-jackson with Apache License 2.0 | 5 votes |
@Override public void testDeserializeValue() { assertDeserialization( new Float( "34.10245" ), "34.10245" ); assertDeserialization( new Float( "-784.15454" ), "-784.15454" ); // the float emulation gives slightly different results => use BigDecimal for precision! if ( !GWT.isProdMode() ) { assertDeserialization( Float.MIN_VALUE, "1.4e-45" ); assertDeserialization( Float.MAX_VALUE, "3.4028235e38" ); } }
Example 14
Source File: FloatJsonSerializerTest.java From gwt-jackson with Apache License 2.0 | 5 votes |
public void testSerializeValue() { assertSerialization( "34.10245", new Float( "34.10245" ) ); assertSerialization( "-784.15454", new Float( "-784.15454" ) ); // the float emulation gives slightly different results => use BigDecimal for precision! if ( !GWT.isProdMode() ) { assertSerialization( "1.4E-45", Float.MIN_VALUE ); assertSerialization( "3.4028235E38", Float.MAX_VALUE ); } }
Example 15
Source File: EventBus.java From SensorWebClient with GNU General Public License v2.0 | 5 votes |
public void fireEvent(GwtEvent<?> event, EventCallback callback) { try { if (!GWT.isProdMode()) { GWT.log("Firing " + event.toDebugString()); } super.fireEvent(event); if (!GWT.isProdMode()) { GWT.log(" Event fired, calling callback"); } callback.onEventFired(); } catch (Exception e) { ExceptionHandler.handleUnexpectedException(e); } }
Example 16
Source File: SimpleBeanJsonMapperTester.java From gwt-jackson with Apache License 2.0 | 5 votes |
public void testWriteWithNullProperties( ObjectWriterTester<SimpleBean> writer ) { String doubleAndFloatZeroString = GWT.isProdMode() ? "0" : "0.0"; String expected = "{\"bytePrimitive\":0," + "\"shortPrimitive\":0," + "\"intPrimitive\":0," + "\"longPrimitive\":0," + "\"doublePrimitive\":" + doubleAndFloatZeroString + "," + "\"floatPrimitive\":" + doubleAndFloatZeroString + "," + "\"booleanPrimitive\":false," + "\"charPrimitive\":\"\\u0000\"}"; assertEquals( expected, writer.write( new SimpleBean() ) ); }
Example 17
Source File: SOSRequestManager.java From SensorWebClient with GNU General Public License v2.0 | 4 votes |
private void getDiagram(final EESDataRequest request) throws Exception { // prepare callback EESDataCallback callback = new EESDataCallback(this, "Could not get diagram.") { @Override public void onSuccess(EESDataResponse result) { removeRequest(); try { // block overview if ( !GWT.isProdMode()) { GWT.log("Got Diagram: " + result.getWidth() + "w x " + result.getHeight() + "h"); GWT.log("For Viewportsize: " + DiagramTab.getPanelWidth() + "w x " + DiagramTab.getPanelHeight() + "h"); } for (String key : result.getAxis().keySet()) { EventBus.getMainEventBus().fireEvent(new StoreAxisDataEvent(key, result.getAxis().get(key))); } for (TimeseriesProperties prop : result.getPropertiesList()) { TimeSeriesHasDataEvent hasDataEvent = new TimeSeriesHasDataEvent(prop.getTimeseriesId(), prop.hasData()); EventBus.getMainEventBus().fireEvent(hasDataEvent); } EventBus.getMainEventBus().fireEvent(new SetImageUrlEvent(result.getImageUrl())); // inner pixel bounds = plotarea EventBus.getMainEventBus().fireEvent(new SetDataAreaPixelBoundsEvent(result.getPlotArea())); Double left = new Double(0); Double right = new Double(new Date().getTime()); Bounds maxDomainBounds = new Bounds(left, right, null, null); EventBus.getMainEventBus().fireEvent(new SetMaxDomainBoundsEvent(maxDomainBounds)); SetDomainBoundsEventHandler[] blocked = {TimeseriesDataStore.getTimeSeriesDataStore().getEventBroker()}; Double mainLeft = new Double(result.getBegin() + 0.0); Double mainRight = new Double(result.getEnd() + 0.0); Double mainTop = result.getPlotArea().getTop(); Double mainBottom = result.getPlotArea().getBottom(); Bounds diagramBounds = new Bounds(mainLeft, mainRight, mainTop, mainBottom); EventBus.getMainEventBus().fireEvent(new SetDomainBoundsEvent(diagramBounds, blocked)); Double overviewRight = new Double(result.getWidth()); Double overviewBottom = new Double(result.getHeight()); Bounds viewportBounds = new Bounds(left, overviewRight, left, overviewBottom); EventBus.getMainEventBus().fireEvent(new SetViewportPixelBoundsEvent(viewportBounds)); List<ImageEntity> ie = new ArrayList<ImageEntity>(); for (ImageEntity imageEntity : result.getImageEntities()) { ie.add(imageEntity); } EventBus.getMainEventBus().fireEvent(new SetImageEntitiesEvent(ie)); EventBus.getOverviewChartEventBus().fireEvent(new SetOverviewDomainBoundsEvent(diagramBounds)); } catch (Exception e) { ExceptionHandler.handleUnexpectedException(e); } finally { Application.setHasStarted(true); result.destroy(); result = null; } } }; // request addRequest(); this.eesDataService.getEESDiagram(request, callback); }
Example 18
Source File: Application.java From SensorWebClient with GNU General Public License v2.0 | 4 votes |
public static void finishStartup() { try { String currentUrl = URL.decode(Window.Location.getHref()); if (hasQueryString(currentUrl) && !isGwtHostedModeParameterOnly()) { String[] services = getDecodedParameters(SERVICES); String[] versions = getDecodedParameters(VERSIONS); String[] features = getDecodedParameters(FEATURES); String[] offerings = getDecodedParameters(OFFERINGS); String[] procedures = getDecodedParameters(PROCEDURES); String[] phenomenons = getDecodedParameters(PHENOMENONS); String[] options = getDecodedParameters("options"); TimeRange timeRange = createTimeRange(); String locale = Window.Location.getParameter("locale"); if (isLocaleOnly(services,versions,offerings,features,procedures,phenomenons,locale)) { return; } if ( !isAllParametersAvailable(services, versions, offerings, features, procedures, phenomenons)) { getToasterInstance().addErrorMessage(i18n.errorUrlParsing()); return; } if (timeRange.isSetStartAndEnd()) { fireNewTimeRangeEvent(timeRange); } PermalinkController permalinkController = new PermalinkController(); for (int i = 0; i < services.length; i++) { final String service = services[i]; final String version = versions[i]; final String offering = offerings[i]; final String procedure = procedures[i]; final String phenomenon = phenomenons[i]; final String feature = features[i]; SosTimeseries sosTimeseries = new SosTimeseries(); sosTimeseries.setFeature(new Feature(feature, service)); sosTimeseries.setOffering(new Offering(offering, service)); sosTimeseries.setPhenomenon(new Phenomenon(phenomenon,service)); sosTimeseries.setSosService(new SosService(service, version)); sosTimeseries.setProcedure(new Procedure(procedure, service)); GWT.log("Timeseries to load: " + sosTimeseries); TimeseriesRenderingOptions tsOptions = null; if (options != null && options.length > i) { tsOptions = createRenderingOptions(options[i]); GWT.log("with options: " + options[i]); permalinkController.addTimeseries(sosTimeseries, tsOptions); } else { permalinkController.addTimeseries(sosTimeseries); } SOSMetadataBuilder builder = new SOSMetadataBuilder() .addServiceURL(service) .addServiceVersion(version); SOSMetadata sosMetadata = new SOSMetadata(builder); getMainEventBus().fireEvent(new StoreSOSMetadataEvent(sosMetadata)); getMainEventBus().fireEvent(new GetPhenomenonsEvent.Builder(service).build()); getMainEventBus().fireEvent(new GetFeatureEvent(service, feature)); getMainEventBus().fireEvent(new GetOfferingEvent(service, offering)); getMainEventBus().fireEvent(new GetProcedureEvent(service, procedure)); getMainEventBus().fireEvent(new GetStationForTimeseriesEvent(sosTimeseries)); getMainEventBus().fireEvent(new GetStationsWithinBBoxEvent(service, null)); getMainEventBus().fireEvent(new NewSOSMetadataEvent()); } } else { showStationSelectorWhenConfigured(); } } catch (Exception e) { if ( !GWT.isProdMode()) { GWT.log("Error evaluating permalink!", e); } showStationSelectorWhenConfigured(); getToasterInstance().addErrorMessage(i18n.errorUrlParsing()); } finally { finalEvents(); } }
Example 19
Source File: Application.java From SensorWebClient with GNU General Public License v2.0 | 4 votes |
private static boolean isGwtHostedModeParameterOnly() { Map<String, List<String>> parameters = Window.Location.getParameterMap(); boolean hasGwtCodesrvParameter = parameters.containsKey("gwt.codesvr"); return !GWT.isProdMode() && parameters.size() == 1 && hasGwtCodesrvParameter; }
Example 20
Source File: RequestManager.java From SensorWebClient with GNU General Public License v2.0 | 4 votes |
public void removeRequest(long duration) { if (!GWT.isProdMode()) GWT.log("Request took " + duration + "ms"); if (requestCount > 0) requestCount--; LoaderManager.getInstance().removeActiveRequest(); }