/plugins/android/src/org/jetbrains/android/dom/drawable/DrawableStateListDomFileDescription.java

https://bitbucket.org/nbargnesi/idea · Java · 55 lines · 30 code · 7 blank · 18 comment · 3 complexity · 568c5de82ad9529b1edd4c119f051202 MD5 · raw file

  1. /*
  2. * Copyright 2000-2011 JetBrains s.r.o.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.jetbrains.android.dom.drawable;
  17. import com.android.resources.ResourceType;
  18. import com.intellij.openapi.module.Module;
  19. import com.intellij.psi.xml.XmlFile;
  20. import com.intellij.psi.xml.XmlTag;
  21. import org.jetbrains.android.dom.AndroidResourceDomFileDescription;
  22. import org.jetbrains.annotations.NonNls;
  23. import org.jetbrains.annotations.NotNull;
  24. import org.jetbrains.annotations.Nullable;
  25. /**
  26. * @author Eugene.Kudelevsky
  27. */
  28. public class DrawableStateListDomFileDescription extends AndroidResourceDomFileDescription<DrawableSelector> {
  29. @NonNls public static final String SELECTOR_TAG_NAME = "selector";
  30. public DrawableStateListDomFileDescription() {
  31. super(DrawableSelector.class, SELECTOR_TAG_NAME, ResourceType.DRAWABLE.getName());
  32. }
  33. @Override
  34. public boolean acceptsOtherRootTagNames() {
  35. return true;
  36. }
  37. @Override
  38. public boolean isMyFile(@NotNull XmlFile file, @Nullable Module module) {
  39. if (!super.isMyFile(file, module)) {
  40. return false;
  41. }
  42. final XmlTag rootTag = file.getRootTag();
  43. if (rootTag == null) {
  44. return false;
  45. }
  46. return SELECTOR_TAG_NAME.equals(rootTag.getName());
  47. }
  48. }