private final OrderedLayout main;
- ArrayList order = new ArrayList();
+ ArrayList<MyComponent> order = new ArrayList<MyComponent>();
public OrderedLayoutSwapComponents() {
up.addListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
int newIndex = order.indexOf(MyComponent.this) - 1;
- MyComponent old = (MyComponent) order.get(newIndex);
+ MyComponent old = order.get(newIndex);
main.replaceComponent(old, MyComponent.this);
order.remove(MyComponent.this);
order.add(newIndex, MyComponent.this);
down.addListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
int newIndex = order.indexOf(MyComponent.this) + 1;
- MyComponent old = (MyComponent) order.get(newIndex);
+ MyComponent old = order.get(newIndex);
main.replaceComponent(old, MyComponent.this);
order.remove(MyComponent.this);
order.add(newIndex, MyComponent.this);
Panel bodyLayout = new Panel();
- HashMap itemCaptions = new HashMap();
+ // TODO this could probably be a simple Set
+ HashMap<Class<?>, String> itemCaptions = new HashMap<Class<?>, String>();
@Override
public void init() {
for (int p = 0; p < testablePackages.length; p++) {
testables.addItem(testablePackages[p]);
try {
- final List testableClasses = getTestableClassesForPackage(testablePackages[p]);
- for (final Iterator it = testableClasses.iterator(); it
+ final List<Class<?>> testableClasses = getTestableClassesForPackage(testablePackages[p]);
+ for (final Iterator<Class<?>> it = testableClasses.iterator(); it
.hasNext();) {
- final Class t = (Class) it.next();
+ final Class<?> t = it.next();
// ignore TestBench itself
if (t.equals(TestBench.class)) {
continue;
menu = new Tree("Testables", testables);
- for (final Iterator i = itemCaptions.keySet().iterator(); i.hasNext();) {
- final Class testable = (Class) i.next();
+ for (final Iterator<Class<?>> i = itemCaptions.keySet().iterator(); i
+ .hasNext();) {
+ final Class<?> testable = i.next();
// simplify captions
final String name = testable.getName().substring(
testable.getName().lastIndexOf('.') + 1);
menu.setItemCaption(testable, name);
}
// expand all root items
- for (final Iterator i = menu.rootItemIds().iterator(); i.hasNext();) {
+ for (final Iterator<?> i = menu.rootItemIds().iterator(); i.hasNext();) {
menu.expandItemsRecursively(i.next());
}
// try to find a proper test class
// exact match
- Iterator iterator = menu.getItemIds().iterator();
+ Iterator<?> iterator = menu.getItemIds().iterator();
while (iterator.hasNext()) {
Object next = iterator.next();
if (next instanceof Class) {
- Class c = (Class) next;
+ Class<?> c = (Class<?>) next;
String string = c.getName();
if (string.equals(fragment)) {
menu.setValue(c);
while (iterator.hasNext()) {
Object next = iterator.next();
if (next instanceof Class) {
- Class c = (Class) next;
+ Class<?> c = (Class<?>) next;
String string = c.getSimpleName();
if (string.equals(fragment)) {
menu.setValue(c);
while (iterator.hasNext()) {
Object next = iterator.next();
if (next instanceof Class) {
- Class c = (Class) next;
+ Class<?> c = (Class<?>) next;
String string = c.getSimpleName();
if (string.startsWith("Ticket" + fragment)) {
menu.setValue(c);
while (iterator.hasNext()) {
Object next = iterator.next();
if (next instanceof Class) {
- Class c = (Class) next;
+ Class<?> c = (Class<?>) next;
String string = c.getSimpleName();
if (string.toLowerCase().contains(
fragment.toLowerCase())) {
setMainWindow(mainWindow);
}
- private Component createTestable(Class c) {
+ private Component createTestable(Class<?> c) {
try {
final Application app = (Application) c.newInstance();
app.init();
final Object o = menu.getValue();
if (o != null && o instanceof Class) {
- final Class c = (Class) o;
+ final Class<?> c = (Class<?>) o;
final String title = c.getName();
bodyLayout.setCaption(title);
bodyLayout.addComponent(createTestable(c));
* @return
* @throws ClassNotFoundException
*/
- public static List getTestableClassesForPackage(String packageName)
+ public static List<Class<?>> getTestableClassesForPackage(String packageName)
throws Exception {
- final ArrayList directories = new ArrayList();
+ final ArrayList<File> directories = new ArrayList<File>();
try {
final ClassLoader cld = Thread.currentThread()
.getContextClassLoader();
}
final String path = packageName.replace('.', '/');
// Ask for all resources for the path
- final Enumeration resources = cld.getResources(path);
+ final Enumeration<URL> resources = cld.getResources(path);
while (resources.hasMoreElements()) {
- final URL url = (URL) resources.nextElement();
+ final URL url = resources.nextElement();
directories.add(new File(url.getFile()));
}
} catch (final Exception x) {
+ " does not appear to be a valid package.");
}
- final ArrayList classes = new ArrayList();
+ final ArrayList<Class<?>> classes = new ArrayList<Class<?>>();
// For every directory identified capture all the .class files
- for (final Iterator it = directories.iterator(); it.hasNext();) {
- final File directory = (File) it.next();
+ for (final Iterator<File> it = directories.iterator(); it.hasNext();) {
+ final File directory = it.next();
if (directory.exists()) {
// Get the list of the files contained in the package
final String[] files = directory.list();
// removes the .class extension
final String p = packageName + '.'
+ files[j].substring(0, files[j].length() - 6);
- final Class c = Class.forName(p);
+ final Class<?> c = Class.forName(p);
if (c.getSuperclass() != null) {
if ((c.getSuperclass()
.equals(com.vaadin.Application.class))) {