Skip to content

Instantly share code, notes, and snippets.

View fastnsilver's full-sized avatar

Chris Phillipson fastnsilver

View GitHub Profile
@fastnsilver
fastnsilver / CompositeValidatableColumn
Created June 1, 2012 05:02
Snippet of GWT client code attempting to "wrap" a number of ValidatableInputCell invoking onBrowserEvent for each
public class CompositeValidatableColumn<T> extends IdentityColumn<T> {
public CompositeValidatableColumn(WrapperCell<T> cell) {
super(cell);
}
@Override
public WrapperCell<T> getCell() {
return (WrapperCell<T>) super.getCell();
}
@fastnsilver
fastnsilver / WrapperCell
Created June 1, 2012 05:04
WrapperCell is a "knock-off" of GWT's CompositeCell. Provides access to inner cells. Used by CompositeValidatableColumn.
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.cell.client.Cell;
import com.google.gwt.cell.client.FieldUpdater;
import com.google.gwt.cell.client.HasCell;
import com.google.gwt.cell.client.ValueUpdater;
import com.google.gwt.dom.client.Element;
@fastnsilver
fastnsilver / EnergyOffer.addPriceMwColumn
Created June 1, 2012 05:08
Revised method impl for EnergyOfferGrid that composes a number of AbstractValidatableColumns into a CompositeValidatableColumn
protected void addPriceMwColumn(final int colIndex, DisplayMode currentDisplayMode) {
// Construct a composite cell for energy offers that includes a pair of text inputs
final List<HasCell<EnergyOfferDTO, String>> columns = new ArrayList<
HasCell<EnergyOfferDTO, String>>();
// this DTO is passed along so that price and mw values for new entries are kept together
final OfferPriceMwPair newOfferPriceMwPair = new OfferPriceMwPair();
// Price
@fastnsilver
fastnsilver / AbstractValidatatableColumn
Created June 1, 2012 05:27
Custom GWT Column extension that offers JSR-303 client-side support for validating cell value within a column (incl. error message pop-up panel)
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import com.google.gwt.user.cellview.client.AbstractHasData;
import com.google.gwt.user.cellview.client.Column;
/**
@fastnsilver
fastnsilver / ValidatableFieldUpdater
Created June 1, 2012 05:29
Updates field contents of a AbstractValidatableColumn
import java.util.Set;
import javax.validation.ConstraintViolation;
import org.spp.im.mui.gwt.client.module.common.widget.grid.ValidatableInputCell.ValidationData;
import org.spp.im.mui.gwt.shared.i18n.UiMessages;
import com.google.gwt.cell.client.FieldUpdater;
import com.google.gwt.user.cellview.client.AbstractHasData;
import com.google.gwt.view.client.ProvidesKey;
@fastnsilver
fastnsilver / SpringViewProvider.java
Created August 26, 2014 14:43
VaadinView and SpringViewProvider enhanced to discriminate version and name
/*
* Copyright 2014 The original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@fastnsilver
fastnsilver / EventBusListenerMethod.java
Created August 26, 2014 16:48
Possible solution to issues 53 and 70 for Vaadin4Spring
/*
* Copyright 2014 The original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.BasicErrorController;
import org.springframework.boot.autoconfigure.web.ErrorAttributes;
import org.springframework.dao.DataIntegrityViolationException;
@fastnsilver
fastnsilver / gist:4af20978e8994ea1463e
Created March 12, 2015 04:19
Obtain Self Signed Cert
private static SSLContext obtainTrustSelfSignedSSL() {
TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {
@Override
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
@Override
public void checkClientTrusted(java.security.cert.X509Certificate[] arg0, String arg1)
@fastnsilver
fastnsilver / CloudWatchMetricCollector.java
Last active December 15, 2023 15:52
How to configure AWS CloudWatch metrics w/ Spring Boot
// Modeled after {@link org.springframework.cloud.netflix.servo.ServoMetricCollector}
// employed explicitly for publication of AWS CloudWatch metrics
public class CloudWatchMetricCollector {
private final Logger log = LoggerFactory.getLogger(getClass());
@Value("${spring.aws.cloudwatch.metrics.polling.timeUnit:SECONDS}")
private String timeUnit;
@Value("${spring.aws.cloudwatch.metrics.polling.interval:5}")