aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDirk Fauth2013-06-26 10:19:28 (EDT)
committerDirk Fauth2013-06-26 10:19:28 (EDT)
commit5f4b3343b380a9973d32f3f45eb22b614ad1e6ef (patch)
tree30a117166e154e7aaa42d09363443874ae82afe2
parentbe1bdf09c0a363b62c8f0f391d6b08c2bc204028 (diff)
downloadorg.eclipse.nebula-5f4b3343b380a9973d32f3f45eb22b614ad1e6ef.zip
org.eclipse.nebula-5f4b3343b380a9973d32f3f45eb22b614ad1e6ef.tar.gz
org.eclipse.nebula-5f4b3343b380a9973d32f3f45eb22b614ad1e6ef.tar.bz2
Added the possibility to connect two GanttCharts where one is on top of
the other. On scrolling from left to right, both charts should scroll the same way.
-rw-r--r--widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/CompoundViewPortHandler.java89
-rw-r--r--widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/GanttComposite.java36
-rw-r--r--widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/HorizontalScrollbarHandler.java7
-rw-r--r--widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/IViewPortHandler.java58
-rw-r--r--widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/ViewPortHandler.java2
5 files changed, 183 insertions, 9 deletions
diff --git a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/CompoundViewPortHandler.java b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/CompoundViewPortHandler.java
new file mode 100644
index 0000000..009c3e6
--- /dev/null
+++ b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/CompoundViewPortHandler.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Dirk Fauth and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dirk Fauth <dirk.fauth@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.nebula.widgets.ganttchart;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class CompoundViewPortHandler implements IViewPortHandler {
+
+ private List<IViewPortHandler> handler = new ArrayList<IViewPortHandler>();
+
+ public void addHandler(IViewPortHandler handler) {
+ this.handler.add(handler);
+ }
+
+ public void removeHandler(IViewPortHandler handler) {
+ this.handler.remove(handler);
+ }
+
+ public void scrollingLeft(int diffCount) {
+ for (IViewPortHandler vph : this.handler) {
+ vph.scrollingLeft(diffCount);
+ }
+ }
+
+ public void scrollingRight(int diffCount) {
+ for (IViewPortHandler vph : this.handler) {
+ vph.scrollingRight(diffCount);
+ }
+ }
+
+ public void nextMonth() {
+ for (IViewPortHandler vph : this.handler) {
+ vph.nextMonth();
+ }
+ }
+
+ public void prevMonth() {
+ for (IViewPortHandler vph : this.handler) {
+ vph.prevMonth();
+ }
+ }
+
+ public void nextWeek() {
+ for (IViewPortHandler vph : this.handler) {
+ vph.nextWeek();
+ }
+ }
+
+ public void prevWeek() {
+ for (IViewPortHandler vph : this.handler) {
+ vph.prevWeek();
+ }
+ }
+
+ public void nextHour() {
+ for (IViewPortHandler vph : this.handler) {
+ vph.nextHour();
+ }
+ }
+
+ public void prevHour() {
+ for (IViewPortHandler vph : this.handler) {
+ vph.prevHour();
+ }
+ }
+
+ public void nextDay() {
+ for (IViewPortHandler vph : this.handler) {
+ vph.nextDay();
+ }
+ }
+
+ public void prevDay() {
+ for (IViewPortHandler vph : this.handler) {
+ vph.prevDay();
+ }
+ }
+
+}
diff --git a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/GanttComposite.java b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/GanttComposite.java
index f0352ab..46f951b 100644
--- a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/GanttComposite.java
+++ b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/GanttComposite.java
@@ -303,7 +303,7 @@ public final class GanttComposite extends Canvas implements MouseListener, Mouse
private Calendar _dDayCalendar;
private HorizontalScrollbarHandler _hScrollHandler;
- private ViewPortHandler _viewPortHandler;
+ private IViewPortHandler _viewPortHandler;
private boolean _savingChartImage = false;
@@ -563,6 +563,31 @@ public final class GanttComposite extends Canvas implements MouseListener, Mouse
}
+ public void vScroll() {
+ // this has got to be a SWT bug, a non-visible scrollbar can report scroll events!
+ if (!_vScrollBar.isVisible()) {
+ _vScrollPos = 0;
+ return;
+ }
+
+ final int vSelection = _vScrollBar.getSelection();
+
+ _vScrollPos = vSelection;
+ final int diff = _vScrollPos - _lastVScrollPos;
+ _lastVScrollPos = _vScrollPos;
+
+ if (diff != 0) {
+ // move all events the fast way. There is truly no reason to recalculate bounds for any event, all we need to do is move them
+ // according to the scroll bar, which is way way faster than recalculating.
+ moveYBounds(diff);
+ //showVscrollInfo();
+
+ _recalcSecBounds = true;
+ redraw();
+ }
+ }
+
+
private void vScroll(final Event event) {
// end of drag, kill dialogs
if (event != null && event.detail == 0) {
@@ -579,7 +604,8 @@ public final class GanttComposite extends Canvas implements MouseListener, Mouse
final int vSelection = _vScrollBar.getSelection();
_vScrollPos = vSelection;
- final int diff = _vScrollPos - _lastVScrollPos;
+ int diff = _vScrollPos - _lastVScrollPos;
+
_lastVScrollPos = _vScrollPos;
// move all events the fast way. There is truly no reason to recalculate bounds for any event, all we need to do is move them
@@ -8177,10 +8203,14 @@ public final class GanttComposite extends Canvas implements MouseListener, Mouse
_forceSBUpdate = true;
}
- ViewPortHandler getViewPortHandler() {
+ public IViewPortHandler getViewPortHandler() {
return _viewPortHandler;
}
+ public void setViewPortHandler(IViewPortHandler vph) {
+ this._viewPortHandler = vph;
+ }
+
void updateHorizontalScrollbar() {
_hScrollHandler.recalculate();
}
diff --git a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/HorizontalScrollbarHandler.java b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/HorizontalScrollbarHandler.java
index 97a4fc9..e3b8936 100644
--- a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/HorizontalScrollbarHandler.java
+++ b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/HorizontalScrollbarHandler.java
@@ -27,8 +27,6 @@ class HorizontalScrollbarHandler implements Listener {
private boolean _scrolling;
private int _lastScrollbarPosition;
- private ViewPortHandler _vpHandler;
-
private boolean _infinite;
private boolean _none;
private boolean _fixed;
@@ -37,7 +35,6 @@ class HorizontalScrollbarHandler implements Listener {
public HorizontalScrollbarHandler(GanttComposite parent, ScrollBar scrollBar, int style) {
_gc = parent;
- _vpHandler = _gc.getViewPortHandler();
_scrollBar = scrollBar;
if ((style & GanttFlags.H_SCROLL_FIXED_RANGE) != 0) {
@@ -144,10 +141,10 @@ class HorizontalScrollbarHandler implements Listener {
private void scrollViewportByOffset(int direction, int diff) {
if (direction == SWT.LEFT) {
- _vpHandler.scrollingLeft(diff);
+ _gc.getViewPortHandler().scrollingLeft(diff);
}
else {
- _vpHandler.scrollingRight(diff);
+ _gc.getViewPortHandler().scrollingRight(diff);
}
}
diff --git a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/IViewPortHandler.java b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/IViewPortHandler.java
new file mode 100644
index 0000000..47c76b6
--- /dev/null
+++ b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/IViewPortHandler.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Dirk Fauth and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dirk Fauth <dirk.fauth@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.nebula.widgets.ganttchart;
+
+public interface IViewPortHandler {
+
+ void scrollingLeft(final int diffCount);
+
+ void scrollingRight(final int diffCount);
+
+ /**
+ * Jumps to the next month.
+ */
+ public void nextMonth();
+
+ /**
+ * Jumps to the previous month.
+ */
+ public void prevMonth();
+
+ /**
+ * Jumps one week forward.
+ */
+ public void nextWeek();
+
+ /**
+ * Jumps one week backwards.
+ */
+ public void prevWeek();
+
+ /**
+ * Jumps to the next hour.
+ */
+ public void nextHour();
+
+ /**
+ * Jumps to the previous hour.
+ */
+ public void prevHour();
+
+ /**
+ * Jumps one day forward.
+ */
+ void nextDay();
+
+ /**
+ * Jumps one day backwards.
+ */
+ void prevDay();
+}
diff --git a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/ViewPortHandler.java b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/ViewPortHandler.java
index 812fbf7..707d8d1 100644
--- a/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/ViewPortHandler.java
+++ b/widgets/ganttchart/org.eclipse.nebula.widgets.ganttchart/src/org/eclipse/nebula/widgets/ganttchart/ViewPortHandler.java
@@ -13,7 +13,7 @@ package org.eclipse.nebula.widgets.ganttchart;
import java.util.Calendar;
-class ViewPortHandler {
+class ViewPortHandler implements IViewPortHandler {
private GanttComposite _ganttComposite;