diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index 97b4d0f6ce..7242b22950 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -192,6 +192,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private static List mapWorkerList = new ArrayList(); 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()); } diff --git a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java index 133bbb03f2..a41f962954 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java +++ b/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()); diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java index a506fd2b3a..8a9a9779c1 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java @@ -255,6 +255,7 @@ public class JDBCDefPane extends JPanel { this.dbtypeComboBox.setSelectedItem(OTHER_DB); } } + this.jdbcDatabase.setIdentity(jdbcDatabase.getIdentity()); this.driverComboBox.setSelectedItem(jdbcDatabase.getDriver()); this.urlTextField.setText(jdbcDatabase.getURL()); this.userNameTextField.setText(jdbcDatabase.getUser()); diff --git a/designer-base/src/main/java/com/fr/design/gui/chart/ChartXMLTag.java b/designer-base/src/main/java/com/fr/design/gui/chart/ChartXMLTag.java new file mode 100644 index 0000000000..b974287058 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/chart/ChartXMLTag.java @@ -0,0 +1,11 @@ +package com.fr.design.gui.chart; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2021-08-02 + */ +public class ChartXMLTag { + + public static final String CHART_TYPE_UI_PROVIDER = "ChartTypeUIProvider"; +} diff --git a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/AbstractFileChooser.java b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/AbstractFileChooser.java deleted file mode 100644 index ee61fd81f5..0000000000 --- a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/AbstractFileChooser.java +++ /dev/null @@ -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); -} diff --git a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/FileChooserProvider.java b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/FileChooserProvider.java new file mode 100644 index 0000000000..aa95fe27bd --- /dev/null +++ b/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); +} diff --git a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/FileSelectionMode.java b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/FileSelectionMode.java new file mode 100644 index 0000000000..bee326f6af --- /dev/null +++ b/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 +} diff --git a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java new file mode 100644 index 0000000000..b5fce35db1 --- /dev/null +++ b/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 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; + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/UINativeFileChooser.java b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/UINativeFileChooser.java deleted file mode 100644 index c1418f834b..0000000000 --- a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/UINativeFileChooser.java +++ /dev/null @@ -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; - } - } - -} diff --git a/designer-base/src/main/java/com/fr/design/style/background/image/ImageFileChooser.java b/designer-base/src/main/java/com/fr/design/style/background/image/ImageFileChooser.java index 1e5e96ab1f..57f0d59d63 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/image/ImageFileChooser.java +++ b/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. - *

D:\finereport\develop\code\test\TestCase\WEB-INF\reportlets\TestCase\01903.cpt - *

- * Extensions are of the type ".foo", which is typically found on - * Windows and Unix boxes, but not on Macinthosh. Case is ignored. - *

- * Example - create a new filter that filerts out all files - * but gif and jpg image files: - *

- * 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"); - *

- * 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"}); - *

- * 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"); - *

- * 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. - *

- * 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. - *

- * For example: the following code will create a filter that filters - * out all files except those that end in ".jpg" and ".tif": - *

- * ExampleFileFilter filter = new ExampleFileFilter(); - * filter.addExtension("jpg"); - * filter.addExtension("tif"); - *

- * 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. - *

- * 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. - *

