@@ -0,0 +1,1535 @@
+package edu.teco.dnd.eclipse.appView;%0A%0Aimport org.eclipse.swt.widgets.Widget;%0A%0A/**%0A * This class is a wrapper for %7B@link Widget#getData()%7D and %7B@link Widget#setData(Object)%7D that does type checking.%0A * %0A * @author Philipp Adolf%0A */%0Apublic class TypecastingWidgetDataStore%3CT%3E %7B%0A%09private final Class%3CT%3E cls;%0A%09private final String key;%0A%0A%09/**%0A%09 * Initializes a new TypecastingWidgetDataStore.%0A%09 * %0A%09 * @param cls%0A%09 *            the class of the data%0A%09 * @param key%0A%09 *            the key that should be used to store the ApplicationInformation%0A%09 */%0A%09public TypecastingWidgetDataStore(final Class%3CT%3E cls, final String key) %7B%0A%09%09this.cls = cls;%0A%09%09this.key = key;%0A%09%7D%0A%0A%09/**%0A%09 * Stores a value on the given widget.%0A%09 * %0A%09 * @param widget%0A%09 *            the widget the value should be stored on%0A%09 * @param value%0A%09 *            the value to store%0A%09 */%0A%09public void store(final Widget widget, final T value) %7B%0A%09%09widget.setData(key, value);%0A%09%7D%0A%0A%09/**%0A%09 * Retrieves a value from a widget. If there is no value or the value has an incompatible type, null is returned.%0A%09 * %0A%09 * @param widget%0A%09 *            the widget to get the value from%0A%09 * @return the value stored on the object or null if there is no value or the value has an incompatible type%0A%09 */%0A%09@SuppressWarnings(%22unchecked%22)%0A%09public T retrieve(final Widget widget) %7B%0A%09%09final Object object = widget.getData(key);%0A%09%09if (object == null) %7B%0A%09%09%09return null;%0A%09%09%7D%0A%0A%09%09final Class%3C?%3E objClass = object.getClass();%0A%09%09if (cls.isAssignableFrom(objClass)) %7B%0A%09%09%09return (T) object;%0A%09%09%7D%0A%0A%09%09return null;%0A%09%7D%0A%7D%0A

Add TypecastingWidgetDataStore