Browse Source

Merge pull request #5261 in DESIGN/design from feature/10.0 to research/10.0

* commit '6f6d1959ac6bb3eb517e8e6c3d389c2cb9a6499a':
  REPORT-56080 图表双击无法进入图表编辑页
  REPORT-55060 数据集预览支持复制
  REPORT-55060 数据集预览支持复制
  REPORT-55060 数据集预览支持复制
  REPORT-55072 设计器内文件选择器替换为原生的
  REPORT-55072 设计器内文件选择器替换为原生的
  REPORT-55072 设计器内文件选择器替换为原生的
research/10.0
superman 3 years ago
parent
commit
83948028db
  1. 12
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  2. 25
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  3. 24
      designer-base/src/main/java/com/fr/design/base/clipboard/ClipboardHelper.java
  4. 203
      designer-base/src/main/java/com/fr/design/data/datapane/preview/CopyableJTable.java
  5. 3
      designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java
  6. 103
      designer-base/src/main/java/com/fr/design/gui/ifilechooser/AbstractFileChooser.java
  7. 12
      designer-base/src/main/java/com/fr/design/gui/ifilechooser/FileChooserProvider.java
  8. 5
      designer-base/src/main/java/com/fr/design/gui/ifilechooser/FileSelectionMode.java
  9. 158
      designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java
  10. 154
      designer-base/src/main/java/com/fr/design/gui/ifilechooser/UINativeFileChooser.java
  11. 289
      designer-base/src/main/java/com/fr/design/style/background/image/ImageFileChooser.java
  12. 27
      designer-base/src/main/java/com/fr/design/upm/UpmBridge.java
  13. 16
      designer-base/src/main/java/com/fr/design/web/CustomIconPane.java
  14. 20
      designer-base/src/main/java/com/fr/env/RemoteEnvPane.java
  15. 352
      designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapCustomPane.java
  16. 5
      designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java
  17. 33
      designer-form/src/main/java/com/fr/design/mainframe/share/action/InstallComponentAction.java
  18. 203
      designer-realize/src/main/java/com/fr/design/cell/clipboard/CellElementsClip.java

12
designer-base/src/main/java/com/fr/design/DesignerEnvManager.java

@ -192,6 +192,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private static List<SwingWorker> mapWorkerList = new ArrayList<SwingWorker>();
private boolean imageCompress = false;//图片压缩
private boolean showImageCompressMoveTip = true;
// 开启内嵌web页面的调试窗口
private boolean openDebug = false;
@ -1637,6 +1638,15 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
this.imageCompress = imageCompress;
}
public boolean isShowImageCompressMoveTip() {
return showImageCompressMoveTip;
}
public void setShowImageCompressMoveTip(boolean showImageCompressMoveTip) {
this.showImageCompressMoveTip = showImageCompressMoveTip;
}
public boolean isOpenDebug() {
return openDebug;
}
@ -1792,6 +1802,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
this.setCachingTemplateLimit(reader.getAttrAsInt("cachingTemplateLimit", CACHINGTEMPLATE_LIMIT));
this.setJoinProductImprove(reader.getAttrAsBoolean("joinProductImprove", true));
this.setImageCompress(reader.getAttrAsBoolean("imageCompress", true));
this.setShowImageCompressMoveTip(reader.getAttrAsBoolean("showImageCompressMoveTip", true));
this.setAutoBackUp(reader.getAttrAsBoolean("autoBackUp", true));
this.setTemplateTreePaneExpanded(reader.getAttrAsBoolean("templateTreePaneExpanded", false));
// peter:读取webinfLocation
@ -2072,6 +2083,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
if (!this.isImageCompress()) {
writer.attr("imageCompress", this.isImageCompress());
}
writer.attr("showImageCompressMoveTip", this.isShowImageCompressMoveTip());
if (!this.isAutoBackUp()) {
writer.attr("autoBackUp", this.isAutoBackUp());
}

25
designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java

