From 79dba16bf94716c5212dd1fb063708931757c610 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Sun, 16 Sep 2018 09:44:26 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-11352=20=E8=BF=9C=E7=A8=8B=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E5=8E=BB=E9=99=A4socketio=E7=9A=84=E9=80=82=E9=85=8D?= =?UTF-8?q?=EF=BC=8C=E9=83=A8=E5=88=86=E4=BB=A3=E7=A0=81=E8=B4=A8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/app/CptApp.java | 59 +++++++++---------- .../com/fr/design/mainframe/app/CptxApp.java | 24 +++++--- .../com/fr/design/mainframe/app/FormApp.java | 29 +++++---- .../com/fr/design/mainframe/app/XlsApp.java | 15 +++-- .../com/fr/design/mainframe/app/XlsxApp.java | 16 +++-- 5 files changed, 85 insertions(+), 58 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java b/designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java index a381cd6d44..72fa9aba6f 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java @@ -6,7 +6,6 @@ import com.fr.base.Style; import com.fr.base.TempNameStyle; import com.fr.base.extension.FileExtension; import com.fr.base.io.XMLEncryptUtils; -import com.fr.base.remote.RemoteDeziConstants; import com.fr.config.ServerPreferenceConfig; import com.fr.design.DesignerEnvManager; import com.fr.design.actions.server.StyleListAction; @@ -15,16 +14,16 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DecodeDialog; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.exception.PermissionDeniedException; +import com.fr.exception.TplLockedException; import com.fr.file.FILE; -import com.fr.general.ComparatorUtils; - -import com.fr.io.utils.ResourceIOUtils; import com.fr.log.FineLoggerFactory; import com.fr.main.impl.WorkBook; -import com.fr.stable.StringUtils; -import javax.swing.*; -import java.awt.*; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; @@ -34,44 +33,44 @@ import java.util.Iterator; * Created by juhaoyu on 2018/6/27. */ class CptApp extends AbstractWorkBookApp { - + @Override public String[] defaultExtensions() { - + return new String[]{FileExtension.CPT.getExtension()}; } - + @Override public WorkBook asIOFile(FILE file) { - + if (XMLEncryptUtils.isCptEncoded() && - !XMLEncryptUtils.checkVaild(DesignerEnvManager.getEnvManager().getEncryptionKey())) { + !XMLEncryptUtils.checkVaild(DesignerEnvManager.getEnvManager().getEncryptionKey())) { if (!new DecodeDialog(file).isPwdRight()) { FRContext.getLogger().error(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ECP_Error_Pwd")); return new WorkBook(); } } - + WorkBook tpl = new WorkBook(); // richer:打开报表通知 FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Template_Opening_And_Waiting", file.getName()) + "..."); TempNameStyle namestyle = TempNameStyle.getInstance(); namestyle.clear(); - String checkStr = StringUtils.EMPTY; try { - checkStr = ResourceIOUtils.inputStream2String(file.asInputStream()); tpl.readStream(file.asInputStream()); + } catch (PermissionDeniedException exp) { + FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + file, exp); + } catch (TplLockedException exp) { + FineLoggerFactory.getLogger().error(file + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked"), exp); } catch (Exception exp) { - String errorMessage = ComparatorUtils.equals(RemoteDeziConstants.INVALID_USER, checkStr) ? Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") - : com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_NS_Exception_ReadError"); - FineLoggerFactory.getLogger().error(errorMessage + file, exp); + FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Report_NS_Exception_ReadError") + file, exp); } checkNameStyle(namestyle); return tpl; } - + private static void checkNameStyle(TempNameStyle namestyle) { - + Iterator it = namestyle.getIterator(); ArrayList al = new ArrayList(); while (it.hasNext()) { @@ -81,9 +80,9 @@ class CptApp extends AbstractWorkBookApp { showConfirmDialog(al); } } - + private static void showConfirmDialog(final ArrayList namelist) { - + final JDialog jd = new JDialog(); // 模态一下,因为可能会多个样式丢失 // jd.setModal(true); @@ -96,14 +95,14 @@ class CptApp extends AbstractWorkBookApp { jl.setHorizontalAlignment(SwingConstants.CENTER); jd.add(jl, BorderLayout.CENTER); JPanel jp = new JPanel(); - + // ”是“按钮,点击之后将生成一个全局样式,并写入xml UIButton confirmButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Yes")); confirmButton.addActionListener(new ActionListener() { - + @Override public void actionPerformed(ActionEvent e) { - + try { for (String name : namelist) { ServerPreferenceConfig.getInstance().putStyle(name, Style.DEFAULT_STYLE); @@ -115,17 +114,17 @@ class CptApp extends AbstractWorkBookApp { new StyleListAction().actionPerformed(e);// 弹窗 } }); - + UIButton noButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_No")); noButton.addActionListener(new ActionListener() { - + @Override public void actionPerformed(ActionEvent e) { - + jd.dispose(); } }); - + jp.add(confirmButton); jp.add(noButton); jd.setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Template_Custom_Style_Missed")); @@ -133,5 +132,5 @@ class CptApp extends AbstractWorkBookApp { GUICoreUtils.centerWindow(jd); jd.setVisible(true); } - + } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/app/CptxApp.java b/designer-realize/src/main/java/com/fr/design/mainframe/app/CptxApp.java index 2f45b413fb..9350100498 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/app/CptxApp.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/app/CptxApp.java @@ -3,8 +3,10 @@ package com.fr.design.mainframe.app; import com.fr.base.extension.FileExtension; import com.fr.base.frpx.exception.FRPackageRunTimeException; import com.fr.base.frpx.exception.InvalidWorkBookException; +import com.fr.design.i18n.Toolkit; +import com.fr.exception.PermissionDeniedException; +import com.fr.exception.TplLockedException; import com.fr.file.FILE; - import com.fr.log.FineLoggerFactory; import com.fr.main.impl.WorkBook; import com.fr.main.impl.WorkBookAdapter; @@ -16,32 +18,38 @@ import java.io.InputStream; * Created by juhaoyu on 2018/6/27. */ class CptxApp extends AbstractWorkBookApp { - + @Override public String[] defaultExtensions() { - + return new String[]{FileExtension.CPTX.getExtension()}; } - + @Override public WorkBook asIOFile(FILE file) { - + FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Template_Opening_And_Waiting", file.getName()) + "..."); - WorkBookX tpl; + WorkBookX tpl = new WorkBookX(); InputStream inputStream; try { inputStream = file.asInputStream(); long time = System.currentTimeMillis(); tpl = new WorkBookX(inputStream); FineLoggerFactory.getLogger().error("cost: " + (System.currentTimeMillis() - time) + " ms"); + + + } catch (PermissionDeniedException exp) { + FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + file, exp); + } catch (TplLockedException exp) { + FineLoggerFactory.getLogger().error(file + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked"), exp); } catch (Exception exp) { if (exp instanceof FRPackageRunTimeException) { throw (FRPackageRunTimeException) exp; } throw new InvalidWorkBookException(file + ":" + exp.getMessage(), exp); } - - + + return new WorkBookAdapter(tpl); } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java b/designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java index a45fdd2140..f0b93cdf2c 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java @@ -2,13 +2,15 @@ package com.fr.design.mainframe.app; import com.fr.base.io.XMLEncryptUtils; import com.fr.design.DesignerEnvManager; +import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.AbstractAppProvider; import com.fr.design.mainframe.BaseJForm; import com.fr.design.mainframe.DecodeDialog; import com.fr.design.mainframe.JTemplate; +import com.fr.exception.PermissionDeniedException; +import com.fr.exception.TplLockedException; import com.fr.file.FILE; import com.fr.form.main.Form; - import com.fr.log.FineLoggerFactory; import com.fr.stable.Constants; import com.fr.stable.bridge.StableFactory; @@ -19,43 +21,46 @@ import java.util.HashMap; * Created by juhaoyu on 2018/6/27. */ class FormApp extends AbstractAppProvider { - + @Override public String[] defaultExtensions() { - + return new String[]{"frm", "form"}; } - + @Override @SuppressWarnings("unchecked") public JTemplate openTemplate(FILE tplFile) { - + HashMap classType = new HashMap(); classType.put(Constants.ARG_0, Form.class); classType.put(Constants.ARG_1, FILE.class); - + return (JTemplate) StableFactory.getMarkedInstanceObjectFromClass(BaseJForm.XML_TAG, - new Object[]{asIOFile(tplFile), tplFile}, classType, BaseJForm.class); + new Object[]{asIOFile(tplFile), tplFile}, classType, BaseJForm.class); } - + @Override public Form asIOFile(FILE file) { - + if (XMLEncryptUtils.isCptEncoded() && - !XMLEncryptUtils.checkVaild(DesignerEnvManager.getEnvManager().getEncryptionKey())) { + !XMLEncryptUtils.checkVaild(DesignerEnvManager.getEnvManager().getEncryptionKey())) { if (!new DecodeDialog(file).isPwdRight()) { FineLoggerFactory.getLogger().error(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_ECP_Error_Password")); return new Form(); } } - - + // peter:打开新报表. Form tpl = new Form(); // richer:打开报表通知 FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("file.getName()", file.getName()) + "..."); try { tpl.readStream(file.asInputStream()); + } catch (PermissionDeniedException exp) { + FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + file, exp); + } catch (TplLockedException exp) { + FineLoggerFactory.getLogger().error(file + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked"), exp); } catch (Exception exp) { FineLoggerFactory.getLogger().error("Failed to generate frm from " + file, exp); return null; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/app/XlsApp.java b/designer-realize/src/main/java/com/fr/design/mainframe/app/XlsApp.java index 312335fb79..0118a8dac0 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/app/XlsApp.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/app/XlsApp.java @@ -1,6 +1,9 @@ package com.fr.design.mainframe.app; import com.fr.base.extension.FileExtension; +import com.fr.design.i18n.Toolkit; +import com.fr.exception.PermissionDeniedException; +import com.fr.exception.TplLockedException; import com.fr.file.FILE; import com.fr.io.importer.ExcelReportImporter; import com.fr.log.FineLoggerFactory; @@ -10,19 +13,23 @@ import com.fr.main.impl.WorkBook; * Created by juhaoyu on 2018/6/27. */ class XlsApp extends AbstractWorkBookApp { - + @Override public String[] defaultExtensions() { - + return new String[]{FileExtension.XLS.getExtension()}; } - + @Override public WorkBook asIOFile(FILE tplFile) { - + WorkBook workbook = null; try { workbook = new ExcelReportImporter().generateWorkBookByStream(tplFile.asInputStream()); + } catch (PermissionDeniedException exp) { + FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + tplFile, exp); + } catch (TplLockedException exp) { + FineLoggerFactory.getLogger().error(tplFile + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked"), exp); } catch (Exception exp) { FineLoggerFactory.getLogger().error("Failed to generate xls from " + tplFile, exp); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/app/XlsxApp.java b/designer-realize/src/main/java/com/fr/design/mainframe/app/XlsxApp.java index f3b5fef76e..fe3f11e508 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/app/XlsxApp.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/app/XlsxApp.java @@ -1,6 +1,9 @@ package com.fr.design.mainframe.app; import com.fr.base.extension.FileExtension; +import com.fr.design.i18n.Toolkit; +import com.fr.exception.PermissionDeniedException; +import com.fr.exception.TplLockedException; import com.fr.file.FILE; import com.fr.io.importer.Excel2007ReportImporter; import com.fr.log.FineLoggerFactory; @@ -10,19 +13,24 @@ import com.fr.main.impl.WorkBook; * Created by juhaoyu on 2018/6/27. */ class XlsxApp extends AbstractWorkBookApp { - + @Override public String[] defaultExtensions() { - + return new String[]{FileExtension.XLSX.getExtension()}; } - + @Override public WorkBook asIOFile(FILE tplFile) { - + WorkBook workbook = null; try { workbook = new Excel2007ReportImporter().generateWorkBookByStream(tplFile.asInputStream()); + + } catch (PermissionDeniedException exp) { + FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + tplFile, exp); + } catch (TplLockedException exp) { + FineLoggerFactory.getLogger().error(tplFile + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked"), exp); } catch (Exception exp) { FineLoggerFactory.getLogger().error("Failed to generate xlsx from " + tplFile, exp); }