Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,19 @@
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;
import java.util.List;

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;
Expand All @@ -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;
Expand All @@ -80,11 +76,12 @@ public class SearchResultTableModel extends DefaultTableModel {
private Collection<GroupData> 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
Expand Down Expand Up @@ -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 <code>null</code>.
*/
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 <code>null</code>.
*/
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) {
Expand All @@ -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) {

Expand All @@ -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);
}
Expand Down Expand Up @@ -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 = "";
Expand All @@ -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();
Expand All @@ -272,7 +272,7 @@ private String getObjectName(DataObject obj) {
name = name.substring(1);
}
}

String idPrefix = null;
if (model.isIdMatch(obj.getClass(), obj.getId())) {
idPrefix = "<font color=\"#ff0000\"><b>[ID: " + obj.getId()
Expand All @@ -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;
Expand Down