@ -15,6 +15,9 @@ import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIDictionaryComboBox;
import com.fr.design.gui.ifilechooser.FileChooserProvider;
import com.fr.design.gui.ifilechooser.FileSelectionMode;
import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser;
import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.iprogressbar.UIProgressBarUI;
@ -47,6 +50,8 @@ import com.fr.transaction.Worker;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.vcs.VcsOperator;
import com.fr.workspace.server.vcs.git.config.GcConfig;
import com.sun.javafx.tk.FileChooserType;
import javafx.stage.FileChooser;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
@ -165,6 +170,7 @@ public class PreferencePane extends BasicPane {
private UICheckBox joinProductImproveCheckBox;
private UICheckBox autoPushUpdateCheckBox;
private UICheckBox embedServerLazyStartupCheckBox;
private UICheckBox imageCompressPanelCheckBox;
private UICheckBox vcsEnableCheckBox;
private UICheckBox saveCommitCheckBox;
@ -256,6 +262,10 @@ public class PreferencePane extends BasicPane {
embedServerPanel.add(embedServerLazyStartupCheckBox);
advancePane.add(embedServerPanel);
JPanel imageCompressPanel = FRGUIPaneFactory.createVerticalTitledBorderPane(i18nText("Fine-Design_Template_Preview_Performance"));
imageCompressPanelCheckBox = new UICheckBox(i18nText("Fine-Design_Image_Compress"));
imageCompressPanel.add(imageCompressPanelCheckBox);
advancePane.add(imageCompressPanel);
}
private void createVcsSettingPane(JPanel generalPane) {
@ -489,11 +499,13 @@ public class PreferencePane extends BasicPane {
chooseDirBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int saveValue = fileChooser.showOpenDialog(DesignerContext.getDesignerFrame());
FileChooserProvider fileChooserProvider =
new JavaFxNativeFileChooser.Builder().
fileSelectionMode(FileSelectionMode.DIR).
build();
int saveValue = fileChooserProvider.showDialog(null);
if (saveValue == JFileChooser.APPROVE_OPTION) {
File selectedFile = fileChooser.getSelectedFile();
File selectedFile = fileChooserProvider.getSelectedFile();
logExportDirectoryField.setText(selectedFile.getAbsolutePath());
}
}
@ -665,7 +677,7 @@ public class PreferencePane extends BasicPane {
defaultStringToFormulaBox.setSelected(false);
}
VcsConfigManager vcsConfigManager = designerEnvManager.getVcsConfigManager();
if (WorkContext.getCurrent().isCluster()){
if (WorkContext.getCurrent().isCluster()) {
vcsEnableCheckBox.setEnabled(false);
gcEnableCheckBox.setEnabled(false);
}
@ -717,6 +729,8 @@ public class PreferencePane extends BasicPane {
}
this.embedServerLazyStartupCheckBox.setSelected(designerEnvManager.isEmbedServerLazyStartup());
this.imageCompressPanelCheckBox.setSelected(designerEnvManager.isImageCompress());
}
private int chooseCase(int sign) {
@ -775,6 +789,7 @@ public class PreferencePane extends BasicPane {
designerEnvManager.setCachingTemplateLimit((int) this.cachingTemplateSpinner.getValue());
designerEnvManager.setJoinProductImprove(this.joinProductImproveCheckBox.isSelected());
designerEnvManager.setEmbedServerLazyStartup(this.embedServerLazyStartupCheckBox.isSelected());
designerEnvManager.setImageCompress(this.imageCompressPanelCheckBox.isSelected());
VcsConfigManager vcsConfigManager = designerEnvManager.getVcsConfigManager();
vcsConfigManager.setSaveInterval(this.saveIntervalEditor.getValue());
vcsConfigManager.setVcsEnable(this.vcsEnableCheckBox.isSelected());

24
designer-base/src/main/java/com/fr/design/base/clipboard/ClipboardHelper.java

@ -0,0 +1,24 @@
package com.fr.design.base.clipboard;
import java.util.List;
public class ClipboardHelper {
public static String formatExcelString(List<List<Object>> table) {
StringBuffer stringBuffer = new StringBuffer();
for (int row = 0; row < table.size(); row++) {
List<Object> rowValue = table.get(row);
for (int col = 0; col < rowValue.size(); col++) {
Object cell = rowValue.get(col);
stringBuffer.append(cell);
if (col != rowValue.size() - 1) {
stringBuffer.append("\t");
}
}
if (row != table.size() - 1) {
stringBuffer.append("\n");
}
}
return stringBuffer.toString();
}
}

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

@ -0,0 +1,203 @@
package com.fr.design.data.datapane.preview;
import com.fr.design.base.clipboard.ClipboardHelper;
import com.fr.design.gui.itable.SortableJTable;
import com.fr.design.gui.itable.TableSorter;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.os.OperatingSystem;
import javax.swing.table.TableCellRenderer;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
public class CopyableJTable extends SortableJTable {
//区域选中用到的定位数据
public int startRow = -1;
public int startCol = -1;
public int endRow = -1;
public int endCol = -1;
//单元格不连续多选用到的定位数据
java.util.List<Point> pointList = new ArrayList<>();
//shift键是否被按下
public boolean isShiftDown = false;
//control\command键是否被按下
public boolean isControlDown = false;
//是否可以复制
public boolean isCopy = true;
int ctrlKeyCode = 17;
int cKeyCode = 67;
int shiftKeyCode = 16;
int commandKeyCode = 157;
//选中单元格的背景色
Color selectBackGround = new Color(54, 133, 242, 63);
public CopyableJTable(TableSorter tableModel) {
super(tableModel);
initListener();
}
private void initListener() {
CopyableJTable self = this;
this.addMouseMotionListener(new java.awt.event.MouseAdapter() {
@Override
public void mouseDragged(MouseEvent evt) {
int row = self.rowAtPoint(evt.getPoint());
int col = self.columnAtPoint(evt.getPoint());
if (self.updateEndPoint(row, col)) {
self.repaint();
}
}
});
this.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
int row = self.rowAtPoint(e.getPoint());
int col = self.columnAtPoint(e.getPoint());
if (!self.isControlDown) {
self.clearPoint();
}
if (self.isShiftDown) {
self.clearPoint();
} else {
self.updateStartPoint(row, col);
}
self.addPoint(row, col);
self.updateEndPoint(row, col);
self.repaint();
}
});
this.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (isControlKey(e)) {
isControlDown = true;
} else if (e.getKeyCode() == shiftKeyCode) {
isShiftDown = true;
} else if (e.getKeyCode() == cKeyCode) {
if (isControlDown && isCopy) {
self.copy();
isCopy = false;
}
}
}
@Override
public void keyReleased(KeyEvent e) {
if (isControlKey(e)) {
isControlDown = false;
isCopy = true;
} else if (e.getKeyCode() == shiftKeyCode) {
isShiftDown = false;
}
}
private boolean isControlKey(KeyEvent e) {
if (e.getKeyCode() == ctrlKeyCode) {
return true;
}
if (e.getKeyCode() == commandKeyCode && OperatingSystem.isMacos()) {
return true;
}
return false;
}
});
}
@Override
public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
Component comp = super.prepareRenderer(renderer, row, column);
if (isChoose(row, column)) {
comp.setBackground(selectBackGround);
} else {
comp.setBackground(this.getBackground());
}
return comp;
}
private boolean updateEndPoint(int row, int col) {
if (endRow != row || endCol != col) {
endRow = row;
endCol = col;
return true;
}
return false;
}
private boolean updateStartPoint(int row, int col) {
if (startRow != row || startCol != col) {
startRow = row;
startCol = col;
return true;
}
return false;
}
private void addPoint(int row, int col) {
pointList.add(new Point(row, col));
}
private void clearPoint() {
pointList = new ArrayList<>();
}
private void copy() {
FineLoggerFactory.getLogger().info("copy cell value");
java.util.List<java.util.List<Object>> table = new ArrayList<>();
if ((startRow != endRow || startCol != endCol) &&
Math.min(startRow, endRow) > -1 && Math.min(startCol, endCol) > -1) {
for (int i = Math.min(startRow, endRow); i <= Math.max(startRow, endRow); i++) {
table.add(new ArrayList<>());
for (int j = Math.min(startCol, endCol); j <= Math.max(startCol, endCol); j++) {
Object text = this.getValueAt(i, j);
table.get(i - Math.min(startRow, endRow)).add(text);
}
}
} else if (pointList.size() > 0) {
Collections.sort(pointList, Comparator.comparing(Point::getX).thenComparing(Point::getY));
int startRow = pointList.get(0).x;
int currentRow = startRow;
table.add(new ArrayList<>());
for (Point point : pointList) {
while (currentRow < point.x) {
table.add(new ArrayList<>());
currentRow++;
}
Object text = this.getValueAt(point.x, point.y);
table.get(currentRow - startRow).add(text);
}
}
Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable tText = new StringSelection(ClipboardHelper.formatExcelString(table));
clip.setContents(tText, null);
}
private boolean isChoose(int row, int col) {
if (row >= Math.min(startRow, endRow) && row <= Math.max(startRow, endRow)) {
if (col >= Math.min(startCol, endCol) && col <= Math.max(startCol, endCol)) {
return true;
}
}
for (Point point : pointList) {
if (point.x == row && point.y == col) {
return true;
}
}
return false;
}
}

3
designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java

@ -26,7 +26,6 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.ui.util.UIUtil;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.function.TIME;
import com.fr.general.FRFont;
import com.fr.log.FineLoggerFactory;
@ -162,7 +161,7 @@ public class PreviewTablePane extends BasicPane {
}
});
preveiwTable = new SortableJTable(new TableSorter());
preveiwTable = new CopyableJTable(new TableSorter());
preveiwTable.setRowSelectionAllowed(false);
preveiwTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

103
designer-base/src/main/java/com/fr/design/gui/ifilechooser/AbstractFileChooser.java

@ -1,103 +0,0 @@
package com.fr.design.gui.ifilechooser;
import javax.swing.filechooser.FileFilter;
import java.awt.*;
import java.io.File;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/3/31
*/
public abstract class AbstractFileChooser {
/**
* 返回当前目录
*
*/
public abstract File getCurrentDirectory();
/**
* 返回当前的文件选择过滤器
*
*/
public abstract FileFilter getFileFilter();
/**
* 返回选择的文件
*
*/
public abstract File getSelectedFile();
/**
* 多文件选择模式下 返回选择的多个文件
*
*/
public abstract File[] getSelectedFiles();
/**
* 是否可以选择多个文件
*
*/
public abstract boolean isMultiSelectionEnabled();
/**
* 设置当前选择的目录
*
*/
public abstract void setCurrentDirectory(File dir);
/**
* 设置左上角标题
*
*/
public abstract void setDialogTitle(String title);
/**
* 设置当前的文件过滤器
*
*/
public abstract void setFileFilter(final FileFilter filter);
/**
* 设置文件选择器模式
*
* JFileChooser.FILES_ONLY
* JFileChooser.DIRECTORIES_ONLY
* JFileChooser.FILES_AND_DIRECTORIES
*/
public abstract void setFileSelectionMode(int selectionMode);
/**
* 设置是否允许选择多个文件
*
*/
public abstract void setMultiSelectionEnabled(boolean multiple);
/**
* 设置选择的文件 用于showSaveDialog
*
*/
public abstract void setSelectedFile(File file);
/**
* 弹出文件选择器 打开文件
*
*/
public abstract int showOpenDialog(Component parent);
/**
* 弹出文件选择器 保存文件
*
*/
public abstract int showSaveDialog(Component parent);
/**
* https://bugs.java.com/bugdatabase/view_bug.do?bug_id=4031440
*
* 设置文件名后缀 起到文件过滤的作用 形如 "*.jpg;*.jpeg"
*
*/
public abstract void setExtensionFilter(String file);
}

12
designer-base/src/main/java/com/fr/design/gui/ifilechooser/FileChooserProvider.java

@ -0,0 +1,12 @@
package com.fr.design.gui.ifilechooser;
import java.awt.*;
import java.io.File;
public interface FileChooserProvider {
File[] getSelectedFiles();
File getSelectedFile();
int showDialog(Component parent);
}

5
designer-base/src/main/java/com/fr/design/gui/ifilechooser/FileSelectionMode.java

