@ -7,12 +7,14 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext ;
import com.fr.design.mainframe.DesignerFrameFileDealerPane ;
import com.fr.design.mainframe.JTemplate ;
import com.fr.design.utils.DesignUtils ;
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 ;
import com.fr.stable.StringUtils ;
import javax.swing.JOptionPane ;
import javax.swing.SwingWorker ;
import javax.swing.UIManager ;
@ -51,6 +53,7 @@ public class OpenWorker<T> extends SwingWorker<T, Void> {
@Override
protected T doInBackground ( ) throws Exception {
TimeUnit . SECONDS . sleep ( 5 ) ;
return this . callable . call ( ) ;
}
@ -61,7 +64,7 @@ public class OpenWorker<T> extends SwingWorker<T, Void> {
} catch ( CancellationException ignored ) {
return ;
} catch ( Throwable t ) {
processFailed ( ) ;
processFailed ( StringUtils . EMPTY ) ;
Throwable cause = t . getCause ( ) ;
if ( cause instanceof DecryptTemplateException ) {
FineJOptionPane . showMessageDialog (
@ -91,6 +94,11 @@ public class OpenWorker<T> extends SwingWorker<T, Void> {
if ( slowly & & templateCallable ! = null ) {
try {
JTemplate < ? , ? > book = templateCallable . call ( ) ;
if ( inValidDesigner ( book ) ) {
String text = Toolkit . i18nText ( "Fine-Design_Report_Template_Version_Not_Match" , DesignUtils . parseVersion ( book . getTarget ( ) . getDesignerVersion ( ) ) ) ;
processFailed ( text ) ;
return ;
}
FILE tplFile = book . getEditingFILE ( ) ;
JTemplate < ? , ? > currentTemplate = HistoryTemplateListCache . getInstance ( ) . getCurrentEditingTemplate ( ) ;
// 当前tab页是正在打开的模板
@ -117,11 +125,21 @@ public class OpenWorker<T> extends SwingWorker<T, Void> {
WorkerManager . getInstance ( ) . removeWorker ( taskName ) ;
}
private void processFailed ( ) {
private boolean inValidDesigner ( JTemplate < ? , ? > jt ) {
return jt . isOldDesigner ( false ) | | ( ! jt . isJWorkBook ( ) & & jt . isNewDesigner ( false ) ) ;
}
private void processFailed ( String text ) {
this . template . setOpenFailed ( true ) ;
this . template . setOpening ( false ) ;
DesignerContext . getDesignerFrame ( ) . getCenterTemplateCardPane ( ) . showOpenFailedCover ( ) ;
DesignerFrameFileDealerPane . getInstance ( ) . stateChange ( ) ;
JTemplate < ? , ? > currentTemplate = HistoryTemplateListCache . getInstance ( ) . getCurrentEditingTemplate ( ) ;
// 需要判断当前打开的模板是不是异步执行后失败的模板 是的话立即展示失败后的提示内容 否则只设置下失败的提示内容
if ( ComparatorUtils . equals ( currentTemplate . getEditingFILE ( ) . getName ( ) , this . template . getName ( ) ) ) {
DesignerContext . getDesignerFrame ( ) . getCenterTemplateCardPane ( ) . showOpenFailedCover ( text ) ;
DesignerFrameFileDealerPane . getInstance ( ) . stateChange ( ) ;
} else {
this . template . setTemplateOpenFailedTip ( text ) ;
}
WorkerManager . getInstance ( ) . removeWorker ( taskName ) ;
}