Skip to content
Snippets Groups Projects
Commit 72741cbb authored by felmer's avatar felmer
Browse files

LMS-1231 Introducing DateTableCell

SVN: 13026
parent 8d1ea862
No related branches found
No related tags found
No related merge requests found
Showing
with 211 additions and 71 deletions
...@@ -21,8 +21,8 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.IColumnDefinition; ...@@ -21,8 +21,8 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.IColumnDefinition;
import ch.systemsx.cisd.openbis.generic.shared.basic.URLMethodWithParameters; import ch.systemsx.cisd.openbis.generic.shared.basic.URLMethodWithParameters;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ISerializableComparable; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ISerializableComparable;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ImageTableCell; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ImageTableCell;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelColumnHeader;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelRow; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelRow;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModel.TableModelColumnHeader;
/** /**
* Definition of dataset report table columns. * Definition of dataset report table columns.
...@@ -76,6 +76,11 @@ public class DataSetReportColumnDefinition implements IColumnDefinition<TableMod ...@@ -76,6 +76,11 @@ public class DataSetReportColumnDefinition implements IColumnDefinition<TableMod
+ imageURL + "' alt='" + cell.toString() + "'/></a></div>"; + imageURL + "' alt='" + cell.toString() + "'/></a></div>";
} }
public boolean isNumeric()
{
return columnHeader.isNumeric();
}
private ISerializableComparable getCellValue(GridRowModel<TableModelRow> rowModel) private ISerializableComparable getCellValue(GridRowModel<TableModelRow> rowModel)
{ {
int index = columnHeader.getIndex(); int index = columnHeader.getIndex();
......
...@@ -41,8 +41,8 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.GridRowModel; ...@@ -41,8 +41,8 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.GridRowModel;
import ch.systemsx.cisd.openbis.generic.shared.basic.IColumnDefinition; import ch.systemsx.cisd.openbis.generic.shared.basic.IColumnDefinition;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseModificationKind; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseModificationKind;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatastoreServiceDescription; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatastoreServiceDescription;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelColumnHeader;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelRow; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelRow;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModel.TableModelColumnHeader;
/** /**
* Grid displaying dataset reporting results. This grid is special comparing to other grids, because * Grid displaying dataset reporting results. This grid is special comparing to other grids, because
...@@ -97,11 +97,6 @@ public class DataSetReporterGrid extends ...@@ -97,11 +97,6 @@ public class DataSetReporterGrid extends
return isHidden; return isHidden;
} }
public boolean isNumeric()
{
return false;
}
// GWT only // GWT only
@SuppressWarnings("unused") @SuppressWarnings("unused")
private DatasetReportColumnUI() private DatasetReportColumnUI()
......
...@@ -20,7 +20,7 @@ import java.util.List; ...@@ -20,7 +20,7 @@ import java.util.List;
import com.google.gwt.user.client.rpc.IsSerializable; import com.google.gwt.user.client.rpc.IsSerializable;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModel.TableModelColumnHeader; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelColumnHeader;
/** /**
* Stores:<br> * Stores:<br>
......
/*
* Copyright 2009 ETH Zuerich, CISD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ch.systemsx.cisd.openbis.generic.shared.basic.dto;
import java.util.Date;
/**
* Table cell wrapping a {@link Date}.
*
* @author Franz-Josef Elmer
*/
public class DateTableCell implements ISerializableComparable
{
private static final long serialVersionUID = ServiceVersionHolder.VERSION;
private long dateTime;
public DateTableCell(long dateTime)
{
this.dateTime = dateTime;
}
public DateTableCell(Date date)
{
dateTime = date.getTime();
}
public Date getDateTime()
{
return new Date(dateTime);
}
public int compareTo(ISerializableComparable o)
{
if (o instanceof DateTableCell)
{
DateTableCell cell = (DateTableCell) o;
return dateTime < cell.dateTime ? -1 : (dateTime > cell.dateTime ? 1 : 0);
}
return toString().compareTo(o.toString());
}
@Override
public boolean equals(Object obj)
{
return this == obj
|| (obj instanceof DateTableCell && dateTime == ((DateTableCell) obj).dateTime);
}
@Override
public int hashCode()
{
return (int) dateTime;
}
@Override
public String toString()
{
return new Date(dateTime).toString();
}
// ---------------------------
// GWT only
@SuppressWarnings("unused")
private DateTableCell()
{
}
// GWT only
@SuppressWarnings("unused")
private void setDateTime(long dateTime)
{
this.dateTime = dateTime;
}
}
...@@ -51,7 +51,6 @@ public class ImageTableCell implements ISerializableComparable ...@@ -51,7 +51,6 @@ public class ImageTableCell implements ISerializableComparable
public ImageTableCell(String path, int maxThumbnailWidth, int maxThumbnailHeight) public ImageTableCell(String path, int maxThumbnailWidth, int maxThumbnailHeight)
{ {
System.out.println("path:"+path);
this.path = path; this.path = path;
this.maxThumbnailWidth = maxThumbnailWidth; this.maxThumbnailWidth = maxThumbnailWidth;
this.maxThumbnailHeight = maxThumbnailHeight; this.maxThumbnailHeight = maxThumbnailHeight;
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
package ch.systemsx.cisd.openbis.generic.shared.basic.dto; package ch.systemsx.cisd.openbis.generic.shared.basic.dto;
/** /**
* Table cell wrapping an integer. * Table cell wrapping a number of type double.
* *
* @author Franz-Josef Elmer * @author Franz-Josef Elmer
*/ */
...@@ -25,42 +25,47 @@ public class NumberTableCell implements ISerializableComparable ...@@ -25,42 +25,47 @@ public class NumberTableCell implements ISerializableComparable
{ {
private static final long serialVersionUID = ServiceVersionHolder.VERSION; private static final long serialVersionUID = ServiceVersionHolder.VERSION;
private Number integer; private double number;
public NumberTableCell(Number integer) public NumberTableCell(double doubleValue)
{ {
this.integer = integer; this.number = doubleValue;
} }
public double getNumber()
{
return number;
}
public int compareTo(ISerializableComparable o) public int compareTo(ISerializableComparable o)
{ {
if (o instanceof NumberTableCell) if (o instanceof NumberTableCell)
{ {
double v1 = integer.doubleValue(); double v1 = number;
NumberTableCell numberTableCell = (NumberTableCell) o; NumberTableCell numberTableCell = (NumberTableCell) o;
double v2 = numberTableCell.integer.doubleValue(); double v2 = numberTableCell.number;
return v1 < v2 ? -1 : (v1 > v2 ? 1 : 0); return v1 < v2 ? -1 : (v1 > v2 ? 1 : 0);
} }
return integer.toString().compareTo(o.toString()); return toString().compareTo(o.toString());
} }
@Override @Override
public boolean equals(Object obj) public boolean equals(Object obj)
{ {
return this == obj return this == obj
|| (obj instanceof NumberTableCell && integer.equals(((NumberTableCell) obj).integer)); || (obj instanceof NumberTableCell && number == ((NumberTableCell) obj).number);
} }
@Override @Override
public int hashCode() public int hashCode()
{ {
return integer.hashCode(); return (int) number;
} }
@Override @Override
public String toString() public String toString()
{ {
return integer.toString(); return Double.toString(number);
} }
// --------------------------- // ---------------------------
...@@ -73,9 +78,9 @@ public class NumberTableCell implements ISerializableComparable ...@@ -73,9 +78,9 @@ public class NumberTableCell implements ISerializableComparable
// GWT only // GWT only
@SuppressWarnings("unused") @SuppressWarnings("unused")
private void setNumber(Number number) private void setNumber(double number)
{ {
this.integer = number; this.number = number;
} }
......
...@@ -79,50 +79,4 @@ public class TableModel implements IsSerializable, Serializable ...@@ -79,50 +79,4 @@ public class TableModel implements IsSerializable, Serializable
{ {
this.header = header; this.header = header;
} }
public static class TableModelColumnHeader implements IsSerializable, Serializable
{
private static final long serialVersionUID = ServiceVersionHolder.VERSION;
private String title;
// allows to fetch the value for this column from the row content
private int index;
public TableModelColumnHeader(String title, int index)
{
this.title = title;
this.index = index;
}
public String getTitle()
{
return title;
}
public int getIndex()
{
return index;
}
// GWT only
@SuppressWarnings("unused")
private TableModelColumnHeader()
{
}
// GWT only
@SuppressWarnings("unused")
private void setTitle(String title)
{
this.title = title;
}
// GWT only
@SuppressWarnings("unused")
private void setIndex(int index)
{
this.index = index;
}
}
} }
/*
* Copyright 2009 ETH Zuerich, CISD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ch.systemsx.cisd.openbis.generic.shared.basic.dto;
import java.io.Serializable;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
* Column header for {@link TableModel}.
*
* @author Tomasz Pylak
*/
public class TableModelColumnHeader implements IsSerializable, Serializable
{
private static final long serialVersionUID = ServiceVersionHolder.VERSION;
private String title;
// allows to fetch the value for this column from the row content
private int index;
private boolean numeric;
public TableModelColumnHeader(String title, int index)
{
this(title, index, false);
}
public TableModelColumnHeader(String title, int index, boolean numeric)
{
this.title = title;
this.index = index;
this.numeric = numeric;
}
public String getTitle()
{
return title;
}
public int getIndex()
{
return index;
}
public boolean isNumeric()
{
return numeric;
}
// GWT only
@SuppressWarnings("unused")
private TableModelColumnHeader()
{
}
// GWT only
@SuppressWarnings("unused")
private void setTitle(String title)
{
this.title = title;
}
// GWT only
@SuppressWarnings("unused")
private void setIndex(int index)
{
this.index = index;
}
// GWT only
@SuppressWarnings("unused")
private void setNumeric(boolean numeric)
{
this.numeric = numeric;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment