aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2012-04-16 13:40:21 -0700
committerandroid code review <noreply-gerritcodereview@google.com>2012-04-16 13:40:22 -0700
commit8b1b0011f26fadf28f0d5303a017c1527ca0d78d (patch)
tree53b3e6c426f094b665a17c0635a23fd4f6e01704
parent62609fb2de127b0e75eb61aefa2b6bddf487d776 (diff)
parent709b85ad8c3ec3791534aa78b5dfb3a4689bdc57 (diff)
downloadsdk-8b1b0011f26fadf28f0d5303a017c1527ca0d78d.zip
sdk-8b1b0011f26fadf28f0d5303a017c1527ca0d78d.tar.gz
sdk-8b1b0011f26fadf28f0d5303a017c1527ca0d78d.tar.bz2
Merge "Fix botched refactoring"
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/ClientRulesEngine.java51
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/ui/ResourceChooser.java51
2 files changed, 52 insertions, 50 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/ClientRulesEngine.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/ClientRulesEngine.java
index 9c73e1c..e08bfc1 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/ClientRulesEngine.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/ClientRulesEngine.java
@@ -248,56 +248,9 @@ class ClientRulesEngine implements IClientRulesEngine {
private String displayResourceInput(String resourceTypeName, String currentValue,
IInputValidator validator) {
- GraphicalEditorPart graphicalEditor = mRulesEngine.getEditor();
- AndroidXmlEditor editor = graphicalEditor.getEditorDelegate().getEditor();
- IProject project = editor.getProject();
ResourceType type = ResourceType.getEnum(resourceTypeName);
- if (project != null) {
- // get the resource repository for this project and the system resources.
- ResourceRepository projectRepository = ResourceManager.getInstance()
- .getProjectResources(project);
- Shell shell = AdtPlugin.getDisplay().getActiveShell();
- if (shell == null) {
- return null;
- }
-
- AndroidTargetData data = editor.getTargetData();
- ResourceRepository systemRepository = data.getFrameworkResources();
-
- // open a resource chooser dialog for specified resource type.
- ResourceChooser dlg = new ResourceChooser(project, type, projectRepository,
- systemRepository, shell);
- dlg.setPreviewHelper(new ResourcePreviewHelper(dlg, graphicalEditor));
-
- // When editing Strings, allow editing the value text directly. When we
- // get inline editing support (where values entered directly into the
- // textual widget are translated automatically into a resource) this can
- // go away.
- if (resourceTypeName.equals(ResourceType.STRING.getName())) {
- dlg.setResourceResolver(graphicalEditor.getResourceResolver());
- dlg.setShowValueText(true);
- } else if (resourceTypeName.equals(ResourceType.DIMEN.getName())
- || resourceTypeName.equals(ResourceType.INTEGER.getName())) {
- dlg.setResourceResolver(graphicalEditor.getResourceResolver());
- }
-
- if (validator != null) {
- // Ensure wide enough to accommodate validator error message
- dlg.setSize(85, 10);
- dlg.setInputValidator(validator);
- }
-
- dlg.setCurrentResource(currentValue);
-
- int result = dlg.open();
- if (result == ResourceChooser.CLEAR_RETURN_CODE) {
- return ""; //$NON-NLS-1$
- } else if (result == Window.OK) {
- return dlg.getCurrentResource();
- }
- }
-
- return null;
+ GraphicalEditorPart graphicalEditor = mRulesEngine.getEditor();
+ return ResourceChooser.chooseResource(graphicalEditor, type, currentValue, validator);
}
@Override
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 202e1cf..7b90633 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
@@ -28,11 +28,14 @@ import com.android.ide.common.resources.ResourceResolver;
import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.AdtUtils;
import com.android.ide.eclipse.adt.internal.assetstudio.OpenCreateAssetSetWizardAction;
+import com.android.ide.eclipse.adt.internal.editors.AndroidXmlEditor;
import com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart;
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.ResourceManager;
+import com.android.ide.eclipse.adt.internal.sdk.AndroidTargetData;
import com.android.resources.ResourceType;
import com.android.util.Pair;
@@ -790,6 +793,52 @@ public class ResourceChooser extends AbstractElementListSelectionDialog implemen
@NonNull GraphicalEditorPart graphicalEditor,
@NonNull ResourceType type,
String currentValue, IInputValidator validator) {
- return ResourceChooser.chooseResource(graphicalEditor, type, currentValue, validator);
+ AndroidXmlEditor editor = graphicalEditor.getEditorDelegate().getEditor();
+ IProject project = editor.getProject();
+ if (project != null) {
+ // get the resource repository for this project and the system resources.
+ ResourceRepository projectRepository = ResourceManager.getInstance()
+ .getProjectResources(project);
+ Shell shell = AdtPlugin.getDisplay().getActiveShell();
+ if (shell == null) {
+ return null;
+ }
+
+ AndroidTargetData data = editor.getTargetData();
+ ResourceRepository systemRepository = data.getFrameworkResources();
+
+ // open a resource chooser dialog for specified resource type.
+ ResourceChooser dlg = new ResourceChooser(project, type, projectRepository,
+ systemRepository, shell);
+ dlg.setPreviewHelper(new ResourcePreviewHelper(dlg, graphicalEditor));
+
+ // When editing Strings, allow editing the value text directly. When we
+ // get inline editing support (where values entered directly into the
+ // textual widget are translated automatically into a resource) this can
+ // go away.
+ if (type == ResourceType.STRING) {
+ dlg.setResourceResolver(graphicalEditor.getResourceResolver());
+ dlg.setShowValueText(true);
+ } else if (type == ResourceType.DIMEN || type == ResourceType.INTEGER) {
+ dlg.setResourceResolver(graphicalEditor.getResourceResolver());
+ }
+
+ if (validator != null) {
+ // Ensure wide enough to accommodate validator error message
+ dlg.setSize(85, 10);
+ dlg.setInputValidator(validator);
+ }
+
+ dlg.setCurrentResource(currentValue);
+
+ int result = dlg.open();
+ if (result == ResourceChooser.CLEAR_RETURN_CODE) {
+ return ""; //$NON-NLS-1$
+ } else if (result == Window.OK) {
+ return dlg.getCurrentResource();
+ }
+ }
+
+ return null;
}
}