ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1683873 - /ace/trunk/org.apache.ace.tageditor/src/org/apache/ace/tageditor/TagTableEntry.java
Date Fri, 05 Jun 2015 21:50:00 GMT
Author: marrs
Date: Fri Jun  5 21:49:59 2015
New Revision: 1683873

URL: http://svn.apache.org/r1683873
Log:
ACE-518 Fixed the UI to signal key validation errors to the user.

Modified:
    ace/trunk/org.apache.ace.tageditor/src/org/apache/ace/tageditor/TagTableEntry.java

Modified: ace/trunk/org.apache.ace.tageditor/src/org/apache/ace/tageditor/TagTableEntry.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.tageditor/src/org/apache/ace/tageditor/TagTableEntry.java?rev=1683873&r1=1683872&r2=1683873&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.tageditor/src/org/apache/ace/tageditor/TagTableEntry.java (original)
+++ ace/trunk/org.apache.ace.tageditor/src/org/apache/ace/tageditor/TagTableEntry.java Fri
Jun  5 21:49:59 2015
@@ -22,6 +22,8 @@ import org.apache.ace.client.repository.
 
 import com.vaadin.data.Property.ValueChangeEvent;
 import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.data.validator.RegexpValidator;
 import com.vaadin.ui.Button;
 import com.vaadin.ui.Table;
 import com.vaadin.ui.TextField;
@@ -44,6 +46,7 @@ public class TagTableEntry {
     public TagTableEntry(RepositoryObject repoObject) {
         m_repoObject = repoObject;
         m_keyField.setImmediate(true);
+        m_keyField.setInputPrompt("key");
         m_keyField.setWidth("100%");
         m_keyField.addListener(new ValueChangeListener() {
             public void valueChange(ValueChangeEvent event) {
@@ -52,6 +55,7 @@ public class TagTableEntry {
         });
         m_valueField.setImmediate(true);
         m_valueField.setWidth("100%");
+        m_valueField.setInputPrompt("value");
         m_valueField.addListener(new ValueChangeListener() {
             public void valueChange(ValueChangeEvent event) {
                 valueChanged();
@@ -109,7 +113,16 @@ public class TagTableEntry {
             m_lastKey = (String) m_keyField.getValue();
         }
         else {
-            m_repoObject.addTag(m_lastKey, null);
+            try {
+                m_repoObject.addTag(m_lastKey, null);
+            }
+            catch (IllegalArgumentException e) {
+                m_keyField.setValue("");
+                m_keyField.setInputPrompt("invalid key, try again");
+                m_lastKey = null;
+                m_keyField.focus();
+                return;
+            }
         }
         m_lastKey = (String) m_keyField.getValue();
         set(m_lastKey, (String) m_valueField.getValue());
@@ -122,7 +135,16 @@ public class TagTableEntry {
     private void set(String key, String value) {
         if ((key != null) && (key.trim().length() > 0)) {
             if ((value != null) && (value.trim().length() > 0)) {
-                m_repoObject.addTag(key, value); // TODO changing the tag that often is probably
not a good idea (especially if nothing changed)
+                try {
+                    m_repoObject.addTag(key, value); // TODO changing the tag that often
is probably not a good idea (especially if nothing changed)
+                }
+                catch (IllegalArgumentException e) {
+                    m_keyField.setValue("");
+                    m_keyField.setInputPrompt("invalid key, try again");
+                    m_keyField.focus();
+                    return;
+                }
+                
                 ChangeListener listener = m_listener;
                 if (listener != null) {
                     listener.changed(this);



Mime
View raw message