@ -0,0 +1,5 @@
package com.fr.design.gui.ifilechooser;
public enum FileSelectionMode {
FILE, MULTIPLE_FILE, DIR
}

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

@ -0,0 +1,158 @@
package com.fr.design.gui.ifilechooser;
import com.fr.design.i18n.Toolkit;
import com.fr.design.upm.UpmUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.sun.javafx.application.PlatformImpl;
import javafx.stage.DirectoryChooser;
import javafx.stage.FileChooser;
import javafx.stage.Window;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import java.awt.*;
import java.io.File;
import java.util.List;
import java.util.concurrent.CountDownLatch;
public class JavaFxNativeFileChooser implements FileChooserProvider {
private File[] selectedFiles = new File[0];
private FileSelectionMode fileSelectionMode = FileSelectionMode.FILE;
private String title = Toolkit.i18nText("Fine-Design_Basic_Open");
private FileChooser.ExtensionFilter[] filters;
private File currentDirectory;
@Override
public File[] getSelectedFiles() {
return selectedFiles;
}
@Override
public File getSelectedFile() {
if (selectedFiles.length > 0) {
return selectedFiles[0];
}
return null;
}
@Override
public int showDialog(Component parent) {
final CountDownLatch latch = new CountDownLatch(1);
PlatformImpl.startup(new Runnable() {
@Override
public void run() {
try {
if (fileSelectionMode == FileSelectionMode.FILE || fileSelectionMode == FileSelectionMode.MULTIPLE_FILE) {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle(title);
fileChooser.getExtensionFilters().addAll(filters);
fileChooser.setInitialDirectory(currentDirectory);
if (fileSelectionMode == FileSelectionMode.FILE) {
File file = fileChooser.showOpenDialog(null);
if (file != null) {
selectedFiles = new File[]{file};
}
} else if (fileSelectionMode == FileSelectionMode.MULTIPLE_FILE) {
List<File> fileList = fileChooser.showOpenMultipleDialog(null);
if (fileList != null) {
selectedFiles = new File[fileList.size()];
fileList.toArray(selectedFiles);
}
}
} else if (fileSelectionMode == FileSelectionMode.DIR) {
DirectoryChooser directoryChooser = new DirectoryChooser();
directoryChooser.setTitle(title);
directoryChooser.setInitialDirectory(currentDirectory);
File folder = directoryChooser.showDialog(null);
if (folder != null) {
selectedFiles = new File[]{folder};
}
System.out.println(folder);
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
} finally {
latch.countDown();
}
}
});
try {
latch.await();
} catch (InterruptedException ignore) {
}
return selectedFiles.length > 0 ? JFileChooser.APPROVE_OPTION : JFileChooser.CANCEL_OPTION;
}
public void setSelectionMode(FileSelectionMode fileSelectionMode) {
this.fileSelectionMode = fileSelectionMode;
}
public void setCurrentDirectory(File currentDirectory) {
this.currentDirectory = currentDirectory;
}
public static class Builder {
private FileSelectionMode fileSelectionMode = FileSelectionMode.FILE;
private String title = Toolkit.i18nText("Fine-Design_Basic_Open");
private FileChooser.ExtensionFilter[] filters = new FileChooser.ExtensionFilter[0];
private File currentDirectory;
public Builder fileSelectionMode(FileSelectionMode fileSelectionMode) {
this.fileSelectionMode = fileSelectionMode;
return this;
}
public Builder title(String title) {
this.title = title;
return this;
}
public Builder filters(FileChooser.ExtensionFilter[] filters) {
this.filters = filters;
return this;
}
public Builder filter(String des, String... extensions) {
if (extensions != null) {
this.filters = new FileChooser.ExtensionFilter[]{new FileChooser.ExtensionFilter(des, extensions)};
}
return this;
}
public Builder currentDirectory(File currentDirectory) {
if (currentDirectory != null) {
if (!currentDirectory.isDirectory()) {
currentDirectory = currentDirectory.getParentFile();
}
if (currentDirectory != null && currentDirectory.isDirectory()) {
this.currentDirectory = currentDirectory;
}
}
return this;
}
public Builder currentDirectory(String path) {
if (path != null) {
return currentDirectory(new File(path));
}
return this;
}
public JavaFxNativeFileChooser build() {
return new JavaFxNativeFileChooser(this);
}
}
private JavaFxNativeFileChooser(Builder builder) {
this.fileSelectionMode = builder.fileSelectionMode;
this.title = builder.title;
this.filters = builder.filters;
this.currentDirectory = builder.currentDirectory;
}
}

154
designer-base/src/main/java/com/fr/design/gui/ifilechooser/UINativeFileChooser.java

@ -1,154 +0,0 @@
package com.fr.design.gui.ifilechooser;
import com.fr.design.gui.ifilechooser.AbstractFileChooser;
import com.fr.design.mainframe.DesignerContext;
import com.fr.stable.os.OperatingSystem;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import java.awt.*;
import java.io.File;
import java.io.FilenameFilter;
/**
* 系统原生风格的文件选择器
*
* jdk问题
* https://bugs.openjdk.java.net/browse/JDK-4811090 不支持文件扩展选择
* https://stackoverflow.com/questions/40713398/filter-not-working-in-filedialog windows下 setFilenameFilter不work
*
* @author hades
* @version 10.0
* Created by hades on 2020/3/31
*/
public class UINativeFileChooser extends AbstractFileChooser {
private final FileDialog fileDialog;
private FileFilter fileFilter;
private int selectionMode;
public UINativeFileChooser(File file) {
fileDialog = new FileDialog(DesignerContext.getDesignerFrame());
if (file != null) {
fileDialog.setDirectory(file.getAbsolutePath());
fileDialog.setFile(file.toString());
}
}
public UINativeFileChooser() {
this(null);
}
@Override
public File getCurrentDirectory() {
return new File(fileDialog.getDirectory());
}
@Override
public FileFilter getFileFilter() {
return fileFilter;
}
@Override
public File getSelectedFile() {
return new File(fileDialog.getDirectory() + fileDialog.getFile());
}
@Override
public File[] getSelectedFiles() {
return fileDialog.getFiles();
}
@Override
public boolean isMultiSelectionEnabled() {
return fileDialog.isMultipleMode();
}
@Override
public void setCurrentDirectory(File f) {
fileDialog.setDirectory(f.toString());
}
@Override
public void setDialogTitle(String title) {
fileDialog.setTitle(title);
}
@Override
public void setFileFilter(final FileFilter cff) {
FilenameFilter filter = new FilenameFilter() {
@Override
public boolean accept(File Directory, String fileName) {
return cff.accept(new File(Directory.getAbsolutePath() + fileName));
}
};
fileDialog.setFilenameFilter(filter);
fileFilter = cff;
}
@Override
public void setFileSelectionMode(int selectionMode) {
this.selectionMode = selectionMode;
}
@Override
public void setMultiSelectionEnabled(boolean multiple) {
fileDialog.setMultipleMode(multiple);
}
@Override
public void setSelectedFile(File file) {
fileDialog.setDirectory(file.getAbsolutePath());
fileDialog.setFile(file.getName());
}
@Override
public int showOpenDialog(Component parent) {
boolean appleProperty = OperatingSystem.isMacos() && selectionMode == JFileChooser.DIRECTORIES_ONLY;
if (appleProperty) {
System.setProperty("apple.awt.fileDialogForDirectories", "true");
}
try {
fileDialog.setLocale(JComponent.getDefaultLocale());
fileDialog.setMode(FileDialog.LOAD);
fileDialog.setVisible(true);
return fileDialog.getFile() == null ? JFileChooser.CANCEL_OPTION : JFileChooser.APPROVE_OPTION;
} finally {
if (appleProperty) {
System.setProperty("apple.awt.fileDialogForDirectories", "false");
}
}
}
@Override
public int showSaveDialog(Component parent) {
fileDialog.setLocale(JComponent.getDefaultLocale());
fileDialog.setMode(FileDialog.SAVE);
fileDialog.setVisible(true);
return fileDialog.getFile() == null ? JFileChooser.CANCEL_OPTION : JFileChooser.APPROVE_OPTION;
}
@Override
public void setExtensionFilter(String file) {
fileDialog.setFile(file);
}
/**
* 确认本地文件选择器是否支持选择模式
* @param selectionMode 选择模式
* @return 是否支持选择模式
*/
public static boolean supportsSelectionMode(int selectionMode) {
switch (selectionMode) {
case JFileChooser.FILES_AND_DIRECTORIES:
return false;
case JFileChooser.DIRECTORIES_ONLY:
return OperatingSystem.isMacos();
case JFileChooser.FILES_ONLY:
default:
return true;
}
}
}

289
designer-base/src/main/java/com/fr/design/style/background/image/ImageFileChooser.java

@ -3,266 +3,77 @@
*/
package com.fr.design.style.background.image;
import com.fr.base.BaseUtils;
import com.fr.design.DesignerEnvManager;
import com.fr.design.style.ChooseFileView;
import javax.swing.filechooser.FileFilter;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import com.fr.design.gui.ifilechooser.FileSelectionMode;
import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.share.collect.ComponentCollector;
import com.fr.design.mainframe.toast.DesignerToastMsgUtil;
import javafx.stage.FileChooser;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.util.Enumeration;
import java.util.Hashtable;
/**
* This class used to choose image files.
*/
public class ImageFileChooser extends ExpandFileChooser {
public class ImageFileChooser {
JavaFxNativeFileChooser javaFxNativeFileChooser;
public ImageFileChooser() {
super(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Image_Compress"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Open"));
ExampleFileFilter bothFilter = new ExampleFileFilter(
new String[]{"jpg", "gif", "png", "bmp"},
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Image_Image_Files"));
bothFilter.setExtensionListInDescription(true);
this.addChoosableFileFilter(bothFilter);
this.setAcceptAllFileFilterUsed(false);
javaFxNativeFileChooser =
new JavaFxNativeFileChooser.Builder().
fileSelectionMode(FileSelectionMode.FILE).
title(Toolkit.i18nText("Fine-Design_Basic_Open")).
filters(new FileChooser.ExtensionFilter[]{
new FileChooser.ExtensionFilter("jpg", "*.jpg"),
new FileChooser.ExtensionFilter("gif", "*.gif"),
new FileChooser.ExtensionFilter("png", "*.png"),
new FileChooser.ExtensionFilter("bmp", "*.bmp")}).
build();
}
// Create Custom FileView
ChooseFileView fileView = new ChooseFileView();
fileView.putIcon("jpg", BaseUtils.readIcon("/com/fr/base/images/dialog/file/jpgFile.gif"));
fileView.putIcon("gif", BaseUtils.readIcon("/com/fr/base/images/dialog/file/gifFile.gif"));
fileView.putIcon("png", BaseUtils.readIcon("/com/fr/base/images/dialog/file/pngFile.png"));
fileView.putIcon("bmp", BaseUtils.readIcon("/com/fr/base/images/dialog/file/bmpFile.gif"));
this.setFileView(fileView);
public int showOpenDialog(Component parent, String approveButtonText) {
return showOpenDialog(parent);
}
public int showDialog(Component parent, String approveButtonText) {
return super.showDialog(parent, approveButtonText);
public int showOpenDialog(Component parent) {
showImageCompressMoveTip();
return javaFxNativeFileChooser.showDialog(parent);
}
@Override
public ActionListener checkAction() {
return new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
DesignerEnvManager.getEnvManager().setImageCompress(isCheckSelected());
DesignerEnvManager.getEnvManager().saveXMLFile();
}
};
public void setCurrentDirectory(File file) {
javaFxNativeFileChooser.setCurrentDirectory(file);
}
/**
* A convenience implementation of FileFilter that filters out
* all files except for those type extensions that it knows about.
* <p/>D:\finereport\develop\code\test\TestCase\WEB-INF\reportlets\TestCase\01903.cpt
* <p>
* Extensions are of the type ".foo", which is typically found on
* Windows and Unix boxes, but not on Macinthosh. Case is ignored.
* <p/>
* Example - create a new filter that filerts out all files
* but gif and jpg image files:
* <p/>
* JFileChooser chooser = new JFileChooser();
* ExampleFileFilter filter = new ExampleFileFilter(
* new String{"gif", "jpg"}, "JPEG & GIF Images")
* chooser.addChoosableFileFilter(filter);
* chooser.showOpenDialog(this);
*
* @author Jeff Dinkins
* @version 1.12 12/03/01
*/
class ExampleFileFilter extends FileFilter {
private Hashtable filters = null;
private String description = null;
private String fullDescription = null;
private boolean useExtensionsInDescription = true;
/**
* Creates a file filter. If no filters are added, then all
* files are accepted.
*
* @see #addExtension
*/
public ExampleFileFilter() {
this.filters = new Hashtable();
}
/**
* Creates a file filter that accepts files with the given extension.
* Example: new ExampleFileFilter("jpg");
*
* @see #addExtension
*/
public ExampleFileFilter(String extension) {
this(extension, null);
}
/**
* Creates a file filter that accepts the given file type.
* Example: new ExampleFileFilter("jpg", "JPEG Image Images");
* <p/>
* Note that the "." before the extension is not needed. If
* provided, it will be ignored.
*
* @see #addExtension
*/
public ExampleFileFilter(String extension, String description) {
this();
if (extension != null) addExtension(extension);
if (description != null) setDescription(description);
}
/**
* Creates a file filter from the given string array.
* Example: new ExampleFileFilter(String {"gif", "jpg"});
* <p/>
* Note that the "." before the extension is not needed adn
* will be ignored.
*
* @see #addExtension
*/
public ExampleFileFilter(String[] filters) {
this(filters, null);
}
/**
* Creates a file filter from the given string array and description.
* Example: new ExampleFileFilter(String {"gif", "jpg"}, "Gif and JPG Images");
* <p/>
* Note that the "." before the extension is not needed and will be ignored.
*
* @see #addExtension
*/
public ExampleFileFilter(String[] filters, String description) {
this();
for (int i = 0; i < filters.length; i++) {
// add filters one by one
addExtension(filters[i]);
}
if (description != null) setDescription(description);
}
/**
* Return true if this file should be shown in the directory pane,
* false if it shouldn't.
* <p/>
* Files that begin with "." are ignored.
*
* @see #getExtension
*/
public boolean accept(File f) {
if (f != null) {
if (f.isDirectory()) {
return true;
}
String extension = getExtension(f);
if (extension != null && filters.get(getExtension(f)) != null) {
return true;
}
}
return false;
}
/**
* Return the extension portion of the file's name .
*
* @see #getExtension
* @see javax.swing.filechooser.FileFilter#accept
*/
public String getExtension(File f) {
if (f != null) {
String filename = f.getName();
int i = filename.lastIndexOf('.');
if (i > 0 && i < filename.length() - 1) {
return filename.substring(i + 1).toLowerCase();
}
}
return null;
}
/**
* Adds a filetype "dot" extension to filter against.
* <p/>
* For example: the following code will create a filter that filters
* out all files except those that end in ".jpg" and ".tif":
* <p/>
* ExampleFileFilter filter = new ExampleFileFilter();
* filter.addExtension("jpg");
* filter.addExtension("tif");
* <p/>
* Note that the "." before the extension is not needed and will be ignored.
*/
public void addExtension(String extension) {
if (filters == null) {
filters = new Hashtable(5);
}
filters.put(extension.toLowerCase(), this);
fullDescription = null;
}
/**
* Returns the human readable description of this filter. For
* example: "JPEG and GIF Image Files (*.jpg, *.gif)"
*
* @see javax.swing.filechooser.FileFilter#getDescription
*/
public String getDescription() {
if (fullDescription == null) {
if (description == null || isExtensionListInDescription()) {
fullDescription = description == null ? "(" : description + " (";
// build the description from the extension list
Enumeration extensions = filters.keys();
if (extensions != null) {
fullDescription += "." + extensions.nextElement();
while (extensions.hasMoreElements()) {
fullDescription += ", ." + extensions.nextElement();
}
}
fullDescription += ")";
} else {
fullDescription = description;
}
}
return fullDescription;
public void setMultiSelectionEnabled(boolean multiple) {
if (multiple) {
javaFxNativeFileChooser.setSelectionMode(FileSelectionMode.MULTIPLE_FILE);
} else {
javaFxNativeFileChooser.setSelectionMode(FileSelectionMode.FILE);
}
}
/**
* Sets the human readable description of this filter. For
* example: filter.setDescription("Gif and JPG Images");
*/
public void setDescription(String description) {
this.description = description;
fullDescription = null;
}
public File getSelectedFile() {
return javaFxNativeFileChooser.getSelectedFile();
}
/**
* Determines whether the extension list (.jpg, .gif, etc) should
* show up in the human readable description.
* <p/>
* Only relevent if a description was provided in the constructor
* or using setDescription();
*/
public void setExtensionListInDescription(boolean b) {
useExtensionsInDescription = b;
fullDescription = null;
}
public boolean isCheckSelected() {
return DesignerEnvManager.getEnvManager().isImageCompress();
}
/**
* Returns whether the extension list (.jpg, .gif, etc) should
* show up in the human readable description.
* <p/>
* Only relevent if a description was provided in the constructor
* or using setDescription();
*/
public boolean isExtensionListInDescription() {
return useExtensionsInDescription;
private void showImageCompressMoveTip() {
if (DesignerEnvManager.getEnvManager().isShowImageCompressMoveTip()) {
DesignerToastMsgUtil.toastWarning(Toolkit.i18nText("Fine-Design_Image_Compress_Move_Tip"));
DesignerEnvManager.getEnvManager().setShowImageCompressMoveTip(false);
}
}
}

27
designer-base/src/main/java/com/fr/design/upm/UpmBridge.java

@ -14,6 +14,9 @@ import com.fr.design.extra.exe.GetPluginPrefixExecutor;
import com.fr.design.extra.exe.PluginLoginExecutor;
import com.fr.design.extra.exe.ReadUpdateOnlineExecutor;
import com.fr.design.extra.exe.SearchOnlineExecutor;
import com.fr.design.gui.ifilechooser.FileChooserProvider;
import com.fr.design.gui.ifilechooser.FileSelectionMode;
import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser;
import com.fr.design.i18n.Toolkit;
import com.fr.design.locale.impl.BbsRegisterMark;
import com.fr.design.locale.impl.BbsResetMark;
@ -36,6 +39,7 @@ import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.JSArray;
import com.teamdev.jxbrowser.chromium.JSFunction;
import com.teamdev.jxbrowser.chromium.JSObject;
import javafx.stage.FileChooser;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
@ -95,7 +99,7 @@ public class UpmBridge {
@JSBridge
public void startDownload(final JSFunction callback) {
callback.invoke(window, "start", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Start"));
new SwingWorker<Void, Void>(){
new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
UpmResourceLoader.INSTANCE.download();
@ -308,16 +312,13 @@ public class UpmBridge {
RunnableFuture<String> future = new FutureTask<>(new Callable<String>() {
@Override
public String call() {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
if (StringUtils.isNotEmpty(filter)) {
fileChooser.setFileFilter(new FileNameExtensionFilter(des, UpmUtils.findMatchedExtension(filter)));
}
int result = fileChooser.showOpenDialog(UpmFinder.getDialog());
FileChooserProvider fileChooserProvider = new JavaFxNativeFileChooser.Builder().
fileSelectionMode(FileSelectionMode.FILE).
filter(des, filter).
build();
int result = fileChooserProvider.showDialog(UpmFinder.getDialog());
if (result == JFileChooser.APPROVE_OPTION) {
return fileChooser.getSelectedFile().getAbsolutePath();
return fileChooserProvider.getSelectedFile().getAbsolutePath();
}
return null;
}
@ -345,11 +346,11 @@ public class UpmBridge {
public String call() {
JFileChooser fileChooser = new JFileChooser();
List<String> filterList = new ArrayList<>();
if (args instanceof String) {
if (args instanceof String) {
filterList.add(GeneralUtils.objectToString(args));
} else if (args instanceof JSArray) {
JSArray array = (JSArray)args;
for (int i = 0, len = array.length(); i < len; i ++) {
JSArray array = (JSArray) args;
for (int i = 0, len = array.length(); i < len; i++) {
filterList.add(array.get(i).getStringValue());
}
}

16
designer-base/src/main/java/com/fr/design/web/CustomIconPane.java

@ -10,6 +10,8 @@ import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ifilechooser.FileChooserProvider;
import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.iscrollbar.UIScrollBar;
import com.fr.design.gui.itextarea.DescriptionTextArea;
@ -28,6 +30,7 @@ import com.fr.stable.ListMap;
import com.fr.stable.StringUtils;
import com.fr.transaction.Configurations;
import com.fr.transaction.WorkerFacade;
import javafx.stage.FileChooser;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
@ -108,7 +111,7 @@ public class CustomIconPane extends BasicPane {
}
protected String createDescriptionText(){
protected String createDescriptionText() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_Message1");
}
@ -447,13 +450,12 @@ public class CustomIconPane extends BasicPane {
}
private void onBrowseButtonClicked() {
JFileChooser jf = new JFileChooser();
// carl:不知道是否只要png格式,反正导出时全部都转成png了
FileNameExtensionFilter fileFilter = new FileNameExtensionFilter("Icon Image File", "jpg", "jpeg", "png", "gif");
jf.setFileFilter(fileFilter);
if (JFileChooser.APPROVE_OPTION == jf.showOpenDialog(DesignerContext.getDesignerFrame())) {
String path = jf.getSelectedFile().getAbsolutePath();
FileChooserProvider fileChooserProvider = new JavaFxNativeFileChooser.Builder().
filter("Icon Image File", "*.jpg", "*.jpeg", "*.png", "*.gif").
build();
if (JFileChooser.APPROVE_OPTION == fileChooserProvider.showDialog(DesignerContext.getDesignerFrame())) {
String path = fileChooserProvider.getSelectedFile().getAbsolutePath();
// 图片存储有最大值48*48限制,没有超过最大值时,按原图大小存储,超过最大值后,压缩至最大值存储
Image image = BaseUtils.readImage(path);
iconImage = ImageUtils.scale((BufferedImage) image, Math.min(image.getWidth(null), IconManager.MAXSTORAGE_ICONWIDTH), Math.min(image.getHeight(null), IconManager.MAXSTORAGE_ICONHEIGHT), true, Image.SCALE_SMOOTH);

20
designer-base/src/main/java/com/fr/env/RemoteEnvPane.java vendored

@ -11,6 +11,9 @@ import com.fr.design.fun.DesignerEnvProcessor;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ifilechooser.FileChooserProvider;
import com.fr.design.gui.ifilechooser.FileSelectionMode;
import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ipasswordfield.UIPassWordField;
import com.fr.design.gui.ipasswordfield.UIPasswordFieldWithFixedLength;
@ -30,6 +33,7 @@ import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.exception.WorkspaceAuthException;
import com.fr.workspace.engine.exception.WorkspaceCheckException;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JDialog;
@ -569,11 +573,11 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
fileChooserButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
int saveValue = fileChooser.showOpenDialog(SwingUtilities.getWindowAncestor(RemoteEnvPane.this));
FileChooserProvider fileChooserProvider = new JavaFxNativeFileChooser.Builder().
fileSelectionMode(FileSelectionMode.FILE).build();
int saveValue = fileChooserProvider.showDialog(SwingUtilities.getWindowAncestor(RemoteEnvPane.this));
if (saveValue == JFileChooser.APPROVE_OPTION) {
File selectedFile = fileChooser.getSelectedFile();
File selectedFile = fileChooserProvider.getSelectedFile();
certPathInput.setText(selectedFile.getAbsolutePath());
}
}
@ -610,10 +614,10 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
dialog.dispose();
FineLoggerFactory.getLogger().error(result.getText().replaceAll(TestConnectionResult.WRAP, StringUtils.EMPTY) + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Modify_PassWord"));
FineJOptionPane.showMessageDialog(RemoteEnvPane.this,
new MessageWithLink(result.getText(), Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Modify_PassWord"), connection.getUrl() + RemoteWorkspaceURL.SYSTEM_LOGIN_PATH),
Toolkit.i18nText("Fine-Design_Basic_Dialog_Message_Title"),
ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon"));
new MessageWithLink(result.getText(), Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Modify_PassWord"), connection.getUrl() + RemoteWorkspaceURL.SYSTEM_LOGIN_PATH),
Toolkit.i18nText("Fine-Design_Basic_Dialog_Message_Title"),
ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon"));
}
message.setText(result.getText());
uiLabel.setIcon(result.getIcon());

352
designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapCustomPane.java

@ -9,6 +9,8 @@ import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.FilterComboBox;
import com.fr.design.gui.ifilechooser.FileChooserProvider;
import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser;
import com.fr.design.gui.ilable.BoldFontTextLabel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.DesignerContext;
@ -40,56 +42,56 @@ import java.awt.event.ItemListener;
* @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2012-10-15 下午03:38:15
*/
public class MapCustomPane extends BasicBeanPane<String> implements AbstrctMapAttrEditPane{ // 储存地图对应的字段. 名称, 类型. shape (点 用圆形代替)
public class MapCustomPane extends BasicBeanPane<String> implements AbstrctMapAttrEditPane { // 储存地图对应的字段. 名称, 类型. shape (点 用圆形代替)
private FilterComboBox<String> areaString;// 区域字段
private DatabaseTableDataPane tableDataNameBox;// 数据集名称 + 后面跟随预览按钮
private MapImageEditPane imageShowPane; // 图片展示编辑的界面
private String lastSelectPath;
private boolean isNeedDataSource = true;
private FilterComboBox<String> areaString;// 区域字段
private DatabaseTableDataPane tableDataNameBox;// 数据集名称 + 后面跟随预览按钮
private MapImageEditPane imageShowPane; // 图片展示编辑的界面
private String lastSelectPath;
private boolean isNeedDataSource = true;
public MapCustomPane() {
initComp();
}
public MapCustomPane() {
initComp();
}
public MapCustomPane(boolean isNeedDataSource){
this.isNeedDataSource = isNeedDataSource;
initComp();
}
public MapCustomPane(boolean isNeedDataSource) {
this.isNeedDataSource = isNeedDataSource;
initComp();
}
private void initComp() {
this.setLayout(new BorderLayout(0, 0));
private void initComp() {
this.setLayout(new BorderLayout(0, 0));
JPanel pane = new JPanel();
this.add(pane, BorderLayout.NORTH);
JPanel pane = new JPanel();
this.add(pane, BorderLayout.NORTH);
pane.setLayout(new BorderLayout());
pane.setLayout(new BorderLayout());
pane.add(northPaneCreate(), BorderLayout.NORTH);
pane.add(northPaneCreate(), BorderLayout.NORTH);
imageShowPane = new MapImageEditPane();
imageShowPane = new MapImageEditPane();
pane.add(imageShowPane, BorderLayout.CENTER);
}
pane.add(imageShowPane, BorderLayout.CENTER);
}
private JPanel northPaneCreate() {
JPanel northPane = new JPanel();
private JPanel northPaneCreate() {
JPanel northPane = new JPanel();
northPane.setLayout(new FlowLayout(FlowLayout.LEFT));
northPane.setLayout(new FlowLayout(FlowLayout.LEFT));
UIButton loadMap = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Import_Map"));
loadMap.setPreferredSize(new Dimension(160, 20));
northPane.add(loadMap);
UIButton loadMap = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Import_Map"));
loadMap.setPreferredSize(new Dimension(160, 20));
northPane.add(loadMap);
loadMap.addActionListener(selectPictureActionListener);
loadMap.addActionListener(selectPictureActionListener);
if(isNeedDataSource){
UILabel label =new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Table_Data") + ":", SwingConstants.RIGHT) ;
if (isNeedDataSource) {
UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Table_Data") + ":", SwingConstants.RIGHT);
tableDataNameBox = new DatabaseTableDataPane(label) {
protected void userEvent() {
refreshAreaNameBox();
}
protected void userEvent() {
refreshAreaNameBox();
}
};
tableDataNameBox.setPreferredSize(new Dimension(200, 20));
northPane.add(tableDataNameBox);
@ -100,158 +102,156 @@ refreshAreaNameBox();
areaString.setPreferredSize(new Dimension(120, 20));
areaString.addItemListener(areaChange);
northPane.add(areaString);
}
return northPane;
}
private ActionListener selectPictureActionListener = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
JFileChooser svgFileChooser = new JFileChooser();
svgFileChooser.addChoosableFileFilter(new SVGFileFilter());
if (StringUtils.isNotBlank(lastSelectPath)) {
svgFileChooser.setSelectedFile(new File(lastSelectPath));
}
int returnVal = svgFileChooser.showOpenDialog(DesignerContext.getDesignerFrame());
if (returnVal != JFileChooser.CANCEL_OPTION) {
File selectedFile = svgFileChooser.getSelectedFile();
try {
lastSelectPath = selectedFile.getCanonicalPath();
} catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
}
if (selectedFile != null && selectedFile.isFile()) {
}
return northPane;
}
private ActionListener selectPictureActionListener = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
FileChooserProvider fileChooserProvider = new JavaFxNativeFileChooser.Builder().
filter(".svg, .svgz", "*.svg", "*.svgz").
currentDirectory(lastSelectPath).build();
int returnVal = fileChooserProvider.showDialog(DesignerContext.getDesignerFrame());
if (returnVal != JFileChooser.CANCEL_OPTION) {
File selectedFile = fileChooserProvider.getSelectedFile();
try {
lastSelectPath = selectedFile.getCanonicalPath();
} catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
}
if (selectedFile != null && selectedFile.isFile()) {
imageShowPane.setSvgMap(selectedFile.getPath());
imageShowPane.repaint();
}
}
}
};
private ItemListener areaChange = new ItemListener() {
public void itemStateChanged(ItemEvent e) {
Object select = areaString.getSelectedItem();
if (select != null) {
String colName = Utils.objectToString(areaString.getSelectedItem());
TableDataWrapper tableDataWrappe = tableDataNameBox.getTableDataWrapper();
imageShowPane.refreshFromDataList(getColValuesInData(tableDataWrappe, colName));
}
}
};
public static List<String> getColValuesInData(TableDataWrapper tableDataWrappe, String colName) {
List<String> colValues = new ArrayList<>();
EmbeddedTableData embeddedTableData = null;
try {
embeddedTableData = DesignTableDataManager.previewTableDataNotNeedInputParameters(tableDataWrappe.getTableData(), TableData.RESULT_ALL, false);
} catch (Exception ee) {
}
}
}
};
private ItemListener areaChange = new ItemListener() {
public void itemStateChanged(ItemEvent e) {
Object select = areaString.getSelectedItem();
if (select != null) {
String colName = Utils.objectToString(areaString.getSelectedItem());
TableDataWrapper tableDataWrappe = tableDataNameBox.getTableDataWrapper();
imageShowPane.refreshFromDataList(getColValuesInData(tableDataWrappe, colName));
}
}
};
public static List<String> getColValuesInData(TableDataWrapper tableDataWrappe, String colName) {
List<String> colValues = new ArrayList<>();
EmbeddedTableData embeddedTableData = null;
try {
embeddedTableData = DesignTableDataManager.previewTableDataNotNeedInputParameters(tableDataWrappe.getTableData(), TableData.RESULT_ALL, false);
} catch (Exception ee) {
FineLoggerFactory.getLogger().error(ee.getMessage(), ee);
}
if(embeddedTableData == null){
return colValues;
}
int columnIndex = getColumnIndex(embeddedTableData, colName);
if(columnIndex == DataModel.COLUMN_NAME_NOT_FOUND){
return colValues;
}
for (int rowIndex = 0, rowCount = embeddedTableData.getRowCount(); rowIndex < rowCount; rowIndex++) {
String colValueName = GeneralUtils.objectToString(embeddedTableData.getValueAt(rowIndex, columnIndex));
if (!colValues.contains(colValueName)) {
colValues.add(colValueName);
}
}
return colValues;
}
private static int getColumnIndex(EmbeddedTableData tableData, String colName) {
for (int columnIndex = 0, columnCount = tableData.getColumnCount(); columnIndex < columnCount; columnIndex++) {
if (ComparatorUtils.tableDataColumnNameEquals(tableData.getColumnName(columnIndex), colName)) {
return columnIndex;
}
}
return DataModel.COLUMN_NAME_NOT_FOUND;
}
/**
* 选中方式: 区域或者点
*/
public void setImageSelectType(int selectType) {
if (imageShowPane != null) {
imageShowPane.setEditType(selectType);
}
}
private void refreshAreaNameBox() {// 刷新区域名称列表
if(!isNeedDataSource){
return;
}
TableDataWrapper tableDataWrappe = tableDataNameBox.getTableDataWrapper();
if (tableDataWrappe == null) {
return;
}
List<String> columnNameList = tableDataWrappe.calculateColumnNameList();
Object oldSelected = areaString.getSelectedItem();
areaString.removeAllItems();
for(String item : columnNameList) {
areaString.addItem(item);
}
areaString.getModel().setSelectedItem(oldSelected);
}
}
if (embeddedTableData == null) {
return colValues;
}
int columnIndex = getColumnIndex(embeddedTableData, colName);
if (columnIndex == DataModel.COLUMN_NAME_NOT_FOUND) {
return colValues;
}
for (int rowIndex = 0, rowCount = embeddedTableData.getRowCount(); rowIndex < rowCount; rowIndex++) {
String colValueName = GeneralUtils.objectToString(embeddedTableData.getValueAt(rowIndex, columnIndex));
if (!colValues.contains(colValueName)) {
colValues.add(colValueName);
}
}
return colValues;
}
private static int getColumnIndex(EmbeddedTableData tableData, String colName) {
for (int columnIndex = 0, columnCount = tableData.getColumnCount(); columnIndex < columnCount; columnIndex++) {
if (ComparatorUtils.tableDataColumnNameEquals(tableData.getColumnName(columnIndex), colName)) {
return columnIndex;
}
}
return DataModel.COLUMN_NAME_NOT_FOUND;
}
/**
* 选中方式: 区域或者点
*/
public void setImageSelectType(int selectType) {
if (imageShowPane != null) {
imageShowPane.setEditType(selectType);
}
}
private void refreshAreaNameBox() {// 刷新区域名称列表
if (!isNeedDataSource) {
return;
}
TableDataWrapper tableDataWrappe = tableDataNameBox.getTableDataWrapper();
if (tableDataWrappe == null) {
return;
}
List<String> columnNameList = tableDataWrappe.calculateColumnNameList();
Object oldSelected = areaString.getSelectedItem();
areaString.removeAllItems();
for (String item : columnNameList) {
areaString.addItem(item);
}
areaString.getModel().setSelectedItem(oldSelected);
}
/**
* 当前正在编辑的条目的类别(国家省市)名和地图名
* @param typeName 类别名
* @param mapName 地图名
*/
public void setTypeNameAndMapName(String typeName, String mapName){
public void setTypeNameAndMapName(String typeName, String mapName) {
imageShowPane.setTypeNameAndMapName(typeName, mapName);
}
/**
* 根据地图名称 加载信息
*/
public void populateBean(String list) {
imageShowPane.populateBean(list);
}
/**
* 根据地图名称 保存信息
*/
public String updateBean() {
// 地图类型等 加入Helper
return imageShowPane.updateBean();
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Map");
}
/**
* 更新界面
* @param attr 地图属性
*/
public void populateMapAttr(MapSvgAttr attr) {
imageShowPane.populateMapSvgAttr(attr);
}
/**
* 更新MapSvgAttr
* @return 返回属性
*/
public MapSvgAttr updateCurrentAttr() {
return imageShowPane.updateWithOutSave();
}
/**
* 根据地图名称 加载信息
*/
public void populateBean(String list) {
imageShowPane.populateBean(list);
}
/**
* 根据地图名称 保存信息
*/
public String updateBean() {
// 地图类型等 加入Helper
return imageShowPane.updateBean();
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Map");
}
/**
* 更新界面
* @param attr 地图属性
*/
public void populateMapAttr(MapSvgAttr attr) {
imageShowPane.populateMapSvgAttr(attr);
}
/**
* 更新MapSvgAttr
* @return 返回属性
*/
public MapSvgAttr updateCurrentAttr() {
return imageShowPane.updateWithOutSave();
}
}

5
designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java

@ -85,13 +85,14 @@ public class SelectionModel {
if (e.getButton() == MouseEvent.BUTTON3 || (!InputEventBaseOnOS.isControlDown(e) && !e.isShiftDown())) {
// 如果Ctrl或者Shift键盘没有按下,则清除已经选择的组件
XCreator selectXCreator = selection.getSelectedCreator();
if (selectXCreator != null && comp != null) {
boolean clickOnce = e.getClickCount() == 1;
boolean hasCom = selectXCreator != null && comp != null;
if (clickOnce && hasCom) {
if (StringUtils.equals(selectXCreator.toData().getWidgetName(), comp.toData().getWidgetName())) {
return;
}
}
selection.reset();
} else {
//按下Ctrl或者shift键时鼠标可以进行多选,两次点击同一控件就取消选中
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(comp).getTopLayout();

33
designer-form/src/main/java/com/fr/design/mainframe/share/action/InstallComponentAction.java

@ -4,7 +4,9 @@ import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.ifilechooser.UINativeFileChooser;
import com.fr.design.gui.ifilechooser.FileChooserProvider;
import com.fr.design.gui.ifilechooser.FileSelectionMode;
import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
@ -17,6 +19,8 @@ import com.fr.design.os.impl.SupportOSImpl;
import com.fr.form.share.record.ShareWidgetInfoManager;
import com.fr.form.share.utils.ReuxUtils;
import com.fr.log.FineLoggerFactory;
import com.sun.javafx.tk.FileChooserType;
import javafx.stage.FileChooser;
import javax.swing.Action;
import javax.swing.JFileChooser;
@ -42,23 +46,16 @@ public class InstallComponentAction extends UpdateAction {
@Override
public void actionPerformed(ActionEvent e) {
if (SupportOSImpl.NATIVE_CHOOSER.support()) {
UINativeFileChooser nativeFileChooser = new UINativeFileChooser();
nativeFileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
nativeFileChooser.setMultiSelectionEnabled(true);
nativeFileChooser.setFileFilter(new FileNameExtensionFilter("reu reus", "reu", "reus"));
nativeFileChooser.setDialogTitle(Toolkit.i18nText("Fine-Design_Basic_Select"));
int returnValue = nativeFileChooser.showOpenDialog(new UILabel());
installComponent(returnValue, nativeFileChooser.getSelectedFiles());
} else {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
fileChooser.setMultiSelectionEnabled(true);
fileChooser.setFileFilter(new FileNameExtensionFilter("reu reus", "reu", "reus"));
int returnValue = fileChooser.showDialog(new UILabel(), Toolkit.i18nText("Fine-Design_Basic_Select"));
installComponent(returnValue, fileChooser.getSelectedFiles());
}
FileChooserProvider fileChooserProvider =
new JavaFxNativeFileChooser.Builder().
fileSelectionMode(FileSelectionMode.MULTIPLE_FILE).
title(Toolkit.i18nText("Fine-Design_Basic_Select")).
filters(new FileChooser.ExtensionFilter[]{
new FileChooser.ExtensionFilter("reu", "*.reu"),
new FileChooser.ExtensionFilter("reus", "*.reus")}).
build();
int returnValue = fileChooserProvider.showDialog(null);
installComponent(returnValue, fileChooserProvider.getSelectedFiles());
}
private void installComponent(int returnValue, File[] selectedFiles) {

203
designer-realize/src/main/java/com/fr/design/cell/clipboard/CellElementsClip.java

@ -3,6 +3,7 @@
*/
package com.fr.design.cell.clipboard;
import com.fr.design.base.clipboard.ClipboardHelper;
import com.fr.grid.selection.CellSelection;
import com.fr.log.FineLoggerFactory;
import com.fr.report.cell.CellElement;
@ -12,8 +13,10 @@ import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.StringUtils;
import com.fr.stable.unit.FU;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
/**
* The clip of CellElement.
@ -21,16 +24,16 @@ import java.util.Iterator;
public class CellElementsClip implements Cloneable, java.io.Serializable {
private int columnSpan = 0;
private int rowSpan = 0;
private FU[] columnWidth;
private FU[] rowHeight;
private FU[] columnWidth;
private FU[] rowHeight;
private TemplateCellElement[] clips;
public CellElementsClip(int columnSpan, int rowSpan, FU[] columnWidth , FU[] rowHeight, TemplateCellElement[] clips) {
this.columnSpan = columnSpan;
this.rowSpan = rowSpan;
this.columnWidth = columnWidth ;
this.rowHeight = rowHeight;
this.clips = clips;
public CellElementsClip(int columnSpan, int rowSpan, FU[] columnWidth, FU[] rowHeight, TemplateCellElement[] clips) {
this.columnSpan = columnSpan;
this.rowSpan = rowSpan;
this.columnWidth = columnWidth;
this.rowHeight = rowHeight;
this.clips = clips;
}
public CellElementsClip(int columnSpan, int rowSpan, TemplateCellElement[] clips) {
@ -39,122 +42,116 @@ public class CellElementsClip implements Cloneable, java.io.Serializable {
this.clips = clips;
}
public int getColumnSpan() {
return columnSpan;
}
public int getColumnSpan() {
return columnSpan;
}
public void setColumnSpan(int columnSpan) {
this.columnSpan = columnSpan;
}
public void setColumnSpan(int columnSpan) {
this.columnSpan = columnSpan;
}
public int getRowSpan() {
return rowSpan;
}
public int getRowSpan() {
return rowSpan;
}
public void setRowSpan(int rowSpan) {
this.rowSpan = rowSpan;
}
public void setRowSpan(int rowSpan) {
this.rowSpan = rowSpan;
}
public FU[] getColumnWidth() {
return columnWidth;
}
public FU[] getColumnWidth() {
return columnWidth;
}
public void setColumnWidth(FU[] columnWidth) {
this.columnWidth = columnWidth;
}
public void setColumnWidth(FU[] columnWidth) {
this.columnWidth = columnWidth;
}
public FU[] getRowHeight() {
return rowHeight;
}
public FU[] getRowHeight() {
return rowHeight;
}
public void setRowHeight(FU[] rowHeight) {
this.rowHeight = rowHeight;
}
public void setRowHeight(FU[] rowHeight) {
this.rowHeight = rowHeight;
}
public TemplateCellElement[] getClips() {
return clips;
}
public TemplateCellElement[] getClips() {
return clips;
}
public void setClips(TemplateCellElement[] clips) {
this.clips = clips;
}
public void setClips(TemplateCellElement[] clips) {
this.clips = clips;
}
public String compateExcelPaste() {
Arrays.sort(this.clips, CellElementComparator.getRowFirstComparator());
public String compateExcelPaste() {
Arrays.sort(this.clips, CellElementComparator.getRowFirstComparator());
// 排序
StringBuffer sbuf = new StringBuffer();
// 排序
int currentRow = -1;
for (int i = 0; i < clips.length; i++) {
CellElement cellElement = clips[i];
if (currentRow == -1) {// 初始化当前行.
currentRow = cellElement.getRow();
}
List<List<Object>> table = new ArrayList<>();
int startRow = -1;
int currentRow = -1;
for (int i = 0; i < clips.length; i++) {
CellElement cellElement = clips[i];
if (currentRow == -1) {// 初始化当前行.
currentRow = cellElement.getRow();
startRow = currentRow;
table.add(new ArrayList<>());
}
if (currentRow < cellElement.getRow()) {
for (int r = currentRow; r < cellElement.getRow(); r++) {
sbuf.append('\n');
}
currentRow = cellElement.getRow();
}
while (currentRow < cellElement.getRow()) {
table.add(new ArrayList<>());
currentRow++;
}
// 添加分隔符号.
if (sbuf.length() > 0 && sbuf.charAt(sbuf.length() - 1) != '\n') {
sbuf.append('\t');
}
//REPORT-5134:会复制出null
if (cellElement.getValue() == null) {
sbuf.append(StringUtils.EMPTY);
} else {
sbuf.append(cellElement.getValue());
}
}
Object cellValue = cellElement.getValue() == null ? StringUtils.EMPTY : cellElement.getValue();
table.get(currentRow - startRow).add(cellValue);
}
return sbuf.toString();
return ClipboardHelper.formatExcelString(table);
}
public CellSelection pasteAt(TemplateElementCase ec, int column, int row) {
Iterator cells = ec.intersect(column, row, columnSpan, rowSpan);
while (cells.hasNext()) {
TemplateCellElement cellElement = (TemplateCellElement)cells.next();
ec.removeCellElement(cellElement);
}
for (int i = 0; i < clips.length; i++) {
TemplateCellElement cellElement;
try {
cellElement = (TemplateCellElement) clips[i].clone();
} catch (CloneNotSupportedException e) {
Iterator cells = ec.intersect(column, row, columnSpan, rowSpan);
while (cells.hasNext()) {
TemplateCellElement cellElement = (TemplateCellElement) cells.next();
ec.removeCellElement(cellElement);
}
for (int i = 0; i < clips.length; i++) {
TemplateCellElement cellElement;
try {
cellElement = (TemplateCellElement) clips[i].clone();
} catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return null;
}
// peter:因为前面已经将这个位置的元素删除了,所以不需要override了.
ec.addCellElement((TemplateCellElement) cellElement.deriveCellElement(
column + cellElement.getColumn(), row + cellElement.getRow()
), false);
}
//设置单元格的宽高
if(this.columnWidth != null && this.rowHeight != null){
return null;
}
// peter:因为前面已经将这个位置的元素删除了,所以不需要override了.
ec.addCellElement((TemplateCellElement) cellElement.deriveCellElement(
column + cellElement.getColumn(), row + cellElement.getRow()
), false);
}
//设置单元格的宽高
if (this.columnWidth != null && this.rowHeight != null) {
pasteWidthAndHeight(ec, column, row, columnSpan, rowSpan);
}
return new CellSelection(column, row, columnSpan, rowSpan);
return new CellSelection(column, row, columnSpan, rowSpan);
}
public void pasteWidthAndHeight(TemplateElementCase ec, int column, int row, int columnSpan, int rowSpan){
for(int i = 0; i < columnSpan; i++){
ec.setColumnWidth(column + i, columnWidth[i]);
}
for(int j = 0; j < rowSpan; j++){
ec.setRowHeight(row + j, rowHeight[j]);
}
}
public void pasteWidthAndHeight(TemplateElementCase ec, int column, int row, int columnSpan, int rowSpan) {
for (int i = 0; i < columnSpan; i++) {
ec.setColumnWidth(column + i, columnWidth[i]);
}
for (int j = 0; j < rowSpan; j++) {
ec.setRowHeight(row + j, rowHeight[j]);
}
}
public void pasteAtRegion(TemplateElementCase ec,
int startColumn, int startRow,
int column, int row,
int columnSpan, int rowSpan) {
int startColumn, int startRow,
int column, int row,
int columnSpan, int rowSpan) {
for (int i = 0; i < clips.length; i++) {
TemplateCellElement cellElement = clips[i];
@ -173,14 +170,14 @@ public class CellElementsClip implements Cloneable, java.io.Serializable {
* Clone.
*/
@Override
public Object clone() throws CloneNotSupportedException {
public Object clone() throws CloneNotSupportedException {
CellElementsClip cloned = (CellElementsClip) super.clone();
if (this.clips != null) {
cloned.clips = new TemplateCellElement[this.clips.length];
for (int i = 0; i < this.clips.length; i++) {
cloned.clips[i] = (TemplateCellElement)this.clips[i].clone();
}
cloned.clips = new TemplateCellElement[this.clips.length];
for (int i = 0; i < this.clips.length; i++) {
cloned.clips[i] = (TemplateCellElement) this.clips[i].clone();
}
}
return cloned;

Loading…
Cancel
Save