aboutsummaryrefslogtreecommitdiffstats
path: root/rule_api
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2012-06-05 09:37:07 -0700
committerTor Norbye <tnorbye@google.com>2012-06-05 09:40:17 -0700
commitcb3758e42389a933203262f9109454c091574d30 (patch)
tree0fb21159142fe9b33d78999f0a139783ae19bc4f /rule_api
parent10b2b237290594bc389a4c952866087b77f0f6ef (diff)
downloadsdk-cb3758e42389a933203262f9109454c091574d30.zip
sdk-cb3758e42389a933203262f9109454c091574d30.tar.gz
sdk-cb3758e42389a933203262f9109454c091574d30.tar.bz2
32745: Lack of warning of using duplicated IDs for element.
This changeset adds a validator to the assign/edit id dialog used in the layout editor such that the user gets a warning if picking an id which is already defined within the same layout. Also cleans up the Rules API for adding a validator and makes the generic resource validator handle both the case of requiring a unique name and requiring an existing name. Change-Id: Id9642c3bcd326f9734cf98c98f6799b67e11a4ae
Diffstat (limited to 'rule_api')
-rw-r--r--rule_api/src/com/android/ide/common/api/IClientRulesEngine.java22
1 files changed, 18 insertions, 4 deletions
diff --git a/rule_api/src/com/android/ide/common/api/IClientRulesEngine.java b/rule_api/src/com/android/ide/common/api/IClientRulesEngine.java
index b9ea6cb..329f38c 100644
--- a/rule_api/src/com/android/ide/common/api/IClientRulesEngine.java
+++ b/rule_api/src/com/android/ide/common/api/IClientRulesEngine.java
@@ -106,11 +106,25 @@ public interface IClientRulesEngine {
/**
* Returns a resource name validator for the current project
*
- * @return an {@link IValidator} for validating a new resource name in the current
- * project
+ * @param resourceTypeName resource type, such as "id", "string", and so on
+ * @param uniqueInProject if true, the resource name must be unique in the
+ * project (not already be defined anywhere else)
+ * @param uniqueInLayout if true, the resource name must be unique at least
+ * within the current layout. This only applies to {@code @id}
+ * resources since only those resources can be defined in-place
+ * within a layout
+ * @param exists if true, the resource name must already exist
+ * @param allowed allowed names (optional). This can for example be used to
+ * request a unique-in-layout validator, but to remove the
+ * current value of the node being edited from consideration such
+ * that it allows you to leave the value the same
+ * @return an {@link IValidator} for validating a new resource name in the
+ * current project
*/
@Nullable
- IValidator getResourceValidator();
+ IValidator getResourceValidator(@NonNull String resourceTypeName,
+ boolean uniqueInProject, boolean uniqueInLayout, boolean exists,
+ String... allowed);
/**
* Displays an input dialog where the user can enter an Android reference value
@@ -119,7 +133,7 @@ public interface IClientRulesEngine {
* @return the reference selected by the user, or null
*/
@Nullable
- String displayReferenceInput(String currentValue);
+ String displayReferenceInput(@Nullable String currentValue);
/**
* Displays an input dialog where the user can enter an Android resource name of the