summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorRemo Arpagaus2013-03-18 14:07:10 (EDT)
committer Judith Gull2013-03-18 14:09:03 (EDT)
commit33304e13de218b6811ee7470ae9dbc54994cfe5e (patch)
tree82185ff5544c575ba3dadd54b04a96244f27b20f
parent1187b1f344391d1cb381740a6841ca02fc407de8 (diff)
downloadorg.eclipse.scout.rt-33304e13de218b6811ee7470ae9dbc54994cfe5e.zip
org.eclipse.scout.rt-33304e13de218b6811ee7470ae9dbc54994cfe5e.tar.gz
org.eclipse.scout.rt-33304e13de218b6811ee7470ae9dbc54994cfe5e.tar.bz2
Bug 403176 - AbstractPlannerField: The resourceId should be of type
java.lang.Object instead of long Applies patch by Remo Arpagaus
-rw-r--r--org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/AbstractActivityMap.java222
-rw-r--r--org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/ActivityCell.java52
-rw-r--r--org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/ActivityMapEvent.java10
-rw-r--r--org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/IActivityCellObserver.java6
-rw-r--r--org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/IActivityMap.java40
-rw-r--r--org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/IActivityMapUIFacade.java10
-rw-r--r--org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/TestTimeScaleBuilder.java4
-rw-r--r--org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/form/fields/plannerfield/AbstractPlannerField.java56
-rw-r--r--org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/form/fields/plannerfield/IPlannerField.java38
-rw-r--r--org.eclipse.scout.rt.extension.client/src/org/eclipse/scout/rt/extension/client/ui/basic/activitymap/AbstractExtensibleActivityMap.java2
-rw-r--r--org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/basic/activitymap/SwingActivityMapModel.java5
-rw-r--r--org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/basic/activitymap/SwingScoutActivityMap.java70
-rw-r--r--org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/form/fields/plannerfield/ISwingScoutPlannerField.java4
-rw-r--r--org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/form/fields/plannerfield/SwingScoutPlannerField.java2
14 files changed, 292 insertions, 229 deletions
diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/AbstractActivityMap.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/AbstractActivityMap.java
index 3ab3fd9..a7cad89 100644
--- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/AbstractActivityMap.java
+++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/AbstractActivityMap.java
@@ -12,6 +12,7 @@ package org.eclipse.scout.rt.client.ui.basic.activitymap;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
@@ -26,9 +27,11 @@ import java.util.TreeMap;
import java.util.TreeSet;
import org.eclipse.scout.commons.CompositeLong;
+import org.eclipse.scout.commons.CompositeObject;
import org.eclipse.scout.commons.ConfigurationUtility;
import org.eclipse.scout.commons.DateUtility;
import org.eclipse.scout.commons.EventListenerList;
+import org.eclipse.scout.commons.TypeCastUtility;
import org.eclipse.scout.commons.annotations.ConfigOperation;
import org.eclipse.scout.commons.annotations.ConfigProperty;
import org.eclipse.scout.commons.annotations.ConfigPropertyValue;
@@ -41,22 +44,25 @@ import org.eclipse.scout.rt.client.ui.action.menu.IMenu;
import org.eclipse.scout.rt.shared.services.common.exceptionhandler.IExceptionHandlerService;
import org.eclipse.scout.service.SERVICES;
-public abstract class AbstractActivityMap extends AbstractPropertyObserver implements IActivityMap {
+public abstract class AbstractActivityMap<RI, AI> extends AbstractPropertyObserver implements IActivityMap<RI, AI> {
private static final IScoutLogger LOG = ScoutLogManager.getLogger(AbstractActivityMap.class);
private boolean m_initialized;
private EventListenerList m_listenerList;
private IActivityMapUIFacade m_activityMapUIFacade;
private long m_minimumActivityDuration;// millis
- private HashMap<Long/* resourceId */, List<ActivityCell>> m_resourceIdToActivities;
- private HashMap<CompositeLong/* resourceId,activityId */, ActivityCell> m_activities;
- private HashSet<Long/* resourceId */> m_selectedResourceIds;
+ private HashMap<RI/* resourceId */, List<ActivityCell<RI, AI>>> m_resourceIdToActivities;
+ private HashMap<CompositeObject/* resourceId,activityId */, ActivityCell<RI, AI>> m_activities;
+ private HashSet<RI/* resourceId */> m_selectedResourceIds;
private int m_tableChanging;
private ArrayList<ActivityMapEvent> m_eventBuffer = new ArrayList<ActivityMapEvent>();
private IMenu[] m_menus;
- private IActivityCellObserver m_cellObserver;
+ private IActivityCellObserver<RI, AI> m_cellObserver;
private boolean m_timeScaleValid;
+ private Class<RI> m_resourceIdClass;
+ private Class<AI> m_activityIdClass;
+
public AbstractActivityMap() {
this(true);
}
@@ -74,6 +80,22 @@ public abstract class AbstractActivityMap extends AbstractPropertyObserver imple
}
}
+ @SuppressWarnings("unchecked")
+ private Class<RI> getResourceIdClass() {
+ if (m_resourceIdClass == null) {
+ m_resourceIdClass = TypeCastUtility.getGenericsParameterClass(getClass(), IActivityMap.class, 0);
+ }
+ return m_resourceIdClass;
+ }
+
+ @SuppressWarnings("unchecked")
+ private Class<AI> getActivityIdClass() {
+ if (m_activityIdClass == null) {
+ m_activityIdClass = TypeCastUtility.getGenericsParameterClass(getClass(), IActivityMap.class, 1);
+ }
+ return m_activityIdClass;
+ }
+
/*
* Configuration
*/
@@ -147,7 +169,7 @@ public abstract class AbstractActivityMap extends AbstractPropertyObserver imple
*/
@ConfigOperation
@Order(60)
- protected void execDecorateActivityCell(ActivityCell cell) throws ProcessingException {
+ protected void execDecorateActivityCell(ActivityCell<RI, AI> cell) throws ProcessingException {
}
/**
@@ -156,7 +178,7 @@ public abstract class AbstractActivityMap extends AbstractPropertyObserver imple
*/
@ConfigOperation
@Order(70)
- protected void execActivityCellSelected(ActivityCell cell) throws ProcessingException {
+ protected void execActivityCellSelected(ActivityCell<RI, AI> cell) throws ProcessingException {
}
/**
@@ -165,7 +187,7 @@ public abstract class AbstractActivityMap extends AbstractPropertyObserver imple
*/
@ConfigOperation
@Order(75)
- protected void execCellAction(long resourceId, MinorTimeColumn column, ActivityCell activityCell) throws ProcessingException {
+ protected void execCellAction(RI resourceId, MinorTimeColumn column, ActivityCell<RI, AI> activityCell) throws ProcessingException {
}
@ConfigOperation
@@ -210,10 +232,10 @@ public abstract class AbstractActivityMap extends AbstractPropertyObserver imple
protected void initConfig() {
m_listenerList = new EventListenerList();
m_activityMapUIFacade = createUIFacade();
- m_resourceIdToActivities = new HashMap<Long, List<ActivityCell>>();
- m_activities = new HashMap<CompositeLong, ActivityCell>();
+ m_resourceIdToActivities = new HashMap<RI, List<ActivityCell<RI, AI>>>();
+ m_activities = new HashMap<CompositeObject, ActivityCell<RI, AI>>();
m_cellObserver = new P_ActivityCellObserver();
- m_selectedResourceIds = new HashSet<Long>();
+ m_selectedResourceIds = new HashSet<RI>();
//
setWorkDayCount(getConfiguredWorkDayCount());
setWorkDaysOnly(getConfiguredWorkDaysOnly());
@@ -276,7 +298,8 @@ public abstract class AbstractActivityMap extends AbstractPropertyObserver imple
}
}
else if (e.getPropertyName().equals(PROP_SELECTED_ACTIVITY_CELL)) {
- ActivityCell cell = (ActivityCell) e.getNewValue();
+ @SuppressWarnings("unchecked")
+ ActivityCell<RI, AI> cell = (ActivityCell<RI, AI>) e.getNewValue();
if (cell != null) {
try {
execActivityCellSelected(cell);
@@ -391,15 +414,16 @@ public abstract class AbstractActivityMap extends AbstractPropertyObserver imple
}
@Override
- public ActivityCell resolveActivityCell(ActivityCell cell) {
+ public ActivityCell<RI, AI> resolveActivityCell(ActivityCell<RI, AI> cell) {
if (cell == null) {
return cell;
}
- return m_activities.get(new CompositeLong(cell.getResourceId(), cell.getActivityId()));
+ return m_activities.get(new CompositeObject(cell.getResourceId(), cell.getActivityId()));
}
+ @SuppressWarnings("unchecked")
@Override
- public ActivityCell[] resolveActivityCells(ActivityCell[] cells) {
+ public ActivityCell<RI, AI>[] resolveActivityCells(ActivityCell<RI, AI>[] cells) {
if (cells == null) {
cells = new ActivityCell[0];
}
@@ -411,7 +435,7 @@ public abstract class AbstractActivityMap extends AbstractPropertyObserver imple
}
}
if (mismatchCount > 0) {
- ActivityCell[] resolvedCells = new ActivityCell[cells.length - mismatchCount];
+ ActivityCell<RI, AI>[] resolvedCells = new ActivityCell[cells.length - mismatchCount];
int index = 0;
for (int i = 0; i < cells.length; i++) {
if (resolveActivityCell(cells[i]) == cells[i]) {
@@ -425,15 +449,19 @@ public abstract class AbstractActivityMap extends AbstractPropertyObserver imple
}
@Override
- public ActivityCell[] getActivityCells(long resourceId) {
- return getActivityCells(new Long[]{resourceId});
+ public ActivityCell<RI, AI>[] getActivityCells(RI resourceId) {
+ @SuppressWarnings("unchecked")
+ RI[] array = (RI[]) Array.newInstance(getResourceIdClass(), 1);
+ array[0] = resourceId;
+ return getActivityCells(array);
}
+ @SuppressWarnings("unchecked")
@Override
- public ActivityCell[] getActivityCells(Long[] resourceIds) {
- ArrayList<ActivityCell> all = new ArrayList<ActivityCell>();
- for (Long resourceId : resourceIds) {
- List<ActivityCell> list = m_resourceIdToActivities.get(resourceId);
+ public ActivityCell<RI, AI>[] getActivityCells(RI[] resourceIds) {
+ ArrayList<ActivityCell<RI, AI>> all = new ArrayList<ActivityCell<RI, AI>>();
+ for (RI resourceId : resourceIds) {
+ List<ActivityCell<RI, AI>> list = m_resourceIdToActivities.get(resourceId);
if (list != null) {
all.addAll(list);
}
@@ -441,21 +469,23 @@ public abstract class AbstractActivityMap extends AbstractPropertyObserver imple
return all.toArray(new ActivityCell[all.size()]);
}
+ @SuppressWarnings("unchecked")
@Override
- public ActivityCell[] getAllActivityCells() {
+ public ActivityCell<RI, AI>[] getAllActivityCells() {
return m_activities.values().toArray(new ActivityCell[m_activities.size()]);
}
+ @SuppressWarnings("unchecked")
@Override
- public void addActivityCells(ActivityCell[] cells) {
- ArrayList<ActivityCell> addedCells = new ArrayList<ActivityCell>();
- for (ActivityCell cell : cells) {
- CompositeLong key = new CompositeLong(cell.getResourceId(), cell.getActivityId());
+ public void addActivityCells(ActivityCell<RI, AI>[] cells) {
+ ArrayList<ActivityCell<RI, AI>> addedCells = new ArrayList<ActivityCell<RI, AI>>();
+ for (ActivityCell<RI, AI> cell : cells) {
+ CompositeObject key = new CompositeObject(cell.getResourceId(), cell.getActivityId());
if (!m_activities.containsKey(key)) {
m_activities.put(key, cell);
- List<ActivityCell> list = m_resourceIdToActivities.get(cell.getResourceId());
+ List<ActivityCell<RI, AI>> list = m_resourceIdToActivities.get(cell.getResourceId());
if (list == null) {
- list = new ArrayList<ActivityCell>();
+ list = new ArrayList<ActivityCell<RI, AI>>();
m_resourceIdToActivities.put(cell.getResourceId(), list);
}
list.add(cell);
@@ -470,42 +500,42 @@ public abstract class AbstractActivityMap extends AbstractPropertyObserver imple
}
@Override
- public void updateActivityCells(ActivityCell[] cells) {
+ public void updateActivityCells(ActivityCell<RI, AI>[] cells) {
cells = resolveActivityCells(cells);
updateActivityCellsInternal(cells);
}
@Override
- public void updateActivityCells(Long[] resourceIds) {
+ public void updateActivityCells(RI[] resourceIds) {
updateActivityCellsInternal(getActivityCells(resourceIds));
}
// resolved cells
- private void updateActivityCellsInternal(ActivityCell[] cells) {
- for (ActivityCell cell : cells) {
+ private void updateActivityCellsInternal(ActivityCell<RI, AI>[] cells) {
+ for (ActivityCell<RI, AI> cell : cells) {
decorateActivityCell(cell);
}
fireActivitiesUpdated(cells);
}
@Override
- public void removeActivityCells(ActivityCell[] cells) {
+ public void removeActivityCells(ActivityCell<RI, AI>[] cells) {
cells = resolveActivityCells(cells);
removeActivityCellsInternal(cells);
}
@Override
- public void removeActivityCells(Long[] resourceIds) {
+ public void removeActivityCells(RI[] resourceIds) {
removeActivityCellsInternal(getActivityCells(resourceIds));
}
// cells are resolved
- private void removeActivityCellsInternal(ActivityCell[] cells) {
+ private void removeActivityCellsInternal(ActivityCell<RI, AI>[] cells) {
if (cells.length > 0) {
- for (ActivityCell cell : cells) {
+ for (ActivityCell<RI, AI> cell : cells) {
cell.setObserver(null);
- m_activities.remove(new CompositeLong(cell.getResourceId(), cell.getActivityId()));
- List<ActivityCell> list = m_resourceIdToActivities.get(cell.getResourceId());
+ m_activities.remove(new CompositeObject(cell.getResourceId(), cell.getActivityId()));
+ List<ActivityCell<RI, AI>> list = m_resourceIdToActivities.get(cell.getResourceId());
if (list != null) {
list.remove(cell);
}
@@ -516,9 +546,9 @@ public abstract class AbstractActivityMap extends AbstractPropertyObserver imple
@Override
public void removeAllActivityCells() {
- ActivityCell[] a = getAllActivityCells();
+ ActivityCell<RI, AI>[] a = getAllActivityCells();
if (a.length > 0) {
- for (ActivityCell cell : a) {
+ for (ActivityCell<RI, AI> cell : a) {
cell.setObserver(null);
}
m_activities.clear();
@@ -527,64 +557,76 @@ public abstract class AbstractActivityMap extends AbstractPropertyObserver imple
}
}
+ @SuppressWarnings("unchecked")
@Override
- public ActivityCell getSelectedActivityCell() {
- return (ActivityCell) propertySupport.getProperty(PROP_SELECTED_ACTIVITY_CELL);
+ public ActivityCell<RI, AI> getSelectedActivityCell() {
+ return (ActivityCell<RI, AI>) propertySupport.getProperty(PROP_SELECTED_ACTIVITY_CELL);
}
@Override
- public void setSelectedActivityCell(ActivityCell cell) {
+ public void setSelectedActivityCell(ActivityCell<RI, AI> cell) {
cell = resolveActivityCell(cell);
propertySupport.setProperty(PROP_SELECTED_ACTIVITY_CELL, cell);
}
@Override
- public boolean isSelectedActivityCell(ActivityCell cell) {
+ public boolean isSelectedActivityCell(ActivityCell<RI, AI> cell) {
return getSelectedActivityCell() == cell;
}
+ @SuppressWarnings("unchecked")
@Override
- public Long[] getSelectedResourceIds() {
- Long[] a = (Long[]) propertySupport.getProperty(PROP_SELECTED_RESOURCE_IDS);
+ public RI[] getSelectedResourceIds() {
+ RI[] a = (RI[]) propertySupport.getProperty(PROP_SELECTED_RESOURCE_IDS);
if (a == null) {
- a = new Long[0];
+ a = (RI[]) Array.newInstance(getResourceIdClass(), 0);
}
return a;
}
+ @SuppressWarnings("unchecked")
@Override
- public void setSelectedResourceIds(Long[] resourceIds) {
+ public void setSelectedResourceIds(RI[] resourceIds) {
+ RI[] internalResourceIds;
if (resourceIds == null) {
- resourceIds = new Long[0];
+ internalResourceIds = (RI[]) Array.newInstance(getResourceIdClass(), 0);
}
+ else {
+ // Guarantee the type of the array. This is necessary for raw type clients which might still pass Object[]
+ internalResourceIds = (RI[]) Array.newInstance(getResourceIdClass(), resourceIds.length);
+ System.arraycopy(resourceIds, 0, internalResourceIds, 0, resourceIds.length);
+ }
+
m_selectedResourceIds.clear();
- m_selectedResourceIds.addAll(Arrays.asList(resourceIds));
- propertySupport.setProperty(PROP_SELECTED_RESOURCE_IDS, resourceIds);
+ m_selectedResourceIds.addAll(Arrays.asList(internalResourceIds));
+ propertySupport.setProperty(PROP_SELECTED_RESOURCE_IDS, internalResourceIds);
}
+ @SuppressWarnings("unchecked")
@Override
- public Long[] getResourceIds() {
- Long[] resourceIds = (Long[]) propertySupport.getProperty(PROP_RESOURCE_IDS);
+ public RI[] getResourceIds() {
+ RI[] resourceIds = (RI[]) propertySupport.getProperty(PROP_RESOURCE_IDS);
if (resourceIds == null) {
- resourceIds = new Long[0];
+ resourceIds = (RI[]) Array.newInstance(getResourceIdClass(), 0);
}
return resourceIds;
}
+ @SuppressWarnings("unchecked")
@Override
- public void setResourceIds(Long[] resourceIds) {
+ public void setResourceIds(RI[] resourceIds) {
if (resourceIds == null) {
- resourceIds = new Long[0];
+ resourceIds = (RI[]) Array.newInstance(getResourceIdClass(), 0);
}
- // delete activities of resourceIds that no longer exist
- HashSet<Long> eliminatedResourceIdSet = new HashSet<Long>();
+ // delete activities of resourceIds that no Objecter exist
+ HashSet<RI> eliminatedResourceIdSet = new HashSet<RI>();
eliminatedResourceIdSet.addAll(Arrays.asList(getResourceIds()));
eliminatedResourceIdSet.removeAll(Arrays.asList(resourceIds));
try {
setActivityMapChanging(true);
//
propertySupport.setProperty(PROP_RESOURCE_IDS, resourceIds);
- removeActivityCells(eliminatedResourceIdSet.toArray(new Long[eliminatedResourceIdSet.size()]));
+ removeActivityCells(eliminatedResourceIdSet.toArray((RI[]) Array.newInstance(getResourceIdClass(), eliminatedResourceIdSet.size())));
updateActivityCellsInternal(getAllActivityCells());
}
finally {
@@ -593,7 +635,7 @@ public abstract class AbstractActivityMap extends AbstractPropertyObserver imple
}
@Override
- public void isSelectedResourceId(Long resourceId) {
+ public void isSelectedResourceId(RI resourceId) {
m_selectedResourceIds.contains(resourceId);
}
@@ -612,7 +654,7 @@ public abstract class AbstractActivityMap extends AbstractPropertyObserver imple
return m_menus;
}
- private IMenu[] fireEditActivityPopup(ActivityCell cell) {
+ private IMenu[] fireEditActivityPopup(ActivityCell<RI, AI> cell) {
if (cell != null) {
ActivityMapEvent e = new ActivityMapEvent(this, ActivityMapEvent.TYPE_EDIT_ACTIVITY_POPUP, cell);
// single observer for declared menus
@@ -675,7 +717,7 @@ public abstract class AbstractActivityMap extends AbstractPropertyObserver imple
}
}
- private void fireCellAction(long resourceId, MinorTimeColumn column, ActivityCell activityCell) {
+ private void fireCellAction(RI resourceId, MinorTimeColumn column, ActivityCell<RI, AI> activityCell) {
// single observer
try {
execCellAction(resourceId, column, activityCell);
@@ -686,26 +728,26 @@ public abstract class AbstractActivityMap extends AbstractPropertyObserver imple
catch (Throwable t) {
SERVICES.getService(IExceptionHandlerService.class).handleException(new ProcessingException("Unexpected", t));
}
- ActivityMapEvent e = new ActivityMapEvent(this, ActivityMapEvent.TYPE_CELL_ACTION, resourceId, column, activityCell);
+ ActivityMapEvent e = new ActivityMapEvent<RI>(this, ActivityMapEvent.TYPE_CELL_ACTION, resourceId, column, activityCell);
fireActivityMapEventInternal(e);
}
- private void fireActivitiesInserted(ActivityCell[] a) {
+ private void fireActivitiesInserted(ActivityCell<RI, AI>[] a) {
ActivityMapEvent e = new ActivityMapEvent(this, ActivityMapEvent.TYPE_ACTIVITIES_INSERTED, a);
fireActivityMapEventInternal(e);
}
- private void fireActivitiesUpdated(ActivityCell[] a) {
+ private void fireActivitiesUpdated(ActivityCell<RI, AI>[] a) {
ActivityMapEvent e = new ActivityMapEvent(this, ActivityMapEvent.TYPE_ACTIVITIES_UPDATED, a);
fireActivityMapEventInternal(e);
}
- private void fireActivitiesDeleted(ActivityCell[] a) {
+ private void fireActivitiesDeleted(ActivityCell<RI, AI>[] a) {
ActivityMapEvent e = new ActivityMapEvent(this, ActivityMapEvent.TYPE_ACTIVITIES_DELETED, a);
fireActivityMapEventInternal(e);
}
- private void fireAllActivitiesDeleted(ActivityCell[] a) {
+ private void fireAllActivitiesDeleted(ActivityCell<RI, AI>[] a) {
ActivityMapEvent e = new ActivityMapEvent(this, ActivityMapEvent.TYPE_ALL_ACTIVITIES_DELETED, a);
fireActivityMapEventInternal(e);
}
@@ -1093,7 +1135,7 @@ public abstract class AbstractActivityMap extends AbstractPropertyObserver imple
}
@Override
- public void decorateActivityCell(ActivityCell cell) {
+ public void decorateActivityCell(ActivityCell<RI, AI> cell) {
try {
cell.setObserver(null);
//
@@ -1111,7 +1153,7 @@ public abstract class AbstractActivityMap extends AbstractPropertyObserver imple
}
}
- protected void decorateActivityCellInternal(ActivityCell p) {
+ protected void decorateActivityCellInternal(ActivityCell<RI, AI> p) {
String from = getTimeScale().getDateFormat().format(p.getBeginTime());
String to = from;
if (p.getEndTime() != null) {
@@ -1188,12 +1230,12 @@ public abstract class AbstractActivityMap extends AbstractPropertyObserver imple
if (multiTimeRange.isEmpty()) {
return;
}
- TreeMap<CompositeLong, ActivityCell> sortMap = new TreeMap<CompositeLong, ActivityCell>();
+ TreeMap<CompositeLong, ActivityCell<Integer, Integer>> sortMap = new TreeMap<CompositeLong, ActivityCell<Integer, Integer>>();
Random rnd = new Random();
int resourceIndex = 0;
- for (Long resourceId : getSelectedResourceIds()) {
+ for (RI resourceId : getSelectedResourceIds()) {
MultiTimeRange localTimeRanges = (MultiTimeRange) multiTimeRange.clone();
- for (ActivityCell a : getActivityCells(resourceId)) {
+ for (ActivityCell<RI, AI> a : getActivityCells(resourceId)) {
localTimeRanges.remove(a.getBeginTime(), a.getEndTime());
}
// now only available time ranges for that resource are left
@@ -1201,13 +1243,13 @@ public abstract class AbstractActivityMap extends AbstractPropertyObserver imple
long durationMillis = tr.getDurationMillis();
long sortNo = chooseRandom ? rnd.nextLong() : resourceIndex;
if (durationMillis >= preferredDuration) {
- ActivityCell a = new ActivityCell(0, 0);
+ ActivityCell<Integer, Integer> a = new ActivityCell<Integer, Integer>(0, 0);
a.setBeginTime(tr.getFrom());
a.setEndTime(new Date(tr.getFrom().getTime() + preferredDuration));
sortMap.put(new CompositeLong(0, a.getBeginTime().getTime(), sortNo), a);
}
else if (durationMillis >= 15L * 60L * 1000L) {// at least 15 minutes
- ActivityCell a = new ActivityCell(0, 0);
+ ActivityCell<Integer, Integer> a = new ActivityCell<Integer, Integer>(0, 0);
a.setBeginTime(tr.getFrom());
a.setEndTime(new Date(tr.getFrom().getTime() + durationMillis));
sortMap.put(new CompositeLong(1, -durationMillis, sortNo), a);
@@ -1217,10 +1259,7 @@ public abstract class AbstractActivityMap extends AbstractPropertyObserver imple
}
// the top entry of the sort map is the one with best score (lowest number)
if (!sortMap.isEmpty()) {
- ActivityCell a = sortMap.get(sortMap.firstKey());
- // select row
- setSelectedResourceIds(new Long[]{a.getResourceId()});
- // add planned item
+ ActivityCell<Integer, Integer> a = sortMap.get(sortMap.firstKey());
setSelectedTime(a.getBeginTime(), a.getEndTime());
}
}
@@ -1239,9 +1278,9 @@ public abstract class AbstractActivityMap extends AbstractPropertyObserver imple
if (multiTimeRange.isEmpty()) {
return;
}
- TreeMap<CompositeLong, ActivityCell> sortMap = new TreeMap<CompositeLong, ActivityCell>();
- for (Long resourceId : getSelectedResourceIds()) {
- for (ActivityCell a : getActivityCells(resourceId)) {
+ TreeMap<CompositeLong, ActivityCell<Integer, Integer>> sortMap = new TreeMap<CompositeLong, ActivityCell<Integer, Integer>>();
+ for (RI resourceId : getSelectedResourceIds()) {
+ for (ActivityCell<RI, AI> a : getActivityCells(resourceId)) {
multiTimeRange.remove(a.getBeginTime(), a.getEndTime());
}
}
@@ -1249,13 +1288,13 @@ public abstract class AbstractActivityMap extends AbstractPropertyObserver imple
for (TimeRange tr : multiTimeRange.getTimeRanges()) {
long durationMillis = tr.getDurationMillis();
if (durationMillis >= preferredDuration) {
- ActivityCell a = new ActivityCell(0, 0);
+ ActivityCell<Integer, Integer> a = new ActivityCell<Integer, Integer>(0, 0);
a.setBeginTime(tr.getFrom());
a.setEndTime(new Date(tr.getFrom().getTime() + preferredDuration));
sortMap.put(new CompositeLong(0, a.getBeginTime().getTime()), a);
}
else if (durationMillis >= 15L * 60L * 1000L) {// at least 15 minutes
- ActivityCell a = new ActivityCell(0, 0);
+ ActivityCell<Integer, Integer> a = new ActivityCell<Integer, Integer>(0, 0);
a.setBeginTime(tr.getFrom());
a.setEndTime(new Date(tr.getFrom().getTime() + durationMillis));
sortMap.put(new CompositeLong(1, -durationMillis), a);
@@ -1263,7 +1302,7 @@ public abstract class AbstractActivityMap extends AbstractPropertyObserver imple
}
// the top entry of the sort map is the one with best score (lowest number)
if (!sortMap.isEmpty()) {
- ActivityCell a = sortMap.get(sortMap.firstKey());
+ ActivityCell<Integer, Integer> a = sortMap.get(sortMap.firstKey());
setSelectedTime(a.getBeginTime(), a.getEndTime());
}
}
@@ -1276,10 +1315,11 @@ public abstract class AbstractActivityMap extends AbstractPropertyObserver imple
/**
* Private planned activity cell observer
*/
- private class P_ActivityCellObserver implements IActivityCellObserver {
+ private class P_ActivityCellObserver implements IActivityCellObserver<RI, AI> {
+ @SuppressWarnings("unchecked")
@Override
- public void cellChanged(ActivityCell cell, int bitPos) {
+ public void cellChanged(ActivityCell<RI, AI> cell, int bitPos) {
fireActivitiesUpdated(new ActivityCell[]{cell});
}
}
@@ -1287,14 +1327,14 @@ public abstract class AbstractActivityMap extends AbstractPropertyObserver imple
/**
* Specialized ui facade
*/
- private class P_ActivityMapUIFacade implements IActivityMapUIFacade {
+ private class P_ActivityMapUIFacade implements IActivityMapUIFacade<RI, AI> {
public void setSelectedDayListFromUI(Date[] days) {
setDays(days);
}
@Override
- public void setSelectionFromUI(Long[] resourceIds, double[] normalizedRange) {
+ public void setSelectionFromUI(RI[] resourceIds, double[] normalizedRange) {
try {
setActivityMapChanging(true);
//
@@ -1325,12 +1365,12 @@ public abstract class AbstractActivityMap extends AbstractPropertyObserver imple
}
@Override
- public void setSelectedActivityCellFromUI(ActivityCell cell) {
+ public void setSelectedActivityCellFromUI(ActivityCell<RI, AI> cell) {
setSelectedActivityCell(cell);
}
@Override
- public void fireCellActionFromUI(long resourceId, double[] normalizedRange, ActivityCell activityCell) {
+ public void fireCellActionFromUI(RI resourceId, double[] normalizedRange, ActivityCell<RI, AI> activityCell) {
if (activityCell != null) {
setSelectedActivityCell(activityCell);
}
diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/ActivityCell.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/ActivityCell.java
index 970569e..fc50e3d 100644
--- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/ActivityCell.java
+++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/ActivityCell.java
@@ -4,7 +4,7 @@
* 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:
* BSI Business Systems Integration AG - initial API and implementation
******************************************************************************/
@@ -17,7 +17,7 @@ import org.eclipse.scout.rt.shared.data.basic.MemoryOptimizedObject;
/**
* Representation of an activity containing an ActivityData
*/
-public class ActivityCell extends MemoryOptimizedObject {
+public class ActivityCell<RI, AI> extends MemoryOptimizedObject {
private static final long serialVersionUID = 1L;
public static final int OBSERVER_BIT = 0;
@@ -99,7 +99,7 @@ public class ActivityCell extends MemoryOptimizedObject {
private ActivityCell() {
}
- public ActivityCell(long resourceId, long activityId) {
+ public ActivityCell(RI resourceId, AI activityId) {
setValueInternal(RESOURCE_ID_BIT, resourceId);
setValueInternal(ACTIVITY_ID_BIT, activityId);
}
@@ -115,7 +115,7 @@ public class ActivityCell extends MemoryOptimizedObject {
* @param majorValue
* @param minorValue
*/
- public ActivityCell(long resourceId, long activityId, Date startTime, Date endTime, String text, String tooltipText, String iconId, float majorValue, float minorValue) {
+ public ActivityCell(RI resourceId, AI activityId, Date startTime, Date endTime, String text, String tooltipText, String iconId, float majorValue, float minorValue) {
setValueInternal(RESOURCE_ID_BIT, resourceId);
setValueInternal(ACTIVITY_ID_BIT, activityId);
setValueInternal(BEGIN_TIME_BIT, startTime);
@@ -128,15 +128,18 @@ public class ActivityCell extends MemoryOptimizedObject {
}
/**
- * @param resourceId
- * @param activityId
- * @param startTime
- * @param endTime
- * @param text
- * @param tooltipText
- * @param iconId
- * @param majorValue
- * @param minorValue
+ * @param row
+ * <ul>
+ * <li>resourceId of type RI
+ * <li>activityId of type AI
+ * <li>startTime of type {@link Date}
+ * <li>endTime of type {@link Date}
+ * <li>text of type {@link String}
+ * <li>tooltipText of type {@link String}
+ * <li>iconId of type {@link String}
+ * <li>majorValue of type {@link Number}
+ * <li>minorValue of type {@link Number}
+ * </ul>
*/
public ActivityCell(Object[] row) {
if (row == null || row.length < 2) {
@@ -146,17 +149,17 @@ public class ActivityCell extends MemoryOptimizedObject {
throw new IllegalArgumentException("resourceId must not be null");
}
if (row[1] == null) {
- throw new IllegalArgumentException("itemid must not be null");
+ throw new IllegalArgumentException("activityId must not be null");
}
for (int i = 0; i < row.length; i++) {
if (row[i] != null) {
switch (i) {
case 0: {
- setValueInternal(RESOURCE_ID_BIT, ((Number) row[i]).longValue());
+ setValueInternal(RESOURCE_ID_BIT, row[i]);
break;
}
case 1: {
- setValueInternal(ACTIVITY_ID_BIT, ((Number) row[i]).longValue());
+ setValueInternal(ACTIVITY_ID_BIT, row[i]);
break;
}
case 2: {
@@ -192,11 +195,12 @@ public class ActivityCell extends MemoryOptimizedObject {
}
}
- public IActivityCellObserver getObserver() {
+ @SuppressWarnings("unchecked")
+ public IActivityCellObserver<RI, AI> getObserver() {
return (IActivityCellObserver) getValueInternal(OBSERVER_BIT);
}
- public void setObserver(IActivityCellObserver observer) {
+ public void setObserver(IActivityCellObserver<RI, AI> observer) {
setValueInternal(OBSERVER_BIT, observer);
}
@@ -211,14 +215,14 @@ public class ActivityCell extends MemoryOptimizedObject {
return b;
}
- public long getActivityId() {
- Object o = getValueInternal(ACTIVITY_ID_BIT);
- return o != null ? (Long) o : null;
+ @SuppressWarnings("unchecked")
+ public AI getActivityId() {
+ return (AI) getValueInternal(ACTIVITY_ID_BIT);
}
- public long getResourceId() {
- Object o = getValueInternal(RESOURCE_ID_BIT);
- return o != null ? (Long) o : null;
+ @SuppressWarnings("unchecked")
+ public RI getResourceId() {
+ return (RI) getValueInternal(RESOURCE_ID_BIT);
}
public Date getBeginTime() {
diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/ActivityMapEvent.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/ActivityMapEvent.java
index 9a36436..c6eda7b 100644
--- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/ActivityMapEvent.java
+++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/ActivityMapEvent.java
@@ -4,7 +4,7 @@
* 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:
* BSI Business Systems Integration AG - initial API and implementation
******************************************************************************/
@@ -19,7 +19,7 @@ import java.util.List;
import org.eclipse.scout.rt.client.ui.action.menu.IMenu;
@SuppressWarnings("serial")
-public class ActivityMapEvent extends java.util.EventObject {
+public class ActivityMapEvent<RI> extends java.util.EventObject {
/**
* Some activities have been added valid properties: activities,
* firstActivity, lastActivity
@@ -59,7 +59,7 @@ public class ActivityMapEvent extends java.util.EventObject {
private int m_type;
private ActivityCell[] m_activities = new ActivityCell[0];
private List<IMenu> m_popupMenus;
- private long m_resourceId;
+ private RI m_resourceId;
private MinorTimeColumn m_column;
public ActivityMapEvent(IActivityMap source, int type) {
@@ -83,7 +83,7 @@ public class ActivityMapEvent extends java.util.EventObject {
}
}
- public ActivityMapEvent(IActivityMap source, int type, long resourceId, MinorTimeColumn column, ActivityCell activity) {
+ public ActivityMapEvent(IActivityMap source, int type, RI resourceId, MinorTimeColumn column, ActivityCell activity) {
super(source);
m_type = type;
if (activity != null) {
@@ -101,7 +101,7 @@ public class ActivityMapEvent extends java.util.EventObject {
return m_type;
}
- public long getResourceId() {
+ public RI getResourceId() {
return m_resourceId;
}
diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/IActivityCellObserver.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/IActivityCellObserver.java
index 880414f..0497110 100644
--- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/IActivityCellObserver.java
+++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/IActivityCellObserver.java
@@ -4,13 +4,13 @@
* 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:
* BSI Business Systems Integration AG - initial API and implementation
******************************************************************************/
package org.eclipse.scout.rt.client.ui.basic.activitymap;
-public interface IActivityCellObserver {
+public interface IActivityCellObserver<RI, AI> {
- void cellChanged(ActivityCell cell, int bitPos);
+ void cellChanged(ActivityCell<RI, AI> cell, int bitPos);
}
diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/IActivityMap.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/IActivityMap.java
index 1773ea8..23d5df3 100644
--- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/IActivityMap.java
+++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/IActivityMap.java
@@ -20,7 +20,7 @@ import org.eclipse.scout.rt.client.ui.form.fields.plannerfield.IPlannerField;
/**
* The activity map is a specialized model which contains a set of {@link ActivityCell}s that are grouped by resourceId.
*/
-public interface IActivityMap extends IPropertyObserver {
+public interface IActivityMap<RI, AI> extends IPropertyObserver {
/**
* {@link java.util.Date}[] truncated to day using {@link com.bsiag.DateUtility#truncDate(Date)}
@@ -223,7 +223,7 @@ public interface IActivityMap extends IPropertyObserver {
void setSelectedTime(Date beginTime, Date endTime);
- void decorateActivityCell(ActivityCell p);
+ void decorateActivityCell(ActivityCell<RI, AI> p);
/**
* collect all selected days from starthour to endhour and intersect with
@@ -253,49 +253,49 @@ public interface IActivityMap extends IPropertyObserver {
*/
void planActivityForSelectedResources(boolean singleMatch, boolean chooseRandom, Date earliestBeginTime, Date latestEndTime, long preferredDuration);
- ActivityCell resolveActivityCell(ActivityCell cell);
+ ActivityCell<RI, AI> resolveActivityCell(ActivityCell<RI, AI> cell);
- ActivityCell[] resolveActivityCells(ActivityCell[] cells);
+ ActivityCell<RI, AI>[] resolveActivityCells(ActivityCell<RI, AI>[] cells);
- ActivityCell[] getActivityCells(long resourceId);
+ ActivityCell<RI, AI>[] getActivityCells(RI resourceId);
- ActivityCell[] getActivityCells(Long[] resourceIds);
+ ActivityCell<RI, AI>[] getActivityCells(RI[] resourceIds);
- ActivityCell[] getAllActivityCells();
+ ActivityCell<RI, AI>[] getAllActivityCells();
- void addActivityCells(ActivityCell[] cells);
+ void addActivityCells(ActivityCell<RI, AI>[] cells);
- void updateActivityCells(ActivityCell[] cells);
+ void updateActivityCells(ActivityCell<RI, AI>[] cells);
- void updateActivityCells(Long[] resourceIds);
+ void updateActivityCells(RI[] resourceIds);
- void removeActivityCells(ActivityCell[] cells);
+ void removeActivityCells(ActivityCell<RI, AI>[] cells);
- void removeActivityCells(Long[] resourceIds);
+ void removeActivityCells(RI[] resourceIds);
void removeAllActivityCells();
- ActivityCell getSelectedActivityCell();
+ ActivityCell<RI, AI> getSelectedActivityCell();
- void setSelectedActivityCell(ActivityCell cell);
+ void setSelectedActivityCell(ActivityCell<RI, AI> cell);
- boolean isSelectedActivityCell(ActivityCell cell);
+ boolean isSelectedActivityCell(ActivityCell<RI, AI> cell);
/**
* available resource ids in the same order as the resource table
*/
- Long[] getResourceIds();
+ RI[] getResourceIds();
- void setResourceIds(Long[] resourceIds);
+ void setResourceIds(RI[] resourceIds);
/**
* selected resource ids in arbitrary order
*/
- Long[] getSelectedResourceIds();
+ RI[] getSelectedResourceIds();
- void setSelectedResourceIds(Long[] resourceIds);
+ void setSelectedResourceIds(RI[] resourceIds);
- void isSelectedResourceId(Long resourceId);
+ void isSelectedResourceId(RI resourceId);
/**
* Indicates whether the selected sections in the activity
diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/IActivityMapUIFacade.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/IActivityMapUIFacade.java
index 20cddf4..643498e 100644
--- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/IActivityMapUIFacade.java
+++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/IActivityMapUIFacade.java
@@ -4,7 +4,7 @@
* 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:
* BSI Business Systems Integration AG - initial API and implementation
******************************************************************************/
@@ -14,13 +14,13 @@ import java.util.Date;
import org.eclipse.scout.rt.client.ui.action.menu.IMenu;
-public interface IActivityMapUIFacade {
+public interface IActivityMapUIFacade<RI, AI> {
void setDaysFromUI(Date[] days);
- void setSelectedActivityCellFromUI(ActivityCell cell);
+ void setSelectedActivityCellFromUI(ActivityCell<RI, AI> cell);
- void setSelectionFromUI(Long[] resourceIds, double[] normalizedRange);
+ void setSelectionFromUI(RI[] resourceIds, double[] normalizedRange);
/**
* Action on a empty cell or activity cell
@@ -28,7 +28,7 @@ public interface IActivityMapUIFacade {
* @param activityCell
* may be null
*/
- void fireCellActionFromUI(long resourceId, double[] normalizedRange, ActivityCell activityCell);
+ void fireCellActionFromUI(RI resourceId, double[] normalizedRange, ActivityCell<RI, AI> activityCell);
/**
* Popup on activity
diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/TestTimeScaleBuilder.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/TestTimeScaleBuilder.java
index e455990..2b15135 100644
--- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/TestTimeScaleBuilder.java
+++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/basic/activitymap/TestTimeScaleBuilder.java
@@ -4,7 +4,7 @@
* 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:
* BSI Business Systems Integration AG - initial API and implementation
******************************************************************************/
@@ -18,7 +18,7 @@ public final class TestTimeScaleBuilder {
}
public static void main(String[] args) {
- IActivityMap map = new AbstractActivityMap() {
+ IActivityMap<Long, Long> map = new AbstractActivityMap<Long, Long>() {
};
map.setDays(new Date[]{new Date(), new Date(System.currentTimeMillis() + 1000L * 3600L * 24L * 5), new Date(System.currentTimeMillis() + 1000L * 3600L * 24L * 7)});
diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/form/fields/plannerfield/AbstractPlannerField.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/form/fields/plannerfield/AbstractPlannerField.java
index 27a0386..9fedf30 100644
--- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/form/fields/plannerfield/AbstractPlannerField.java
+++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/form/fields/plannerfield/AbstractPlannerField.java
@@ -13,6 +13,7 @@ package org.eclipse.scout.rt.client.ui.form.fields.plannerfield;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
+import java.util.Date;
import java.util.HashSet;
import org.eclipse.scout.commons.ConfigurationUtility;
@@ -36,12 +37,12 @@ import org.eclipse.scout.rt.client.ui.form.fields.AbstractFormField;
import org.eclipse.scout.rt.shared.services.common.exceptionhandler.IExceptionHandlerService;
import org.eclipse.scout.service.SERVICES;
-public abstract class AbstractPlannerField<T extends ITable, P extends IActivityMap> extends AbstractFormField implements IPlannerField<T, P> {
+public abstract class AbstractPlannerField<T extends ITable, P extends IActivityMap<RI, AI>, RI, AI> extends AbstractFormField implements IPlannerField<T, P, RI, AI> {
private static final IScoutLogger LOG = ScoutLogManager.getLogger(AbstractPlannerField.class);
private IPlannerFieldUIFacade m_uiFacade;
private T m_resourceTable;
- private IColumn<Long> m_resourceIdColumn;
+ private IColumn<RI> m_resourceIdColumn;
private P m_activityMap;
private boolean m_selectionMediatorRunning;// true when mediation is running
@@ -113,20 +114,20 @@ public abstract class AbstractPlannerField<T extends ITable, P extends IActivity
/**
* Load data matrix with the maximum of the following columns:
* <ul>
- * <li>resourceId
- * <li>activityId
- * <li>startTime
- * <li>endTime
- * <li>text
- * <li>tooltipText
- * <li>iconId
- * <li>majorValue
- * <li>minorValue
+ * <li>resourceId of type RI
+ * <li>activityId of type AI
+ * <li>startTime of type {@link Date}
+ * <li>endTime of type {@link Date}
+ * <li>text of type {@link String}
+ * <li>tooltipText of type {@link String}
+ * <li>iconId of type {@link String}
+ * <li>majorValue of type {@link Number}
+ * <li>minorValue of type {@link Number}
* </ul>
*/
@ConfigOperation
@Order(10)
- protected Object[][] execLoadActivityMapData(Long[] resourceIds, ITableRow[] resourceRows) throws ProcessingException {
+ protected Object[][] execLoadActivityMapData(RI[] resourceIds, ITableRow[] resourceRows) throws ProcessingException {
return null;
}
@@ -136,13 +137,14 @@ public abstract class AbstractPlannerField<T extends ITable, P extends IActivity
* {@link ActivityCell}, maps to resources using the resourceId, and sets the {@link ActivityCell}s on the
* coresponding activtyRow.
*/
+ @SuppressWarnings("unchecked")
@ConfigOperation
@Order(10)
- protected void execPopulateActivities(Long[] resourceIds, ITableRow[] resourceRows) throws ProcessingException {
+ protected void execPopulateActivities(RI[] resourceIds, ITableRow[] resourceRows) throws ProcessingException {
Object[][] data = execLoadActivityMapData(resourceIds, resourceRows);
- ArrayList<ActivityCell> list = new ArrayList<ActivityCell>();
+ ArrayList<ActivityCell<RI, AI>> list = new ArrayList<ActivityCell<RI, AI>>();
for (Object[] row : data) {
- ActivityCell cell = new ActivityCell(row);
+ ActivityCell<RI, AI> cell = new ActivityCell<RI, AI>(row);
list.add(cell);
}
getActivityMap().removeActivityCells(resourceIds);
@@ -168,10 +170,8 @@ public abstract class AbstractPlannerField<T extends ITable, P extends IActivity
LOG.warn(null, e);
}
for (IColumn c : getResourceTable().getColumnSet().getKeyColumns()) {
- if (Long.class.isAssignableFrom(c.getDataType())) {
- m_resourceIdColumn = c;
- break;
- }
+ m_resourceIdColumn = c;
+ break;
}
}
else {
@@ -209,7 +209,7 @@ public abstract class AbstractPlannerField<T extends ITable, P extends IActivity
* Runtime
*/
- private IColumn<Long> getResourceIdColumnInternal() {
+ private IColumn<RI> getResourceIdColumnInternal() {
return m_resourceIdColumn;
}
@@ -276,7 +276,7 @@ public abstract class AbstractPlannerField<T extends ITable, P extends IActivity
}
private void loadActivityMapDataInternal(ITableRow[] resourceRows) throws ProcessingException {
- Long[] resourceIds = getResourceIdColumnInternal().getValues(resourceRows);
+ RI[] resourceIds = getResourceIdColumnInternal().getValues(resourceRows);
try {
getActivityMap().setActivityMapChanging(true);
//
@@ -288,7 +288,7 @@ public abstract class AbstractPlannerField<T extends ITable, P extends IActivity
}
@Override
- public ITableRow activityCellToResourceRow(ActivityCell activityCell) {
+ public ITableRow activityCellToResourceRow(ActivityCell<RI, AI> activityCell) {
if (activityCell != null) {
return getResourceIdColumnInternal().findRow(activityCell.getResourceId());
}
@@ -298,9 +298,9 @@ public abstract class AbstractPlannerField<T extends ITable, P extends IActivity
}
@Override
- public ITableRow[] activityCellsToResourceRows(ActivityCell[] activityCells) {
+ public ITableRow[] activityCellsToResourceRows(ActivityCell<RI, AI>[] activityCells) {
HashSet<ITableRow> resourceRowSet = new HashSet<ITableRow>();
- for (ActivityCell cell : activityCells) {
+ for (ActivityCell<RI, AI> cell : activityCells) {
ITableRow resourceRow = getResourceIdColumnInternal().findRow(cell.getResourceId());
if (resourceRow != null) {
resourceRowSet.add(resourceRow);
@@ -310,13 +310,13 @@ public abstract class AbstractPlannerField<T extends ITable, P extends IActivity
}
@Override
- public ActivityCell[] resourceRowToActivityCells(ITableRow resourceRow) {
+ public ActivityCell<RI, AI>[] resourceRowToActivityCells(ITableRow resourceRow) {
return resourceRowsToActivityCells(new ITableRow[]{resourceRow});
}
@Override
- public ActivityCell[] resourceRowsToActivityCells(ITableRow[] resourceRows) {
- return getActivityMap().getActivityCells(getResourceIdColumnInternal().getValues(resourceRows));
+ public ActivityCell<RI, AI>[] resourceRowsToActivityCells(ITableRow[] resourceRows) {
+ return getActivityMap().getActivityCells((RI[]) getResourceIdColumnInternal().getValues(resourceRows));
}
private void syncSelectionFromResourceToActivity() {
@@ -326,7 +326,7 @@ public abstract class AbstractPlannerField<T extends ITable, P extends IActivity
try {
m_selectionMediatorRunning = true;
//
- getActivityMap().setSelectedResourceIds(getResourceIdColumnInternal().getSelectedValues());
+ getActivityMap().setSelectedResourceIds((RI[]) getResourceIdColumnInternal().getSelectedValues());
}
finally {
m_selectionMediatorRunning = false;
diff --git a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/form/fields/plannerfield/IPlannerField.java b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/form/fields/plannerfield/IPlannerField.java
index 2a5b79f..559c420 100644
--- a/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/form/fields/plannerfield/IPlannerField.java
+++ b/org.eclipse.scout.rt.client/src/org/eclipse/scout/rt/client/ui/form/fields/plannerfield/IPlannerField.java
@@ -26,27 +26,41 @@ import org.eclipse.scout.rt.client.ui.form.fields.IFormField;
* This class strintly uses java.util.Date staticly AND dynamicly<br>
* All Date-Objects and subclasses are run through {@link com.bsiag.DateUtility#toUtilDate(java.util.Date)}()
* <p>
- * The planner field contains a ITable and a IPlanner<br>
- * The inner table contains at least one primary key column, the first primary key column of type Long is assumed to be
- * the resourceId column.<br>
- * which values are passed to {@link #execLoadActivityMapData(ITableRow[])} and {@link #execLoadActivities(ITableRow[])}
+ * The planner field contains one inner class extending {@link ITable} and another one extending {@link IActivityMap}<br>
+ * The inner table contains a primary key column, the type of the primary key column corresponds with RI the type
+ * parameter for the resourceId. The the type parameter AI for the activityId is passed on together with RI to
+ * {@link IActivityMap}<br>
* <p>
* Example usage:
*
* <pre>
- * public class ExamplePlannerField extends AbstractPlannerField&lt;ExamplePlannerField.ResourceTable, ExamplePlannerField.ActivityMap&gt; {
+ * public class ExamplePlannerField extends AbstractPlannerField&lt;ExamplePlannerField.ResourceTable, ExamplePlannerField.ActivityMap, Long, Long&gt; {
+ *
+ * protected Object[][] execLoadActivityMapData(Long[] resourceIds, ITableRow[] resourceRows) throws ProcessingException {
+ * return ...;
+ * }
+ *
* public class ResourceTable extends AbstractTable {
- * public class ResourceIdColumn extends AbstractLongColumn {
+ * public class ResourceIdColumn extends AbstractColumn&lt;Long&gt; {
* }
* }
*
- * public class ActivityMap extends AbstractActivityMap {
+ * public class ActivityMap extends AbstractActivityMap&lt;Long, Long&gt; {
+ * protected void execCellAction(Long resourceId, MinorTimeColumn column, ActivityCell&lt;Long, Long&gt; activityCell) throws ProcessingException {
+ * }
+ *
+ * protected void execDecorateActivityCell(ActivityCell&lt;Long, Long&gt; cell) {
+ * }
* }
* }
+ *
+ *
+ *
+ *
* </pre>
*/
-public interface IPlannerField<T extends ITable, P extends IActivityMap> extends IFormField {
+public interface IPlannerField<T extends ITable, P extends IActivityMap<RI, AI>, RI, AI> extends IFormField {
String PROP_MINI_CALENDAR_COUNT = "miniCalendarCount";
@@ -79,13 +93,13 @@ public interface IPlannerField<T extends ITable, P extends IActivityMap> extends
*/
void loadActivityMapDataOfSelectedRecources() throws ProcessingException;
- ITableRow activityCellToResourceRow(ActivityCell activityCell);
+ ITableRow activityCellToResourceRow(ActivityCell<RI, AI> activityCell);
- ITableRow[] activityCellsToResourceRows(ActivityCell[] activityCells);
+ ITableRow[] activityCellsToResourceRows(ActivityCell<RI, AI>[] activityCells);
- ActivityCell[] resourceRowToActivityCells(ITableRow resourceRow);
+ ActivityCell<RI, AI>[] resourceRowToActivityCells(ITableRow resourceRow);
- ActivityCell[] resourceRowsToActivityCells(ITableRow[] resourceRows);
+ ActivityCell<RI, AI>[] resourceRowsToActivityCells(ITableRow[] resourceRows);
IPlannerFieldUIFacade getUIFacade();
diff --git a/org.eclipse.scout.rt.extension.client/src/org/eclipse/scout/rt/extension/client/ui/basic/activitymap/AbstractExtensibleActivityMap.java b/org.eclipse.scout.rt.extension.client/src/org/eclipse/scout/rt/extension/client/ui/basic/activitymap/AbstractExtensibleActivityMap.java
index b6cc543..fa9166e 100644
--- a/org.eclipse.scout.rt.extension.client/src/org/eclipse/scout/rt/extension/client/ui/basic/activitymap/AbstractExtensibleActivityMap.java
+++ b/org.eclipse.scout.rt.extension.client/src/org/eclipse/scout/rt/extension/client/ui/basic/activitymap/AbstractExtensibleActivityMap.java
@@ -26,7 +26,7 @@ import org.eclipse.scout.rt.extension.client.ui.action.menu.MenuExtensionUtility
*
* @since 3.9.0
*/
-public abstract class AbstractExtensibleActivityMap extends AbstractActivityMap implements IExtensibleScoutObject {
+public abstract class AbstractExtensibleActivityMap<RI, AI> extends AbstractActivityMap<RI, AI> implements IExtensibleScoutObject {
public AbstractExtensibleActivityMap() {
super();
diff --git a/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/basic/activitymap/SwingActivityMapModel.java b/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/basic/activitymap/SwingActivityMapModel.java
index c2a6969..b85a4b8 100644
--- a/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/basic/activitymap/SwingActivityMapModel.java
+++ b/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/basic/activitymap/SwingActivityMapModel.java
@@ -4,7 +4,7 @@
* 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:
* BSI Business Systems Integration AG - initial API and implementation
******************************************************************************/
@@ -25,10 +25,11 @@ public class SwingActivityMapModel implements ActivityMapModel {
private final JTable m_metricsTable;
private final SwingActivityComponent[] m_components;
+ @SuppressWarnings("unchecked")
public SwingActivityMapModel(IActivityMap map, JTable metricsTable) {
m_map = map;
m_metricsTable = metricsTable;
- Long[] resourceIds = map.getResourceIds();
+ Object[] resourceIds = map.getResourceIds();
ArrayList<SwingActivityComponent> list = new ArrayList<SwingActivityComponent>();
for (int i = 0; i < resourceIds.length; i++) {
for (ActivityCell cell : map.getActivityCells(resourceIds[i])) {
diff --git a/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/basic/activitymap/SwingScoutActivityMap.java b/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/basic/activitymap/SwingScoutActivityMap.java
index 96e20e6..34f4e59 100644
--- a/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/basic/activitymap/SwingScoutActivityMap.java
+++ b/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/basic/activitymap/SwingScoutActivityMap.java
@@ -4,7 +4,7 @@
* 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:
* BSI Business Systems Integration AG - initial API and implementation
******************************************************************************/
@@ -17,6 +17,7 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Arrays;
import java.util.HashSet;
+import java.util.Set;
import java.util.TreeSet;
import javax.swing.JScrollPane;
@@ -37,7 +38,7 @@ import org.eclipse.scout.rt.ui.swing.ext.activitymap.ActivityMapSelectionEvent;
import org.eclipse.scout.rt.ui.swing.ext.activitymap.ActivityMapSelectionListener;
import org.eclipse.scout.rt.ui.swing.ext.activitymap.JActivityMap;
-public class SwingScoutActivityMap extends SwingScoutComposite<IActivityMap> {
+public class SwingScoutActivityMap extends SwingScoutComposite<IActivityMap<?, ?>> {
private JScrollPane m_swingScrollPane;
/**
* The metrics table is used to determine header and row heights
@@ -194,32 +195,32 @@ public class SwingScoutActivityMap extends SwingScoutComposite<IActivityMap> {
case ActivityMapEvent.TYPE_ACTIVITIES_INSERTED:
case ActivityMapEvent.TYPE_ACTIVITIES_UPDATED:
case ActivityMapEvent.TYPE_ALL_ACTIVITIES_DELETED: {
- Runnable t = new Runnable() {
- @Override
- public void run() {
- switch (e.getType()) {
- case ActivityMapEvent.TYPE_ACTIVITIES_DELETED:
- case ActivityMapEvent.TYPE_ACTIVITIES_INSERTED:
- case ActivityMapEvent.TYPE_ACTIVITIES_UPDATED:
- case ActivityMapEvent.TYPE_ALL_ACTIVITIES_DELETED: {
- try {
- getUpdateSwingFromScoutLock().acquire();
- //
- handleActivitiesChangedFromScout();
+ Runnable t = new Runnable() {
+ @Override
+ public void run() {
+ switch (e.getType()) {
+ case ActivityMapEvent.TYPE_ACTIVITIES_DELETED:
+ case ActivityMapEvent.TYPE_ACTIVITIES_INSERTED:
+ case ActivityMapEvent.TYPE_ACTIVITIES_UPDATED:
+ case ActivityMapEvent.TYPE_ALL_ACTIVITIES_DELETED: {
+ try {
+ getUpdateSwingFromScoutLock().acquire();
+ //
+ handleActivitiesChangedFromScout();
+ }
+ finally {
+ getUpdateSwingFromScoutLock().release();
+ }
+ break;
+ }
}
- finally {
- getUpdateSwingFromScoutLock().release();
- }
- break;
}
- }
+ };
+ getSwingEnvironment().invokeSwingLater(t);
+ break;
}
- };
- getSwingEnvironment().invokeSwingLater(t);
- break;
}
}
- }
};
getScoutActivityMap().addActivityMapListener(m_scoutListener);
}
@@ -229,7 +230,7 @@ public class SwingScoutActivityMap extends SwingScoutComposite<IActivityMap> {
setSelectionFromScout();
}
- public IActivityMap getScoutActivityMap() {
+ public IActivityMap<?, ?> getScoutActivityMap() {
return getScoutObject();
}
@@ -247,7 +248,7 @@ public class SwingScoutActivityMap extends SwingScoutComposite<IActivityMap> {
setSelectionFromScout();
}
- private void setResourceIdsFromScout(Long[] resourceIds) {
+ private void setResourceIdsFromScout(Object[] resourceIds) {
getSwingActivityMap().setModel(new SwingActivityMapModel(getScoutActivityMap(), m_metricsTable));
}
@@ -260,9 +261,10 @@ public class SwingScoutActivityMap extends SwingScoutComposite<IActivityMap> {
return;
}
//
- final ActivityCell cell = (comp != null ? comp.getScoutActivityCell() : null);
+ final ActivityCell<?, ?> cell = (comp != null ? comp.getScoutActivityCell() : null);
// notify Scout
Runnable t = new Runnable() {
+ @SuppressWarnings("unchecked")
@Override
public void run() {
getScoutActivityMap().getUIFacade().setSelectedActivityCellFromUI(cell);
@@ -284,9 +286,10 @@ public class SwingScoutActivityMap extends SwingScoutComposite<IActivityMap> {
final int row = getSwingActivityMap().pixToRow(p.y);
// notify Scout
Runnable t = new Runnable() {
+ @SuppressWarnings("unchecked")
@Override
public void run() {
- long resourceId = getScoutActivityMap().getResourceIds()[row];
+ Object resourceId = getScoutActivityMap().getResourceIds()[row];
getScoutActivityMap().getUIFacade().fireCellActionFromUI(resourceId, range, cell);
}
};
@@ -295,8 +298,8 @@ public class SwingScoutActivityMap extends SwingScoutComposite<IActivityMap> {
}
private void setSelectionFromScout() {
- HashSet<Long> selectedIds = new HashSet<Long>(Arrays.asList(getScoutActivityMap().getSelectedResourceIds()));
- Long[] ids = getScoutActivityMap().getResourceIds();
+ HashSet<Object> selectedIds = new HashSet<Object>(Arrays.asList(getScoutActivityMap().getSelectedResourceIds()));
+ Object[] ids = getScoutActivityMap().getResourceIds();
TreeSet<Integer> indexes = new TreeSet<Integer>();
for (int i = 0; i < ids.length; i++) {
if (selectedIds.contains(ids[i])) {
@@ -318,16 +321,17 @@ public class SwingScoutActivityMap extends SwingScoutComposite<IActivityMap> {
}
//
final double[] normalizedRange = range;
- Long[] ids = getScoutActivityMap().getResourceIds();
- final TreeSet<Long> selectedIds = new TreeSet<Long>();
+ Object[] ids = getScoutActivityMap().getResourceIds();
+ final Set<Object> selectedIds = new HashSet<Object>();
for (int i : rows) {
selectedIds.add(ids[i]);
}
// notify Scout
Runnable t = new Runnable() {
+ @SuppressWarnings("unchecked")
@Override
public void run() {
- getScoutActivityMap().getUIFacade().setSelectionFromUI(selectedIds.toArray(new Long[selectedIds.size()]), normalizedRange);
+ getScoutActivityMap().getUIFacade().setSelectionFromUI(selectedIds.toArray(new Object[selectedIds.size()]), normalizedRange);
}
};
@@ -385,7 +389,7 @@ public class SwingScoutActivityMap extends SwingScoutComposite<IActivityMap> {
setSelectionFromScout();
}
else if (name.equals(IActivityMap.PROP_RESOURCE_IDS)) {
- setResourceIdsFromScout((Long[]) newValue);
+ setResourceIdsFromScout((Object[]) newValue);
}
else if (name.equals(IActivityMap.PROP_DRAW_SECTIONS)) {
getSwingActivityMap().getSelector().setDrawSections((Boolean) newValue);
diff --git a/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/form/fields/plannerfield/ISwingScoutPlannerField.java b/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/form/fields/plannerfield/ISwingScoutPlannerField.java
index b036a6b..2fceeb0 100644
--- a/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/form/fields/plannerfield/ISwingScoutPlannerField.java
+++ b/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/form/fields/plannerfield/ISwingScoutPlannerField.java
@@ -4,7 +4,7 @@
* 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:
* BSI Business Systems Integration AG - initial API and implementation
******************************************************************************/
@@ -15,7 +15,7 @@ import org.eclipse.scout.rt.ui.swing.basic.activitymap.SwingScoutActivityMap;
import org.eclipse.scout.rt.ui.swing.basic.table.ISwingScoutTable;
import org.eclipse.scout.rt.ui.swing.form.fields.ISwingScoutFormField;
-public interface ISwingScoutPlannerField extends ISwingScoutFormField<IPlannerField<?, ?>> {
+public interface ISwingScoutPlannerField extends ISwingScoutFormField<IPlannerField<?, ?, ?, ?>> {
ISwingScoutTable getResourceTableComposite();
diff --git a/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/form/fields/plannerfield/SwingScoutPlannerField.java b/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/form/fields/plannerfield/SwingScoutPlannerField.java
index 5988b36..cebbcc1 100644
--- a/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/form/fields/plannerfield/SwingScoutPlannerField.java
+++ b/org.eclipse.scout.rt.ui.swing/src/org/eclipse/scout/rt/ui/swing/form/fields/plannerfield/SwingScoutPlannerField.java
@@ -43,7 +43,7 @@ import org.eclipse.scout.rt.ui.swing.form.fields.SwingScoutFieldComposite;
import org.eclipse.scout.rt.ui.swing.form.fields.plannerfield.layout.PlannerFieldLayout;
import org.eclipse.scout.rt.ui.swing.form.fields.plannerfield.layout.PlannerFieldLayoutConstraints;
-public class SwingScoutPlannerField extends SwingScoutFieldComposite<IPlannerField<?, ?>> implements ISwingScoutPlannerField {
+public class SwingScoutPlannerField extends SwingScoutFieldComposite<IPlannerField<?, ?, ?, ?>> implements ISwingScoutPlannerField {
private ISwingScoutTable m_resourceTableComposite;
private SwingScoutActivityMap m_activityMapComposite;
private DateChooser[] m_miniDateChooser;