[kune-commits] r1498 - trunk/src/main/java/cc/kune/gspace/client/tool/selector

Vicente J. Ruiz Jurado vjrj_ at ourproject.org
Wed Aug 17 03:33:52 CEST 2011


Author: vjrj_
Date: 2011-08-17 03:33:52 +0200 (Wed, 17 Aug 2011)
New Revision: 1498

Modified:
   trunk/src/main/java/cc/kune/gspace/client/tool/selector/ToolSelectorItem.java
   trunk/src/main/java/cc/kune/gspace/client/tool/selector/ToolSelectorItemPresenter.java
   trunk/src/main/java/cc/kune/gspace/client/tool/selector/ToolSelectorPresenter.java
Log:
CLOSED - # 62: Tool links should point to the previous content (not the root) 
http://kune.ourproject.org/issues/ticket/62

Modified: trunk/src/main/java/cc/kune/gspace/client/tool/selector/ToolSelectorItem.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/tool/selector/ToolSelectorItem.java	2011-08-16 19:51:42 UTC (rev 1497)
+++ trunk/src/main/java/cc/kune/gspace/client/tool/selector/ToolSelectorItem.java	2011-08-17 01:33:52 UTC (rev 1498)
@@ -19,18 +19,21 @@
  \*/
 package cc.kune.gspace.client.tool.selector;
 
+import cc.kune.core.shared.domain.utils.StateToken;
 import cc.kune.gspace.client.tool.selector.ToolSelectorItemPresenter.ToolSelectorItemView;
 
 public interface ToolSelectorItem {
 
-    String getShortName();
+  String getShortName();
 
-    ToolSelectorItemView getView();
+  ToolSelectorItemView getView();
 
-    void setGroupShortName(String groupShortName);
+  void setGroupShortName(String groupShortName);
 
-    void setSelected(boolean selected);
+  void setSelected(boolean selected);
 
-    void setVisible(boolean visible);
+  void setToken(StateToken token);
 
+  void setVisible(boolean visible);
+
 }

Modified: trunk/src/main/java/cc/kune/gspace/client/tool/selector/ToolSelectorItemPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/tool/selector/ToolSelectorItemPresenter.java	2011-08-16 19:51:42 UTC (rev 1497)
+++ trunk/src/main/java/cc/kune/gspace/client/tool/selector/ToolSelectorItemPresenter.java	2011-08-17 01:33:52 UTC (rev 1498)
@@ -35,15 +35,12 @@
 
     HasText getLabel();
 
-    // void setTheme(WsTheme oldTheme, WsTheme newTheme);
-
     void setSelected(boolean selected);
 
     void setVisible(boolean visible);
   }
 
   private final String longName;
-  // private final WsThemeManager wsThemePresenter;
   private final String shortName;
   private StateToken token;
   private final ToolSelector toolSelector;
@@ -54,7 +51,6 @@
     this.shortName = shortName;
     this.longName = longName;
     this.toolSelector = toolSelector;
-    // this.wsThemePresenter = wsThemePresenter;
   }
 
   @Override
@@ -77,12 +73,6 @@
       }
     });
     view.getLabel().setText(longName);
-    // wsThemePresenter.addOnThemeChanged(new Listener2<WsTheme, WsTheme>()
-    // {
-    // public void onEvent(final WsTheme oldTheme, final WsTheme newTheme) {
-    // setTheme(oldTheme, newTheme);
-    // }
-    // });
   }
 
   @Override
@@ -95,9 +85,10 @@
     view.setSelected(selected);
   }
 
