[kune-commits] r1642 - in trunk/src/main/java/cc/kune: common/client/tooltip events/client/viewer

Vicente J. Ruiz Jurado vjrj_ at ourproject.org
Tue Dec 20 18:27:02 CET 2011


Author: vjrj_
Date: 2011-12-20 18:27:01 +0100 (Tue, 20 Dec 2011)
New Revision: 1642

Modified:
   trunk/src/main/java/cc/kune/common/client/tooltip/TooltipPositionCalculator.java
   trunk/src/main/java/cc/kune/events/client/viewer/CalendarViewerPresenter.java
Log:
Tooltip fix & some minor change

Modified: trunk/src/main/java/cc/kune/common/client/tooltip/TooltipPositionCalculator.java
===================================================================
--- trunk/src/main/java/cc/kune/common/client/tooltip/TooltipPositionCalculator.java	2011-12-20 00:39:19 UTC (rev 1641)
+++ trunk/src/main/java/cc/kune/common/client/tooltip/TooltipPositionCalculator.java	2011-12-20 17:27:01 UTC (rev 1642)
@@ -23,64 +23,70 @@
 
 public class TooltipPositionCalculator {
 
-    public static TooltipPosition calculate(final int windowWitdh, final int windowHeight, final int widgetLeft,
-            final int widgetTop, final int widgetWidth, final int widgetHeight, final int tooltipWidth,
-            final int tooltipHeight) {
-        // GWT.log("ww: " + windowWitdh + " wh: " + windowHeight + " widL: " +
-        // widgetLeft + " widT: " + widgetTop
-        // + " widW: " + widgetWidth + " widH: " + widgetHeight + " tW: " +
-        // tooltipWidth + " tH: " + tooltipHeight);
-        final boolean overflowsWidth = overflowsWidth(windowWitdh, widgetLeft, tooltipWidth);
-        final boolean overflowsHeight = overflowsHeight(windowHeight, widgetTop, tooltipHeight);
-        // GWT.log("ow: " + overflowsWidth + " oH: " + overflowsHeight);
-        if (overflowsWidth && overflowsHeight) {
-            // esta es mezcla de las anteriores (y falta)
-            return new TooltipPosition(leftOverflow(widgetLeft, widgetWidth, tooltipWidth), widgetTop - tooltipHeight
-                    - TooltipPosition.TOOLTIP_DISTANCE, ArrowPosition.SE, leftArrowOverflow(tooltipWidth), -2
-                    * TooltipPosition.ARROW_SIZE);
-        } else if (overflowsHeight) {
-            return new TooltipPosition(leftNoOverflow(widgetLeft), widgetTop - tooltipHeight
-                    - TooltipPosition.TOOLTIP_DISTANCE, ArrowPosition.SW, 0, -2 * TooltipPosition.ARROW_SIZE);
-        } else if (overflowsWidth) {
-            return new TooltipPosition(leftOverflow(widgetLeft, widgetWidth, tooltipWidth), topNoOverflow(widgetTop,
-                    widgetHeight), ArrowPosition.NE, leftArrowOverflow(tooltipWidth), -2 * TooltipPosition.ARROW_SIZE
-                    - 1);
-            // 10 in the border width
-        } else if (overflowsHeight) {
-            return new TooltipPosition(onTopPositionTop(widgetLeft, widgetWidth), widgetTop - tooltipHeight
-                    - TooltipPosition.TOOLTIP_DISTANCE, ArrowPosition.SW, TooltipPosition.ARROW_DEF_MARGIN, 0);
-        } else {
-            // Don't overflow
-            return new TooltipPosition(leftNoOverflow(widgetLeft), topNoOverflow(widgetTop, widgetHeight),
-                    ArrowPosition.NW, TooltipPosition.ARROW_DEF_MARGIN, -2 * TooltipPosition.ARROW_SIZE - 1);
-        }
+  public static TooltipPosition calculate(final int windowWitdh, final int windowHeight,
+      final int widgetLeft, final int widgetTop, final int widgetWidth, final int widgetHeight,
+      final int tooltipWidth, final int tooltipHeight) {
+    // GWT.log("ww: " + windowWitdh + " wh: " + windowHeight + " widL: " +
+    // widgetLeft + " widT: " + widgetTop
+    // + " widW: " + widgetWidth + " widH: " + widgetHeight + " tW: " +
+    // tooltipWidth + " tH: " + tooltipHeight);
+    final boolean overflowsWidth = overflowsWidth(windowWitdh, widgetLeft, tooltipWidth);
+    final boolean overflowsHeight = overflowsHeight(windowHeight, widgetTop, tooltipHeight);
+    // GWT.log("ow: " + overflowsWidth + " oH: " + overflowsHeight);
+    if (overflowsWidth && overflowsHeight) {
+      // esta es mezcla de las anteriores (y falta)
+      return new TooltipPosition(leftOverflow(widgetLeft, widgetWidth, tooltipWidth), widgetTop
+          - tooltipHeight - TooltipPosition.TOOLTIP_DISTANCE, ArrowPosition.SE,
+          leftArrowOverflow(tooltipWidth), -2 * TooltipPosition.ARROW_SIZE);
+    } else if (overflowsHeight) {
+      return new TooltipPosition(leftNoOverflow(widgetLeft), widgetTop - tooltipHeight
+          - TooltipPosition.TOOLTIP_DISTANCE, ArrowPosition.SW, TooltipPosition.ARROW_DEF_MARGIN + 5, -2
+          * TooltipPosition.ARROW_SIZE);
+    } else if (overflowsWidth) {
+      return new TooltipPosition(leftOverflow(widgetLeft, widgetWidth, tooltipWidth), topNoOverflow(
+          widgetTop, widgetHeight), ArrowPosition.NE, leftArrowOverflow(tooltipWidth), -2
+          * TooltipPosition.ARROW_SIZE - 1);
+      // 10 in the border width
+      // } else if (overflowsHeight) {
+      //
+      // return new TooltipPosition(onTopPositionTop(widgetLeft, widgetWidth),
+      // widgetTop - tooltipHeight
+      // - TooltipPosition.TOOLTIP_DISTANCE, ArrowPosition.SW,
+      // TooltipPosition.ARROW_DEF_MARGIN, 0);
+    } else {
+      // Don't overflow
+      return new TooltipPosition(leftNoOverflow(widgetLeft), topNoOverflow(widgetTop, widgetHeight),
+          ArrowPosition.NW, TooltipPosition.ARROW_DEF_MARGIN + 5, -2 * TooltipPosition.ARROW_SIZE - 1);
     }
+  }
 
-    private static int leftArrowOverflow(final int tooltipWidth) {
-        return tooltipWidth - TooltipPosition.ARROW_DEF_MARGIN - 2 * 10;
-    }
+  private static int leftArrowOverflow(final int tooltipWidth) {
+    return tooltipWidth - TooltipPosition.ARROW_DEF_MARGIN - 2 * 10;
+  }
 
-    private static int leftNoOverflow(final int widgetLeft) {
-        return widgetLeft;
-    }
+  private static int leftNoOverflow(final int widgetLeft) {
+    return widgetLeft;
+  }
 
-    private static int leftOverflow(final int widgetLeft, final int widgetWidth, final int tooltipWidth) {
-        return widgetLeft + widgetWidth - tooltipWidth - TooltipPosition.TOOLTIP_DISTANCE;
-    }
+  private static int leftOverflow(final int widgetLeft, final int widgetWidth, final int tooltipWidth) {
+    return widgetLeft + widgetWidth - tooltipWidth - TooltipPosition.TOOLTIP_DISTANCE;
+  }
 
-    private static int onTopPositionTop(final int widgetTop, final int widgetHeight) {
-        return topNoOverflow(widgetTop, widgetHeight);
-    }
+  private static int onTopPositionTop(final int widgetTop, final int widgetHeight) {
+    return topNoOverflow(widgetTop, widgetHeight);
+  }
 
-    private static boolean overflowsHeight(final int windowHeight, final int widgetTop, final int tooltipHeight) {
-        return widgetTop + TooltipPosition.TOOLTIP_DISTANCE + tooltipHeight > windowHeight;
-    }
+  private static boolean overflowsHeight(final int windowHeight, final int widgetTop,
+      final int tooltipHeight) {
+    return widgetTop + TooltipPosition.TOOLTIP_DISTANCE + tooltipHeight > windowHeight;
+  }
 
-    private static boolean overflowsWidth(final int windowWitdh, final int widgetLeft, final int tooltipWidth) {
-        return widgetLeft + TooltipPosition.TOOLTIP_DISTANCE + tooltipWidth > windowWitdh;
-    }
+  private static boolean overflowsWidth(final int windowWitdh, final int widgetLeft,
+      final int tooltipWidth) {
+    return widgetLeft + TooltipPosition.TOOLTIP_DISTANCE + tooltipWidth > windowWitdh;
+  }
 
-    private static int topNoOverflow(final int widgetTop, final int widgetHeight) {
-        return widgetTop + widgetHeight + TooltipPosition.TOOLTIP_DISTANCE;
-    }
+  private static int topNoOverflow(final int widgetTop, final int widgetHeight) {
+    return widgetTop + widgetHeight + TooltipPosition.TOOLTIP_DISTANCE;
+  }
 }

Modified: trunk/src/main/java/cc/kune/events/client/viewer/CalendarViewerPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/events/client/viewer/CalendarViewerPresenter.java	2011-12-20 00:39:19 UTC (rev 1641)
+++ trunk/src/main/java/cc/kune/events/client/viewer/CalendarViewerPresenter.java	2011-12-20 17:27:01 UTC (rev 1642)
@@ -5,6 +5,9 @@
 import javax.annotation.Nonnull;
 
 import cc.kune.common.client.notify.NotifyUser;
+import cc.kune.common.client.tooltip.Tooltip;
+import cc.kune.common.client.utils.SimpleResponseCallback;
+import cc.kune.common.shared.i18n.I18nTranslationService;
 import cc.kune.core.shared.dto.HasContent;
 import cc.kune.gspace.client.viewers.AbstractFolderViewerView;
 import cc.kune.gspace.client.viewers.FolderViewerUtils;
@@ -19,14 +22,21 @@
 import com.bradrydzewski.gwt.calendar.client.event.HasMouseOverHandlers;
 import com.bradrydzewski.gwt.calendar.client.event.HasTimeBlockClickHandlers;
 import com.bradrydzewski.gwt.calendar.client.event.HasUpdateHandlers;
+import com.bradrydzewski.gwt.calendar.client.event.MouseOverEvent;
+import com.bradrydzewski.gwt.calendar.client.event.MouseOverHandler;
 import com.bradrydzewski.gwt.calendar.client.event.TimeBlockClickEvent;
 import com.bradrydzewski.gwt.calendar.client.event.TimeBlockClickHandler;
+import com.bradrydzewski.gwt.calendar.client.event.UpdateEvent;
+import com.bradrydzewski.gwt.calendar.client.event.UpdateHandler;
 import com.google.gwt.event.logical.shared.HasOpenHandlers;
 import com.google.gwt.event.logical.shared.HasSelectionHandlers;
+import com.google.gwt.event.logical.shared.OpenEvent;
+import com.google.gwt.event.logical.shared.OpenHandler;
 import com.google.gwt.event.logical.shared.SelectionEvent;
 import com.google.gwt.event.logical.shared.SelectionHandler;
 import com.google.gwt.event.shared.EventBus;
 import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.user.client.ui.Widget;
 import com.google.gwt.user.datepicker.client.CalendarUtil;
 import com.google.inject.Inject;
 import com.gwtplatform.mvp.client.Presenter;
@@ -67,12 +77,15 @@
   private CalendarViews currentCalView;
   private int currentDaysView = 7;
   private final FolderViewerUtils folderViewerUtils;
+  private final I18nTranslationService i18n;
 
   @Inject
   public CalendarViewerPresenter(final EventBus eventBus, final CalendarViewerView view,
-      final CalendarViewerProxy proxy, final FolderViewerUtils folderViewerUtils) {
+      final CalendarViewerProxy proxy, final FolderViewerUtils folderViewerUtils,
+      final I18nTranslationService i18n) {
     super(eventBus, view, proxy);
     this.folderViewerUtils = folderViewerUtils;
+    this.i18n = i18n;
     addListeners();
     setViewImpl(DEF_VIEW, currentDaysView);
   }
@@ -81,13 +94,47 @@
     getView().addTimeBlockClickHandler(new TimeBlockClickHandler<Date>() {
       @Override
       public void onTimeBlockClick(final TimeBlockClickEvent<Date> event) {
-        getView().addAppointment("Only a test", event.getTarget());
-        NotifyUser.info("Appointment added but not yet saved (this is under development)");
+        NotifyUser.askConfirmation(i18n.t("Confirm, please"), i18n.t("Add a new appointment?"),
+            new SimpleResponseCallback() {
+              @Override
+              public void onCancel() {
+                // do nothing
+              }
+
+              @Override
+              public void onSuccess() {
+                getView().addAppointment("Only a test", event.getTarget());
+                NotifyUser.info("Appointment added but not yet saved (this is under development)");
+              }
+            });
       }
     });
+    getView().addMouseOverHandler(new MouseOverHandler<Appointment>() {
+      @Override
+      public void onMouseOver(final MouseOverEvent<Appointment> event) {
+        Tooltip.to((Widget) event.getSource(), "kk");
+        // final Tooltip tooltip = new Tooltip();
+        // tooltip.setText("lalala");
+        // tooltip.setPopupPosition(, currentDaysView)
+        // tooltip.showRelativeTo((UIObject) event.getElement());
+      }
+    });
+    getView().addUpdateHandler(new UpdateHandler<Appointment>() {
+      @Override
+      public void onUpdate(final UpdateEvent<Appointment> event) {
+        NotifyUser.info("updated handler");
+      }
+    });
+    getView().addOpenHandler(new OpenHandler<Appointment>() {
+      @Override
+      public void onOpen(final OpenEvent<Appointment> event) {
+        NotifyUser.info("open handler");
+      }
+    });
     getView().addSelectionHandler(new SelectionHandler<Appointment>() {
       @Override
       public void onSelection(final SelectionEvent<Appointment> event) {
+        NotifyUser.info("on selection");
         // getView().removeAppointment(event.getSelectedItem());
       }
     });




More information about the kune-commits mailing list