Author: adietish
Date: 2010-09-10 13:13:20 -0400 (Fri, 10 Sep 2010)
New Revision: 24877
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/JBossComponents.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/util/BundleUtils.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/util/CollectionFilterUtils.java
Log:
[JBIDE-7035] switching from custom component recognition to feature based recognition
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/JBossComponents.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/JBossComponents.java 2010-09-10
17:04:13 UTC (rev 24876)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/reporting/JBossComponents.java 2010-09-10
17:13:20 UTC (rev 24877)
@@ -13,7 +13,10 @@
import java.util.Collection;
import java.util.Set;
import java.util.TreeSet;
+import java.util.regex.Pattern;
+import org.eclipse.core.runtime.IBundleGroup;
+import org.eclipse.core.runtime.IBundleGroupProvider;
import org.jboss.tools.usage.util.BundleUtils;
import org.jboss.tools.usage.util.CollectionFilterUtils;
import org.jboss.tools.usage.util.ICollectionEntryFilter;
@@ -231,7 +234,7 @@
private JBossComponents() {
// inhibit instantiation
}
-
+
/**
* Returns the jboss components that the given bundles are members of
*
@@ -250,4 +253,21 @@
BundleUtils.getBundles(compositeFilter, bundles);
return jbossComponentNames;
}
+
+ private static class JBossBundleGroupNameFilter implements
ICollectionEntryFilter<IBundleGroup> {
+
+ Pattern pattern = Pattern.compile(JBOSS_TOOLS_BUNDLES_PREFIX);
+
+ public boolean matches(IBundleGroup bundleGroup) {
+ return pattern.matcher(bundleGroup.getName()).matches();
+ }
+ }
+
+ public static Collection<String> getComponentIds(IBundleGroupProvider[]
bundleGroupProviders) {
+ Set<String> components = new TreeSet<String>();
+ for (IBundleGroupProvider bundleGroupProvider : bundleGroupProviders) {
+ CollectionFilterUtils.filter(new JBossBundleGroupNameFilter(),
bundleGroupProvider.getBundleGroups());
+ }
+ return components;
+ }
}
\ No newline at end of file
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/util/BundleUtils.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/util/BundleUtils.java 2010-09-10
17:04:13 UTC (rev 24876)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/util/BundleUtils.java 2010-09-10
17:13:20 UTC (rev 24877)
@@ -10,8 +10,7 @@
******************************************************************************/
package org.jboss.tools.usage.util;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Collection;
import java.util.regex.Pattern;
import org.eclipse.core.runtime.Assert;
@@ -29,14 +28,8 @@
* @param bundles the bundles
* @return the bundles that match the given filter
*/
- public static List<Bundle> getBundles(ICollectionEntryFilter<Bundle> filter,
Bundle[] bundles) {
- List<Bundle> bundleList = new ArrayList<Bundle>();
- for (Bundle bundle : bundles) {
- if (filter.matches(bundle)) {
- bundleList.add(bundle);
- }
- }
- return bundleList;
+ public static Collection<Bundle> getBundles(ICollectionEntryFilter<Bundle>
filter, Bundle[] bundles) {
+ return CollectionFilterUtils.filter(filter, bundles);
}
/**
@@ -46,7 +39,7 @@
* @param bundles the bundles
* @return the bundles
*/
- public static List<Bundle> getBundles(String bundleSymbolicNameRegex, Bundle[]
bundles) {
+ public static Collection<Bundle> getBundles(String bundleSymbolicNameRegex,
Bundle[] bundles) {
return getBundles(new BundleSymbolicNameFilter(bundleSymbolicNameRegex), bundles);
}
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/util/CollectionFilterUtils.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/util/CollectionFilterUtils.java 2010-09-10
17:04:13 UTC (rev 24876)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/util/CollectionFilterUtils.java 2010-09-10
17:13:20 UTC (rev 24877)
@@ -10,7 +10,11 @@
******************************************************************************/
package org.jboss.tools.usage.util;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
/**
* @author Andre Dietisheim
*/
@@ -47,4 +51,22 @@
return true;
}
}
+
+ /**
+ * Returns the entries that match the given filter.
+ *
+ * @param filter the filter to match the available entries against
+ * @param entries the entries to filter
+ * @return the entries that match the given filter
+ */
+ public static <E> Collection<E> filter(ICollectionEntryFilter<E>
filter, E[] entries) {
+ List<E> filteredList = new ArrayList<E>();
+ for (E entry : entries) {
+ if (filter.matches(entry)) {
+ filteredList.add(entry);
+ }
+ }
+ return filteredList;
+ }
+
}
Show replies by date