ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1310281 - /ace/trunk/ace-target-mgmt-ui/src/main/java/org/apache/ace/target/management/ui/TargetManagementExtension.java
Date Fri, 06 Apr 2012 11:29:29 GMT
Author: jawi
Date: Fri Apr  6 11:29:29 2012
New Revision: 1310281

URL: http://svn.apache.org/viewvc?rev=1310281&view=rev
Log:
ACE-252: improve the target managment UI a bit.

Modified:
    ace/trunk/ace-target-mgmt-ui/src/main/java/org/apache/ace/target/management/ui/TargetManagementExtension.java

Modified: ace/trunk/ace-target-mgmt-ui/src/main/java/org/apache/ace/target/management/ui/TargetManagementExtension.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-target-mgmt-ui/src/main/java/org/apache/ace/target/management/ui/TargetManagementExtension.java?rev=1310281&r1=1310280&r2=1310281&view=diff
==============================================================================
--- ace/trunk/ace-target-mgmt-ui/src/main/java/org/apache/ace/target/management/ui/TargetManagementExtension.java
(original)
+++ ace/trunk/ace-target-mgmt-ui/src/main/java/org/apache/ace/target/management/ui/TargetManagementExtension.java
Fri Apr  6 11:29:29 2012
@@ -62,66 +62,59 @@ public class TargetManagementExtension i
         registerCB.setImmediate(true);
         registerCB.setEnabled(!target.isRegistered());
         registerCB.setValue(Boolean.valueOf(target.isRegistered()));
-        registerCB.addListener(new Button.ClickListener() {
-            public void buttonClick(ClickEvent event) {
-                if (event.getButton().booleanValue()) {
-                    target.register();
-                    registerCB.setEnabled(!target.isRegistered());
-                }
-            }
-        });
 
         result.addComponent(registerCB);
 
-        CheckBox autoApproveCB = new CheckBox("Auto approve?");
+        final CheckBox autoApproveCB = new CheckBox("Auto approve?");
         autoApproveCB.setImmediate(true);
         autoApproveCB.setEnabled(target.isRegistered());
         autoApproveCB.setValue(Boolean.valueOf(target.getAutoApprove()));
-        autoApproveCB.addListener(new Button.ClickListener() {
-            public void buttonClick(ClickEvent event) {
-                target.setAutoApprove(event.getButton().booleanValue());
-            }
-        });
 
         result.addComponent(autoApproveCB);
 
 
         final Button approveButton = new Button("Approve changes");
         approveButton.setImmediate(true);
-        approveButton.setEnabled(hasUnapprovedChanges(target));
-        approveButton.addListener(new Button.ClickListener() {
-            public void buttonClick(ClickEvent event) {
-                target.approve();
-                approveButton.setEnabled(hasUnapprovedChanges(target));
-            }
-        });
+        approveButton.setEnabled(target.needsApprove());
 
         result.addComponent(approveButton);
         
         // Add a spacer that fill the remainder of the available space...
         result.addComponent(new Label(" "));
         result.setRowExpandRatio(3, 1.0f);
+        
+        // Add all listeners...
+        registerCB.addListener(new Button.ClickListener() {
+            public void buttonClick(ClickEvent event) {
+                if (event.getButton().booleanValue()) {
+                    target.register();
+                    registerCB.setEnabled(!target.isRegistered());
+                    autoApproveCB.setEnabled(target.isRegistered());
+                }
+            }
+        });
+        autoApproveCB.addListener(new Button.ClickListener() {
+            public void buttonClick(ClickEvent event) {
+                target.setAutoApprove(event.getButton().booleanValue());
+                approveButton.setEnabled(target.needsApprove());
+            }
+        });
+        approveButton.addListener(new Button.ClickListener() {
+            public void buttonClick(ClickEvent event) {
+                target.approve();
+                approveButton.setEnabled(target.needsApprove());
+            }
+        });
 
         return result;
     }
 
-    /**
-     * @param target
-     * @return
-     */
-    private boolean hasUnapprovedChanges(StatefulTargetObject target) {
-    	return target.needsApprove();
-    }
-
     private RepositoryObject getRepositoryObjectFromContext(Map<String, Object> context)
{
         Object contextObject = context.get("object");
         if (contextObject == null) {
             throw new IllegalStateException("No context object found");
         }
-        // It looks like there is some bug (or some other reason that escapes
-        // me) why ace is using either the object directly or wraps it in a
-        // NamedObject first.
-        // Its unclear when it does which so for now we cater for both.
+
         return (contextObject instanceof NamedObject ? ((NamedObject) contextObject).getObject()
             : (RepositoryObject) contextObject);
     }



Mime
View raw message