diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/SearchResultTable.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/SearchResultTable.java index c0449a5b6ee..34533becf7a 100644 --- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/SearchResultTable.java +++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/SearchResultTable.java @@ -73,7 +73,7 @@ public class SearchResultTable extends JXTable { /** Defines the format how the date is shown */ private static final DateFormat DATE_FORMAT = new SimpleDateFormat( - "yyyy-MM-dd hh:mm:ss"); //2013-04-20 18:13:43 + "yyyy-MM-dd HH:mm:ss"); //2013-04-20 18:13:43 /** Reference to the DataBrowserModel */ private AdvancedResultSearchModel model; diff --git a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/SearchResultTableModel.java b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/SearchResultTableModel.java index 3965eb643aa..5a8f8d0116b 100644 --- a/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/SearchResultTableModel.java +++ b/components/insight/SRC/org/openmicroscopy/shoola/agents/dataBrowser/view/SearchResultTableModel.java @@ -20,6 +20,7 @@ package org.openmicroscopy.shoola.agents.dataBrowser.view; import java.awt.FontMetrics; +import java.sql.Timestamp; import java.util.ArrayList; import java.util.Collection; import java.util.Date; @@ -27,14 +28,11 @@ import javax.swing.Icon; import javax.swing.table.DefaultTableModel; - -import org.openmicroscopy.shoola.agents.dataBrowser.DataBrowserAgent; import org.openmicroscopy.shoola.agents.dataBrowser.browser.Thumbnail; import org.openmicroscopy.shoola.agents.treeviewer.IconManager; import org.openmicroscopy.shoola.agents.treeviewer.TreeViewerAgent; import org.openmicroscopy.shoola.agents.util.EditorUtil; import org.openmicroscopy.shoola.util.ui.UIUtilities; -import org.openmicroscopy.shoola.env.log.Logger; import pojos.DataObject; import pojos.DatasetData; @@ -54,14 +52,12 @@ */ public class SearchResultTableModel extends DefaultTableModel { - private Logger logger = DataBrowserAgent.getRegistry().getLogger(); - /** The name of the columns */ public static final String[] COLUMN_NAMES = { "Type", "Name", "Acquired", "Imported", "Group", " " }; /** - * The index of the column which contains the View buttons (i. e. the last + * The index of the column which contains the View buttons (i.e. the last * column) */ public static final int VIEWBUTTON_COLUMN_INDEX = COLUMN_NAMES.length - 1; @@ -80,11 +76,12 @@ public class SearchResultTableModel extends DefaultTableModel { private Collection groups = TreeViewerAgent .getAvailableUserGroups(); + /** Reference to the parent.*/ private SearchResultTable parent; - + /** * Creates a new instance - * + * * @param data * The {@link DataObject}s which should be shown in the table * @param model @@ -135,32 +132,36 @@ public Object getValueAt(int row, int column) { /** * Get the acquisition date of the {@link DataObject} - * - * @param obj - * @return + * + * @param obj The object to handle. + * @return Returns the date or null. */ private Date getADate(DataObject obj) { - if(obj instanceof ImageData) - return new Date(((ImageData) obj).getAcquisitionDate().getTime()); - else - return null; + if (obj instanceof ImageData) { + Timestamp time = EditorUtil.getAcquisitionTime((ImageData) obj); + if (time == null) return null; + return new Date(time.getTime()); + } + return null; } - + /** * Get the creation date of the {@link DataObject} - * - * @param obj - * @return + * + * @param obj The object to handle. + * @return Returns the date or null. */ - private Date getIDate(DataObject obj) { - return new Date(obj.getCreated().getTime()); + private Object getIDate(DataObject obj) { + Timestamp time = obj.getCreated(); + if (time == null) return null; //in case it is not loaded. + return new Date(time.getTime()); } /** * Get the group name the {@link DataObject} belongs to - * - * @param obj - * @return + * + * @param obj The object to handle. + * @return See above. */ private String getGroup(DataObject obj) { for (GroupData g : groups) { @@ -173,10 +174,10 @@ private String getGroup(DataObject obj) { /** * Get the {@link Icon} for the {@link DataObject} - * - * @param obj - * @return A general icon (e. g. for DataSets) or a thumbnail icon (for - * Images); a tranparent icon if the data type is not supported + * + * @param obj The object to handle. + * @return A general icon (e.g. for DataSets) or a thumbnail icon (for + * Images); a transparent icon if the data type is not supported */ private Icon getIcon(DataObject obj) { @@ -193,7 +194,7 @@ else if (obj instanceof ProjectData) { else if (obj instanceof DatasetData) { return IconManager.getInstance().getIcon(IconManager.DATASET); } - + else if (obj instanceof ScreenData) { return IconManager.getInstance().getIcon(IconManager.SCREEN); } @@ -227,9 +228,9 @@ public Class getColumnClass(int column) { /** * Get the name of the {@link DataObject} - * - * @param obj - * @return + * + * @param obj The object to handle. + * @return See above. */ private String getObjectName(DataObject obj) { String name = ""; @@ -244,8 +245,7 @@ private String getObjectName(DataObject obj) { } else if (obj instanceof PlateData) { name = ((PlateData) obj).getName(); } - - + FontMetrics fm = parent.getGraphics().getFontMetrics(); int colWidth = parent.getColumn(1).getWidth(); @@ -272,7 +272,7 @@ private String getObjectName(DataObject obj) { name = name.substring(1); } } - + String idPrefix = null; if (model.isIdMatch(obj.getClass(), obj.getId())) { idPrefix = "[ID: " + obj.getId() @@ -281,7 +281,7 @@ private String getObjectName(DataObject obj) { return idPrefix!=null ? idPrefix+""+name : name; } - + @Override public boolean isCellEditable(int row, int column) { return column == VIEWBUTTON_COLUMN_INDEX;