mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
GT-3286 - Updated usage of timestamps in the UI to be consistent
This commit is contained in:
parent
2cafb27574
commit
feaf203365
17 changed files with 130 additions and 165 deletions
|
@ -17,7 +17,6 @@ package ghidra.app.plugin.core.comments;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JTextPane;
|
import javax.swing.JTextPane;
|
||||||
|
@ -26,6 +25,7 @@ import javax.swing.text.*;
|
||||||
import ghidra.program.model.address.Address;
|
import ghidra.program.model.address.Address;
|
||||||
import ghidra.program.model.listing.CommentHistory;
|
import ghidra.program.model.listing.CommentHistory;
|
||||||
import ghidra.program.model.listing.Program;
|
import ghidra.program.model.listing.Program;
|
||||||
|
import ghidra.util.DateUtils;
|
||||||
import ghidra.util.Msg;
|
import ghidra.util.Msg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,7 +44,6 @@ class CommentHistoryPanel extends JPanel {
|
||||||
private StyledDocument doc;
|
private StyledDocument doc;
|
||||||
private JTextPane textPane;
|
private JTextPane textPane;
|
||||||
|
|
||||||
private SimpleDateFormat formatter;
|
|
||||||
private int commentType;
|
private int commentType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,7 +55,6 @@ class CommentHistoryPanel extends JPanel {
|
||||||
super(new BorderLayout());
|
super(new BorderLayout());
|
||||||
setUpAttributes();
|
setUpAttributes();
|
||||||
this.commentType = commentType;
|
this.commentType = commentType;
|
||||||
formatter = new SimpleDateFormat("yyyy MMM dd hh:mm aaa");
|
|
||||||
create();
|
create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,8 +103,8 @@ class CommentHistoryPanel extends JPanel {
|
||||||
doc.insertString(offset, userName, userAttrSet);
|
doc.insertString(offset, userName, userAttrSet);
|
||||||
|
|
||||||
offset = doc.getLength();
|
offset = doc.getLength();
|
||||||
doc.insertString(offset, "\t" + formatter.format(history.getModificationDate()),
|
doc.insertString(offset,
|
||||||
dateAttrSet);
|
"\t" + DateUtils.formatDateTimestamp(history.getModificationDate()), dateAttrSet);
|
||||||
doc.setParagraphAttributes(offset, 1, tabAttrSet, false);
|
doc.setParagraphAttributes(offset, 1, tabAttrSet, false);
|
||||||
|
|
||||||
offset = doc.getLength();
|
offset = doc.getLength();
|
||||||
|
|
|
@ -15,18 +15,16 @@
|
||||||
*/
|
*/
|
||||||
package ghidra.app.plugin.core.datamgr;
|
package ghidra.app.plugin.core.datamgr;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import ghidra.program.model.data.DataType;
|
import ghidra.program.model.data.DataType;
|
||||||
import ghidra.program.model.data.DataTypeManager;
|
import ghidra.program.model.data.DataTypeManager;
|
||||||
|
import ghidra.util.DateUtils;
|
||||||
import ghidra.util.UniversalID;
|
import ghidra.util.UniversalID;
|
||||||
|
|
||||||
public class DataTypeSyncInfo {
|
public class DataTypeSyncInfo {
|
||||||
private static DateFormat dateFormat;
|
|
||||||
|
|
||||||
private final DataType refDt;
|
private final DataType refDt;
|
||||||
private final DataType sourceDt;
|
private final DataType sourceDt;
|
||||||
|
@ -106,7 +104,7 @@ public class DataTypeSyncInfo {
|
||||||
/**
|
/**
|
||||||
* Commits the data type to the source archive.
|
* Commits the data type to the source archive.
|
||||||
* Call canCommit() to check the state before calling this.
|
* Call canCommit() to check the state before calling this.
|
||||||
* @see canCommit()
|
* @see #canCommit()
|
||||||
*/
|
*/
|
||||||
public void commit() {
|
public void commit() {
|
||||||
DataTypeSynchronizer.commitAssumingTransactionsOpen(sourceDTM, refDt);
|
DataTypeSynchronizer.commitAssumingTransactionsOpen(sourceDTM, refDt);
|
||||||
|
@ -115,7 +113,7 @@ public class DataTypeSyncInfo {
|
||||||
/**
|
/**
|
||||||
* Updates the data type from the one in the source archive.
|
* Updates the data type from the one in the source archive.
|
||||||
* Call canUpdate() to check the state before calling this.
|
* Call canUpdate() to check the state before calling this.
|
||||||
* @see canUpdate()
|
* @see #canUpdate()
|
||||||
*/
|
*/
|
||||||
public void update() {
|
public void update() {
|
||||||
DataTypeSynchronizer.updateAssumingTransactionsOpen(refDt.getDataTypeManager(), sourceDt);
|
DataTypeSynchronizer.updateAssumingTransactionsOpen(refDt.getDataTypeManager(), sourceDt);
|
||||||
|
@ -124,7 +122,7 @@ public class DataTypeSyncInfo {
|
||||||
/**
|
/**
|
||||||
* Reverts the data type to match the one in the source archive.
|
* Reverts the data type to match the one in the source archive.
|
||||||
* Call canRevert() to check the state before calling this.
|
* Call canRevert() to check the state before calling this.
|
||||||
* @see canRevert()
|
* @see #canRevert()
|
||||||
*/
|
*/
|
||||||
public void revert() {
|
public void revert() {
|
||||||
DataTypeSynchronizer.updateAssumingTransactionsOpen(refDt.getDataTypeManager(), sourceDt);
|
DataTypeSynchronizer.updateAssumingTransactionsOpen(refDt.getDataTypeManager(), sourceDt);
|
||||||
|
@ -177,10 +175,7 @@ public class DataTypeSyncInfo {
|
||||||
if (date == 0) {
|
if (date == 0) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
if (dateFormat == null) {
|
return DateUtils.formatDateTimestamp(new Date(date));
|
||||||
dateFormat = new SimpleDateFormat("MM/dd/yy HH:mm:ss");
|
|
||||||
}
|
|
||||||
return dateFormat.format(new Date(date));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataType getRefDataType() {
|
public DataType getRefDataType() {
|
||||||
|
|
|
@ -18,7 +18,6 @@ package ghidra.app.plugin.core.label;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
@ -42,13 +41,14 @@ class LabelHistoryPanel extends JPanel {
|
||||||
|
|
||||||
private LabelHistoryTableModel tableModel;
|
private LabelHistoryTableModel tableModel;
|
||||||
private JTable historyTable;
|
private JTable historyTable;
|
||||||
private SimpleDateFormat dateFormatter;
|
|
||||||
private LabelHistoryListener listener;
|
private LabelHistoryListener listener;
|
||||||
private boolean showAddresses;
|
private boolean showAddresses;
|
||||||
private final Program program;
|
private final Program program;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new history panel.
|
* Construct a new history panel
|
||||||
|
*
|
||||||
|
* @param program the program
|
||||||
* @param list list of LabelHistory objects
|
* @param list list of LabelHistory objects
|
||||||
* @param listener listener that is notified when the user clicks on a
|
* @param listener listener that is notified when the user clicks on a
|
||||||
* row in the table; null if only label history at a specific address
|
* row in the table; null if only label history at a specific address
|
||||||
|
@ -60,13 +60,9 @@ class LabelHistoryPanel extends JPanel {
|
||||||
showAddresses = listener != null;
|
showAddresses = listener != null;
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
|
|
||||||
dateFormatter = new SimpleDateFormat("yyyy MMM dd hh:mm aaa");
|
|
||||||
create(list);
|
create(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Show the label history for the given address.
|
|
||||||
*/
|
|
||||||
void setCurrentAddress(java.util.List<LabelHistory> list) {
|
void setCurrentAddress(java.util.List<LabelHistory> list) {
|
||||||
tableModel = new LabelHistoryTableModel(list, true);
|
tableModel = new LabelHistoryTableModel(list, true);
|
||||||
}
|
}
|
||||||
|
@ -91,7 +87,7 @@ class LabelHistoryPanel extends JPanel {
|
||||||
TableColumn column = columnModel.getColumn(i);
|
TableColumn column = columnModel.getColumn(i);
|
||||||
String name = (String) column.getIdentifier();
|
String name = (String) column.getIdentifier();
|
||||||
if (name.equals(LabelHistoryTableModel.DATE)) {
|
if (name.equals(LabelHistoryTableModel.DATE)) {
|
||||||
column.setCellRenderer(new GenericDateCellRenderer(dateFormatter));
|
column.setCellRenderer(new GenericDateCellRenderer());
|
||||||
column.setPreferredWidth(190);
|
column.setPreferredWidth(190);
|
||||||
}
|
}
|
||||||
else if (name.equals(LabelHistoryTableModel.LABEL)) {
|
else if (name.equals(LabelHistoryTableModel.LABEL)) {
|
||||||
|
@ -131,8 +127,8 @@ class LabelHistoryPanel extends JPanel {
|
||||||
private Font monoFont;
|
private Font monoFont;
|
||||||
|
|
||||||
LabelCellRenderer() {
|
LabelCellRenderer() {
|
||||||
Font defaultFont = getFont();
|
Font f = getFont();
|
||||||
monoFont = new Font("monospaced", defaultFont.getStyle(), defaultFont.getSize());
|
monoFont = new Font("monospaced", f.getStyle(), f.getSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -19,8 +19,6 @@ import java.awt.*;
|
||||||
import java.awt.geom.AffineTransform;
|
import java.awt.geom.AffineTransform;
|
||||||
import java.awt.print.*;
|
import java.awt.print.*;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import docking.util.GraphicsUtils;
|
import docking.util.GraphicsUtils;
|
||||||
|
@ -29,6 +27,7 @@ import docking.widgets.fieldpanel.LayoutModel;
|
||||||
import docking.widgets.fieldpanel.internal.EmptyLayoutBackgroundColorManager;
|
import docking.widgets.fieldpanel.internal.EmptyLayoutBackgroundColorManager;
|
||||||
import docking.widgets.fieldpanel.internal.LayoutBackgroundColorManager;
|
import docking.widgets.fieldpanel.internal.LayoutBackgroundColorManager;
|
||||||
import docking.widgets.fieldpanel.internal.PaintContext;
|
import docking.widgets.fieldpanel.internal.PaintContext;
|
||||||
|
import ghidra.util.DateUtils;
|
||||||
import ghidra.util.Msg;
|
import ghidra.util.Msg;
|
||||||
import ghidra.util.task.TaskMonitor;
|
import ghidra.util.task.TaskMonitor;
|
||||||
|
|
||||||
|
@ -60,7 +59,8 @@ public class CodeUnitPrintable implements Printable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CodeUnitPrintable(LayoutModel lm, int startIndex, int endIndex, double scaleAmount,
|
public CodeUnitPrintable(LayoutModel lm, int startIndex, int endIndex, double scaleAmount,
|
||||||
TaskMonitor monitor, PrintOptionsDialog pod, Book book, PrinterJob job, Date startDate) {
|
TaskMonitor monitor, PrintOptionsDialog pod, Book book, PrinterJob job,
|
||||||
|
Date startDate) {
|
||||||
this.lm = lm;
|
this.lm = lm;
|
||||||
this.startIndex = startIndex;
|
this.startIndex = startIndex;
|
||||||
this.endIndex = endIndex;
|
this.endIndex = endIndex;
|
||||||
|
@ -71,14 +71,17 @@ public class CodeUnitPrintable implements Printable {
|
||||||
this.job = job;
|
this.job = job;
|
||||||
this.startDate = startDate;
|
this.startDate = startDate;
|
||||||
|
|
||||||
if (pod.getMonochrome())
|
if (pod.getMonochrome()) {
|
||||||
PAINT_CONTEXT.setPrintColor(Color.BLACK);
|
PAINT_CONTEXT.setPrintColor(Color.BLACK);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
PAINT_CONTEXT.setPrintColor(null);
|
PAINT_CONTEXT.setPrintColor(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CodeUnitPrintable(LayoutModel lm, java.util.List<Layout> layouts, double scaleAmount,
|
public CodeUnitPrintable(LayoutModel lm, java.util.List<Layout> layouts, double scaleAmount,
|
||||||
TaskMonitor monitor, PrintOptionsDialog pod, Book book, PrinterJob job, Date startDate) {
|
TaskMonitor monitor, PrintOptionsDialog pod, Book book, PrinterJob job,
|
||||||
|
Date startDate) {
|
||||||
this.lm = lm;
|
this.lm = lm;
|
||||||
this.layouts = layouts;
|
this.layouts = layouts;
|
||||||
this.scaleAmount = scaleAmount;
|
this.scaleAmount = scaleAmount;
|
||||||
|
@ -88,10 +91,12 @@ public class CodeUnitPrintable implements Printable {
|
||||||
this.job = job;
|
this.job = job;
|
||||||
this.startDate = startDate;
|
this.startDate = startDate;
|
||||||
|
|
||||||
if (pod.getMonochrome())
|
if (pod.getMonochrome()) {
|
||||||
PAINT_CONTEXT.setPrintColor(Color.BLACK);
|
PAINT_CONTEXT.setPrintColor(Color.BLACK);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
PAINT_CONTEXT.setPrintColor(null);
|
PAINT_CONTEXT.setPrintColor(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -107,13 +112,12 @@ public class CodeUnitPrintable implements Printable {
|
||||||
return NO_SUCH_PAGE;
|
return NO_SUCH_PAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle rect =
|
Rectangle rect = new Rectangle((int) pageFormat.getImageableWidth(),
|
||||||
new Rectangle((int) pageFormat.getImageableWidth(),
|
(int) pageFormat.getImageableHeight());
|
||||||
(int) pageFormat.getImageableHeight());
|
if (scaleAmount < 1.0) {
|
||||||
if (scaleAmount < 1.0)
|
rect = new Rectangle((int) (pageFormat.getImageableWidth() / scaleAmount),
|
||||||
rect =
|
(int) (pageFormat.getImageableHeight() / scaleAmount));
|
||||||
new Rectangle((int) (pageFormat.getImageableWidth() / scaleAmount),
|
}
|
||||||
(int) (pageFormat.getImageableHeight() / scaleAmount));
|
|
||||||
LayoutBackgroundColorManager ls =
|
LayoutBackgroundColorManager ls =
|
||||||
new EmptyLayoutBackgroundColorManager(PAINT_CONTEXT.getBackground());
|
new EmptyLayoutBackgroundColorManager(PAINT_CONTEXT.getBackground());
|
||||||
|
|
||||||
|
@ -128,8 +132,7 @@ public class CodeUnitPrintable implements Printable {
|
||||||
GraphicsUtils.drawString(null, g2, job.getJobName(), 0, metrics.getMaxAscent());
|
GraphicsUtils.drawString(null, g2, job.getJobName(), 0, metrics.getMaxAscent());
|
||||||
}
|
}
|
||||||
if (pod.getPrintDate()) {
|
if (pod.getPrintDate()) {
|
||||||
DateFormat format = new SimpleDateFormat("MM/dd/yy h:mm:ss a");
|
String dateTime = DateUtils.formatDateTimestamp(startDate);
|
||||||
String dateTime = format.format(startDate);
|
|
||||||
GraphicsUtils.drawString(null, g2, dateTime, 0, (int) bottomPos);
|
GraphicsUtils.drawString(null, g2, dateTime, 0, (int) bottomPos);
|
||||||
}
|
}
|
||||||
if (pod.getPrintPageNum()) {
|
if (pod.getPrintPageNum()) {
|
||||||
|
@ -139,16 +142,19 @@ public class CodeUnitPrintable implements Printable {
|
||||||
(int) bottomPos);
|
(int) bottomPos);
|
||||||
}
|
}
|
||||||
g2.setFont(originalFont);
|
g2.setFont(originalFont);
|
||||||
if (pod.showHeader())
|
if (pod.showHeader()) {
|
||||||
g2.translate(0, pod.getHeaderHeight());
|
g2.translate(0, pod.getHeaderHeight());
|
||||||
|
}
|
||||||
|
|
||||||
if (scaleAmount < 1.0)
|
if (scaleAmount < 1.0) {
|
||||||
g2.transform(AffineTransform.getScaleInstance(scaleAmount, scaleAmount));
|
g2.transform(AffineTransform.getScaleInstance(scaleAmount, scaleAmount));
|
||||||
|
}
|
||||||
|
|
||||||
if (layouts != null) {
|
if (layouts != null) {
|
||||||
//If no layouts, ignore blank page
|
//If no layouts, ignore blank page
|
||||||
if (layouts.size() == 0)
|
if (layouts.size() == 0) {
|
||||||
return NO_SUCH_PAGE;
|
return NO_SUCH_PAGE;
|
||||||
|
}
|
||||||
for (int i = 0; i < layouts.size(); i++) {
|
for (int i = 0; i < layouts.size(); i++) {
|
||||||
Layout layout = layouts.get(i);
|
Layout layout = layouts.get(i);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
package ghidra.program.flatapi;
|
package ghidra.program.flatapi;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import ghidra.app.cmd.comments.SetCommentCmd;
|
import ghidra.app.cmd.comments.SetCommentCmd;
|
||||||
|
@ -42,7 +42,6 @@ import ghidra.program.model.util.CodeUnitInsertionException;
|
||||||
import ghidra.program.util.AddressEvaluator;
|
import ghidra.program.util.AddressEvaluator;
|
||||||
import ghidra.program.util.string.*;
|
import ghidra.program.util.string.*;
|
||||||
import ghidra.util.Conv;
|
import ghidra.util.Conv;
|
||||||
import ghidra.util.SystemUtilities;
|
|
||||||
import ghidra.util.ascii.AsciiCharSetRecognizer;
|
import ghidra.util.ascii.AsciiCharSetRecognizer;
|
||||||
import ghidra.util.datastruct.Accumulator;
|
import ghidra.util.datastruct.Accumulator;
|
||||||
import ghidra.util.datastruct.ListAccumulator;
|
import ghidra.util.datastruct.ListAccumulator;
|
||||||
|
@ -2456,8 +2455,9 @@ public class FlatProgramAPI {
|
||||||
folder.createFile(program.getName(), program, monitor);
|
folder.createFile(program.getName(), program, monitor);
|
||||||
}
|
}
|
||||||
catch (DuplicateFileException e) {
|
catch (DuplicateFileException e) {
|
||||||
folder.createFile(program.getName() + "_" + SystemUtilities.currentTimeStamp(), program,
|
SimpleDateFormat formatter = new SimpleDateFormat("dd.MMM.yyyy_HH.mm.ss");
|
||||||
monitor);
|
String time = formatter.format(new Date());
|
||||||
|
folder.createFile(program.getName() + "_" + time, program, monitor);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (program == currentProgram) {
|
if (program == currentProgram) {
|
||||||
|
|
|
@ -16,13 +16,13 @@
|
||||||
package docking.widgets;
|
package docking.widgets;
|
||||||
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
|
|
||||||
import docking.widgets.table.GTableCellRenderer;
|
import docking.widgets.table.GTableCellRenderer;
|
||||||
import docking.widgets.table.GTableCellRenderingData;
|
import docking.widgets.table.GTableCellRenderingData;
|
||||||
|
import ghidra.util.DateUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The JDK-provided DateRenderer does not inherit the backgrounds and such properly.
|
* The JDK-provided DateRenderer does not inherit the backgrounds and such properly.
|
||||||
|
@ -30,16 +30,15 @@ import docking.widgets.table.GTableCellRenderingData;
|
||||||
* column does not have the correct background. This fixes that.
|
* column does not have the correct background. This fixes that.
|
||||||
*/
|
*/
|
||||||
public class GenericDateCellRenderer extends GTableCellRenderer {
|
public class GenericDateCellRenderer extends GTableCellRenderer {
|
||||||
private DateFormat format;
|
|
||||||
private String toolTip;
|
private String toolTip;
|
||||||
|
|
||||||
public GenericDateCellRenderer(DateFormat format, String toolTip) {
|
public GenericDateCellRenderer() {
|
||||||
this.format = format;
|
this(null);
|
||||||
this.toolTip = toolTip;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GenericDateCellRenderer(DateFormat format) {
|
public GenericDateCellRenderer(String toolTip) {
|
||||||
this(format, null);
|
this.toolTip = toolTip;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -47,7 +46,8 @@ public class GenericDateCellRenderer extends GTableCellRenderer {
|
||||||
|
|
||||||
Date value = (Date) data.getValue();
|
Date value = (Date) data.getValue();
|
||||||
|
|
||||||
GTableCellRenderingData newData = data.copyWithNewValue(format.format(value));
|
GTableCellRenderingData newData =
|
||||||
|
data.copyWithNewValue(DateUtils.formatDateTimestamp(value));
|
||||||
|
|
||||||
JComponent c = (JComponent) super.getTableCellRendererComponent(newData);
|
JComponent c = (JComponent) super.getTableCellRendererComponent(newData);
|
||||||
if (toolTip != null) {
|
if (toolTip != null) {
|
||||||
|
|
|
@ -134,7 +134,7 @@ class DirectoryTable extends GTable implements GhidraFileChooserDirectoryModelIf
|
||||||
column.setCellRenderer(new FileSizeRenderer());
|
column.setCellRenderer(new FileSizeRenderer());
|
||||||
|
|
||||||
column = columnModel.getColumn(DirectoryTableModel.TIME_COL);
|
column = columnModel.getColumn(DirectoryTableModel.TIME_COL);
|
||||||
column.setCellRenderer(new GenericDateCellRenderer(GhidraFileChooser.format));
|
column.setCellRenderer(new GenericDateCellRenderer());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void maybeSelectItem(MouseEvent e) {
|
private void maybeSelectItem(MouseEvent e) {
|
||||||
|
|
|
@ -25,6 +25,7 @@ import javax.swing.filechooser.FileSystemView;
|
||||||
import docking.widgets.DropDownSelectionTextField;
|
import docking.widgets.DropDownSelectionTextField;
|
||||||
import docking.widgets.DropDownTextFieldDataModel;
|
import docking.widgets.DropDownTextFieldDataModel;
|
||||||
import docking.widgets.list.GListCellRenderer;
|
import docking.widgets.list.GListCellRenderer;
|
||||||
|
import ghidra.util.DateUtils;
|
||||||
import ghidra.util.HTMLUtilities;
|
import ghidra.util.HTMLUtilities;
|
||||||
import ghidra.util.exception.AssertException;
|
import ghidra.util.exception.AssertException;
|
||||||
|
|
||||||
|
@ -130,7 +131,7 @@ public class FileDropDownSelectionDataModel implements DropDownTextFieldDataMode
|
||||||
"<b>" + HTMLUtilities.escapeHTML(file.getName()) + "</b>" + "</td></tr>" +
|
"<b>" + HTMLUtilities.escapeHTML(file.getName()) + "</b>" + "</td></tr>" +
|
||||||
"<tr><td>Size:</td><td>" + (isDir ? "0" : file.length()) + " bytes" + "</td></tr>" +
|
"<tr><td>Size:</td><td>" + (isDir ? "0" : file.length()) + " bytes" + "</td></tr>" +
|
||||||
"<tr><td>Last modified:</td><td>" +
|
"<tr><td>Last modified:</td><td>" +
|
||||||
GhidraFileChooser.format.format(new Date(file.lastModified())) + "</td></tr>" +
|
DateUtils.formatDateTimestamp(new Date(file.lastModified())) + "</td></tr>" +
|
||||||
"</table>";
|
"</table>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileFilter;
|
import java.io.FileFilter;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
@ -126,8 +125,6 @@ public class GhidraFileChooser extends DialogComponentProvider
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static final SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy hh:mm aaa");
|
|
||||||
|
|
||||||
/** Instruction to display only files. */
|
/** Instruction to display only files. */
|
||||||
public static final int FILES_ONLY = 0;
|
public static final int FILES_ONLY = 0;
|
||||||
/** Instruction to display only directories. */
|
/** Instruction to display only directories. */
|
||||||
|
|
|
@ -24,8 +24,20 @@ import java.util.*;
|
||||||
import ghidra.util.exception.AssertException;
|
import ghidra.util.exception.AssertException;
|
||||||
|
|
||||||
public class DateUtils {
|
public class DateUtils {
|
||||||
private static final String DATEFORMAT_STR = "MM/dd/yyyy";
|
|
||||||
private static final String TIMEFORMAT_STR = "h:mm";
|
/** Example: Oct 31, 2019 03:24 PM */
|
||||||
|
private static final String DATE_TIME_FORMAT_STRING = "MMM dd, yyyy hh:mm aaa";
|
||||||
|
private static final String DATE_FORMAT_STRING = "MM/dd/yyyy";
|
||||||
|
private static final String TIME_FORMAT_STRING = "h:mm";
|
||||||
|
|
||||||
|
private static final ThreadLocal<SimpleDateFormat> DATE_TIME_FORMAT =
|
||||||
|
ThreadLocal.withInitial(() -> new SimpleDateFormat(DATE_TIME_FORMAT_STRING));
|
||||||
|
|
||||||
|
private static final ThreadLocal<SimpleDateFormat> DATE_FORMAT =
|
||||||
|
ThreadLocal.withInitial(() -> new SimpleDateFormat(DATE_FORMAT_STRING));
|
||||||
|
|
||||||
|
private static final ThreadLocal<SimpleDateFormat> TIME_FORMAT =
|
||||||
|
ThreadLocal.withInitial(() -> new SimpleDateFormat(TIME_FORMAT_STRING));
|
||||||
|
|
||||||
public static final long MS_PER_SEC = 1000;
|
public static final long MS_PER_SEC = 1000;
|
||||||
public static final long MS_PER_MIN = MS_PER_SEC * 60;
|
public static final long MS_PER_MIN = MS_PER_SEC * 60;
|
||||||
|
@ -172,7 +184,7 @@ public class DateUtils {
|
||||||
|
|
||||||
public static Date normalizeDate(Date date) {
|
public static Date normalizeDate(Date date) {
|
||||||
try {
|
try {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat(DATEFORMAT_STR);
|
SimpleDateFormat sdf = DATE_FORMAT.get();
|
||||||
return sdf.parse(sdf.format(date));
|
return sdf.parse(sdf.format(date));
|
||||||
}
|
}
|
||||||
catch (ParseException e) {
|
catch (ParseException e) {
|
||||||
|
@ -201,19 +213,35 @@ public class DateUtils {
|
||||||
return dayOfWeek == SATURDAY || dayOfWeek == SUNDAY;
|
return dayOfWeek == SATURDAY || dayOfWeek == SUNDAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats the given date into a string. This is in contrast to
|
||||||
|
* {@link #formatDateTimestamp(Date)}, which will also return the time portion of the date.
|
||||||
|
*
|
||||||
|
* @param date the date to format
|
||||||
|
* @return the date string
|
||||||
|
*/
|
||||||
public static String formatDate(Date date) {
|
public static String formatDate(Date date) {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat(DATEFORMAT_STR);
|
return DATE_FORMAT.get().format(date);
|
||||||
return sdf.format(date);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current local timezone time-of-day as an HOUR:MIN string.
|
* Formats the given date into a string that contains the date and time. This is in
|
||||||
|
* contrast to {@link #formatDate(Date)}, which only returns a date string.
|
||||||
|
*
|
||||||
|
* @param date the date to format
|
||||||
|
* @return the date and time string
|
||||||
|
*/
|
||||||
|
public static String formatDateTimestamp(Date date) {
|
||||||
|
return DATE_TIME_FORMAT.get().format(date);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current local time zone time-of-day as an HOUR:MIN string.
|
||||||
*
|
*
|
||||||
* @return current time-of-day as "HOUR:MIN"
|
* @return current time-of-day as "HOUR:MIN"
|
||||||
*/
|
*/
|
||||||
public static String getTimeNow() {
|
public static String getTimeNow() {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat(TIMEFORMAT_STR);
|
return TIME_FORMAT.get().format(new Date());
|
||||||
return sdf.format(new Date());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Date getDate(int year, int month, int day) {
|
public static Date getDate(int year, int month, int day) {
|
||||||
|
@ -230,7 +258,7 @@ public class DateUtils {
|
||||||
int days = 0;
|
int days = 0;
|
||||||
while (cal.getTime().compareTo(date2) < 0) {
|
while (cal.getTime().compareTo(date2) < 0) {
|
||||||
cal.add(Calendar.DAY_OF_MONTH, 1);
|
cal.add(Calendar.DAY_OF_MONTH, 1);
|
||||||
if (!DateUtils.isWeekend(cal) && !DateUtils.isHoliday(cal)) {
|
if (!isWeekend(cal) && !isHoliday(cal)) {
|
||||||
days++;
|
days++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -239,8 +267,8 @@ public class DateUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats a millisecond duration as a English string expressing the number of
|
* Formats a millisecond duration as a English string expressing the number of
|
||||||
* hours, minutes and seconds in the duration.
|
* hours, minutes and seconds in the duration
|
||||||
* <p>
|
*
|
||||||
* @param millis Count of milliseconds of an elapsed duration.
|
* @param millis Count of milliseconds of an elapsed duration.
|
||||||
* @return String such as "5 hours, 3 mins, 22 secs".
|
* @return String such as "5 hours, 3 mins, 22 secs".
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -15,49 +15,41 @@
|
||||||
*/
|
*/
|
||||||
package ghidra.util;
|
package ghidra.util;
|
||||||
|
|
||||||
import java.util.Date;
|
import static org.junit.Assert.*;
|
||||||
import java.util.List;
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import generic.test.AbstractGenericTest;
|
public class DateUtilsTest {
|
||||||
|
|
||||||
public class DateUtilsTest extends AbstractGenericTest {
|
@Test
|
||||||
|
public void testFormatDate() {
|
||||||
public DateUtilsTest() {
|
Date date = new Date(1572896586687L);
|
||||||
// nada
|
assertEquals("11/04/2019", DateUtils.formatDate(date));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Test
|
||||||
* This test was moved here from DateUtils.main()
|
public void testFormatDateTime() {
|
||||||
*/
|
Date date = new Date(1572896586687L);
|
||||||
//@Test
|
assertEquals("Nov 04, 2019 02:43 PM", DateUtils.formatDateTimestamp(date));
|
||||||
public void testHolidays() {
|
|
||||||
for (int year = 2012; year < 2020; year++) {
|
|
||||||
List<Date> holidays = DateUtils.getHolidays(year);
|
|
||||||
for (Date date : holidays) {
|
|
||||||
System.out.println(DateUtils.formatDate(date));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFormatDuration() {
|
public void testFormatDuration() {
|
||||||
Assert.assertEquals("0 secs", DateUtils.formatDuration(100));
|
assertEquals("0 secs", DateUtils.formatDuration(100));
|
||||||
Assert.assertEquals("0 secs", DateUtils.formatDuration(DateUtils.MS_PER_SEC - 1));
|
assertEquals("0 secs", DateUtils.formatDuration(DateUtils.MS_PER_SEC - 1));
|
||||||
Assert.assertEquals("1 secs", DateUtils.formatDuration(DateUtils.MS_PER_SEC));
|
assertEquals("1 secs", DateUtils.formatDuration(DateUtils.MS_PER_SEC));
|
||||||
Assert.assertEquals("1 secs", DateUtils.formatDuration(DateUtils.MS_PER_SEC + 1));
|
assertEquals("1 secs", DateUtils.formatDuration(DateUtils.MS_PER_SEC + 1));
|
||||||
Assert.assertEquals("59 secs", DateUtils.formatDuration(DateUtils.MS_PER_MIN - 1));
|
assertEquals("59 secs", DateUtils.formatDuration(DateUtils.MS_PER_MIN - 1));
|
||||||
Assert.assertEquals("1 mins, 0 secs", DateUtils.formatDuration(DateUtils.MS_PER_MIN));
|
assertEquals("1 mins, 0 secs", DateUtils.formatDuration(DateUtils.MS_PER_MIN));
|
||||||
Assert.assertEquals("1 mins, 1 secs",
|
assertEquals("1 mins, 1 secs",
|
||||||
DateUtils.formatDuration(DateUtils.MS_PER_MIN + DateUtils.MS_PER_SEC));
|
DateUtils.formatDuration(DateUtils.MS_PER_MIN + DateUtils.MS_PER_SEC));
|
||||||
Assert.assertEquals("23 hours, 59 mins, 59 secs",
|
assertEquals("23 hours, 59 mins, 59 secs",
|
||||||
DateUtils.formatDuration(DateUtils.MS_PER_DAY - 1));
|
DateUtils.formatDuration(DateUtils.MS_PER_DAY - 1));
|
||||||
Assert.assertEquals("1 days, 0 hours, 0 mins, 0 secs",
|
assertEquals("1 days, 0 hours, 0 mins, 0 secs",
|
||||||
DateUtils.formatDuration(DateUtils.MS_PER_DAY));
|
DateUtils.formatDuration(DateUtils.MS_PER_DAY));
|
||||||
Assert.assertEquals("1 days, 0 hours, 0 mins, 0 secs",
|
assertEquals("1 days, 0 hours, 0 mins, 0 secs",
|
||||||
DateUtils.formatDuration(DateUtils.MS_PER_DAY + 1));
|
DateUtils.formatDuration(DateUtils.MS_PER_DAY + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,6 @@ package ghidra.framework.main.datatable;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -35,8 +33,7 @@ import docking.widgets.table.threaded.*;
|
||||||
import ghidra.framework.main.FrontEndPlugin;
|
import ghidra.framework.main.FrontEndPlugin;
|
||||||
import ghidra.framework.model.*;
|
import ghidra.framework.model.*;
|
||||||
import ghidra.framework.plugintool.PluginTool;
|
import ghidra.framework.plugintool.PluginTool;
|
||||||
import ghidra.util.HelpLocation;
|
import ghidra.util.*;
|
||||||
import ghidra.util.SystemUtilities;
|
|
||||||
import ghidra.util.bean.GGlassPane;
|
import ghidra.util.bean.GGlassPane;
|
||||||
import ghidra.util.bean.GGlassPanePainter;
|
import ghidra.util.bean.GGlassPanePainter;
|
||||||
|
|
||||||
|
@ -117,16 +114,12 @@ public class ProjectDataTablePanel extends JPanel {
|
||||||
table.dispose(); // this will dispose the gTable as well
|
table.dispose(); // this will dispose the gTable as well
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the help location for the data tree.
|
|
||||||
*/
|
|
||||||
public void setHelpLocation(HelpLocation helpLocation) {
|
public void setHelpLocation(HelpLocation helpLocation) {
|
||||||
HelpService help = Help.getHelpService();
|
HelpService help = Help.getHelpService();
|
||||||
help.registerHelp(table, helpLocation);
|
help.registerHelp(table, helpLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DateCellRenderer extends GTableCellRenderer {
|
private class DateCellRenderer extends GTableCellRenderer {
|
||||||
DateFormat formatter = new SimpleDateFormat("MMM dd, yyyy HH:mm");
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getTableCellRendererComponent(GTableCellRenderingData data) {
|
public Component getTableCellRendererComponent(GTableCellRenderingData data) {
|
||||||
|
@ -136,7 +129,7 @@ public class ProjectDataTablePanel extends JPanel {
|
||||||
Object value = data.getValue();
|
Object value = data.getValue();
|
||||||
|
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
renderer.setText(formatter.format((Date) value));
|
renderer.setText(DateUtils.formatDateTimestamp((Date) value));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
renderer.setText("");
|
renderer.setText("");
|
||||||
|
|
|
@ -17,7 +17,6 @@ package ghidra.framework.main.datatree;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -52,7 +51,6 @@ public class CheckoutsPanel extends JPanel {
|
||||||
private DomainFile domainFile;
|
private DomainFile domainFile;
|
||||||
private CheckoutsTableModel tableModel;
|
private CheckoutsTableModel tableModel;
|
||||||
private GTable table;
|
private GTable table;
|
||||||
private SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy MMM dd hh:mm aaa");
|
|
||||||
private MyFolderListener listener;
|
private MyFolderListener listener;
|
||||||
|
|
||||||
private User user;
|
private User user;
|
||||||
|
@ -63,7 +61,7 @@ public class CheckoutsPanel extends JPanel {
|
||||||
* @param tool tool to get project data for adding a listener
|
* @param tool tool to get project data for adding a listener
|
||||||
* @param user user that is logged in
|
* @param user user that is logged in
|
||||||
* @param domainFile domain file to view checkouts
|
* @param domainFile domain file to view checkouts
|
||||||
* @throws IOException
|
* @param checkouts the checkouts to show
|
||||||
*/
|
*/
|
||||||
public CheckoutsPanel(Component parent, PluginTool tool, User user, DomainFile domainFile,
|
public CheckoutsPanel(Component parent, PluginTool tool, User user, DomainFile domainFile,
|
||||||
ItemCheckoutStatus[] checkouts) {
|
ItemCheckoutStatus[] checkouts) {
|
||||||
|
@ -115,8 +113,7 @@ public class CheckoutsPanel extends JPanel {
|
||||||
|
|
||||||
column = columnModel.getColumn(CheckoutsTableModel.DATE_COL);
|
column = columnModel.getColumn(CheckoutsTableModel.DATE_COL);
|
||||||
column.setPreferredWidth(120);
|
column.setPreferredWidth(120);
|
||||||
column.setCellRenderer(
|
column.setCellRenderer(new GenericDateCellRenderer("Date when file was checked out"));
|
||||||
new GenericDateCellRenderer(dateFormatter, "Date when file was checked out"));
|
|
||||||
columnModel.getColumn(CheckoutsTableModel.VERSION_COL).setPreferredWidth(50);
|
columnModel.getColumn(CheckoutsTableModel.VERSION_COL).setPreferredWidth(50);
|
||||||
columnModel.getColumn(CheckoutsTableModel.USER_COL).setPreferredWidth(80);
|
columnModel.getColumn(CheckoutsTableModel.USER_COL).setPreferredWidth(80);
|
||||||
columnModel.getColumn(CheckoutsTableModel.HOST_COL).setPreferredWidth(120);
|
columnModel.getColumn(CheckoutsTableModel.HOST_COL).setPreferredWidth(120);
|
||||||
|
@ -127,8 +124,8 @@ public class CheckoutsPanel extends JPanel {
|
||||||
private void terminateCheckout(int[] rows) {
|
private void terminateCheckout(int[] rows) {
|
||||||
|
|
||||||
Set<ItemCheckoutStatus> toTerminate = new HashSet<>();
|
Set<ItemCheckoutStatus> toTerminate = new HashSet<>();
|
||||||
for (int i = 0; i < rows.length; i++) {
|
for (int row : rows) {
|
||||||
ItemCheckoutStatus item = tableModel.getRowObject(rows[i]);
|
ItemCheckoutStatus item = tableModel.getRowObject(row);
|
||||||
toTerminate.add(item);
|
toTerminate.add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ package ghidra.framework.main.datatree;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
|
@ -38,8 +37,7 @@ import ghidra.framework.main.projectdata.actions.VersionControlUndoCheckOutActio
|
||||||
import ghidra.framework.model.DomainFile;
|
import ghidra.framework.model.DomainFile;
|
||||||
import ghidra.framework.model.DomainFolder;
|
import ghidra.framework.model.DomainFolder;
|
||||||
import ghidra.framework.plugintool.Plugin;
|
import ghidra.framework.plugintool.Plugin;
|
||||||
import ghidra.util.HelpLocation;
|
import ghidra.util.*;
|
||||||
import ghidra.util.Msg;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dialog that shows all checkouts in a specific folder and all of its subfolders.
|
* Dialog that shows all checkouts in a specific folder and all of its subfolders.
|
||||||
|
@ -51,7 +49,6 @@ public class FindCheckoutsDialog extends DialogComponentProvider {
|
||||||
private Plugin plugin;
|
private Plugin plugin;
|
||||||
private DomainFolder folder;
|
private DomainFolder folder;
|
||||||
private JTable table;
|
private JTable table;
|
||||||
private SimpleDateFormat formatter;
|
|
||||||
private VersionControlCheckInAction checkInAction;
|
private VersionControlCheckInAction checkInAction;
|
||||||
private VersionControlUndoCheckOutAction undoCheckOutAction;
|
private VersionControlUndoCheckOutAction undoCheckOutAction;
|
||||||
private boolean showMessage = true;
|
private boolean showMessage = true;
|
||||||
|
@ -61,7 +58,6 @@ public class FindCheckoutsDialog extends DialogComponentProvider {
|
||||||
super("Find Checkouts");
|
super("Find Checkouts");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.folder = folder;
|
this.folder = folder;
|
||||||
formatter = new SimpleDateFormat("yyyy MMM dd hh:mm aaa");
|
|
||||||
create();
|
create();
|
||||||
setHelpLocation(new HelpLocation("VersionControl", "Find_Checkouts"));
|
setHelpLocation(new HelpLocation("VersionControl", "Find_Checkouts"));
|
||||||
}
|
}
|
||||||
|
@ -165,7 +161,7 @@ public class FindCheckoutsDialog extends DialogComponentProvider {
|
||||||
Object value = data.getValue();
|
Object value = data.getValue();
|
||||||
|
|
||||||
if (value instanceof Date) {
|
if (value instanceof Date) {
|
||||||
setText(formatter.format((Date) value));
|
setText(DateUtils.formatDateTimestamp((Date) value));
|
||||||
}
|
}
|
||||||
|
|
||||||
setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
|
setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
|
||||||
|
|
|
@ -21,7 +21,6 @@ import java.awt.dnd.*;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -59,7 +58,6 @@ public class VersionHistoryPanel extends JPanel implements Draggable {
|
||||||
private String domainFilePath;
|
private String domainFilePath;
|
||||||
private VersionHistoryTableModel tableModel;
|
private VersionHistoryTableModel tableModel;
|
||||||
private GTable table;
|
private GTable table;
|
||||||
private SimpleDateFormat formatter;
|
|
||||||
|
|
||||||
private DragSource dragSource;
|
private DragSource dragSource;
|
||||||
private DragGestureAdapter dragGestureAdapter;
|
private DragGestureAdapter dragGestureAdapter;
|
||||||
|
@ -87,7 +85,6 @@ public class VersionHistoryPanel extends JPanel implements Draggable {
|
||||||
super(new BorderLayout());
|
super(new BorderLayout());
|
||||||
this.tool = tool;
|
this.tool = tool;
|
||||||
create();
|
create();
|
||||||
formatter = new SimpleDateFormat("yyyy MMM dd hh:mm aaa");
|
|
||||||
if (enableUserInteraction) {
|
if (enableUserInteraction) {
|
||||||
setUpDragSite();
|
setUpDragSite();
|
||||||
table.addMouseListener(new MyMouseListener());
|
table.addMouseListener(new MyMouseListener());
|
||||||
|
@ -389,7 +386,7 @@ public class VersionHistoryPanel extends JPanel implements Draggable {
|
||||||
int col = data.getColumnModelIndex();
|
int col = data.getColumnModelIndex();
|
||||||
|
|
||||||
if (value instanceof Date) {
|
if (value instanceof Date) {
|
||||||
setText(formatter.format((Date) value));
|
setText(DateUtils.formatDateTimestamp((Date) value));
|
||||||
}
|
}
|
||||||
|
|
||||||
setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
|
setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
|
||||||
|
|
|
@ -75,9 +75,6 @@ class VersionHistoryTableModel extends AbstractSortedTableModel<Version> {
|
||||||
return columnNames[column];
|
return columnNames[column];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Refresh the table model.
|
|
||||||
*/
|
|
||||||
void refresh(Version[] newVersions) {
|
void refresh(Version[] newVersions) {
|
||||||
List<Version> newVersionList = new ArrayList<>();
|
List<Version> newVersionList = new ArrayList<>();
|
||||||
for (Version version : newVersions) {
|
for (Version version : newVersions) {
|
||||||
|
@ -98,7 +95,7 @@ class VersionHistoryTableModel extends AbstractSortedTableModel<Version> {
|
||||||
public Object getColumnValueForRow(Version version, int columnIndex) {
|
public Object getColumnValueForRow(Version version, int columnIndex) {
|
||||||
switch (columnIndex) {
|
switch (columnIndex) {
|
||||||
case VERSION_COL:
|
case VERSION_COL:
|
||||||
return new Integer(version.getVersion());
|
return version.getVersion();
|
||||||
case DATE_COL:
|
case DATE_COL:
|
||||||
return new Date(version.getCreateTime());
|
return new Date(version.getCreateTime());
|
||||||
case USER_COL:
|
case USER_COL:
|
||||||
|
|
|
@ -19,8 +19,8 @@ import java.awt.Font;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.text.SimpleDateFormat;
|
import java.util.Objects;
|
||||||
import java.util.*;
|
import java.util.StringTokenizer;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
@ -35,8 +35,6 @@ import utilities.util.reflection.ReflectionUtilities;
|
||||||
*/
|
*/
|
||||||
public class SystemUtilities {
|
public class SystemUtilities {
|
||||||
|
|
||||||
private final static String DATE_TIME_FORMAT = "MMM d yyyy HH:mm:ss";
|
|
||||||
|
|
||||||
private static String userName;
|
private static String userName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -168,32 +166,6 @@ public class SystemUtilities {
|
||||||
return font.deriveFont((float) FONT_SIZE_OVERRIDE_VALUE.intValue());
|
return font.deriveFont((float) FONT_SIZE_OVERRIDE_VALUE.intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* returns the current date/time using default DATE/TIME format
|
|
||||||
* @return the current date/time using default DATE/TIME format
|
|
||||||
*/
|
|
||||||
public static String getDateTime() {
|
|
||||||
return getDateTime(DATE_TIME_FORMAT);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String currentTimeStamp() {
|
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("dd.MMM.yyyy_HH.mm.ss");
|
|
||||||
return formatter.format(new Date());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* returns the current date/time using specified DATE/TIME format
|
|
||||||
*
|
|
||||||
* @param dateTimeFormat the format for the time
|
|
||||||
* @return the formatted date
|
|
||||||
*/
|
|
||||||
public static String getDateTime(String dateTimeFormat) {
|
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat(dateTimeFormat, Locale.getDefault());
|
|
||||||
formatter.setTimeZone(TimeZone.getDefault());
|
|
||||||
|
|
||||||
return formatter.format(new Date());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the system is running during a test.
|
* Returns true if the system is running during a test.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue