Java Code Examples for com.google.gwt.core.client.GWT#log()

The following examples show how to use com.google.gwt.core.client.GWT#log() . 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: ClientUtils.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param begin
 *        in millis
 * @param end
 *        in millis
 * @return if given time range is allowed with respect to <code>minTimeFrameZoom</code> parameter.
 */
public static boolean isValidTimeFrameForZoomIn(long begin, long end) {
    long minTime = 1;
    String parameter = getPropertiesManager().getParameterAsString("minTimeFrameZoom");
    try {
        minTime = Long.parseLong(parameter);
    }
    catch (Exception e) {
        GWT.log("Could not read property minTimeFrameZoom: " + parameter);
    }
    if ( (end - begin) >= (minTime * 1000 * 60)) {
        return true;
    }
    Toaster.getToasterInstance().addMessage(i18n.maxZoomInTime());
    return false;
}
 
Example 2
Source File: StationSelectorMap.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
public StationSelectorMap(MapController controller) {
    super("523px"); // XXX map needs explicit height in px
    getMapWidget().setStylePrimaryName("n52-sensorwebclient-stationselector-map");
    this.controller = controller;
    map.addLayer(markerLayer);
    try {
        if (isDefinedGlobalExtent()) {
            PropertiesManager propertiesMgr = getPropertiesManager();
            double lleftX = new Double(propertiesMgr.getParameterAsString("lleftX"));
            double lleftY = new Double(propertiesMgr.getParameterAsString("lleftY"));
            double urightX = new Double(propertiesMgr.getParameterAsString("urightX"));
            double urightY = new Double(propertiesMgr.getParameterAsString("urightY"));
            defaultExtent = new Bounds(lleftX, lleftY, urightX, urightY);
        }
        else {
            GWT.log("No global extent configured. Zooming to: " + FALLBACK_EXTENT);
            defaultExtent = FALLBACK_EXTENT;
        }
    }
    catch (NumberFormatException e) {
        GWT.log("Error while parsing configured bounding box. Zooming to: " + FALLBACK_EXTENT);
        defaultExtent = FALLBACK_EXTENT;
    }
    zoomToExtent(defaultExtent);
}
 
Example 3
Source File: DateUtils.java    From swellrt with Apache License 2.0 6 votes vote down vote up
/**
 * Package-private version, takes a fixed "now" time - used for testing
 */
String formatPastDate(Date date, Date now) {

  // NOTE(zdwang): For now skip it for junit code; also see formatDateTime()
  if (!GWT.isClient()) {
    return "formatPastDate is not yet implemented in unit test code";
  }

  if (!isValid(date, now)) {
    GWT.log("formatPastDate can only format time in the past, trying anyway", null);
  }

  if (isRecent(date, now, 6 * HOUR_MS) || onSameDay(date, now)) {
    return formatTime(date);
  } else if (isRecent(date, now, 30 * DAY_MS)) {
    return getMonthDayFormat().format(date) + " " + formatTime(date);
  } else if (isSameYear(date, now)) {
    return getMonthDayFormat().format(date);
  } else {
    return DateTimeFormat.getMediumDateFormat().format(date);
  }
}
 
Example 4
Source File: DateUtils.java    From incubator-retired-wave with Apache License 2.0 6 votes vote down vote up
/**
 * Package-private version, takes a fixed "now" time - used for testing
 */
String formatPastDate(Date date, Date now) {

  // NOTE(zdwang): For now skip it for junit code; also see formatDateTime()
  if (!GWT.isClient()) {
    return "formatPastDate is not yet implemented in unit test code";
  }

  if (!isValid(date, now)) {
    GWT.log("formatPastDate can only format time in the past, trying anyway", null);
  }

  if (isRecent(date, now, 6 * HOUR_MS) || onSameDay(date, now)) {
    return formatTime(date);
  } else if (isRecent(date, now, 30 * DAY_MS)) {
    return getMonthDayFormat().format(date) + " " + formatTime(date);
  } else if (isSameYear(date, now)) {
    return getMonthDayFormat().format(date);
  } else {
    return DateTimeFormat.getMediumDateFormat().format(date);
  }
}
 
Example 5
Source File: MaterialListValueBox.java    From gwt-material with Apache License 2.0 6 votes vote down vote up
public void setEmptyPlaceHolder(String value) {
    if (value == null) {
        // about to un-set emptyPlaceHolder
        if (emptyPlaceHolder != null) {
            // emptyPlaceHolder is about to change from null to non-null
            if (isEmptyPlaceHolderListed()) {
                // indeed first item is actually emptyPlaceHolder
                removeEmptyPlaceHolder();
            } else {
                GWT.log("WARNING: emptyPlaceHolder is set but not listed.", new IllegalStateException());
            }
        }   // else no change
    } else {
        if (!value.equals(emptyPlaceHolder)) {
            // adding emptyPlaceHolder
            insertEmptyPlaceHolder(value);
        }   // else no change
    }

    emptyPlaceHolder = value;
}
 
