diff --git a/README.md b/README.md index 19597b6..d8a8cd1 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ To build and install this plugin you must have the following items installed: + [Java 8](http://www.oracle.com/technetwork/java/javase/downloads/index.html) + A tool for checking out a [Git](http://git-scm.com/) repository + Apache's [Maven](http://maven.apache.org/index.html) -+ A Protégé (5.0.0 Beta 21 or higher) distribution. Download [here](http://protege.stanford.edu/products.php#desktop-protege). ++ A Protégé 5.0.0 or higher distribution. Download [here](http://protege.stanford.edu/products.php#desktop-protege). Get a copy of the latest code: @@ -68,7 +68,7 @@ On build completion the ```target``` directory will contain a cellfie-${version} The JAR is generated in the OSGi bundle format required by Protégé's plugin-in mechanism. To install in your local Protégé, copy this JAR file to the ```plugins``` subdirectory of your Protégé installation (e.g., -/Applications/Protege-5.0.0/plugins/). +/Applications/Protege-5.5.0/plugins/). ### Questions diff --git a/pom.xml b/pom.xml index 185ca7e..7d2d950 100644 --- a/pom.xml +++ b/pom.xml @@ -33,17 +33,17 @@ edu.stanford.protege protege-editor-core - 5.2.0 + 5.5.0 edu.stanford.protege protege-editor-owl - 5.2.0 + 5.5.0 edu.stanford.protege mapping-master - 1.7 + 2.1.1 diff --git a/src/main/java/org/mm/cellfie/ui/view/SheetPanel.java b/src/main/java/org/mm/cellfie/ui/view/SheetPanel.java index 32583c4..865333b 100644 --- a/src/main/java/org/mm/cellfie/ui/view/SheetPanel.java +++ b/src/main/java/org/mm/cellfie/ui/view/SheetPanel.java @@ -1,23 +1,21 @@ package org.mm.cellfie.ui.view; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.awt.BorderLayout; -import java.awt.Point; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.DataFormatter; +import org.apache.poi.ss.usermodel.DateUtil; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.mm.ss.SpreadSheetUtil; import javax.annotation.Nonnull; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTable; +import javax.swing.*; import javax.swing.table.AbstractTableModel; import javax.swing.table.JTableHeader; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.mm.ss.SpreadSheetUtil; +import static com.google.common.base.Preconditions.checkNotNull; /** * @author Josef Hardi
@@ -42,6 +40,8 @@ public class SheetPanel extends JPanel { private int endColumnIndex = START_INDEX; private int endRowIndex = END_INDEX; + private final DataFormatter dataFormatter = new DataFormatter(); + private Point startMousePt; private Point endMousePt; @@ -95,6 +95,11 @@ private void setSelectionRange(int startColumnIndex, int startRowIndex, int endC this.endRowIndex = endRowIndex; } + private boolean isDateFormatted(Cell cell) + { + return DateUtil.isCellDateFormatted(cell); + } + /** * Returns the array of the cell selection from this UI panel. The array is composed by * { startColumnIndex, startRowIndex, endColumnIndex, endRowIndex } @@ -151,13 +156,15 @@ public Object getValueAt(int row, int column) { return ""; case Cell.CELL_TYPE_STRING : return cell.getStringCellValue(); - case Cell.CELL_TYPE_NUMERIC : - // Check if the numeric is double or integer - if (isInteger(cell.getNumericCellValue())) { - return (int) cell.getNumericCellValue(); - } else { - return cell.getNumericCellValue(); - } + case Cell.CELL_TYPE_NUMERIC : + // Check if the numeric is an integer or double or a date + if (isDateFormatted(cell)) { + return dataFormatter.formatCellValue(cell); + } else if (isInteger(cell.getNumericCellValue())) { + return Integer.toString((int)cell.getNumericCellValue()); + } else { + return Double.toString(cell.getNumericCellValue()); + } case Cell.CELL_TYPE_BOOLEAN : return cell.getBooleanCellValue(); case Cell.CELL_TYPE_FORMULA : diff --git a/src/main/java/org/mm/cellfie/ui/view/SheetTable.java b/src/main/java/org/mm/cellfie/ui/view/SheetTable.java index a443af4..351c179 100644 --- a/src/main/java/org/mm/cellfie/ui/view/SheetTable.java +++ b/src/main/java/org/mm/cellfie/ui/view/SheetTable.java @@ -1,13 +1,6 @@ package org.mm.cellfie.ui.view; -import java.awt.Color; -import java.awt.Component; -import java.awt.Insets; - -import javax.swing.JLabel; -import javax.swing.JTable; -import javax.swing.ListSelectionModel; -import javax.swing.UIManager; +import javax.swing.*; import javax.swing.border.CompoundBorder; import javax.swing.border.EmptyBorder; import javax.swing.event.ListSelectionEvent; @@ -16,6 +9,7 @@ import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumnModel; import javax.swing.table.TableModel; +import java.awt.*; public class SheetTable extends JTable {