From 74634277cf5fbe2c831f8ac4d6beceade72ba802 Mon Sep 17 00:00:00 2001 From: Alexander Lobas Date: Fri, 22 Jun 2012 21:02:52 +0400 Subject: [PATCH] Work with resources --- .../designer/propertyTable/AttributeProperty.java | 14 ++++++++++++-- .../propertyTable/editors/ResourceEditor.java | 9 +++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/plugins/android-designer/src/com/intellij/android/designer/propertyTable/AttributeProperty.java b/plugins/android-designer/src/com/intellij/android/designer/propertyTable/AttributeProperty.java index 8d7cb6c02ce9..5c049489bda3 100644 --- a/plugins/android-designer/src/com/intellij/android/designer/propertyTable/AttributeProperty.java +++ b/plugins/android-designer/src/com/intellij/android/designer/propertyTable/AttributeProperty.java @@ -15,6 +15,7 @@ */ package com.intellij.android.designer.propertyTable; +import com.android.resources.ResourceType; import com.intellij.android.designer.model.RadViewComponent; import com.intellij.android.designer.propertyTable.editors.ResourceEditor; import com.intellij.android.designer.propertyTable.editors.StringsComboEditor; @@ -27,6 +28,7 @@ import com.intellij.designer.propertyTable.renderers.LabelPropertyRenderer; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.xml.XmlAttribute; +import org.jetbrains.android.dom.AndroidDomUtil; import org.jetbrains.android.dom.attrs.AttributeDefinition; import org.jetbrains.android.dom.attrs.AttributeFormat; import org.jetbrains.annotations.NotNull; @@ -65,15 +67,23 @@ public class AttributeProperty extends Property implements IXm } else { myRenderer = new ResourceRenderer(formats); - myEditor = new ResourceEditor(formats, definition.getValues()); + myEditor = createResourceEditor(definition, formats); } } else { myRenderer = new ResourceRenderer(formats); - myEditor = new ResourceEditor(formats, definition.getValues()); + myEditor = createResourceEditor(definition, formats); } } + private static ResourceEditor createResourceEditor(AttributeDefinition definition, Set formats) { + String type = AndroidDomUtil.SPECIAL_RESOURCE_TYPES.get(definition.getName()); + if (type == null) { + return new ResourceEditor(formats, definition.getValues()); + } + return new ResourceEditor(new ResourceType[]{ResourceType.getEnum(type)}, formats, definition.getValues()); + } + @Override public Property createForNewPresentation(@Nullable Property parent, @NotNull String name) { return new AttributeProperty(parent, name, myDefinition); diff --git a/plugins/android-designer/src/com/intellij/android/designer/propertyTable/editors/ResourceEditor.java b/plugins/android-designer/src/com/intellij/android/designer/propertyTable/editors/ResourceEditor.java index b67bfb97e7c7..0f08b55dad2b 100644 --- a/plugins/android-designer/src/com/intellij/android/designer/propertyTable/editors/ResourceEditor.java +++ b/plugins/android-designer/src/com/intellij/android/designer/propertyTable/editors/ResourceEditor.java @@ -22,6 +22,9 @@ import com.intellij.designer.model.RadComponent; import com.intellij.designer.propertyTable.InplaceContext; import com.intellij.designer.propertyTable.PropertyEditor; import com.intellij.designer.propertyTable.editors.ComboEditor; +import com.intellij.openapi.Disposable; +import com.intellij.openapi.fileChooser.FileChooserDescriptor; +import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.ComponentWithBrowseButton; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.TextFieldWithBrowseButton; @@ -111,6 +114,12 @@ public class ResourceEditor extends PropertyEditor { } else { myEditor = new TextFieldWithBrowseButton() { + @Override + protected void installPathCompletion(@Nullable Project project, + FileChooserDescriptor fileChooserDescriptor, + @Nullable Disposable parent) { + } + @Override public Dimension getPreferredSize() { return getComponentPreferredSize();