- * 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); } } } diff --git a/designer-base/src/main/java/com/fr/design/upm/UpmBridge.java b/designer-base/src/main/java/com/fr/design/upm/UpmBridge.java index fb40d54345..fee07ac467 100644 --- a/designer-base/src/main/java/com/fr/design/upm/UpmBridge.java +++ b/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(){ + new SwingWorker() { @Override protected Void doInBackground() throws Exception { UpmResourceLoader.INSTANCE.download(); @@ -308,16 +312,13 @@ public class UpmBridge { RunnableFuture future = new FutureTask<>(new Callable() { @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 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()); } } diff --git a/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java b/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java index ef66fc039a..9e03dcc9dc 100644 --- a/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java +++ b/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); diff --git a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java index 3635937783..fe56bd4330 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java @@ -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 { 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 { 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()); diff --git a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java index b50c740a32..a9dcca2a2c 100644 --- a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java @@ -157,7 +157,8 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr @Override public boolean accept(PluginContext context) { - return context.contain(PluginModule.ExtraChartDesign, SpecialLevel.IndependentChartUIProvider.getTagName()); + return context.contain(PluginModule.ExtraChartDesign, SpecialLevel.IndependentChartUIProvider.getTagName()) + || context.contain(PluginModule.ExtraChartDesign, ChartTypeUIProvider.XML_TAG); } }); } diff --git a/designer-chart/src/main/java/com/fr/design/chart/fun/ChartTypeUIProvider.java b/designer-chart/src/main/java/com/fr/design/chart/fun/ChartTypeUIProvider.java index 9db47e4318..1843a18864 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/fun/ChartTypeUIProvider.java +++ b/designer-chart/src/main/java/com/fr/design/chart/fun/ChartTypeUIProvider.java @@ -3,6 +3,7 @@ package com.fr.design.chart.fun; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; import com.fr.design.condition.ConditionAttributesPane; +import com.fr.design.gui.chart.ChartXMLTag; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.mainframe.chart.AbstractChartAttrPane; import com.fr.design.mainframe.chart.ChartEditPane; @@ -22,8 +23,8 @@ import com.fr.stable.fun.Level; * 自定义 图表类型 界面接口 */ public interface ChartTypeUIProvider extends Level { - - String XML_TAG = "ChartTypeUIProvider"; + + String XML_TAG = ChartXMLTag.CHART_TYPE_UI_PROVIDER; String OLD_TAG = SpecialLevel.IndependentChartUIProvider.getTagName(); diff --git a/designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapCustomPane.java b/designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapCustomPane.java index 8cd0743dab..133e2fef74 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapCustomPane.java +++ b/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 implements AbstrctMapAttrEditPane{ // 储存地图对应的字段. 名称, 类型. shape (点 用圆形代替) +public class MapCustomPane extends BasicBeanPane implements AbstrctMapAttrEditPane { // 储存地图对应的字段. 名称, 类型. shape (点 用圆形代替) - private FilterComboBox areaString;// 区域字段 - private DatabaseTableDataPane tableDataNameBox;// 数据集名称 + 后面跟随预览按钮 - private MapImageEditPane imageShowPane; // 图片展示编辑的界面 - private String lastSelectPath; - private boolean isNeedDataSource = true; + private FilterComboBox 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 getColValuesInData(TableDataWrapper tableDataWrappe, String colName) { - List 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 getColValuesInData(TableDataWrapper tableDataWrappe, String colName) { + List 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 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 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(); + } } \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java index d17351f587..485c73b164 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java @@ -210,6 +210,10 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ reshuffleBorderPaintingEffectIfTitleExists(titleParent, titleCreator, bodyXCreator); reshuffleBackgroundPaintingEffectIfTitleExists(titleParent, titleCreator, bodyXCreator); + } else { + titleParent.setBorder(null); + titleParent.setBorderImage4Painting(null, 0.0); + titleParent.setBackground4Painting(null, 0.0); } } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java index c04c93a380..71129bed46 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java @@ -62,6 +62,13 @@ public class XWTitleLayout extends DedicateLayoutContainer { this.bodyBackgroundOpacity4Painting = opacity; } + @Override + protected void initBorderAndBackgroundStyle() { + setBorder(null); + setBorderImage4Painting(null, 0.0); + setBackground4Painting(null, 0.0); + } + @Override protected void initXCreatorProperties() { super.initXCreatorProperties(); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormParaWidgetPane.java b/designer-form/src/main/java/com/fr/design/mainframe/FormParaWidgetPane.java index b8f3ff6380..09e02ac670 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormParaWidgetPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormParaWidgetPane.java @@ -8,6 +8,7 @@ import com.fr.design.designer.beans.events.DesignerEditListener; import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.fun.FormWidgetOptionProvider; +import com.fr.design.gui.chart.ChartXMLTag; import com.fr.design.gui.core.FormWidgetOption; import com.fr.design.gui.core.UserDefinedWidgetOption; import com.fr.design.gui.core.WidgetOption; @@ -38,20 +39,20 @@ import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JSeparator; import javax.swing.SwingConstants; -import java.awt.Cursor; -import java.awt.event.MouseListener; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.awt.BorderLayout; import java.awt.Color; +import java.awt.Cursor; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; /** * @author null @@ -105,7 +106,8 @@ public class FormParaWidgetPane extends JPanel { public boolean accept(PluginContext context) { return context.contain(PluginModule.ExtraDesign, FormWidgetOptionProvider.XML_TAG) - || context.contain(PluginModule.ExtraChartDesign, SpecialLevel.IndependentChartUIProvider.getTagName()); + || context.contain(PluginModule.ExtraChartDesign, SpecialLevel.IndependentChartUIProvider.getTagName()) + || context.contain(PluginModule.ExtraChartDesign, ChartXMLTag.CHART_TYPE_UI_PROVIDER); } }); } @@ -246,7 +248,7 @@ public class FormParaWidgetPane extends JPanel { private JPanel createComponentReuseToolPane() { JPanel jPanel = new JPanel(new BorderLayout(17, 10)); UILabel uiLabel = new UILabel(BaseUtils.readIcon("/com/fr/design/images/form/designer/widget_apply_icon.png")); - uiLabel.setBorder(BorderFactory.createEmptyBorder(5, 0 ,5, 0)); + uiLabel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); jPanel.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/action/InstallComponentAction.java b/designer-form/src/main/java/com/fr/design/mainframe/share/action/InstallComponentAction.java index d3173e36bf..fd03dc72a1 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/action/InstallComponentAction.java +++ b/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) {