aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/ResourceDeltaKind.java5
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/ResourceHelper.java109
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/CountryCodeQualifier.java9
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/DockModeQualifier.java9
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/KeyboardStateQualifier.java8
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/LanguageQualifier.java9
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/NavigationMethodQualifier.java9
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/NavigationStateQualifier.java8
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/NetworkCodeQualifier.java9
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/NightModeQualifier.java8
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/PixelDensityQualifier.java8
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/RegionQualifier.java9
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ResourceQualifier.java6
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenDimensionQualifier.java9
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenOrientationQualifier.java8
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenRatioQualifier.java8
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenSizeQualifier.java8
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/TextInputMethodQualifier.java8
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/TouchScreenQualifier.java8
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/VersionQualifier.java9
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/FrameworkResources.java8
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ProjectResources.java13
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceFolder.java9
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceItem.java13
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceManager.java12
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceRepository.java17
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/ui/ConfigurationSelector.java3
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/ui/ReferenceChooserDialog.java4
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/ui/ResourceChooser.java7
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/resources/ResourceHelperTest.java114
30 files changed, 271 insertions, 193 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/ResourceDeltaKind.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/ResourceDeltaKind.java
new file mode 100644
index 0000000..80a0ec7
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/ResourceDeltaKind.java
@@ -0,0 +1,5 @@
+package com.android.ide.eclipse.adt.internal.resources;
+
+public enum ResourceDeltaKind {
+ CHANGED, ADDED, REMOVED;
+}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/ResourceHelper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/ResourceHelper.java
index 568174c..4d482f5 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/ResourceHelper.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/ResourceHelper.java
@@ -16,25 +16,112 @@
package com.android.ide.eclipse.adt.internal.resources;
-import com.android.ide.eclipse.adt.internal.resources.manager.ResourceItem;
-import com.android.resources.ResourceType;
+import com.android.ide.eclipse.adt.internal.editors.IconFactory;
+import com.android.ide.eclipse.adt.internal.resources.configurations.CountryCodeQualifier;
+import com.android.ide.eclipse.adt.internal.resources.configurations.DockModeQualifier;
+import com.android.ide.eclipse.adt.internal.resources.configurations.KeyboardStateQualifier;
+import com.android.ide.eclipse.adt.internal.resources.configurations.LanguageQualifier;
+import com.android.ide.eclipse.adt.internal.resources.configurations.NavigationMethodQualifier;
+import com.android.ide.eclipse.adt.internal.resources.configurations.NavigationStateQualifier;
+import com.android.ide.eclipse.adt.internal.resources.configurations.NetworkCodeQualifier;
+import com.android.ide.eclipse.adt.internal.resources.configurations.NightModeQualifier;
+import com.android.ide.eclipse.adt.internal.resources.configurations.PixelDensityQualifier;
+import com.android.ide.eclipse.adt.internal.resources.configurations.RegionQualifier;
+import com.android.ide.eclipse.adt.internal.resources.configurations.ResourceQualifier;
+import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenDimensionQualifier;
+import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenOrientationQualifier;
+import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenRatioQualifier;
+import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenSizeQualifier;
+import com.android.ide.eclipse.adt.internal.resources.configurations.TextInputMethodQualifier;
+import com.android.ide.eclipse.adt.internal.resources.configurations.TouchScreenQualifier;
+import com.android.ide.eclipse.adt.internal.resources.configurations.VersionQualifier;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.swt.graphics.Image;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Helper class to deal with SWT specifics for the resources.
+ */
public class ResourceHelper {
+ private final static Map<Class<?>, Image> ICON_MAP = new HashMap<Class<?>, Image>(20);
+
/**
- * Returns a formatted string usable in an XML to use the specified {@link ResourceItem}.
- * @param resourceItem The resource item.
- * @param system Whether this is a system resource or a project resource.
- * @return a string in the format @[type]/[name]
+ * Returns the icon for the qualifier.
*/
- public static String getXmlString(ResourceType type, ResourceItem resourceItem,
- boolean system) {
- if (type == ResourceType.ID && resourceItem.isDeclaredInline()) {
- return (system?"@android:":"@+") + type.getName() + "/" + resourceItem.getName(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ public static Image getIcon(Class<? extends ResourceQualifier> theClass) {
+ Image image = ICON_MAP.get(theClass);
+ if (image == null) {
+ image = computeImage(theClass);
+ ICON_MAP.put(theClass, image);
+ }
+
+ return image;
+ }
+
+ private static Image computeImage(Class<? extends ResourceQualifier> theClass) {
+ if (theClass == CountryCodeQualifier.class) {
+ return IconFactory.getInstance().getIcon("mcc"); //$NON-NLS-1$
+ } else if (theClass == NetworkCodeQualifier.class) {
+ return IconFactory.getInstance().getIcon("mnc"); //$NON-NLS-1$
+ } else if (theClass == LanguageQualifier.class) {
+ return IconFactory.getInstance().getIcon("language"); //$NON-NLS-1$
+ } else if (theClass == RegionQualifier.class) {
+ return IconFactory.getInstance().getIcon("region"); //$NON-NLS-1$
+ } else if (theClass == ScreenSizeQualifier.class) {
+ return IconFactory.getInstance().getIcon("size"); //$NON-NLS-1$
+ } else if (theClass == ScreenRatioQualifier.class) {
+ return IconFactory.getInstance().getIcon("ratio"); //$NON-NLS-1$
+ } else if (theClass == ScreenOrientationQualifier.class) {
+ return IconFactory.getInstance().getIcon("orientation"); //$NON-NLS-1$
+ } else if (theClass == DockModeQualifier.class) {
+ return IconFactory.getInstance().getIcon("dockmode"); //$NON-NLS-1$
+ } else if (theClass == NightModeQualifier.class) {
+ return IconFactory.getInstance().getIcon("nightmode"); //$NON-NLS-1$
+ } else if (theClass == PixelDensityQualifier.class) {
+ return IconFactory.getInstance().getIcon("dpi"); //$NON-NLS-1$
+ } else if (theClass == TouchScreenQualifier.class) {
+ return IconFactory.getInstance().getIcon("touch"); //$NON-NLS-1$
+ } else if (theClass == KeyboardStateQualifier.class) {
+ return IconFactory.getInstance().getIcon("keyboard"); //$NON-NLS-1$
+ } else if (theClass == TextInputMethodQualifier.class) {
+ return IconFactory.getInstance().getIcon("text_input"); //$NON-NLS-1$
+ } else if (theClass == NavigationStateQualifier.class) {
+ return IconFactory.getInstance().getIcon("navpad"); //$NON-NLS-1$
+ } else if (theClass == NavigationMethodQualifier.class) {
+ return IconFactory.getInstance().getIcon("navpad"); //$NON-NLS-1$
+ } else if (theClass == ScreenDimensionQualifier.class) {
+ return IconFactory.getInstance().getIcon("dimension"); //$NON-NLS-1$
+ } else if (theClass == VersionQualifier.class) {
+ return IconFactory.getInstance().getIcon("version"); //$NON-NLS-1$
}
- return (system?"@android:":"@") + type.getName() + "/" + resourceItem.getName(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ // this can only happen if we forget to add a class above.
+ return null;
}
+ /**
+ * Returns a {@link ResourceDeltaKind} from an {@link IResourceDelta} value.
+ * @param kind a {@link IResourceDelta} integer constant.
+ * @return a matching {@link ResourceDeltaKind} or null.
+ *
+ * @see IResourceDelta#ADDED
+ * @see IResourceDelta#REMOVED
+ * @see IResourceDelta#CHANGED
+ */
+ public static ResourceDeltaKind getResourceDeltaKind(int kind) {
+ switch (kind) {
+ case IResourceDelta.ADDED:
+ return ResourceDeltaKind.ADDED;
+ case IResourceDelta.REMOVED:
+ return ResourceDeltaKind.REMOVED;
+ case IResourceDelta.CHANGED:
+ return ResourceDeltaKind.CHANGED;
+ }
+
+ return null;
+ }
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/CountryCodeQualifier.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/CountryCodeQualifier.java
index fcad2dc..42dc6e1 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/CountryCodeQualifier.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/CountryCodeQualifier.java
@@ -16,10 +16,6 @@
package com.android.ide.eclipse.adt.internal.resources.configurations;
-import com.android.ide.eclipse.adt.internal.editors.IconFactory;
-
-import org.eclipse.swt.graphics.Image;
-
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -98,11 +94,6 @@ public final class CountryCodeQualifier extends ResourceQualifier {
}
@Override
- public Image getIcon() {
- return IconFactory.getInstance().getIcon("mcc"); //$NON-NLS-1$
- }
-
- @Override
public boolean isValid() {
return mCode != DEFAULT_CODE;
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/DockModeQualifier.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/DockModeQualifier.java
index 37af3b4..32dab22 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/DockModeQualifier.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/DockModeQualifier.java
@@ -16,12 +16,9 @@
package com.android.ide.eclipse.adt.internal.resources.configurations;
-import com.android.ide.eclipse.adt.internal.editors.IconFactory;
import com.android.resources.DockMode;
import com.android.resources.ResourceEnum;
-import org.eclipse.swt.graphics.Image;
-
/**
* Resource Qualifier for Navigation Method.
*/
@@ -58,12 +55,6 @@ public final class DockModeQualifier extends EnumBasedResourceQualifier {
return "Dock Mode";
}
-
- @Override
- public Image getIcon() {
- return IconFactory.getInstance().getIcon("dockmode"); //$NON-NLS-1$
- }
-
@Override
public boolean checkAndSet(String value, FolderConfiguration config) {
DockMode mode = DockMode.getEnum(value);
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/KeyboardStateQualifier.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/KeyboardStateQualifier.java
index 3cf6091..3b331f7 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/KeyboardStateQualifier.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/KeyboardStateQualifier.java
@@ -16,12 +16,9 @@
package com.android.ide.eclipse.adt.internal.resources.configurations;
-import com.android.ide.eclipse.adt.internal.editors.IconFactory;
import com.android.resources.KeyboardState;
import com.android.resources.ResourceEnum;
-import org.eclipse.swt.graphics.Image;
-
/**
* Resource Qualifier for keyboard state.
*/
@@ -59,11 +56,6 @@ public final class KeyboardStateQualifier extends EnumBasedResourceQualifier {
}
@Override
- public Image getIcon() {
- return IconFactory.getInstance().getIcon("keyboard"); //$NON-NLS-1$
- }
-
- @Override
public boolean checkAndSet(String value, FolderConfiguration config) {
KeyboardState orientation = KeyboardState.getEnum(value);
if (orientation != null) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/LanguageQualifier.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/LanguageQualifier.java
index 2686eac..73809a1 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/LanguageQualifier.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/LanguageQualifier.java
@@ -16,10 +16,6 @@
package com.android.ide.eclipse.adt.internal.resources.configurations;
-import com.android.ide.eclipse.adt.internal.editors.IconFactory;
-
-import org.eclipse.swt.graphics.Image;
-
import java.util.regex.Pattern;
/**
@@ -90,11 +86,6 @@ public final class LanguageQualifier extends ResourceQualifier {
}
@Override
- public Image getIcon() {
- return IconFactory.getInstance().getIcon("language"); //$NON-NLS-1$
- }
-
- @Override
public boolean isValid() {
return mValue != null;
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/NavigationMethodQualifier.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/NavigationMethodQualifier.java
index 5faa293..32020d9 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/NavigationMethodQualifier.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/NavigationMethodQualifier.java
@@ -16,12 +16,9 @@
package com.android.ide.eclipse.adt.internal.resources.configurations;
-import com.android.ide.eclipse.adt.internal.editors.IconFactory;
import com.android.resources.Navigation;
import com.android.resources.ResourceEnum;
-import org.eclipse.swt.graphics.Image;
-
/**
* Resource Qualifier for Navigation Method.
*/
@@ -58,12 +55,6 @@ public final class NavigationMethodQualifier extends EnumBasedResourceQualifier
return NAME;
}
-
- @Override
- public Image getIcon() {
- return IconFactory.getInstance().getIcon("navpad"); //$NON-NLS-1$
- }
-
@Override
public boolean checkAndSet(String value, FolderConfiguration config) {
Navigation method = Navigation.getEnum(value);
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/NavigationStateQualifier.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/NavigationStateQualifier.java
index 8cea2d3..d1f6513 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/NavigationStateQualifier.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/NavigationStateQualifier.java
@@ -16,12 +16,9 @@
package com.android.ide.eclipse.adt.internal.resources.configurations;
-import com.android.ide.eclipse.adt.internal.editors.IconFactory;
import com.android.resources.NavigationState;
import com.android.resources.ResourceEnum;
-import org.eclipse.swt.graphics.Image;
-
/**
* Resource Qualifier for navigation state.
*/
@@ -59,11 +56,6 @@ public final class NavigationStateQualifier extends EnumBasedResourceQualifier {
}
@Override
- public Image getIcon() {
- return IconFactory.getInstance().getIcon("navpad"); //$NON-NLS-1$
- }
-
- @Override
public boolean checkAndSet(String value, FolderConfiguration config) {
NavigationState state = NavigationState.getEnum(value);
if (state != null) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/NetworkCodeQualifier.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/NetworkCodeQualifier.java
index 4ef0c75..63dddea 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/NetworkCodeQualifier.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/NetworkCodeQualifier.java
@@ -16,10 +16,6 @@
package com.android.ide.eclipse.adt.internal.resources.configurations;
-import com.android.ide.eclipse.adt.internal.editors.IconFactory;
-
-import org.eclipse.swt.graphics.Image;
-
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -98,11 +94,6 @@ public final class NetworkCodeQualifier extends ResourceQualifier {
}
@Override
- public Image getIcon() {
- return IconFactory.getInstance().getIcon("mnc"); //$NON-NLS-1$
- }
-
- @Override
public boolean isValid() {
return mCode != DEFAULT_CODE;
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/NightModeQualifier.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/NightModeQualifier.java
index 15aea6b..058bea7 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/NightModeQualifier.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/NightModeQualifier.java
@@ -16,12 +16,9 @@
package com.android.ide.eclipse.adt.internal.resources.configurations;
-import com.android.ide.eclipse.adt.internal.editors.IconFactory;
import com.android.resources.NightMode;
import com.android.resources.ResourceEnum;
-import org.eclipse.swt.graphics.Image;
-
/**
* Resource Qualifier for Navigation Method.
*/
@@ -59,11 +56,6 @@ public final class NightModeQualifier extends EnumBasedResourceQualifier {
}
@Override
- public Image getIcon() {
- return IconFactory.getInstance().getIcon("nightmode"); //$NON-NLS-1$
- }
-
- @Override
public boolean checkAndSet(String value, FolderConfiguration config) {
NightMode mode = NightMode.getEnum(value);
if (mode != null) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/PixelDensityQualifier.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/PixelDensityQualifier.java
index 32fc0c5..e730a39 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/PixelDensityQualifier.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/PixelDensityQualifier.java
@@ -16,12 +16,9 @@
package com.android.ide.eclipse.adt.internal.resources.configurations;
-import com.android.ide.eclipse.adt.internal.editors.IconFactory;
import com.android.resources.Density;
import com.android.resources.ResourceEnum;
-import org.eclipse.swt.graphics.Image;
-
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -63,11 +60,6 @@ public final class PixelDensityQualifier extends EnumBasedResourceQualifier {
}
@Override
- public Image getIcon() {
- return IconFactory.getInstance().getIcon("dpi"); //$NON-NLS-1$
- }
-
- @Override
public boolean checkAndSet(String value, FolderConfiguration config) {
Density density = Density.getEnum(value);
if (density == null) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/RegionQualifier.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/RegionQualifier.java
index dfe02cf..2a9bd36 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/RegionQualifier.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/RegionQualifier.java
@@ -16,10 +16,6 @@
package com.android.ide.eclipse.adt.internal.resources.configurations;
-import com.android.ide.eclipse.adt.internal.editors.IconFactory;
-
-import org.eclipse.swt.graphics.Image;
-
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -94,11 +90,6 @@ public final class RegionQualifier extends ResourceQualifier {
}
@Override
- public Image getIcon() {
- return IconFactory.getInstance().getIcon("region"); //$NON-NLS-1$
- }
-
- @Override
public boolean isValid() {
return mValue != null;
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ResourceQualifier.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ResourceQualifier.java
index b4d9a34..14d6bd0 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ResourceQualifier.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ResourceQualifier.java
@@ -16,7 +16,6 @@
package com.android.ide.eclipse.adt.internal.resources.configurations;
-import org.eclipse.swt.graphics.Image;
/**
* Base class for resource qualifiers.
@@ -36,11 +35,6 @@ public abstract class ResourceQualifier implements Comparable<ResourceQualifier>
public abstract String getShortName();
/**
- * Returns the icon for the qualifier.
- */
- public abstract Image getIcon();
-
- /**
* Returns whether the qualifier has a valid filter value.
*/
public abstract boolean isValid();
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenDimensionQualifier.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenDimensionQualifier.java
index c9ff7c2..61fa94e 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenDimensionQualifier.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenDimensionQualifier.java
@@ -16,10 +16,6 @@
package com.android.ide.eclipse.adt.internal.resources.configurations;
-import com.android.ide.eclipse.adt.internal.editors.IconFactory;
-
-import org.eclipse.swt.graphics.Image;
-
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -75,11 +71,6 @@ public final class ScreenDimensionQualifier extends ResourceQualifier {
}
@Override
- public Image getIcon() {
- return IconFactory.getInstance().getIcon("dimension"); //$NON-NLS-1$
- }
-
- @Override
public boolean isValid() {
return mValue1 != DEFAULT_SIZE && mValue2 != DEFAULT_SIZE;
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenOrientationQualifier.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenOrientationQualifier.java
index d7d6bd3..0ca17a6 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenOrientationQualifier.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenOrientationQualifier.java
@@ -16,12 +16,9 @@
package com.android.ide.eclipse.adt.internal.resources.configurations;
-import com.android.ide.eclipse.adt.internal.editors.IconFactory;
import com.android.resources.ResourceEnum;
import com.android.resources.ScreenOrientation;
-import org.eclipse.swt.graphics.Image;
-
/**
* Resource Qualifier for Screen Orientation.
*/
@@ -58,11 +55,6 @@ public final class ScreenOrientationQualifier extends EnumBasedResourceQualifier
}
@Override
- public Image getIcon() {
- return IconFactory.getInstance().getIcon("orientation"); //$NON-NLS-1$
- }
-
- @Override
public boolean checkAndSet(String value, FolderConfiguration config) {
ScreenOrientation orientation = ScreenOrientation.getEnum(value);
if (orientation != null) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenRatioQualifier.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenRatioQualifier.java
index 4444273..1d710ba 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenRatioQualifier.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenRatioQualifier.java
@@ -16,12 +16,9 @@
package com.android.ide.eclipse.adt.internal.resources.configurations;
-import com.android.ide.eclipse.adt.internal.editors.IconFactory;
import com.android.resources.ResourceEnum;
import com.android.resources.ScreenRatio;
-import org.eclipse.swt.graphics.Image;
-
public class ScreenRatioQualifier extends EnumBasedResourceQualifier {
public static final String NAME = "Screen Ratio";
@@ -55,11 +52,6 @@ public class ScreenRatioQualifier extends EnumBasedResourceQualifier {
}
@Override
- public Image getIcon() {
- return IconFactory.getInstance().getIcon("ratio"); //$NON-NLS-1$
- }
-
- @Override
public boolean checkAndSet(String value, FolderConfiguration config) {
ScreenRatio size = ScreenRatio.getEnum(value);
if (size != null) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenSizeQualifier.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenSizeQualifier.java
index 023a861..9c0a507 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenSizeQualifier.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenSizeQualifier.java
@@ -16,12 +16,9 @@
package com.android.ide.eclipse.adt.internal.resources.configurations;
-import com.android.ide.eclipse.adt.internal.editors.IconFactory;
import com.android.resources.ResourceEnum;
import com.android.resources.ScreenSize;
-import org.eclipse.swt.graphics.Image;
-
/**
* Resource Qualifier for Screen Size. Size can be "small", "normal", "large" and "x-large"
*/
@@ -59,11 +56,6 @@ public class ScreenSizeQualifier extends EnumBasedResourceQualifier {
}
@Override
- public Image getIcon() {
- return IconFactory.getInstance().getIcon("size"); //$NON-NLS-1$
- }
-
- @Override
public boolean checkAndSet(String value, FolderConfiguration config) {
ScreenSize size = ScreenSize.getEnum(value);
if (size != null) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/TextInputMethodQualifier.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/TextInputMethodQualifier.java
index b5ce166..a2d7fc7 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/TextInputMethodQualifier.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/TextInputMethodQualifier.java
@@ -16,12 +16,9 @@
package com.android.ide.eclipse.adt.internal.resources.configurations;
-import com.android.ide.eclipse.adt.internal.editors.IconFactory;
import com.android.resources.Keyboard;
import com.android.resources.ResourceEnum;
-import org.eclipse.swt.graphics.Image;
-
/**
* Resource Qualifier for Text Input Method.
*/
@@ -60,11 +57,6 @@ public final class TextInputMethodQualifier extends EnumBasedResourceQualifier {
}
@Override
- public Image getIcon() {
- return IconFactory.getInstance().getIcon("text_input"); //$NON-NLS-1$
- }
-
- @Override
public boolean checkAndSet(String value, FolderConfiguration config) {
Keyboard method = Keyboard.getEnum(value);
if (method != null) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/TouchScreenQualifier.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/TouchScreenQualifier.java
index f3b8eb0..3396b9c 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/TouchScreenQualifier.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/TouchScreenQualifier.java
@@ -16,12 +16,9 @@
package com.android.ide.eclipse.adt.internal.resources.configurations;
-import com.android.ide.eclipse.adt.internal.editors.IconFactory;
import com.android.resources.ResourceEnum;
import com.android.resources.TouchScreen;
-import org.eclipse.swt.graphics.Image;
-
/**
* Resource Qualifier for Touch Screen type.
@@ -60,11 +57,6 @@ public final class TouchScreenQualifier extends EnumBasedResourceQualifier {
}
@Override
- public Image getIcon() {
- return IconFactory.getInstance().getIcon("touch"); //$NON-NLS-1$
- }
-
- @Override
public boolean checkAndSet(String value, FolderConfiguration config) {
TouchScreen type = TouchScreen.getEnum(value);
if (type != null) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/VersionQualifier.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/VersionQualifier.java
index 199e804..509a218 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/VersionQualifier.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/VersionQualifier.java
@@ -16,10 +16,6 @@
package com.android.ide.eclipse.adt.internal.resources.configurations;
-import com.android.ide.eclipse.adt.internal.editors.IconFactory;
-
-import org.eclipse.swt.graphics.Image;
-
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -99,11 +95,6 @@ public final class VersionQualifier extends ResourceQualifier {
}
@Override
- public Image getIcon() {
- return IconFactory.getInstance().getIcon("version"); //$NON-NLS-1$
- }
-
- @Override
public boolean isValid() {
return mVersion != DEFAULT_VERSION;
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/FrameworkResources.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/FrameworkResources.java
index fc29dd9..4a16aa4 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/FrameworkResources.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/FrameworkResources.java
@@ -18,7 +18,7 @@ package com.android.ide.eclipse.adt.internal.resources.manager;
import static com.android.AndroidConstants.FD_RES_VALUES;
-import com.android.ide.eclipse.adt.AdtPlugin;
+import com.android.ide.common.log.ILogger;
import com.android.io.IAbstractFile;
import com.android.io.IAbstractFolder;
import com.android.resources.ResourceType;
@@ -103,7 +103,7 @@ class FrameworkResources extends ResourceRepository {
*
* @param osFrameworkResourcePath The root folder of the resources
*/
- void loadPublicResources(IAbstractFolder resFolder) {
+ void loadPublicResources(IAbstractFolder resFolder, ILogger logger) {
IAbstractFolder valueFolder = resFolder.getFolder(FD_RES_VALUES);
if (valueFolder.exists() == false) {
return;
@@ -176,7 +176,9 @@ class FrameworkResources extends ResourceRepository {
}
}
} catch (Exception e) {
- AdtPlugin.log(e, "Can't read and parse public attribute list");
+ if (logger != null) {
+ logger.error(e, "Can't read and parse public attribute list");
+ }
} finally {
if (reader != null) {
try {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ProjectResources.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ProjectResources.java
index 4dd01bb..6b8106c 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ProjectResources.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ProjectResources.java
@@ -20,9 +20,11 @@ import com.android.ide.common.rendering.api.ResourceValue;
import com.android.ide.eclipse.adt.internal.resources.configurations.FolderConfiguration;
import com.android.ide.eclipse.adt.internal.sdk.ProjectState;
import com.android.ide.eclipse.adt.internal.sdk.Sdk;
+import com.android.ide.eclipse.adt.io.IFolderWrapper;
import com.android.resources.ResourceType;
import com.android.util.Pair;
+import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import java.util.ArrayList;
@@ -154,6 +156,17 @@ public class ProjectResources extends ResourceRepository {
}
/**
+ * Returns the {@link ResourceFolder} associated with a {@link IFolder}.
+ * @param folder The {@link IFolder} object.
+ * @return the {@link ResourceFolder} or null if it was not found.
+ *
+ * @see ResourceRepository#getResourceFolder(com.android.io.IAbstractFolder)
+ */
+ public ResourceFolder getResourceFolder(IFolder folder) {
+ return getResourceFolder(new IFolderWrapper(folder));
+ }
+
+ /**
* Resolves a compiled resource id into the resource name and type
* @param id the resource integer id.
* @return a {@link Pair} of 2 strings { name, type } or null if the id could not be resolved
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceFolder.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceFolder.java
index 09c98df..7fafe1a 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceFolder.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceFolder.java
@@ -18,6 +18,7 @@ package com.android.ide.eclipse.adt.internal.resources.manager;
import com.android.annotations.VisibleForTesting;
import com.android.annotations.VisibleForTesting.Visibility;
+import com.android.ide.eclipse.adt.internal.resources.ResourceDeltaKind;
import com.android.ide.eclipse.adt.internal.resources.configurations.Configurable;
import com.android.ide.eclipse.adt.internal.resources.configurations.FolderConfiguration;
import com.android.io.IAbstractFile;
@@ -26,8 +27,6 @@ import com.android.resources.FolderTypeRelationship;
import com.android.resources.ResourceFolderType;
import com.android.resources.ResourceType;
-import org.eclipse.core.resources.IResourceDelta;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -66,12 +65,12 @@ public final class ResourceFolder implements Configurable {
* @param kind the file change kind.
* @return the {@link ResourceFile} that was created.
*/
- public ResourceFile processFile(IAbstractFile file, int kind) {
+ public ResourceFile processFile(IAbstractFile file, ResourceDeltaKind kind) {
// look for this file if it's already been created
ResourceFile resFile = getFile(file);
if (resFile == null) {
- if (kind != IResourceDelta.REMOVED) {
+ if (kind != ResourceDeltaKind.REMOVED) {
// create a ResourceFile for it.
// check if that's a single or multi resource type folder. For now we define this by
@@ -94,7 +93,7 @@ public final class ResourceFolder implements Configurable {
addFile(resFile);
}
} else {
- if (kind == IResourceDelta.REMOVED) {
+ if (kind == ResourceDeltaKind.REMOVED) {
removeFile(resFile);
} else {
resFile.update();
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceItem.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceItem.java
index b085832..e11fc96 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceItem.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceItem.java
@@ -217,6 +217,19 @@ public class ResourceItem implements Comparable<ResourceItem> {
return count;
}
+ /**
+ * Returns a formatted string usable in an XML to use for the {@link ResourceItem}.
+ * @param system Whether this is a system resource or a project resource.
+ * @return a string in the format @[type]/[name]
+ */
+ public String getXmlString(ResourceType type, boolean system) {
+ if (type == ResourceType.ID && isDeclaredInline()) {
+ return (system ? "@android:" : "@+") + type.getName() + "/" + mName; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ return (system ? "@android:" : "@") + type.getName() + "/" + mName; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
@Override
public String toString() {
return "ResourceItem [mName=" + mName + ", mFiles=" + mFiles + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceManager.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceManager.java
index dc14e18..df7caf6 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceManager.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceManager.java
@@ -20,6 +20,7 @@ import com.android.annotations.VisibleForTesting;
import com.android.annotations.VisibleForTesting.Visibility;
import com.android.ide.eclipse.adt.AdtConstants;
import com.android.ide.eclipse.adt.AdtPlugin;
+import com.android.ide.eclipse.adt.internal.resources.ResourceHelper;
import com.android.ide.eclipse.adt.internal.resources.manager.GlobalProjectMonitor.IFileListener;
import com.android.ide.eclipse.adt.internal.resources.manager.GlobalProjectMonitor.IFolderListener;
import com.android.ide.eclipse.adt.internal.resources.manager.GlobalProjectMonitor.IProjectListener;
@@ -327,7 +328,8 @@ public final class ResourceManager {
// folder will have taken care of things.
if (folder != null) {
ResourceFile resFile = folder.processFile(
- new IFileWrapper(file), kind);
+ new IFileWrapper(file),
+ ResourceHelper.getResourceDeltaKind(kind));
notifyListenerOnFileChange(project, resFile, kind);
}
}
@@ -412,7 +414,7 @@ public final class ResourceManager {
try {
loadResources(resources, frameworkRes);
- resources.loadPublicResources(frameworkRes);
+ resources.loadPublicResources(frameworkRes, AdtPlugin.getDefault());
return resources;
} catch (IOException e) {
// since we test that folders are folders, and files are files, this shouldn't
@@ -459,7 +461,8 @@ public final class ResourceManager {
for (IAbstractResource childRes : children) {
if (childRes instanceof IAbstractFile) {
- resFolder.processFile((IAbstractFile) childRes, IResourceDelta.ADDED);
+ resFolder.processFile((IAbstractFile) childRes,
+ ResourceHelper.getResourceDeltaKind(IResourceDelta.ADDED));
}
}
}
@@ -512,7 +515,8 @@ public final class ResourceManager {
IFile file = (IFile)fileRes;
resFolder.processFile(new IFileWrapper(file),
- IResourceDelta.ADDED);
+ ResourceHelper.getResourceDeltaKind(
+ IResourceDelta.ADDED));
}
}
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceRepository.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceRepository.java
index b10bf03..bb4e95c 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceRepository.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceRepository.java
@@ -22,14 +22,11 @@ import com.android.ide.eclipse.adt.internal.resources.configurations.Configurabl
import com.android.ide.eclipse.adt.internal.resources.configurations.FolderConfiguration;
import com.android.ide.eclipse.adt.internal.resources.configurations.LanguageQualifier;
import com.android.ide.eclipse.adt.internal.resources.configurations.RegionQualifier;
-import com.android.ide.eclipse.adt.io.IFolderWrapper;
import com.android.io.IAbstractFolder;
import com.android.resources.FolderTypeRelationship;
import com.android.resources.ResourceFolderType;
import com.android.resources.ResourceType;
-import org.eclipse.core.resources.IFolder;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -47,7 +44,7 @@ import java.util.TreeSet;
* A repository is both a file representation of a resource folder and a representation
* of the generated resources, organized by type.
*
- * {@link #getResourceFolder(IFolder)} and {@link #getSourceFiles(ResourceType, String, FolderConfiguration)}
+ * {@link #getResourceFolder(IAbstractFolder)} and {@link #getSourceFiles(ResourceType, String, FolderConfiguration)}
* give access to the folders and files of the resource folder.
*
* {@link #getResources(ResourceType)} gives access to the resources directly.
@@ -136,7 +133,6 @@ public abstract class ResourceRepository {
int count = list.size();
for (int i = 0 ; i < count ; i++) {
ResourceFolder resFolder = list.get(i);
- // this is only used for Eclipse stuff so we know it's an IFolderWrapper
IAbstractFolder folder = resFolder.getFolder();
if (removedFolder.equals(folder)) {
// we found the matching ResourceFolder. we need to remove it.
@@ -297,16 +293,15 @@ public abstract class ResourceRepository {
}
/**
- * Returns the {@link ResourceFolder} associated with a {@link IFolder}.
- * @param folder The {@link IFolder} object.
+ * Returns the {@link ResourceFolder} associated with a {@link IAbstractFolder}.
+ * @param folder The {@link IAbstractFolder} object.
* @return the {@link ResourceFolder} or null if it was not found.
*/
- public ResourceFolder getResourceFolder(IFolder folder) {
+ public ResourceFolder getResourceFolder(IAbstractFolder folder) {
for (List<ResourceFolder> list : mFolderMap.values()) {
for (ResourceFolder resFolder : list) {
- // this is only used for Eclipse stuff so we know it's an IFolderWrapper
- IFolderWrapper wrapper = (IFolderWrapper) resFolder.getFolder();
- if (wrapper.getIFolder().equals(folder)) {
+ IAbstractFolder wrapper = resFolder.getFolder();
+ if (wrapper.equals(folder)) {
return resFolder;
}
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/ui/ConfigurationSelector.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/ui/ConfigurationSelector.java
index f9748f6..0235e3f 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/ui/ConfigurationSelector.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/ui/ConfigurationSelector.java
@@ -17,6 +17,7 @@
package com.android.ide.eclipse.adt.internal.ui;
import com.android.AndroidConstants;
+import com.android.ide.eclipse.adt.internal.resources.ResourceHelper;
import com.android.ide.eclipse.adt.internal.resources.configurations.CountryCodeQualifier;
import com.android.ide.eclipse.adt.internal.resources.configurations.DockModeQualifier;
import com.android.ide.eclipse.adt.internal.resources.configurations.FolderConfiguration;
@@ -657,7 +658,7 @@ public class ConfigurationSelector extends Composite {
public Image getColumnImage(Object element, int columnIndex) {
// only one column, so we can ignore columnIndex
if (element instanceof ResourceQualifier) {
- return ((ResourceQualifier)element).getIcon();
+ return ResourceHelper.getIcon(((ResourceQualifier)element).getClass());
}
return null;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/ui/ReferenceChooserDialog.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/ui/ReferenceChooserDialog.java
index c6bbd0d..f070e40 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/ui/ReferenceChooserDialog.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/ui/ReferenceChooserDialog.java
@@ -19,7 +19,6 @@ package com.android.ide.eclipse.adt.internal.ui;
import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.internal.refactorings.extractstring.ExtractStringRefactoring;
import com.android.ide.eclipse.adt.internal.refactorings.extractstring.ExtractStringWizard;
-import com.android.ide.eclipse.adt.internal.resources.ResourceHelper;
import com.android.ide.eclipse.adt.internal.resources.manager.ResourceItem;
import com.android.ide.eclipse.adt.internal.resources.manager.ResourceRepository;
import com.android.resources.ResourceType;
@@ -115,8 +114,7 @@ public class ReferenceChooserDialog extends SelectionStatusDialog {
ResourceType resourceType = (ResourceType)treeSelection.getFirstSegment();
ResourceItem resourceItem = (ResourceItem)treeSelection.getLastSegment();
- mCurrentResource = ResourceHelper.getXmlString(resourceType,
- resourceItem, false /* system */);
+ mCurrentResource = resourceItem.getXmlString(resourceType, false /* system */);
}
}
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/ui/ResourceChooser.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/ui/ResourceChooser.java
index 83d0f96..b2c3ced 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/ui/ResourceChooser.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/ui/ResourceChooser.java
@@ -30,7 +30,6 @@ import com.android.ide.eclipse.adt.internal.editors.resources.descriptors.Resour
import com.android.ide.eclipse.adt.internal.editors.xml.Hyperlinks;
import com.android.ide.eclipse.adt.internal.refactorings.extractstring.ExtractStringRefactoring;
import com.android.ide.eclipse.adt.internal.refactorings.extractstring.ExtractStringWizard;
-import com.android.ide.eclipse.adt.internal.resources.ResourceHelper;
import com.android.ide.eclipse.adt.internal.resources.ResourceNameValidator;
import com.android.ide.eclipse.adt.internal.resources.manager.ResourceItem;
import com.android.ide.eclipse.adt.internal.resources.manager.ResourceRepository;
@@ -158,8 +157,7 @@ public class ResourceChooser extends AbstractElementListSelectionDialog {
if (elements.length == 1 && elements[0] instanceof ResourceItem) {
ResourceItem item = (ResourceItem)elements[0];
- mCurrentResource = ResourceHelper.getXmlString(mResourceType, item,
- mSystemButton.getSelection());
+ mCurrentResource = item.getXmlString(mResourceType, mSystemButton.getSelection());
if (mInputValidator != null && mInputValidator.isValid(mCurrentResource) != null) {
mCurrentResource = null;
@@ -257,8 +255,7 @@ public class ResourceChooser extends AbstractElementListSelectionDialog {
Object[] elements = getSelectedElements();
if (elements.length == 1 && elements[0] instanceof ResourceItem) {
ResourceItem item = (ResourceItem)elements[0];
- String current = ResourceHelper.getXmlString(mResourceType, item,
- mSystemButton.getSelection());
+ String current = item.getXmlString(mResourceType, mSystemButton.getSelection());
String error = mInputValidator.isValid(current);
IStatus status;
if (error != null) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/resources/ResourceHelperTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/resources/ResourceHelperTest.java
new file mode 100644
index 0000000..48b5ca6
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/resources/ResourceHelperTest.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/org/documents/epl-v10.php
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.ide.eclipse.adt.internal.resources;
+
+import com.android.ide.eclipse.adt.internal.resources.configurations.FolderConfiguration;
+import com.android.ide.eclipse.adt.internal.resources.configurations.ResourceQualifier;
+
+import org.eclipse.core.resources.IResourceDelta;
+
+import junit.framework.TestCase;
+
+/**
+ * Test ResourceHelper
+ */
+public class ResourceHelperTest extends TestCase {
+
+ /**
+ * temp fake qualifier class.
+ */
+ private static class FakeQualifierClass extends ResourceQualifier {
+
+ @Override
+ public boolean checkAndSet(String value, FolderConfiguration config) {
+ return false;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ return false;
+ }
+
+ @Override
+ public String getFolderSegment() {
+ return null;
+ }
+
+ @Override
+ public String getLongDisplayValue() {
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
+
+ @Override
+ public String getShortDisplayValue() {
+ return null;
+ }
+
+ @Override
+ public String getShortName() {
+ return null;
+ }
+
+ @Override
+ public boolean hasFakeValue() {
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ @Override
+ public boolean isValid() {
+ return false;
+ }
+
+ }
+
+ public void testgetIcon() throws Exception {
+ // check that the method returns null for an unknown qualifier class
+ assertNull(ResourceHelper.getIcon(FakeQualifierClass.class));
+
+ // find all the qualifiers through FolderConfiguration.createdefault()
+ FolderConfiguration config = new FolderConfiguration();
+ config.createDefault();
+ final int count = FolderConfiguration.getQualifierCount();
+ for (int i = 0 ; i < count ; i++) {
+ ResourceQualifier qual = config.getQualifier(i);
+ assertNotNull(qual);
+ assertNotNull(qual.getClass().getCanonicalName(),
+ ResourceHelper.getIcon(qual.getClass()));
+ }
+ }
+
+ public void testGetResourceDeltaKind() {
+ assertEquals(ResourceDeltaKind.ADDED,
+ ResourceHelper.getResourceDeltaKind(IResourceDelta.ADDED));
+ assertEquals(ResourceDeltaKind.REMOVED,
+ ResourceHelper.getResourceDeltaKind(IResourceDelta.REMOVED));
+ assertEquals(ResourceDeltaKind.CHANGED,
+ ResourceHelper.getResourceDeltaKind(IResourceDelta.CHANGED));
+
+ assertNull(ResourceHelper.getResourceDeltaKind(IResourceDelta.ADDED_PHANTOM));
+ }
+}