aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse
diff options
context:
space:
mode:
Diffstat (limited to 'eclipse')
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/IClientRulesEngine.java10
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseViewRule.java16
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PlayAnimationMenu.java2
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/RulesEngine.java33
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newxmlfile/NewXmlFileCreationPage.java4
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/DdmsPlugin.java6
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/preferences/PreferenceInitializer.java10
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/preferences/PreferencePage.java23
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/.classpath1
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/LayoutTestBase.java4
10 files changed, 104 insertions, 5 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/IClientRulesEngine.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/IClientRulesEngine.java
index d6ff1bd..6a01e8a 100755
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/IClientRulesEngine.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/IClientRulesEngine.java
@@ -108,5 +108,15 @@ public interface IClientRulesEngine {
*/
String displayReferenceInput(String currentValue);
+ /**
+ * Displays an input dialog where the user can enter an Android resource name of the
+ * given resource type ("id", "string", "drawable", and so on.)
+ *
+ * @param currentValue the current reference to select
+ * @param resourceTypeName resource type, such as "id", "string", and so on (never
+ * null)
+ * @return the resource selected by the user, or null
+ */
+ String displayResourceInput(String resourceTypeName, String currentValue);
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseViewRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseViewRule.java
index 131bf7a..3674633 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseViewRule.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseViewRule.java
@@ -186,7 +186,7 @@ public class BaseViewRule implements IViewRule {
} else if (fullActionId.equals(EDIT_TEXT_ID)) {
String oldText = node.getStringAttr(ANDROID_URI, ATTR_TEXT);
oldText = ensureValidString(oldText);
- String newText = mRulesEngine.displayReferenceInput(oldText);
+ String newText = mRulesEngine.displayResourceInput("string", oldText); //$NON-NLS-1$
if (newText != null) {
node.editXml("Change text", new PropertySettingNodeHandler(ANDROID_URI,
ATTR_TEXT, newText));
@@ -264,6 +264,20 @@ public class BaseViewRule implements IViewRule {
&& IAttributeInfo.Format.REFERENCE.in(attributeInfo.getFormats())) {
return mRulesEngine.displayReferenceInput(oldValue);
} else {
+ // A single resource type? If so use a resource chooser initialized
+ // to this specific type
+ /* This does not work well, because the metadata is a bit misleading:
+ * for example a Button's "text" property and a Button's "onClick" property
+ * both claim to be of type [string], but @string/ is NOT valid for
+ * onClick..
+ if (attributeInfo != null && attributeInfo.getFormats().length == 1) {
+ // Resource chooser
+ Format format = attributeInfo.getFormats()[0];
+ return mRulesEngine.displayResourceInput(format.name(), oldValue);
+ }
+ */
+
+ // Fallback: just edit the raw XML string
String message = String.format("New %1$s Value:", attribute);
return mRulesEngine.displayInput(message, oldValue, null);
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PlayAnimationMenu.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PlayAnimationMenu.java
index 03a446a..7d32f78 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PlayAnimationMenu.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PlayAnimationMenu.java
@@ -51,7 +51,7 @@ import java.util.List;
* "Play Animation" context menu which lists available animations in the project and in
* the framework, as well as a "Create Animation" shortcut, and allows the animation to be
* run on the selection
- * <p>
+ * <p/>
* TODO: Add transport controls for play/rewind/pause/loop, and (if possible) scrubbing
*/
public class PlayAnimationMenu extends SubmenuAction {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/RulesEngine.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/RulesEngine.java
index 24366da..2bcc32f 100755
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/RulesEngine.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/RulesEngine.java
@@ -36,11 +36,13 @@ import com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorP
import com.android.ide.eclipse.adt.internal.editors.layout.gle2.SimpleElement;
import com.android.ide.eclipse.adt.internal.editors.layout.uimodel.UiViewElementNode;
import com.android.ide.eclipse.adt.internal.resources.IResourceRepository;
+import com.android.ide.eclipse.adt.internal.resources.ResourceType;
import com.android.ide.eclipse.adt.internal.resources.manager.ResourceManager;
import com.android.ide.eclipse.adt.internal.sdk.AndroidTargetData;
import com.android.ide.eclipse.adt.internal.sdk.ProjectState;
import com.android.ide.eclipse.adt.internal.sdk.Sdk;
import com.android.ide.eclipse.adt.internal.ui.ReferenceChooserDialog;
+import com.android.ide.eclipse.adt.internal.ui.ResourceChooser;
import com.android.sdklib.IAndroidTarget;
import com.android.sdklib.internal.project.ProjectProperties;
@@ -816,5 +818,36 @@ public class RulesEngine {
return null;
}
+
+ public String displayResourceInput(String resourceTypeName, String currentValue) {
+ AndroidXmlEditor editor = mEditor.getLayoutEditor();
+ IProject project = editor.getProject();
+ ResourceType type = ResourceType.valueOf(resourceTypeName.toUpperCase());
+ if (project != null) {
+ // get the resource repository for this project and the system resources.
+ IResourceRepository projectRepository = ResourceManager.getInstance()
+ .getProjectResources(project);
+ Shell shell = AdtPlugin.getDisplay().getActiveShell();
+ if (shell == null) {
+ return null;
+ }
+
+ AndroidTargetData data = editor.getTargetData();
+ IResourceRepository systemRepository = data.getSystemResources();
+
+ // open a resource chooser dialog for specified resource type.
+ ResourceChooser dlg = new ResourceChooser(project, type, projectRepository,
+ systemRepository, shell);
+
+ dlg.setCurrentResource(currentValue);
+
+ if (dlg.open() == Window.OK) {
+ return dlg.getCurrentResource();
+ }
+ }
+
+ return null;
+ }
+
}
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newxmlfile/NewXmlFileCreationPage.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newxmlfile/NewXmlFileCreationPage.java
index b3f34aa..b8162b6 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newxmlfile/NewXmlFileCreationPage.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newxmlfile/NewXmlFileCreationPage.java
@@ -728,8 +728,8 @@ class NewXmlFileCreationPage extends WizardPage {
* <li>The project name, valid if it's an android nature.</li>
* <li>The current folder, valid if it's a folder under /res</li>
* <li>An existing filename, in which case the user will be asked whether to override it.</li>
- * <ul>
- * <p>
+ * </ul>
+ * <p/>
* The selection can also be set to a {@link Pair} of {@link IProject} and a workspace
* resource path (where the resource path does not have to exist yet, such as res/anim/).
*
diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/DdmsPlugin.java b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/DdmsPlugin.java
index ef7628d..182f91d 100644
--- a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/DdmsPlugin.java
+++ b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/DdmsPlugin.java
@@ -212,6 +212,12 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
} else if (PreferenceInitializer.ATTR_TIME_OUT.equals(property)) {
DdmPreferences.setTimeOut(
eclipseStore.getInt(PreferenceInitializer.ATTR_TIME_OUT));
+ } else if (PreferenceInitializer.ATTR_USE_ADBHOST.equals(property)) {
+ DdmPreferences.setUseAdbHost(
+ eclipseStore.getBoolean(PreferenceInitializer.ATTR_USE_ADBHOST));
+ } else if (PreferenceInitializer.ATTR_ADBHOST_VALUE.equals(property)) {
+ DdmPreferences.setAdbHostValue(
+ eclipseStore.getString(PreferenceInitializer.ATTR_ADBHOST_VALUE));
}
}
});
diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/preferences/PreferenceInitializer.java b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/preferences/PreferenceInitializer.java
index 95571fc..4e47365 100644
--- a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/preferences/PreferenceInitializer.java
+++ b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/preferences/PreferenceInitializer.java
@@ -68,6 +68,12 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
public final static String ATTR_LOGCAT_GOTO_PROBLEM =
DdmsPlugin.PLUGIN_ID + ".logcatGoToProblem"; //$NON-NLS-1$
+ public final static String ATTR_USE_ADBHOST =
+ DdmsPlugin.PLUGIN_ID + ".useAdbHost"; //$NON-NLS-1$
+
+ public final static String ATTR_ADBHOST_VALUE =
+ DdmsPlugin.PLUGIN_ID + ".adbHostValue"; //$NON-NLS-1$
+
/*
* (non-Javadoc)
*
@@ -101,6 +107,8 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
store.setDefault(ATTR_TIME_OUT, DdmPreferences.DEFAULT_TIMEOUT);
store.setDefault(ATTR_LOGCAT_GOTO_PROBLEM, LogCatView.CHOICE_ERROR_LINE);
+ store.setDefault(ATTR_USE_ADBHOST, DdmPreferences.DEFAULT_USE_ADBHOST);
+ store.setDefault(ATTR_ADBHOST_VALUE, DdmPreferences.DEFAULT_ADBHOST_VALUE);
}
/**
@@ -116,5 +124,7 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
DdmPreferences.setInitialHeapUpdate(store.getBoolean(ATTR_DEFAULT_HEAP_UPDATE));
DdmUiPreferences.setThreadRefreshInterval(store.getInt(ATTR_THREAD_INTERVAL));
DdmPreferences.setTimeOut(store.getInt(ATTR_TIME_OUT));
+ DdmPreferences.setUseAdbHost(store.getBoolean(ATTR_USE_ADBHOST));
+ DdmPreferences.setAdbHostValue(store.getString(ATTR_ADBHOST_VALUE));
}
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/preferences/PreferencePage.java b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/preferences/PreferencePage.java
index fb852f5..47445f8 100644
--- a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/preferences/PreferencePage.java
+++ b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/preferences/PreferencePage.java
@@ -26,12 +26,17 @@ import org.eclipse.jface.preference.ComboFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.RadioGroupFieldEditor;
+import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
public class PreferencePage extends FieldEditorPreferencePage implements
IWorkbenchPreferencePage {
+ private BooleanFieldEditor mUseAdbHost;
+ private StringFieldEditor mAdbHostValue;
+
public PreferencePage() {
super(GRID);
setPreferenceStore(DdmsPlugin.getDefault().getPreferenceStore());
@@ -87,8 +92,26 @@ public class PreferencePage extends FieldEditorPreferencePage implements
},
getFieldEditorParent(), true);
addField(rgfe);
+
+ mUseAdbHost = new BooleanFieldEditor(PreferenceInitializer.ATTR_USE_ADBHOST,
+ "Use ADBHOST", getFieldEditorParent());
+ addField(mUseAdbHost);
+
+ mAdbHostValue = new StringFieldEditor(PreferenceInitializer.ATTR_ADBHOST_VALUE,
+ "ADBHOST value:", getFieldEditorParent());
+ mAdbHostValue.setEnabled(getPreferenceStore()
+ .getBoolean(PreferenceInitializer.ATTR_USE_ADBHOST), getFieldEditorParent());
+ addField(mAdbHostValue);
}
public void init(IWorkbench workbench) {
}
+
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ // TODO Auto-generated method stub
+ if (event.getSource().equals(mUseAdbHost)) {
+ mAdbHostValue.setEnabled(mUseAdbHost.getBooleanValue(), getFieldEditorParent());
+ }
+ }
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/.classpath b/eclipse/plugins/com.android.ide.eclipse.tests/.classpath
index 3faf0d1..b3b276a 100644
--- a/eclipse/plugins/com.android.ide.eclipse.tests/.classpath
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/.classpath
@@ -4,7 +4,6 @@
<classpathentry kind="src" path="unittests"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="lib" path="layoutlib.jar" sourcepath="/layoutlib_api"/>
<classpathentry kind="lib" path="kxml2-2.3.0.jar"/>
<classpathentry kind="lib" path="easymock.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/ddmlib"/>
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/LayoutTestBase.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/LayoutTestBase.java
index 4cdbad0..21e4597 100644
--- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/LayoutTestBase.java
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/LayoutTestBase.java
@@ -234,6 +234,10 @@ public abstract class LayoutTestBase extends TestCase {
return null;
}
+ public String displayResourceInput(String resourceTypeName, String currentValue) {
+ fail("Not supported in tests yet");
+ return null;
+ }
}
public void testDummy() {