diff --git a/designer-base/src/main/java/com/fr/design/DesignModelAdapter.java b/designer-base/src/main/java/com/fr/design/DesignModelAdapter.java index 45c9684af0..3eb3b78579 100644 --- a/designer-base/src/main/java/com/fr/design/DesignModelAdapter.java +++ b/designer-base/src/main/java/com/fr/design/DesignModelAdapter.java @@ -300,6 +300,9 @@ public abstract class DesignModelAdapter map, Filter filter) { + // 兼容下通过老数据集参数获取 + tableDataParameters = getLatestTableDataParameters(); + // 处理初始化添加 if (tableDataParametersMap.isEmpty()) { addTableDataParameters(map, filter); diff --git a/designer-base/src/main/java/com/fr/design/actions/file/EditEnvAction.java b/designer-base/src/main/java/com/fr/design/actions/file/EditEnvAction.java index a4b7c88034..d007e315fe 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/EditEnvAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/EditEnvAction.java @@ -3,6 +3,8 @@ package com.fr.design.actions.file; import com.fr.design.EnvChangeEntrance; import com.fr.design.actions.UpdateAction; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.mainframe.JTemplate; import java.awt.event.ActionEvent; @@ -17,4 +19,13 @@ public class EditEnvAction extends UpdateAction { public void actionPerformed(ActionEvent e) { EnvChangeEntrance.getInstance().chooseEnv(); } + + @Override + public void update() { + super.update(); + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (template != null) { + this.setEnabled(!template.isSaving()); + } + } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java b/designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java index bc88f72fd0..c59a92b975 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java @@ -1,10 +1,11 @@ package com.fr.design.actions.file; -import com.fr.base.svg.IconUtils; import com.fr.design.DesignerEnvManager; import com.fr.design.EnvChangeEntrance; import com.fr.design.actions.UpdateAction; import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.mainframe.JTemplate; import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.MenuDef; import com.fr.design.menu.SeparatorDef; @@ -68,5 +69,14 @@ public class SwitchExistEnv extends MenuDef { EnvChangeEntrance.getInstance().switch2Env(envName); } } + + @Override + public void update() { + super.update(); + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (template != null) { + this.setEnabled(!template.isSaving()); + } + } } } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java index 6460cadb9e..2a8446f893 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java @@ -1,7 +1,6 @@ package com.fr.design.data.datapane; import com.fr.base.TableData; -import com.fr.concurrent.NamedThreadFactory; import com.fr.data.core.DataCoreUtils; import com.fr.data.core.db.DBUtils; import com.fr.data.core.db.TableProcedure; @@ -18,7 +17,7 @@ import com.fr.design.data.datapane.preview.PreviewLabel.Previewable; import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.data.tabledata.Prepare4DataSourceChange; import com.fr.design.dialog.FineJOptionPane; -import com.fr.design.gui.icombobox.SearchPreTaskTreeComboBox; +import com.fr.design.gui.icombobox.FRTreeComboBox; import com.fr.design.gui.icombobox.FilterableComboBoxModel; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBoxEditor; @@ -60,10 +59,6 @@ import java.util.Collection; import java.util.Enumeration; import java.util.List; import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.FutureTask; /** * @author zhou @@ -85,25 +80,20 @@ public class ChoosePane extends BasicBeanPane implements Refresha /** * 表名 */ - protected SearchPreTaskTreeComboBox tableNameComboBox; + protected FRTreeComboBox tableNameComboBox; private SwingWorker populateWorker; - private static final ExecutorService SERVICE = Executors.newSingleThreadExecutor(new NamedThreadFactory("ChoosePaneThread")); - private PopupMenuListener popupMenuListener = new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { - FutureTask task = new FutureTask(new Callable() { + new Thread() { @Override - public Object call() { + public void run() { calculateTableDataNames(); - return null; } - }); - SERVICE.submit(task); - tableNameComboBox.setPreSearchTask(task); + }.start(); } @Override @@ -167,7 +157,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha schemaBox = new StringUIComboBox(); schemaBox.setEditor(new ComboBoxEditor()); - tableNameComboBox = new SearchPreTaskTreeComboBox(new JTree(new DefaultMutableTreeNode()), tableNameTreeRenderer, false); + tableNameComboBox = new FRTreeComboBox(new JTree(new DefaultMutableTreeNode()), tableNameTreeRenderer, false); tableNameComboBox.setEditable(true); tableNameComboBox.setRenderer(listCellRenderer); registerDSChangeListener(); 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 18681ca186..4331828238 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 @@ -51,9 +51,10 @@ public class JDBCDefPane extends JPanel { public static final String DRIVER_TYPE = "driver_type"; public static final String USER_NAME = "user_name"; private static final String OTHER_DB = "Others"; - private static final Pattern ORACLE_URL = Pattern.compile("^jdbc:oracle:thin:@[/]*([0-9a-zA-Z_\\.]+)(:([0-9]+|port))?([:/](.*))?.*", Pattern.CASE_INSENSITIVE); - private static final Pattern GENERAL_URL = Pattern.compile("^jdbc:(mysql|sqlserver|db2|derby|postgresql|inceptor|inceptor2|hive2)://([0-9a-zA-Z_\\.]+)(:([0-9]+|port))?((/|;DatabaseName=)(.*))?.*", Pattern.CASE_INSENSITIVE); + private static final Pattern ORACLE_URL = Pattern.compile("^jdbc:oracle:thin:@[/]*([-0-9a-zA-Z_\\.]+)(:([0-9]+|port))?([:/](.*))?.*", Pattern.CASE_INSENSITIVE); + private static final Pattern GENERAL_URL = Pattern.compile("^jdbc:(mysql|sqlserver|db2|derby|postgresql|inceptor|inceptor2|hive2)://([-0-9a-zA-Z_\\.]+)(:([0-9]+|port))?((/|;DatabaseName=)(.*))?.*", Pattern.CASE_INSENSITIVE); private static final Pattern PORT = Pattern.compile("^0$|^[1-9][\\d]*[\\d]*$"); + private static final Pattern CHAR_NEED_ESCAPE = Pattern.compile("[?|$^*\\\\\\[\\](){}.+]"); // 编码转换. private String originalCharSet = null; private static Map jdbcMap = new HashMap(); @@ -389,6 +390,9 @@ public class JDBCDefPane extends JPanel { InputMethodListener portInputMethodListener = new InputMethodListener() { @Override public void inputMethodTextChanged(InputMethodEvent event) { + if (null == event.getText()) { + return; + } char ch = event.getText().current(); if (!(ch >= '0' && ch <= '9')) { event.consume(); @@ -484,13 +488,13 @@ public class JDBCDefPane extends JPanel { KeyListener portKeyListener = new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { - String port = portTextField.getText().trim(); + String port = portTextField.getText(); if (isPortValid(port)) { updateURL(); } else { - portTextField.setText(port.replaceAll(e.getKeyChar() + "", "")); + portTextField.setText(port.replaceAll(getCharNeedReplace(e.getKeyChar()) , "")); if (!isPortValid(portTextField.getText())) { - portTextField.setText(""); + portTextField.setText(StringUtils.EMPTY); updateURL(); } } @@ -501,6 +505,15 @@ public class JDBCDefPane extends JPanel { return PORT.matcher(port).find(); } + private String getCharNeedReplace(char c) { + String charNeedReplace = c + ""; + Matcher matcher = CHAR_NEED_ESCAPE.matcher(charNeedReplace); + if (matcher.find()) { + charNeedReplace = "\\" + charNeedReplace; + } + return charNeedReplace; + } + DocumentListener updateURLListener = new DocumentListener() { @Override diff --git a/designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java b/designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java index 8a1f55cbdf..889a0c3c9c 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java +++ b/designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java @@ -9,6 +9,7 @@ import java.awt.Font; import java.net.URI; import javax.swing.JEditorPane; import javax.swing.event.HyperlinkEvent; +import javax.swing.event.HyperlinkListener; /** * 用来构建JOptionPane带超链的消息提示 @@ -19,31 +20,45 @@ import javax.swing.event.HyperlinkEvent; */ public class MessageWithLink extends JEditorPane { + private static final UILabel LABEL = new UILabel(); + + public MessageWithLink(String message, String linkName, String link) { - super("text/html", "" + message + "" + linkName + "" + ""); - addHyperlinkListener(e -> { - if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { - try { - Desktop.getDesktop().browse(URI.create(link)); - } catch (Exception exception) { - FineLoggerFactory.getLogger().error(exception.getMessage(), exception); - } - } - }); - setEditable(false); - setBorder(null); + this(message, linkName, link, LABEL.getBackground(), LABEL.getFont()); } public MessageWithLink(String linkName, String link ) { this(StringUtils.EMPTY, linkName, link); } - private static StringBuilder getStyle() { - // 构建和相同风格样式 - UILabel label = new UILabel(); - Font font = label.getFont(); - Color color = label.getBackground(); + public MessageWithLink(String message, String linkName, String link, Color color) { + this(message, linkName, link, color, LABEL.getFont()); + } + + public MessageWithLink(String message, String linkName, String link, Color color, Font font) { + super("text/html", "" + message + "" + linkName + "" + ""); + initListener(link); + setEditable(false); + setBorder(null); + } + + protected void initListener(String link) { + addHyperlinkListener(new HyperlinkListener() { + @Override + public void hyperlinkUpdate(HyperlinkEvent e) { + if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { + try { + Desktop.getDesktop().browse(URI.create(link)); + } catch (Exception exception) { + FineLoggerFactory.getLogger().error(exception.getMessage(), exception); + } + } + } + }); + } + private static StringBuilder generateStyle(Color color, Font font) { + // 构建相同风格样式 StringBuilder style = new StringBuilder("font-family:" + font.getFamily() + ";"); style.append("font-weight:").append(font.isBold() ? "bold" : "normal").append(";"); style.append("font-size:").append(font.getSize()).append("pt;"); diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/SearchPreTaskTreeComboBox.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/SearchPreTaskTreeComboBox.java index 9e453471ef..9ee2a59495 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/SearchPreTaskTreeComboBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/SearchPreTaskTreeComboBox.java @@ -1,5 +1,6 @@ package com.fr.design.gui.icombobox; +import com.fr.design.ui.util.UIUtil; import com.fr.log.FineLoggerFactory; import javax.swing.JTree; @@ -64,7 +65,12 @@ public class SearchPreTaskTreeComboBox extends FRTreeComboBox { // 任务执行后置空,否则会被别的操作重复触发 setPreSearchTask(null); } - search(); + UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override + public void run() { + search(); + } + }); return null; } }.execute(); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java index f940f89045..a2cc6f8065 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java @@ -21,10 +21,16 @@ import javax.swing.JLayeredPane; */ public class DesktopCardPane extends BasicPane implements TargetModifiedListener { + private static final int CONTENT_LAYER = 0; + private static final int TRANSPARENT_LAYER = 1; + private static final int LOADING_LAYER = 2; + private static final int FAILED_LAYER = 3; + private static final long serialVersionUID = 1L; private JTemplate component; private TransparentPane transparentPane = new TransparentPane(); private OpenLoadingPane loadingPane = new OpenLoadingPane(); + private OpenFailedPane failedPane = new OpenFailedPane(); private JLayeredPane layeredPane = new JLayeredPane() { @Override public void doLayout() { @@ -36,8 +42,9 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener protected DesktopCardPane() { setLayout(new BorderLayout()); - layeredPane.add(transparentPane, 1); - layeredPane.add(loadingPane, 2); + layeredPane.add(transparentPane, TRANSPARENT_LAYER); + layeredPane.add(failedPane, FAILED_LAYER); + add(layeredPane, BorderLayout.CENTER); } protected void showJTemplate(final JTemplate jt) { @@ -53,7 +60,7 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener layeredPane.remove(component); } component = jt; - layeredPane.add(component, 0); + layeredPane.add(component, CONTENT_LAYER); checkSavingAndOpening(jt); add(layeredPane, BorderLayout.CENTER); validate(); @@ -69,18 +76,34 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener showCover(); } else if (jt.isOpening()) { showOpenStatus(); + } else if (jt.isOpenFailed()) { + showOpenFailedCover(); } else { hideCover(); } } + /** + * 让loadingPane懒加载 + */ + private void checkLoadingPane() { + if (layeredPane.getComponent(LOADING_LAYER) != loadingPane) { + layeredPane.add(loadingPane, LOADING_LAYER); + } + } + private void showOpenStatus() { DesignerContext.getDesignerFrame().refreshUIToolBar(); DesignerFrameFileDealerPane.getInstance().stateChange(); EastRegionContainerPane.getInstance().updateAllPropertyPane(); + checkLoadingPane(); layeredPane.moveToFront(loadingPane); } + public void showOpenFailedCover() { + layeredPane.moveToFront(failedPane); + } + public void showCover() { layeredPane.moveToFront(transparentPane); DesignerContext.getDesignerFrame().refreshUIToolBar(); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java index 8097d02f40..e55526408c 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java @@ -794,7 +794,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { public void setEnabled(boolean isEnabled) { JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (template != null) { - this.isEnabled = isEnabled && !template.isOpening() && !template.isSaving(); + this.isEnabled = isEnabled && template.checkEnable(); } else { this.isEnabled = isEnabled; } @@ -843,8 +843,10 @@ public class EastRegionContainerPane extends UIEastResizableContainer { } public void replaceContentPane(JComponent pane) { - contentArea.remove(this.contentPane); - contentArea.add(this.contentPane = pane); + if (pane != this.contentPane) { + contentArea.remove(this.contentPane); + contentArea.add(this.contentPane = pane); + } if (popupDialog != null && isPoppedOut) { popupDialog.replaceContentPane(this); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index f8af057eff..d9c98ce4a0 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -119,6 +119,7 @@ public abstract class JTemplate> protected TimeConsumeTimer consumeTimer = new TimeConsumeTimer(); private volatile boolean saving = false; private volatile boolean opening = false; + private volatile boolean openFailed = false; private PluginEventListener pluginListener; @@ -1601,8 +1602,16 @@ public abstract class JTemplate> this.opening = opening; } + public boolean isOpenFailed() { + return openFailed; + } + + public void setOpenFailed(boolean openFailed) { + this.openFailed = openFailed; + } + public boolean checkEnable() { - return !isSaving() && !isOpening(); + return !isSaving() && !isOpening() && !isOpenFailed(); } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/OpenFailedPane.java b/designer-base/src/main/java/com/fr/design/mainframe/OpenFailedPane.java new file mode 100644 index 0000000000..101585abb3 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/OpenFailedPane.java @@ -0,0 +1,92 @@ +package com.fr.design.mainframe; + +import com.fr.design.dialog.link.MessageWithLink; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.general.IOUtils; +import com.fr.stable.StringUtils; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.LayoutManager; +import javax.swing.JPanel; +import javax.swing.event.HyperlinkEvent; +import javax.swing.event.HyperlinkListener; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/4/20 + */ +public class OpenFailedPane extends JPanel { + + private UILabel label; + private MessageWithLink link; + + public OpenFailedPane() { + this.setLayout(new LayoutManager() { + @Override + public void addLayoutComponent(String name, Component comp) { + + } + + @Override + public void removeLayoutComponent(Component comp) { + + } + + @Override + public Dimension preferredLayoutSize(Container parent) { + return parent.getPreferredSize(); + } + + @Override + public Dimension minimumLayoutSize(Container parent) { + return null; + } + + @Override + public void layoutContainer(Container parent) { + int width = parent.getParent().getWidth(); + int height = parent.getParent().getHeight(); + int labelWidth = label.getPreferredSize().width; + int labelHeight = label.getPreferredSize().height; + int labelX = (width - labelWidth) / 2; + int labelY = (height - labelHeight) / 2; + int linkWidth = link.getPreferredSize().width; + int linkHeight = link.getPreferredSize().height; + int linkX = (width - linkWidth) / 2; + int linkY = (height - labelHeight) / 2 + labelHeight; + label.setBounds(labelX, labelY, labelWidth, labelHeight); + link.setBounds(linkX, linkY, linkWidth, linkHeight); + } + }); + this.setBackground(Color.WHITE); + label = new UILabel(IOUtils.readIcon("/com/fr/design/images/mainframe/open_failed.png"), UILabel.CENTER); + link = new MessageWithLink(Toolkit.i18nText("Fine-Design_Open_Failed_Tip"), Toolkit.i18nText("Fine-Design_Open_Failed_Retry"), StringUtils.EMPTY, Color.WHITE) { + @Override + protected void initListener(String link) { + addHyperlinkListener(new HyperlinkListener() { + @Override + public void hyperlinkUpdate(HyperlinkEvent e) { + if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { + // 重试 + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + template = JTemplateFactory.createJTemplate(template.getEditingFILE()); + DesignerContext.getDesignerFrame().addAndActivateJTemplate(template); + HistoryTemplateListCache.getInstance(). setCurrentEditingTemplate(template); + } + } + }); + } + }; + link.setBackground(Color.WHITE); + this.add(label); + this.add(link); + } + + + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/OpenLoadingPane.java b/designer-base/src/main/java/com/fr/design/mainframe/OpenLoadingPane.java index 5a81319739..9ee095c996 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/OpenLoadingPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/OpenLoadingPane.java @@ -1,7 +1,6 @@ package com.fr.design.mainframe; import com.fr.design.gui.ilable.UILabel; -import com.fr.general.IOUtils; import java.awt.Color; import java.awt.Component; import java.awt.Container; @@ -17,6 +16,8 @@ import javax.swing.JPanel; */ public class OpenLoadingPane extends JPanel { + private static final ImageIcon LOADING_ICON = new ImageIcon(OpenLoadingPane.class.getResource("/com/fr/design/images/mainframe/loading.gif")); + private UILabel loadingLabel; public OpenLoadingPane() { @@ -53,7 +54,7 @@ public class OpenLoadingPane extends JPanel { } }); setBackground(Color.WHITE); - loadingLabel = new UILabel(new ImageIcon(IOUtils.readImage("com/fr/plugin/chart/vanchart/export/loading.png"))); + loadingLabel = new UILabel(LOADING_ICON); add(loadingLabel); } diff --git a/designer-base/src/main/java/com/fr/design/menu/MenuDef.java b/designer-base/src/main/java/com/fr/design/menu/MenuDef.java index 55b80c0ec8..cee1658b91 100644 --- a/designer-base/src/main/java/com/fr/design/menu/MenuDef.java +++ b/designer-base/src/main/java/com/fr/design/menu/MenuDef.java @@ -411,7 +411,7 @@ public class MenuDef extends ShortCut { JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); boolean flag = true; if (template != null) { - flag = !template.isSaving() && !template.isOpening(); + flag = template.checkEnable(); } component.setEnabled(flag); if (!flag) { diff --git a/designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java b/designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java index f166020513..2da4d335ec 100644 --- a/designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java +++ b/designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java @@ -1,11 +1,15 @@ package com.fr.design.worker.open; +import com.fr.chart.exception.ChartNotFoundException; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrameFileDealerPane; import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.JTemplate; import com.fr.design.worker.WorkerManager; +import com.fr.exception.DecryptTemplateException; import com.fr.file.FILE; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; @@ -13,7 +17,9 @@ import java.util.concurrent.Callable; import java.util.concurrent.CancellationException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import javax.swing.JOptionPane; import javax.swing.SwingWorker; +import javax.swing.UIManager; /** * 模板打开的worker @@ -54,11 +60,34 @@ public class OpenWorker extends SwingWorker { result = get(); } catch (CancellationException ignored) { return; - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); + } catch (Throwable t) { + processFailed(); + Throwable cause = t.getCause(); + if (cause instanceof DecryptTemplateException) { + FineJOptionPane.showMessageDialog( + DesignerContext.getDesignerFrame(), + Toolkit.i18nText("Fine-Design_Encrypt_Decrypt_Exception"), + Toolkit.i18nText("Fine-Design_Basic_Alert"), + JOptionPane.WARNING_MESSAGE, + UIManager.getIcon("OptionPane.errorIcon") + ); + } + if (cause instanceof ChartNotFoundException) { + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), + Toolkit.i18nText("Fine-Design_Chart_Not_Found_Exception"), + Toolkit.i18nText("Fine-Design_Basic_Error"), + JOptionPane.ERROR_MESSAGE, + UIManager.getIcon("OptionPane.errorIcon")); + } + FineLoggerFactory.getLogger().error(t.getMessage(), t); + return; } - this.template.setOpening(false); // 后续动作 + processResult(); + } + + private void processResult() { + this.template.setOpening(false); if (slowly && templateCallable != null) { try { JTemplate book = templateCallable.call(); @@ -89,6 +118,15 @@ public class OpenWorker extends SwingWorker { WorkerManager.getInstance().removeWorker(taskName); } + private void processFailed() { + this.template.setOpenFailed(true); + this.template.setOpening(false); + DesignerContext.getDesignerFrame().getCenterTemplateCardPane().showOpenFailedCover(); + DesignerFrameFileDealerPane.getInstance().stateChange(); + WorkerManager.getInstance().removeWorker(taskName); + + } + public void addCallBack(Callable> templateCallable) { this.templateCallable = templateCallable; } diff --git a/designer-base/src/main/resources/com/fr/design/images/m_file/preview_disabled.svg b/designer-base/src/main/resources/com/fr/design/images/m_file/preview_disabled.svg index 2b0ad52e74..6f2c4afa1f 100644 --- a/designer-base/src/main/resources/com/fr/design/images/m_file/preview_disabled.svg +++ b/designer-base/src/main/resources/com/fr/design/images/m_file/preview_disabled.svg @@ -1,11 +1,7 @@ - - icon_报表web属性_打印预览_normal - - - - - - + + icon_预览_disabled + + \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/images/mainframe/loading.gif b/designer-base/src/main/resources/com/fr/design/images/mainframe/loading.gif new file mode 100644 index 0000000000..c77b4fe100 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/mainframe/loading.gif differ diff --git a/designer-base/src/main/resources/com/fr/design/images/mainframe/open_failed.png b/designer-base/src/main/resources/com/fr/design/images/mainframe/open_failed.png new file mode 100644 index 0000000000..0d43a117fb Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/mainframe/open_failed.png differ