forked from fanruan/design
Browse Source
* commit '048231994bff5e7f8696128d0f8fabf17c91b77b': REPORT-65475 AlphaFine搜索慢 CHART-22259 feat:插件重新加载或者切换env fvs模板重新加载 REPORT-65474 设计器-水印,平台改变水印开关,模板水印变成了模板单独设置 1.新建水印默认不是模板水印,当新建模板水印的时候,进行配置即可。 REPORT-64811 10.0设计器下载的组件文件无法解压缩 REPORT-65290 设计器-水印,平台改变水印开关,模板水印变成了模板单独设置 1.修改水印的isvalid REPORT-65369 设计器内对macOS12的处理-按钮图标设置-在点击 选择图片时回到了父弹窗界面,没有实时显示出来,而需要再次单机设计器界面 REPORT-65381 linux_arm设计器-点击菜单栏文件-选项,出现弹窗后再点击 确定按钮,弹窗不消失,无任何反应 REPORT-64009 设计器内对macOS12的处理 fix import REPORT-64009 设计器内对macOS12的处理 fix门槛用例的bug REPORT-64009 设计器内对macOS12的处理 REPORT-64920 复制粘贴接口报错处理 REPORT-64609 磁盘空间满时 保存模板造成模板丢失 REPORT-64811 保持设计器商城下载reu文件名中的版本信息 REPORT-64741 【组件可更新提醒】组件复用-设计器端安装设计器版本高于当前设计器版本的组件的情况final/10.0
superman
3 years ago
27 changed files with 915 additions and 134 deletions
@ -0,0 +1,12 @@
|
||||
package com.fr.common.exception; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/12/27 |
||||
*/ |
||||
public interface ThrowableHandler { |
||||
|
||||
boolean process(Throwable e); |
||||
|
||||
} |
@ -0,0 +1,25 @@
|
||||
package com.fr.design.gui.ifilechooser; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/12/29 |
||||
*/ |
||||
public class ExtensionFilter { |
||||
|
||||
private final String des; |
||||
private final String[] extensions; |
||||
|
||||
public ExtensionFilter(String des, String... extensions) { |
||||
this.des = des; |
||||
this.extensions = extensions; |
||||
} |
||||
|
||||
public String getDes() { |
||||
return des; |
||||
} |
||||
|
||||
public String[] getExtensions() { |
||||
return extensions; |
||||
} |
||||
} |
@ -0,0 +1,109 @@
|
||||
package com.fr.design.gui.ifilechooser; |
||||
|
||||
/** |
||||
* 文件选择器可设置的参数集合 |
||||
* |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/12/21 |
||||
*/ |
||||
public class FileChooserArgs { |
||||
|
||||
private final FileSelectionMode fileSelectionMode; |
||||
private final String filterDes; |
||||
private final String[] extensions; |
||||
private final String selectedPath; |
||||
private final ExtensionFilter[] filters; |
||||
private final String tipText; |
||||
private final boolean multiSelectionEnabled; |
||||
|
||||
public static Builder newBuilder() { |
||||
return new Builder(); |
||||
} |
||||
|
||||
private FileChooserArgs(Builder builder) { |
||||
this.fileSelectionMode = builder.fileSelectionMode; |
||||
this.filterDes = builder.filterDes; |
||||
this.extensions = builder.extensions; |
||||
this.selectedPath = builder.selectedPath; |
||||
this.filters = builder.filters; |
||||
this.tipText = builder.tipText; |
||||
this.multiSelectionEnabled = builder.multiSelectionEnabled; |
||||
} |
||||
|
||||
public FileSelectionMode getFileSelectionMode() { |
||||
return fileSelectionMode; |
||||
} |
||||
|
||||
public String getFilterDes() { |
||||
return filterDes; |
||||
} |
||||
|
||||
public String[] getExtensions() { |
||||
return extensions; |
||||
} |
||||
|
||||
public String getSelectedPath() { |
||||
return selectedPath; |
||||
} |
||||
|
||||
public ExtensionFilter[] getFilters() { |
||||
return filters; |
||||
} |
||||
|
||||
public String getTipText() { |
||||
return tipText; |
||||
} |
||||
|
||||
public boolean isMultiSelectionEnabled() { |
||||
return multiSelectionEnabled; |
||||
} |
||||
|
||||
public static class Builder { |
||||
|
||||
private FileSelectionMode fileSelectionMode; |
||||
private String filterDes; |
||||
private String[] extensions; |
||||
private String selectedPath; |
||||
private ExtensionFilter[] filters = new ExtensionFilter[0]; |
||||
private String tipText; |
||||
private boolean multiSelectionEnabled; |
||||
|
||||
public Builder setFileSelectionMode(FileSelectionMode fileSelectionMode) { |
||||
this.fileSelectionMode = fileSelectionMode; |
||||
return this; |
||||
} |
||||
|
||||
public Builder setFilter(String filterDes, String... extensions) { |
||||
this.filterDes = filterDes; |
||||
this.extensions = extensions; |
||||
return this; |
||||
} |
||||
|
||||
public Builder setSelectedPath(String selectedPath) { |
||||
this.selectedPath = selectedPath; |
||||
return this; |
||||
} |
||||
|
||||
public Builder setFilters(ExtensionFilter[] filters) { |
||||
this.filters = filters; |
||||
return this; |
||||
} |
||||
|
||||
public Builder setTipText(String tipText) { |
||||
this.tipText = tipText; |
||||
return this; |
||||
} |
||||
|
||||
public Builder setMultiSelectionEnabled(boolean multiSelectionEnabled) { |
||||
this.multiSelectionEnabled = multiSelectionEnabled; |
||||
return this; |
||||
} |
||||
|
||||
public FileChooserArgs build() { |
||||
return new FileChooserArgs(this); |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,44 @@
|
||||
package com.fr.design.gui.ifilechooser; |
||||
|
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.os.impl.SupportOSImpl; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/12/21 |
||||
*/ |
||||
public class FileChooserFactory { |
||||
|
||||
public static FileChooserProvider createFileChooser(FileChooserArgs fileChooserArgs) { |
||||
if (SupportOSImpl.OLD_STYLE_CHOOSER.support()) { |
||||
return new SwingFileChooser.Builder(). |
||||
setFileSelectionMode(fileChooserArgs.getFileSelectionMode()). |
||||
setFileFilter(fileChooserArgs.getFilterDes(), fileChooserArgs.getExtensions()). |
||||
setSelectedFile(fileChooserArgs.getSelectedPath()). |
||||
setMultiSelectionEnabled(fileChooserArgs.isMultiSelectionEnabled()). |
||||
setTipText(fileChooserArgs.getTipText()). |
||||
setFileFilter(fileChooserArgs.getFilters()).build(); |
||||
} else { |
||||
return new JavaFxNativeFileChooser.Builder(). |
||||
fileSelectionMode(fileChooserArgs.getFileSelectionMode()). |
||||
filter(fileChooserArgs.getFilterDes(), fileChooserArgs.getExtensions()). |
||||
currentDirectory(fileChooserArgs.getSelectedPath()). |
||||
title(fileChooserArgs.getTipText()). |
||||
filters(fileChooserArgs.getFilters()).build(); |
||||
} |
||||
} |
||||
|
||||
public static FileChooserProvider createImageFileChooser() { |
||||
if (SupportOSImpl.OLD_STYLE_CHOOSER.support()) { |
||||
return new SwingImageFileChooser(); |
||||
} else { |
||||
return new JavaFxNativeFileChooser.Builder(). |
||||
fileSelectionMode(FileSelectionMode.FILE). |
||||
title(Toolkit.i18nText("Fine-Design_Basic_Open")). |
||||
filter(Toolkit.i18nText("Fine-Design_Basic_Image_Image_Files"), "*.jpg", "*.gif", "*.png", "*.bmp"). |
||||
build(); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,130 @@
|
||||
package com.fr.design.gui.ifilechooser; |
||||
|
||||
import com.fr.common.annotations.Negative; |
||||
import com.fr.design.upm.UpmUtils; |
||||
import com.fr.stable.ArrayUtils; |
||||
import com.fr.stable.StringUtils; |
||||
import java.awt.Component; |
||||
import java.io.File; |
||||
import javax.swing.JFileChooser; |
||||
import javax.swing.filechooser.FileFilter; |
||||
import javax.swing.filechooser.FileNameExtensionFilter; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/12/21 |
||||
*/ |
||||
@Negative(until = "2022-6-1") |
||||
class SwingFileChooser implements FileChooserProvider { |
||||
|
||||
private final JFileChooser fileChooser; |
||||
private final Builder builder; |
||||
|
||||
private SwingFileChooser(Builder builder) { |
||||
fileChooser = new JFileChooser(); |
||||
fileChooser.setFileSelectionMode(builder.fileSelectionMode); |
||||
fileChooser.setFileFilter(builder.fileFilter); |
||||
fileChooser.setSelectedFile(builder.selectedFile); |
||||
fileChooser.setMultiSelectionEnabled(builder.multiSelectionEnabled); |
||||
this.builder = builder; |
||||
} |
||||
|
||||
@Override |
||||
public File[] getSelectedFiles() { |
||||
return fileChooser.getSelectedFiles(); |
||||
} |
||||
|
||||
@Override |
||||
public File getSelectedFile() { |
||||
return fileChooser.getSelectedFile(); |
||||
} |
||||
|
||||
@Override |
||||
public int showDialog(Component parent) { |
||||
if (StringUtils.isEmpty(builder.tipText)) { |
||||
return fileChooser.showOpenDialog(parent); |
||||
} else { |
||||
return fileChooser.showDialog(parent, builder.tipText); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public int showOpenDialog(Component parent, String approveButtonText) { |
||||
return fileChooser.showDialog(parent, approveButtonText); |
||||
} |
||||
|
||||
@Override |
||||
public void setCurrentDirectory(File file) { |
||||
fileChooser.setCurrentDirectory(file); |
||||
} |
||||
|
||||
@Override |
||||
public void setMultiSelectionEnabled(boolean multiple) { |
||||
fileChooser.setMultiSelectionEnabled(multiple); |
||||
} |
||||
|
||||
/** |
||||
* 和一般builder不同的是 setXXX还做参数转换逻辑 |
||||
*/ |
||||
public static class Builder { |
||||
|
||||
private int fileSelectionMode = JFileChooser.FILES_ONLY; |
||||
private FileFilter fileFilter; |
||||
private File selectedFile; |
||||
private boolean multiSelectionEnabled; |
||||
private String tipText; |
||||
|
||||
public Builder setFileSelectionMode(FileSelectionMode fileSelectionMode) { |
||||
if (FileSelectionMode.DIR.equals(fileSelectionMode)) { |
||||
this.fileSelectionMode = JFileChooser.DIRECTORIES_ONLY; |
||||
} else if (FileSelectionMode.FILE.equals(fileSelectionMode)) { |
||||
this.fileSelectionMode = JFileChooser.FILES_ONLY; |
||||
} else if (FileSelectionMode.MULTIPLE_FILE.equals(fileSelectionMode)) { |
||||
this.fileSelectionMode = JFileChooser.FILES_AND_DIRECTORIES; |
||||
} |
||||
return this; |
||||
} |
||||
|
||||
public Builder setFileFilter(String des, String... extension) { |
||||
if (StringUtils.isNotEmpty(des) && ArrayUtils.isNotEmpty(extension)) { |
||||
this.fileFilter = new FileNameExtensionFilter(des, UpmUtils.findMatchedExtension(extension)); |
||||
} |
||||
return this; |
||||
} |
||||
|
||||
public Builder setFileFilter(ExtensionFilter[] extensionFilters) { |
||||
StringBuilder desBuilder = new StringBuilder(); |
||||
String[] extensions = new String[0]; |
||||
for (ExtensionFilter extensionFilter : extensionFilters) { |
||||
desBuilder.append(extensionFilter.getDes()).append(" "); |
||||
extensions = ArrayUtils.addAll(extensions, UpmUtils.findMatchedExtension(extensionFilter.getExtensions())); |
||||
} |
||||
if (ArrayUtils.isNotEmpty(extensionFilters)) { |
||||
this.fileFilter = new FileNameExtensionFilter(desBuilder.toString().trim(), extensions); |
||||
} |
||||
return this; |
||||
} |
||||
|
||||
public Builder setSelectedFile(String selectedPath) { |
||||
if (StringUtils.isNotEmpty(selectedPath)) { |
||||
this.selectedFile = new File(selectedPath); |
||||
} |
||||
return this; |
||||
} |
||||
|
||||
public Builder setMultiSelectionEnabled(boolean multiSelectionEnabled) { |
||||
this.multiSelectionEnabled = multiSelectionEnabled; |
||||
return this; |
||||
} |
||||
|
||||
public Builder setTipText(String tipText) { |
||||
this.tipText = tipText; |
||||
return this; |
||||
} |
||||
|
||||
public SwingFileChooser build() { |
||||
return new SwingFileChooser(this); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,276 @@
|
||||
package com.fr.design.gui.ifilechooser; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.common.annotations.Negative; |
||||
import com.fr.design.DesignerEnvManager; |
||||
import com.fr.design.style.ChooseFileView; |
||||
import com.fr.design.style.background.image.ExpandFileChooser; |
||||
import java.awt.Component; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.io.File; |
||||
import java.util.Enumeration; |
||||
import java.util.Hashtable; |
||||
import javax.swing.filechooser.FileFilter; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/12/30 |
||||
*/ |
||||
@Negative(until = "2022-6-1") |
||||
class SwingImageFileChooser extends ExpandFileChooser implements FileChooserProvider { |
||||
|
||||
public SwingImageFileChooser() { |
||||
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); |
||||
|
||||
// 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); |
||||
} |
||||
|
||||
@Override |
||||
public int showDialog(Component parent, String approveButtonText) { |
||||
return super.showDialog(parent, approveButtonText); |
||||
} |
||||
|
||||
@Override |
||||
public ActionListener checkAction() { |
||||
return new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
DesignerEnvManager.getEnvManager().setImageCompress(isCheckSelected()); |
||||
DesignerEnvManager.getEnvManager().saveXMLFile(); |
||||
} |
||||
}; |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public int showDialog(Component parent) { |
||||
return showOpenDialog(parent); |
||||
} |
||||
|
||||
/** |
||||
* 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 |
||||
*/ |
||||
@Override |
||||
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 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 FileFilter#getDescription |
||||
*/ |
||||
@Override |
||||
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; |
||||
} |
||||
|
||||
/** |
||||
* 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; |
||||
} |
||||
|
||||
/** |
||||
* 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; |
||||
} |
||||
|
||||
/** |
||||
* 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; |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,70 @@
|
||||
package com.fr.design.worker.save; |
||||
|
||||
import com.fr.common.exception.ThrowableHandler; |
||||
import com.fr.design.dialog.FineJOptionPane; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.general.IOUtils; |
||||
import com.fr.workspace.exception.DiskSpaceFullException; |
||||
import java.awt.Frame; |
||||
import javax.swing.JOptionPane; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/12/7 |
||||
*/ |
||||
public class SaveFailureHandler implements ThrowableHandler { |
||||
|
||||
private static final SaveFailureHandler INSTANCE = new SaveFailureHandler(); |
||||
|
||||
public static SaveFailureHandler getInstance() { |
||||
return INSTANCE; |
||||
} |
||||
|
||||
@Override |
||||
public boolean process(Throwable e) { |
||||
for (Handler handler : Handler.values()) { |
||||
if (handler.process(e)) { |
||||
break; |
||||
} |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
public enum Handler implements ThrowableHandler { |
||||
|
||||
FullDisk { |
||||
@Override |
||||
public boolean process(Throwable e) { |
||||
if (e.getCause() instanceof DiskSpaceFullException |
||||
|| e instanceof DiskSpaceFullException |
||||
|| e.getCause().getCause() instanceof DiskSpaceFullException) { |
||||
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), |
||||
Toolkit.i18nText("Fine_Design_Template_Save_Failed_By_Full_Disk"), |
||||
Toolkit.i18nText("Fine-Design_Basic_Alert"), |
||||
JOptionPane.WARNING_MESSAGE, |
||||
IOUtils.readIcon("/com/fr/design/images/warnings/warning32.png")); |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
}, |
||||
|
||||
Other { |
||||
@Override |
||||
public boolean process(Throwable e) { |
||||
boolean minimized = (DesignerContext.getDesignerFrame().getExtendedState() & Frame.ICONIFIED ) != 0; |
||||
FineJOptionPane.showMessageDialog( |
||||
minimized ? null : DesignerContext.getDesignerFrame(), |
||||
Toolkit.i18nText("Fine-Design-Basic_Save_Failure"), |
||||
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), |
||||
JOptionPane.ERROR_MESSAGE); |
||||
return true; |
||||
} |
||||
}; |
||||
|
||||
|
||||
|
||||
} |
||||
} |
Loading…
Reference in new issue