IDEA-69493 add "animation-list" to android dom model

This commit is contained in:
Eugene Kudelevsky
2011-05-17 13:38:26 +04:00
parent 50d3a3e7f1
commit 6f39d05743
15 changed files with 126 additions and 0 deletions
+1
View File
@@ -73,6 +73,7 @@
<dom.fileDescription implementation="org.jetbrains.android.dom.drawable.LevelListDomFileDescription"/>
<dom.fileDescription implementation="org.jetbrains.android.dom.drawable.InsetOrClipOrScaleDomFileDescription"/>
<dom.fileDescription implementation="org.jetbrains.android.dom.drawable.ShapeDomFileDescription"/>
<dom.fileDescription implementation="org.jetbrains.android.dom.drawable.AnimationListDomFileDescription"/>
<dom.fileDescription implementation="org.jetbrains.android.dom.color.ColorDomFileDescription"/>
<dom.fileDescription implementation="org.jetbrains.android.dom.manifest.ManifestDomFileDescription"/>
@@ -574,6 +574,9 @@ public class AndroidDomExtender extends DomExtender<AndroidDomElement> {
else if (element instanceof LevelListItem) {
registerAttributes(facet, element, "LevelListDrawableItem", SYSTEM_RESOURCE_PACKAGE, registrar);
}
else if (element instanceof AnimationListItem) {
registerAttributes(facet, element, "AnimationDrawableItem", SYSTEM_RESOURCE_PACKAGE, registrar);
}
}
@Nullable
@@ -40,6 +40,7 @@ public class AndroidDrawableDomUtil {
SPECIAL_STYLEABLE_NAMES.put("inset", "InsetDrawable");
SPECIAL_STYLEABLE_NAMES.put("clip", "ClipDrawable");
SPECIAL_STYLEABLE_NAMES.put("scale", "ScaleDrawable");
SPECIAL_STYLEABLE_NAMES.put("animation-list", "AnimationDrawable");
SPECIAL_STYLEABLE_NAMES.put("shape", "GradientDrawable");
SPECIAL_STYLEABLE_NAMES.put("corners", "DrawableCorners");
@@ -0,0 +1,13 @@
package org.jetbrains.android.dom.drawable;
import com.intellij.util.xml.DefinesXml;
import java.util.List;
/**
* @author Eugene.Kudelevsky
*/
@DefinesXml
public interface AnimationList extends DrawableDomElement {
List<AnimationListItem> getItems();
}
@@ -0,0 +1,40 @@
package org.jetbrains.android.dom.drawable;
import com.intellij.openapi.module.Module;
import com.intellij.psi.xml.XmlFile;
import com.intellij.psi.xml.XmlTag;
import org.jetbrains.android.dom.AndroidResourceDomFileDescription;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author Eugene.Kudelevsky
*/
public class AnimationListDomFileDescription extends AndroidResourceDomFileDescription<AnimationList> {
@NonNls static final String ANIMATION_LIST_TAG = "animation-list";
public AnimationListDomFileDescription() {
super(AnimationList.class, ANIMATION_LIST_TAG, "drawable");
}
@Override
public boolean acceptsOtherRootTagNames() {
return true;
}
@Override
public boolean isMyFile(@NotNull XmlFile file, @Nullable Module module) {
if (!super.isMyFile(file, module)) {
return false;
}
final XmlTag rootTag = file.getRootTag();
if (rootTag == null) {
return false;
}
return ANIMATION_LIST_TAG.equals(rootTag.getName());
}
}
@@ -0,0 +1,16 @@
package org.jetbrains.android.dom.drawable;
import com.intellij.util.xml.Convert;
import org.jetbrains.android.dom.AndroidAttributeValue;
import org.jetbrains.android.dom.ResourceType;
import org.jetbrains.android.dom.converters.ResourceReferenceConverter;
import org.jetbrains.android.dom.resources.ResourceValue;
/**
* @author Eugene.Kudelevsky
*/
public interface AnimationListItem extends DrawableDomElement {
@Convert(ResourceReferenceConverter.class)
@ResourceType("drawable")
AndroidAttributeValue<ResourceValue> getDrawable();
}
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:one<caret>>
<item android:drawable="@drawable/myDrawable" android:duration="400"/>
</animation-list>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="">
<item android:drawable="@drawable/myDrawable" android:duration="400"/>
</animation-list>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/myDrawa<caret>" android:duration="400"/>
</animation-list>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/myDrawable" android:duration="400"/>
</animation-list>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:dur<caret>/>
</animation-list>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:duration=""/>
</animation-list>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false">
<item android:drawable="@drawable/myDrawable" android:duration="400"/>
</animation-list>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
<item/>
</animation-list>
@@ -213,6 +213,26 @@ public class AndroidDrawableResourcesDomTest extends AndroidDomTest {
doTestCompletionVariants(getTestName(true) + ".xml", "gradient", "solid", "size", "stroke", "padding", "corners");
}
public void testAnimationListHighlighting1() throws Throwable {
doTestHighlighting();
}
public void testAnimationListHighlighting2() throws Throwable {
doTestHighlighting();
}
public void testAnimationListCompletion1() throws Throwable {
doTestCompletion();
}
public void testAnimationListCompletion2() throws Throwable {
doTestCompletion();
}
public void testAnimationListCompletion3() throws Throwable {
doTestCompletion();
}
public void testIncorrectRootTag() throws Throwable {
doTestHighlighting();
}