Skip to content

Instantly share code, notes, and snippets.

@timfel
Created November 30, 2009 14:15
Show Gist options
  • Save timfel/245463 to your computer and use it in GitHub Desktop.
Save timfel/245463 to your computer and use it in GitHub Desktop.
abstract class AbstractListView<S extends IDescribable> extends ViewPart implements ISelectionListener {
public java.lang.Class<?> getGenericType() {
ParameterizedType parameterizedType = (ParameterizedType) getClass().getGenericSuperclass();
java.lang.Class<?> rawType = (java.lang.Class<?>) parameterizedType.getRawType();
Type actualType = parameterizedType.getActualTypeArguments()[0];
TypeVariable<?> typeVariable = rawType.getTypeParameters()[0];
return (java.lang.Class<?>) actualType;
}
public Classifier getGenericTypeClassifier() {
try {
return (Classifier) ((java.lang.Class).getGenericType()).getDeclaredField("CLASS").get(getGenericType());
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
return null;
}
}
/**
* This is a general view with a search/filter box that will contain a
* {@link ListComposite}
*/
public class ListView<ModelType extends IDescribable> extends AbstractSearchableListView<ModelType> {
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment