[kune-commits] r1376 - trunk/src/main/java/cc/kune/gspace/client/options/tools

Vicente J. Ruiz Jurado vjrj_ at ourproject.org
Wed May 11 11:09:08 CEST 2011


Author: vjrj_
Date: 2011-05-11 11:09:08 +0200 (Wed, 11 May 2011)
New Revision: 1376

Modified:
   trunk/src/main/java/cc/kune/gspace/client/options/tools/EntityOptionsToolsConfPanel.java
   trunk/src/main/java/cc/kune/gspace/client/options/tools/EntityOptionsToolsConfPresenter.java
   trunk/src/main/java/cc/kune/gspace/client/options/tools/EntityOptionsToolsConfView.java
Log:
tool prefs bug fix

Modified: trunk/src/main/java/cc/kune/gspace/client/options/tools/EntityOptionsToolsConfPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/options/tools/EntityOptionsToolsConfPanel.java	2011-05-11 00:24:00 UTC (rev 1375)
+++ trunk/src/main/java/cc/kune/gspace/client/options/tools/EntityOptionsToolsConfPanel.java	2011-05-11 09:09:08 UTC (rev 1376)
@@ -62,10 +62,13 @@
   }
 
   @Override
-  public void add(final ToolSimpleDTO tool, final ClickHandler handler) {
+  public void add(final ToolSimpleDTO tool, final boolean enabled, final boolean checked,
+      final ClickHandler handler) {
     final CheckBox checkbox = new CheckBox();
     checkbox.setFieldLabel(tool.getRootName());
-    // checkbox.setValue(false);
+    // checkbox.setFireChangeEventOnSetValue(false);
+    checkbox.setValue(checked);
+    setEnabled(checkbox, enabled);
     checkbox.addListener(Events.Change, new Listener<BaseEvent>() {
       @Override
       public void handleEvent(final BaseEvent be) {
@@ -128,17 +131,21 @@
     field.setValue(checked);
   }
 
-  @Override
-  public void setEnabled(final String tool, final boolean enabled) {
-    final CheckBox field = getTool(tool);
+  private void setEnabled(final CheckBox checkbox, final boolean enabled) {
     if (enabled) {
-      field.enable();
+      checkbox.enable();
     } else {
-      field.disable();
+      checkbox.disable();
     }
   }
 
   @Override
+  public void setEnabled(final String tool, final boolean enabled) {
+    final CheckBox field = getTool(tool);
+    setEnabled(field, enabled);
+  }
+
+  @Override
   public void setTooltip(final String tool, final String tip) {
     final CheckBox field = getTool(tool);
     Tooltip.to(field, tip);

Modified: trunk/src/main/java/cc/kune/gspace/client/options/tools/EntityOptionsToolsConfPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/options/tools/EntityOptionsToolsConfPresenter.java	2011-05-11 00:24:00 UTC (rev 1375)
+++ trunk/src/main/java/cc/kune/gspace/client/options/tools/EntityOptionsToolsConfPresenter.java	2011-05-11 09:09:08 UTC (rev 1376)
@@ -84,14 +84,12 @@
   private void onCheck(final ToolSimpleDTO tool, final boolean checked) {
     final List<String> enabledTools = getEnabledTools();
     final String toolName = tool.getName();
-    if (checked) {
-      if (!(enabledTools.contains(toolName))) {
-        setToolCheckedInServer(checked, toolName);
-      }
-    } else {
+    setToolCheckedInServer(checked, toolName);
+    if (!checked) {
       if (enabledTools.contains(toolName)) {
-        setToolCheckedInServer(checked, toolName);
-        gotoDifLocationIfNecessary(toolName);
+        // FIXME uncomment this when fixed
+        // setToolCheckedInServer(checked, toolName);
+        // gotoDifLocationIfNecessary(toolName);
       }
     }
   }
@@ -104,19 +102,18 @@
   protected void setState() {
     reset();
     final Collection<ToolSimpleDTO> toolCollection = getAllTools();
+    final List<String> enabledTools = getEnabledTools();
     for (final ToolSimpleDTO tool : toolCollection) {
-      view.add(tool, new ClickHandler() {
+      final boolean checked = enabledTools.contains(tool.getName());
+      final boolean enabled = true;
+      view.add(tool, enabled, checked, new ClickHandler() {
         @Override
         public void onClick(final ClickEvent event) {
           onCheck(tool, view.isChecked(tool.getName()));
         }
       });
-      view.setEnabled(tool.getName(), true);
     }
-    for (final String tool : getEnabledTools()) {
-      view.setChecked(tool, true);
-    }
-
+    // Disable def content tool (don't works now)
     final StateToken token = getDefContentToken();
     if (token != null) {
       final String defContentTool = token.getTool();
@@ -129,6 +126,7 @@
 
   protected void setToolCheckedInServer(final boolean checked, final String toolName) {
     // view.mask();
+    // NotifyUser.info("Dis/Enabling tool" + toolName + " - " + checked);
     groupService.get().setToolEnabled(session.getUserHash(), getOperationToken(), toolName, checked,
         new AsyncCallback<Void>() {
           @Override

Modified: trunk/src/main/java/cc/kune/gspace/client/options/tools/EntityOptionsToolsConfView.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/options/tools/EntityOptionsToolsConfView.java	2011-05-11 00:24:00 UTC (rev 1375)
+++ trunk/src/main/java/cc/kune/gspace/client/options/tools/EntityOptionsToolsConfView.java	2011-05-11 09:09:08 UTC (rev 1376)
@@ -26,7 +26,7 @@
 
 public interface EntityOptionsToolsConfView extends EntityOptionsTabView {
 
-  void add(ToolSimpleDTO tool, ClickHandler clickHandler);
+  void add(ToolSimpleDTO tool, boolean enabled, boolean checked, ClickHandler clickHandler);
 
   void clear();
 




More information about the kune-commits mailing list