-  // private void setTheme(final WsTheme oldTheme, final WsTheme newTheme) {
-  // view.setTheme(oldTheme, newTheme);
-  // }
+  @Override
+  public void setToken(final StateToken token) {
+    this.token = token;
+  }
 
   @Override
   public void setVisible(final boolean visible) {

Modified: trunk/src/main/java/cc/kune/gspace/client/tool/selector/ToolSelectorPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/tool/selector/ToolSelectorPresenter.java	2011-08-16 19:51:42 UTC (rev 1497)
+++ trunk/src/main/java/cc/kune/gspace/client/tool/selector/ToolSelectorPresenter.java	2011-08-17 01:33:52 UTC (rev 1498)
@@ -31,6 +31,7 @@
 import cc.kune.core.client.state.StateManager;
 import cc.kune.core.client.state.ToolChangedEvent;
 import cc.kune.core.client.state.ToolChangedEvent.ToolChangedHandler;
+import cc.kune.core.shared.domain.utils.StateToken;
 import cc.kune.gspace.client.tool.selector.ToolSelectorItemPresenter.ToolSelectorItemView;
 
 import com.google.gwt.event.shared.EventBus;
@@ -42,94 +43,103 @@
 import com.gwtplatform.mvp.client.proxy.RevealRootContentEvent;
 
 public class ToolSelectorPresenter extends
-        Presenter<ToolSelectorPresenter.ToolSelectorView, ToolSelectorPresenter.ToolSelectorProxy> implements
-        ToolSelector {
+    Presenter<ToolSelectorPresenter.ToolSelectorView, ToolSelectorPresenter.ToolSelectorProxy> implements
+    ToolSelector {
 
-    @ProxyCodeSplit
-    public interface ToolSelectorProxy extends Proxy<ToolSelectorPresenter> {
-    }
+  @ProxyCodeSplit
+  public interface ToolSelectorProxy extends Proxy<ToolSelectorPresenter> {
+  }
 
-    public interface ToolSelectorView extends View {
-        void addItem(ToolSelectorItemView item);
-    }
+  public interface ToolSelectorView extends View {
+    void addItem(ToolSelectorItemView item);
+  }
 
-    private final HashMap<String, ToolSelectorItem> tools;
+  private final HashMap<String, ToolSelectorItem> tools;
 
-    @Inject
-    public ToolSelectorPresenter(final EventBus eventBus, final ToolSelectorView view, final ToolSelectorProxy proxy,
-            final StateManager stateManager) {
-        super(eventBus, view, proxy);
-        tools = new HashMap<String, ToolSelectorItem>();
-        stateManager.onStateChanged(true, new StateChangedHandler() {
-            @Override
-            public void onStateChanged(final StateChangedEvent event) {
-                for (final String tool : tools.keySet()) {
-                    final List<String> enabledTools = event.getState().getEnabledTools();
-                    if (enabledTools != null && enabledTools.contains(tool)) {
-                        tools.get(tool).setVisible(true);
-                    } else {
-                        tools.get(tool).setVisible(false);
-                    }
-                }
-            }
-        });
-        stateManager.onGroupChanged(true, new GroupChangedHandler() {
-            @Override
-            public void onGroupChanged(final GroupChangedEvent event) {
-                ToolSelectorPresenter.this.onGroupChanged(event.getNewGroup());
-            }
-        });
-        stateManager.onToolChanged(false, new ToolChangedHandler() {
-            @Override
-            public void onToolChanged(final ToolChangedEvent event) {
-                ToolSelectorPresenter.this.onToolChanged(event.getPreviousTool(), event.getNewTool());
-            }
-        });
-    }
-
-    @Override
-    public void addTool(final ToolSelectorItem item) {
-        final String name = item.getShortName();
-        if (name == null) {
-            throw new UIException("You cannot add a tool without a name");
+  @Inject
+  public ToolSelectorPresenter(final EventBus eventBus, final ToolSelectorView view,
+      final ToolSelectorProxy proxy, final StateManager stateManager) {
+    super(eventBus, view, proxy);
+    tools = new HashMap<String, ToolSelectorItem>();
+    stateManager.onStateChanged(true, new StateChangedHandler() {
+      @Override
+      public void onStateChanged(final StateChangedEvent event) {
+        for (final String tool : tools.keySet()) {
+          final List<String> enabledTools = event.getState().getEnabledTools();
+          if (enabledTools != null && enabledTools.contains(tool)) {
+            tools.get(tool).setVisible(true);
+          } else {
+            tools.get(tool).setVisible(false);
+          }
         }
-        if (tools.get(name) != null) {
-            throw new UIException("A tool with the same name already added");
+      }
+    });
+    stateManager.onGroupChanged(true, new GroupChangedHandler() {
+      @Override
+      public void onGroupChanged(final GroupChangedEvent event) {
+        ToolSelectorPresenter.this.onGroupChanged(event.getNewGroup());
+      }
+    });
+    stateManager.onToolChanged(false, new ToolChangedHandler() {
+      @Override
+      public void onToolChanged(final ToolChangedEvent event) {
+        ToolSelectorPresenter.this.onToolChanged(event.getPreviousTool(), event.getNewTool());
+      }
+    });
+    stateManager.onStateChanged(true, new StateChangedHandler() {
+      @Override
+      public void onStateChanged(final StateChangedEvent event) {
+        final StateToken token = event.getState().getStateToken();
+        if (token.hasAll() || token.hasGroupToolAndFolder()) {
+          tools.get(token.getTool()).setToken(token);
         }
-        tools.put(name, item);
-        item.setSelected(false);
-        getView().addItem(item.getView());
+      }
+    });
+  }
+
+  @Override
+  public void addTool(final ToolSelectorItem item) {
+    final String name = item.getShortName();
+    if (name == null) {
+      throw new UIException("You cannot add a tool without a name");
     }
+    if (tools.get(name) != null) {
+      throw new UIException("A tool with the same name already added");
+    }
+    tools.put(name, item);
+    item.setSelected(false);
+    getView().addItem(item.getView());
+  }
 
-    private void checkTool(final ToolSelectorItem tool) {
-        if (tool == null) {
-            throw new UIException("Trying to activate an unregistered tool in client");
-        }
-
+  private void checkTool(final ToolSelectorItem tool) {
+    if (tool == null) {
+      throw new UIException("Trying to activate an unregistered tool in client");
     }
 
-    void onGroupChanged(final String newGroupName) {
-        for (final String name : tools.keySet()) {
-            tools.get(name).setGroupShortName(newGroupName);
-        }
+  }
+
+  void onGroupChanged(final String newGroupName) {
+    for (final String name : tools.keySet()) {
+      tools.get(name).setGroupShortName(newGroupName);
     }
+  }
 
-    void onToolChanged(final String oldTool, final String newTool) {
-        Log.debug("Registered tools: " + tools.keySet().toString());
-        if (oldTool != null && !oldTool.equals("")) {
-            final ToolSelectorItem tool = tools.get(oldTool);
-            checkTool(tool);
-            tool.setSelected(false);
-        }
-        if (!newTool.equals("")) {
-            final ToolSelectorItem tool = tools.get(newTool);
-            checkTool(tool);
-            tool.setSelected(true);
-        }
+  void onToolChanged(final String oldTool, final String newTool) {
+    Log.debug("Registered tools: " + tools.keySet().toString());
+    if (oldTool != null && !oldTool.equals("")) {
+      final ToolSelectorItem tool = tools.get(oldTool);
+      checkTool(tool);
+      tool.setSelected(false);
     }
+    if (!newTool.equals("")) {
+      final ToolSelectorItem tool = tools.get(newTool);
+      checkTool(tool);
+      tool.setSelected(true);
+    }
+  }
 
-    @Override
-    protected void revealInParent() {
-        RevealRootContentEvent.fire(this, this);
-    }
+  @Override
+  protected void revealInParent() {
+    RevealRootContentEvent.fire(this, this);
+  }
 }




More information about the kune-commits mailing list