|
|
|
@ -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<T> extends SwingWorker<T, Void> {
|
|
|
|
|
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<T> extends SwingWorker<T, Void> {
|
|
|
|
|
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<JTemplate<?, ?>> templateCallable) { |
|
|
|
|
this.templateCallable = templateCallable; |
|
|
|
|
} |
|
|
|
|