aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse/plugins
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2012-10-29 08:07:51 -0700
committerTor Norbye <tnorbye@google.com>2012-10-29 08:07:51 -0700
commitb1308b3157364c5c7c47037ac95d494f24f339ac (patch)
treeaef4c5cb909991e5bf4817c8c40e1eec35565ac0 /eclipse/plugins
parentd4a7e7b92f518e45800dc32ae7cbe5f6d4ed4c43 (diff)
downloadsdk-b1308b3157364c5c7c47037ac95d494f24f339ac.zip
sdk-b1308b3157364c5c7c47037ac95d494f24f339ac.tar.gz
sdk-b1308b3157364c5c7c47037ac95d494f24f339ac.tar.bz2
38994: UI designer's -> "Edit ID" should allow ID removal
Change-Id: I7ca6454f9a698d2bcd35350e6bd324fd01eaf7d7
Diffstat (limited to 'eclipse/plugins')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseViewRule.java5
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/LinearLayoutRule.java3
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/ClientRulesEngine.java29
3 files changed, 35 insertions, 2 deletions
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 a555ef4..3fe89e0 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
@@ -207,6 +207,11 @@ public class BaseViewRule extends AbstractViewRule {
node.editXml("Change ID", new PropertySettingNodeHandler(ANDROID_URI,
ATTR_ID, newId));
editedProperty(ATTR_ID);
+ } else if (newId != null) {
+ // Clear
+ node.editXml("Change ID", new PropertySettingNodeHandler(ANDROID_URI,
+ ATTR_ID, null));
+ editedProperty(ATTR_ID);
} else if (newId == null) {
// Cancelled
break;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/LinearLayoutRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/LinearLayoutRule.java
index d7a3026..610fe5d 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/LinearLayoutRule.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/LinearLayoutRule.java
@@ -188,6 +188,9 @@ public class LinearLayoutRule extends BaseLayoutRule {
weight = mRulesEngine.displayInput("Enter Weight Value:", weight,
null);
if (weight != null) {
+ if (weight.isEmpty()) {
+ weight = null; // remove attribute
+ }
for (INode child : children) {
child.setAttribute(ANDROID_URI,
ATTR_LAYOUT_WEIGHT, weight);
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 c5f976f..5162a48 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
@@ -116,6 +116,11 @@ import java.util.concurrent.atomic.AtomicReference;
* with a few methods they can use to access functionality from this {@link RulesEngine}.
*/
class ClientRulesEngine implements IClientRulesEngine {
+ /** The return code from the dialog for the user choosing "Clear" */
+ public static final int CLEAR_RETURN_CODE = -5;
+ /** The dialog button ID for the user choosing "Clear" */
+ private static final int CLEAR_BUTTON_ID = CLEAR_RETURN_CODE;
+
private final RulesEngine mRulesEngine;
private final String mFqcn;
@@ -174,8 +179,28 @@ class ClientRulesEngine implements IClientRulesEngine {
mFqcn, // title
message,
value == null ? "" : value, //$NON-NLS-1$
- validator);
- if (d.open() == Window.OK) {
+ validator) {
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ createButton(parent, CLEAR_BUTTON_ID, "Clear", false /*defaultButton*/);
+ super.createButtonsForButtonBar(parent);
+ }
+
+ @Override
+ protected void buttonPressed(int buttonId) {
+ super.buttonPressed(buttonId);
+
+ if (buttonId == CLEAR_BUTTON_ID) {
+ assert CLEAR_RETURN_CODE != Window.OK && CLEAR_RETURN_CODE != Window.CANCEL;
+ setReturnCode(CLEAR_RETURN_CODE);
+ close();
+ }
+ }
+ };
+ int result = d.open();
+ if (result == ResourceChooser.CLEAR_RETURN_CODE) {
+ return "";
+ } else if (result == Window.OK) {
return d.getValue();
}
return null;