Example 6
Source File: SOSSelectionChangedHandler.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
private void parseAndSetServiceConfiguration(SOSMetadataBuilder builder, Record record) {
	try {
	    builder.addServiceURL(getValueFor(record, "url"))
	           .addServiceName(getValueFor(record, "itemName"))
                  .addServiceVersion(getValueFor(record, "version"))
                  .setWaterML(Boolean.parseBoolean(getValueFor(record, "waterML")))
                  .setForceXYAxisOrder(Boolean.parseBoolean(getValueFor(record, "forceXYAxisOrder")))
                  .setAutoZoom(Boolean.parseBoolean(getValueFor(record, "autoZoom")))
                  .setRequestChunk(Integer.parseInt(getValueFor(record, "requestChunk")))
                  //.addDefaultZoom(Integer.parseInt(getValueFor(record, "defaultZoom")))
                  .setEnableEventing(Boolean.parseBoolean(getValueFor(record, "enableEventing")))
                  .withExtent(createBoundingBox(record));
	} catch (Exception e) {
		GWT.log("Could not parse SERVICES configuration for: " + builder.getServiceURL(), e);
	}
}
 
Example 7
Source File: GanttConnector.java    From gantt with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isTwelveHourClock() {
    try {
        return LocaleService.isTwelveHourClock(locale);
    } catch (LocaleNotLoadedException e) {
        GWT.log(e.getMessage(), e);
    }
    return false;
}
 
Example 8
Source File: ServiceWorkerManager.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onServerFailing(ServiceEvent event) {
    GWT.log("Can't connect to the server at the moment.", new RuntimeException());

    for (ServiceWorkerPlugin plugin : plugins.values()) {
        if(plugin.onServerFailing(event) || event.isStopPropagation()) {
            break; // Stop propagation
        }
    }

    if (isUsingDefaultPlugin() && !event.isPreventDefault()) {
        defaultPlugin.onServerFailing(event);
    }
    return false;
}
 
Example 9
Source File: ServiceWorkerManager.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onOffline(ServiceEvent event) {
    GWT.log("Network Status is now offline");

    for (ServiceWorkerPlugin plugin : plugins.values()) {
        if(plugin.onOffline(event) || event.isStopPropagation()) {
            break; // Stop propagation
        }
    }

    if (isUsingDefaultPlugin() && !event.isPreventDefault()) {
        defaultPlugin.onOffline(event);
    }
    return false;
}
 
Example 10
Source File: ExceptionHandler.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
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 11
Source File: MaterialTooltip.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
public void setAttribute(String attr, String value) {
    if (widget != null) {
        AttachEvent.Handler handler = event -> {
            widget.getElement().setAttribute(attr, value);
        };
        if (widget.isAttached()) {
            handler.onAttachOrDetach(null);
        } else {
            EventHelper.onAttachOnce(widget, handler);
        }
    } else {
        GWT.log("Please initialize the Target widget.", new IllegalStateException());
    }
}
 
Example 12
Source File: ClearOnKeyUpMixin.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
protected void applyClearOnKeyUp() {
    if (uiObject != null){
        uiObject.addKeyUpHandler(event -> {
            if (event.getNativeKeyCode() == getClearKeyCode()) {
                uiObject.reset();
                setPlaceholderActive(true);
            }
        });
    } else {
        GWT.log("Target element to register the keyup event is null", new NullPointerException());
    }
}
 
Example 13
Source File: EditorHarness.java    From swellrt with Apache License 2.0 5 votes vote down vote up
/**
 * Logs an error exception and shouts error!
 *
 * @param t
 */
private void logUncaughtExceptions(Throwable t) {
  showRedFatalIndicator();
  logger.fatal().log(t);
  logger.trace();
  GWT.log("Uncaught Exception", t);
  t.printStackTrace(System.err);
}
 
Example 14
Source File: EventBus.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
@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 15
Source File: MaterialWebpImage.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
protected void extractFallbackExtension(String fallbackExtension) {
    if (getUrl() != null && !getUrl().isEmpty()) {
        String fallbackUrl = getUrl();
        if (fallbackUrl.indexOf(".") > 0) {
            fallbackUrl = fallbackUrl.substring(0, fallbackUrl.lastIndexOf(".")) + "." + fallbackExtension;
            setFallbackUrl(fallbackUrl);
        }
        return;
    } else {
        GWT.log("Url must not be null or empty", new IllegalStateException());
    }
}
 
Example 16
Source File: TimelineWidget.java    From gantt with Apache License 2.0 5 votes vote down vote up
private void fillTimelineForResolution(final long startDate, long endDate, final int left) {
    if (resolution == Resolution.Day || resolution == Resolution.Week) {
        fillTimelineForDayResolution(startDate, endDate, left);
    } else if (resolution == Resolution.Hour) {
        fillTimelineForHourResolution(startDate, endDate, left);
    } else {
        GWT.log(getClass().getSimpleName() + " resolution " + (resolution != null ? resolution.name() : "null")
                + " is not supported");
        return;
    }

    GWT.log(getClass().getSimpleName() + " Filled new data and styles to visible timeline elements");
}
 
Example 17
Source File: ServiceWorkerPlugin.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onActivated(ServiceEvent event) {
    GWT.log("ServiceWorker State : Activated");
    return false;
}
 
Example 18
Source File: Log.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static void debug(String message) {
	try {
		GWT.log("debug: " + message, null);
	} catch (Throwable t) {
	}
}
 
Example 19
Source File: ContactsView.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
@UiHandler("contactTable")
void onRowClik(RowClickEvent event) {
	GWT.log("" + event.<Person> getValue().getName());
}
 
Example 20
Source File: DefaultMvp4gLogger.java    From mvp4g with Apache License 2.0 4 votes vote down vote up
public void log(String message,
                int depth) {
  GWT.log(createLog(message,
                    depth),
          null);
}