Browse Source

Merge branch 'final/11.0' of ssh://code.fineres.com:7999/~zheng/C-design into final/11.0

new-design
shine 3 years ago
parent
commit
a701fec3ee
  1. 23
      designer-base/src/main/java/com/fr/design/data/datapane/preview/CopyableJTable.java
  2. 2
      designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java

23
designer-base/src/main/java/com/fr/design/data/datapane/preview/CopyableJTable.java

@ -106,6 +106,7 @@ public class CopyableJTable extends SortableJTable {
self.updateEndPoint(-1, column); self.updateEndPoint(-1, column);
self.refreshTable(); self.refreshTable();
} }
self.requestFocusInWindow();
} }
private int getColumn(MouseEvent e) { private int getColumn(MouseEvent e) {
@ -249,14 +250,29 @@ public class CopyableJTable extends SortableJTable {
FineLoggerFactory.getLogger().info("copy cell value"); FineLoggerFactory.getLogger().info("copy cell value");
java.util.List<java.util.List<Object>> table = new ArrayList<>(); java.util.List<java.util.List<Object>> table = new ArrayList<>();
if ((startRow != endRow || startCol != endCol) && Math.min(startCol, endCol) > -1) { if ((startRow != endRow || startCol != endCol) && Math.min(startCol, endCol) > -1) {
copyAreaData(table);
} else if (pointList.size() > 0) {
copyPointsData(table);
}
Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable tText = new StringSelection(ClipboardHelper.formatExcelString(table));
clip.setContents(tText, null);
}
private void copyAreaData(java.util.List<java.util.List<Object>> table) {
for (int i = Math.min(startRow, endRow); i <= Math.max(startRow, endRow); i++) { for (int i = Math.min(startRow, endRow); i <= Math.max(startRow, endRow); i++) {
table.add(new ArrayList<>()); table.add(new ArrayList<>());
for (int j = Math.min(startCol, endCol); j <= Math.max(startCol, endCol); j++) { for (int j = Math.min(startCol, endCol); j <= Math.max(startCol, endCol); j++) {
Object text = this.getTableValue(i, j); Object text = this.getTableValue(i, j);
if (text != null) {
table.get(table.size() - 1).add(text); table.get(table.size() - 1).add(text);
} }
} }
} else if (pointList.size() > 0) { }
}
private void copyPointsData(java.util.List<java.util.List<Object>> table) {
Collections.sort(pointList, Comparator.comparing(Point::getX).thenComparing(Point::getY)); Collections.sort(pointList, Comparator.comparing(Point::getX).thenComparing(Point::getY));
int startRow = pointList.get(0).x; int startRow = pointList.get(0).x;
int currentRow = startRow; int currentRow = startRow;
@ -267,13 +283,10 @@ public class CopyableJTable extends SortableJTable {
currentRow++; currentRow++;
} }
Object text = this.getTableValue(point.x, point.y); Object text = this.getTableValue(point.x, point.y);
if (text != null) {
table.get(table.size() - 1).add(text); table.get(table.size() - 1).add(text);
} }
} }
Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable tText = new StringSelection(ClipboardHelper.formatExcelString(table));
clip.setContents(tText, null);
} }
private Object getTableValue(int row, int col) { private Object getTableValue(int row, int col) {

2
designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java

@ -163,6 +163,8 @@ public class JavaFxNativeFileChooser implements FileChooserProvider {
try { try {
latch.await(); latch.await();
} catch (InterruptedException ignore) { } catch (InterruptedException ignore) {
} finally {
setShowDialogState(false);
} }
return selectedFiles.length > 0 ? JFileChooser.APPROVE_OPTION : JFileChooser.CANCEL_OPTION; return selectedFiles.length > 0 ? JFileChooser.APPROVE_OPTION : JFileChooser.CANCEL_OPTION;
} }

Loading…
Cancel
Save