summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Rennie2013-07-29 15:14:05 (EDT)
committerMike Rennie2013-07-29 15:14:05 (EDT)
commitcdaa70592430f16eb6a38e3ad63391f95a25517f (patch)
tree0e285dbec55b0da330aad2df30bf9c92a23648b2
parent374fa3fa8070a7ff9d119ce17faeeae5a6e5fb17 (diff)
downloadeclipse.pde.ui-cdaa70592430f16eb6a38e3ad63391f95a25517f.zip
eclipse.pde.ui-cdaa70592430f16eb6a38e3ad63391f95a25517f.tar.gz
eclipse.pde.ui-cdaa70592430f16eb6a38e3ad63391f95a25517f.tar.bz2
Bug 413944 - Consider removing generics from the ImageBrowserView /refs/changes/36/14936/1
-rw-r--r--ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/ImageBrowserView.java35
-rw-r--r--ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/AndFilter.java15
-rw-r--r--ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/ElementsFilter.java12
-rw-r--r--ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/IFilter.java9
-rw-r--r--ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/NotFilter.java13
-rw-r--r--ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/OrFilter.java15
-rw-r--r--ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/PatternFilter.java8
-rw-r--r--ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/SizeFilter.java41
8 files changed, 79 insertions, 69 deletions
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/ImageBrowserView.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/ImageBrowserView.java
index 0018688..74e0af5 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/ImageBrowserView.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/ImageBrowserView.java
@@ -39,10 +39,10 @@ public class ImageBrowserView extends ViewPart implements IImageTarget {
private final UpdateUI mUIJob = new UpdateUI();
- private final List<IFilter<ImageElement>> mFilters = new ArrayList<IFilter<ImageElement>>();
- private final IFilter<ImageElement> disabledIcons;
- private final IFilter<ImageElement> enabledIcons;
- private final IFilter<ImageElement> wizard;
+ private final List<IFilter> mFilters = new ArrayList<IFilter>();
+ private final IFilter disabledIcons;
+ private final IFilter enabledIcons;
+ private final IFilter wizard;
private ScrolledComposite scrolledComposite;
private Composite imageComposite;
@@ -58,23 +58,22 @@ public class ImageBrowserView extends ViewPart implements IImageTarget {
private List<Image> displayedImages = new ArrayList<Image>();
- @SuppressWarnings({"unchecked"})
public ImageBrowserView() {
// create default filters
- final IFilter<ImageElement> iconSize = new SizeFilter(16, SizeFilter.TYPE_EXACT, 16, SizeFilter.TYPE_EXACT);
- final IFilter<ImageElement> disabled1 = new PatternFilter(".*/obj16/\\w+dis(_obj)?\\W.+"); //$NON-NLS-1$
- final IFilter<ImageElement> disabled2 = new PatternFilter(".*/d(?!ialogs)(?!ecorations)(?!nd)(?!evguide)\\w+/.+"); //$NON-NLS-1$
- final IFilter<ImageElement> disabled = new OrFilter<ImageElement>(new IFilter[] {disabled1, disabled2});
- disabledIcons = new AndFilter<ImageElement>(new IFilter[] {iconSize, disabled});
+ final IFilter iconSize = new SizeFilter(16, SizeFilter.TYPE_EXACT, 16, SizeFilter.TYPE_EXACT);
+ final IFilter disabled1 = new PatternFilter(".*/obj16/\\w+dis(_obj)?\\W.+"); //$NON-NLS-1$
+ final IFilter disabled2 = new PatternFilter(".*/d(?!ialogs)(?!ecorations)(?!nd)(?!evguide)\\w+/.+"); //$NON-NLS-1$
+ final IFilter disabled = new OrFilter(new IFilter[] {disabled1, disabled2});
+ disabledIcons = new AndFilter(new IFilter[] {iconSize, disabled});
- final IFilter<ImageElement> enabled = new NotFilter<ImageElement>(disabled);
- enabledIcons = new AndFilter<ImageElement>(new IFilter[] {iconSize, enabled});
+ final IFilter enabled = new NotFilter(disabled);
+ enabledIcons = new AndFilter(new IFilter[] {iconSize, enabled});
- final IFilter<ImageElement> wizardSize = new SizeFilter(75, SizeFilter.TYPE_EXACT, 66, SizeFilter.TYPE_EXACT);
- final IFilter<ImageElement> wizard1 = new PatternFilter(".*/wizban/.+"); //$NON-NLS-1$
- final IFilter<ImageElement> wizard2 = new PatternFilter(".+_wiz\\.\\w+"); //$NON-NLS-1$
- final IFilter<ImageElement> wizardName = new OrFilter<ImageElement>(new IFilter[] {wizard1, wizard2});
- wizard = new AndFilter<ImageElement>(new IFilter[] {wizardSize, wizardName});
+ final IFilter wizardSize = new SizeFilter(75, SizeFilter.TYPE_EXACT, 66, SizeFilter.TYPE_EXACT);
+ final IFilter wizard1 = new PatternFilter(".*/wizban/.+"); //$NON-NLS-1$
+ final IFilter wizard2 = new PatternFilter(".+_wiz\\.\\w+"); //$NON-NLS-1$
+ final IFilter wizardName = new OrFilter(new IFilter[] {wizard1, wizard2});
+ wizard = new AndFilter(new IFilter[] {wizardSize, wizardName});
mFilters.add(enabledIcons);
}
@@ -218,7 +217,7 @@ public class ImageBrowserView extends ViewPart implements IImageTarget {
}
public void notifyImage(final ImageElement element) {
- for (final IFilter<ImageElement> filter : mFilters) {
+ for (final IFilter filter : mFilters) {
if (!filter.accept(element))
return;
}
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/AndFilter.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/AndFilter.java
index 7af7095..cb3a866 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/AndFilter.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/AndFilter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Christian Pontesegger and others.
+ * Copyright (c) 2012, 2013 Christian Pontesegger and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,20 +7,23 @@
*
* Contributors:
* Christian Pontesegger - initial API and implementation
+ * IBM Corporation - bugs fixing
*******************************************************************************/
package org.eclipse.pde.internal.ui.views.imagebrowser.filter;
-public class AndFilter<T> implements IFilter<T> {
+import org.eclipse.pde.internal.ui.views.imagebrowser.ImageElement;
- private final IFilter<T>[] mFilter;
+public class AndFilter implements IFilter {
- public AndFilter(final IFilter<T>[] filter) {
+ private final IFilter[] mFilter;
+
+ public AndFilter(final IFilter[] filter) {
mFilter = filter;
}
- public boolean accept(final T element) {
- for (IFilter<T> filter : mFilter) {
+ public boolean accept(final ImageElement element) {
+ for (IFilter filter : mFilter) {
if (!filter.accept(element))
return false;
}
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/ElementsFilter.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/ElementsFilter.java
index 191cdba..d1c63ba 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/ElementsFilter.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/ElementsFilter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Christian Pontesegger and others.
+ * Copyright (c) 2012, 2013 Christian Pontesegger and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,18 +7,15 @@
*
* Contributors:
* Christian Pontesegger - initial API and implementation
+ * IBM Corporation - bugs fixing
*******************************************************************************/
package org.eclipse.pde.internal.ui.views.imagebrowser.filter;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-
+import java.util.*;
import org.eclipse.pde.internal.ui.views.imagebrowser.ImageElement;
-
-public class ElementsFilter implements IFilter<ImageElement> {
+public class ElementsFilter implements IFilter {
private final List<ImageElement> mElements = new LinkedList<ImageElement>();
@@ -33,6 +30,7 @@ public class ElementsFilter implements IFilter<ImageElement> {
return mElements.contains(element);
}
+ @Override
public String toString() {
return "Displayed images"; //$NON-NLS-1$
}
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/IFilter.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/IFilter.java
index 7b04cd4..c4d2852 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/IFilter.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/IFilter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Christian Pontesegger and others.
+ * Copyright (c) 2012, 2013 Christian Pontesegger and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,11 +7,14 @@
*
* Contributors:
* Christian Pontesegger - initial API and implementation
+ * IBM Corporation - bugs fixing
*******************************************************************************/
package org.eclipse.pde.internal.ui.views.imagebrowser.filter;
-public interface IFilter<T> {
+import org.eclipse.pde.internal.ui.views.imagebrowser.ImageElement;
- boolean accept(T element);
+public interface IFilter {
+
+ boolean accept(ImageElement element);
}
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/NotFilter.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/NotFilter.java
index 1757bff..096b493 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/NotFilter.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/NotFilter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Christian Pontesegger and others.
+ * Copyright (c) 2012, 2013 Christian Pontesegger and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,19 +7,22 @@
*
* Contributors:
* Christian Pontesegger - initial API and implementation
+ * IBM Corporation - bugs fixing
*******************************************************************************/
package org.eclipse.pde.internal.ui.views.imagebrowser.filter;
-public class NotFilter<T> implements IFilter<T> {
+import org.eclipse.pde.internal.ui.views.imagebrowser.ImageElement;
- private final IFilter<T> mFilter;
+public class NotFilter implements IFilter {
- public NotFilter(final IFilter<T> filter) {
+ private final IFilter mFilter;
+
+ public NotFilter(final IFilter filter) {
mFilter = filter;
}
- public boolean accept(final T element) {
+ public boolean accept(final ImageElement element) {
return !mFilter.accept(element);
}
}
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/OrFilter.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/OrFilter.java
index d460f0c..acf21a8 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/OrFilter.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/OrFilter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Christian Pontesegger and others.
+ * Copyright (c) 2012, 2013 Christian Pontesegger and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,20 +7,23 @@
*
* Contributors:
* Christian Pontesegger - initial API and implementation
+ * IBM Corporation - bugs fixing
*******************************************************************************/
package org.eclipse.pde.internal.ui.views.imagebrowser.filter;
-public class OrFilter<T> implements IFilter<T> {
+import org.eclipse.pde.internal.ui.views.imagebrowser.ImageElement;
- private final IFilter<T>[] mFilter;
+public class OrFilter implements IFilter {
- public OrFilter(final IFilter<T>[] filter) {
+ private final IFilter[] mFilter;
+
+ public OrFilter(final IFilter[] filter) {
mFilter = filter;
}
- public boolean accept(final T element) {
- for (IFilter<T> filter : mFilter) {
+ public boolean accept(final ImageElement element) {
+ for (IFilter filter : mFilter) {
if (filter.accept(element))
return true;
}
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/PatternFilter.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/PatternFilter.java
index 79bd14a..b42cf2c 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/PatternFilter.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/PatternFilter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Christian Pontesegger and others.
+ * Copyright (c) 2012, 2013 Christian Pontesegger and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,16 +7,15 @@
*
* Contributors:
* Christian Pontesegger - initial API and implementation
+ * IBM Corporation - bugs fixing
*******************************************************************************/
package org.eclipse.pde.internal.ui.views.imagebrowser.filter;
import java.util.regex.Pattern;
-
import org.eclipse.pde.internal.ui.views.imagebrowser.ImageElement;
-
-public class PatternFilter implements IFilter<ImageElement> {
+public class PatternFilter implements IFilter {
private final Pattern mPattern;
@@ -28,6 +27,7 @@ public class PatternFilter implements IFilter<ImageElement> {
return mPattern.matcher(element.getPlugin() + "/" + element.getPath()).matches(); //$NON-NLS-1$
}
+ @Override
public String toString() {
return "match " + mPattern.pattern(); //$NON-NLS-1$
}
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/SizeFilter.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/SizeFilter.java
index f1e27b6..196ec81 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/SizeFilter.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/views/imagebrowser/filter/SizeFilter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Christian Pontesegger and others.
+ * Copyright (c) 2012, 2013 Christian Pontesegger and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,13 +7,14 @@
*
* Contributors:
* Christian Pontesegger - initial API and implementation
+ * IBM Corporation - bugs fixing
*******************************************************************************/
package org.eclipse.pde.internal.ui.views.imagebrowser.filter;
import org.eclipse.pde.internal.ui.views.imagebrowser.ImageElement;
-public class SizeFilter implements IFilter<ImageElement> {
+public class SizeFilter implements IFilter {
public static final int TYPE_EXACT = 0;
public static final int TYPE_BIGGER_EQUALS = 1;
@@ -34,27 +35,27 @@ public class SizeFilter implements IFilter<ImageElement> {
boolean accept = true;
switch (mWidthType) {
- case TYPE_EXACT:
- accept &= (element.getImageData().width == mWidth);
- break;
- case TYPE_BIGGER_EQUALS:
- accept &= (element.getImageData().width >= mWidth);
- break;
- case TYPE_SMALLER_EQUALS:
- accept &= (element.getImageData().width <= mWidth);
- break;
+ case TYPE_EXACT :
+ accept &= (element.getImageData().width == mWidth);
+ break;
+ case TYPE_BIGGER_EQUALS :
+ accept &= (element.getImageData().width >= mWidth);
+ break;
+ case TYPE_SMALLER_EQUALS :
+ accept &= (element.getImageData().width <= mWidth);
+ break;
}
switch (mHeightType) {
- case TYPE_EXACT:
- accept &= (element.getImageData().height == mHeight);
- break;
- case TYPE_BIGGER_EQUALS:
- accept &= (element.getImageData().height >= mHeight);
- break;
- case TYPE_SMALLER_EQUALS:
- accept &= (element.getImageData().height <= mHeight);
- break;
+ case TYPE_EXACT :
+ accept &= (element.getImageData().height == mHeight);
+ break;
+ case TYPE_BIGGER_EQUALS :
+ accept &= (element.getImageData().height >= mHeight);
+ break;
+ case TYPE_SMALLER_EQUALS :
+ accept &= (element.getImageData().height <= mHeight);
+ break;
}
return accept;