@ -4,6 +4,7 @@ import com.fr.base.svg.IconUtils;
import com.fr.design.dialog.FineJOptionPane ;
import com.fr.design.file.HistoryTemplateListCache ;
import com.fr.design.file.MultiTemplateTabPane ;
import com.fr.design.file.TemplateTreePane ;
import com.fr.design.gui.ilable.UILabel ;
import com.fr.design.i18n.Toolkit ;
import com.fr.design.mainframe.DesignerContext ;
@ -16,10 +17,15 @@ import com.fr.design.mainframe.vcs.common.VcsCacheFileNodeFile;
import com.fr.design.mainframe.vcs.common.VcsHelper ;
import com.fr.file.FileNodeFILE ;
import com.fr.file.filetree.FileNode ;
import com.fr.file.filetree.FileNodes ;
import com.fr.io.utils.ResourceIOUtils ;
import com.fr.report.InconsistentLockException ;
import com.fr.report.entity.VcsEntity ;
import com.fr.stable.StableUtils ;
import com.fr.stable.StringUtils ;
import com.fr.stable.project.ProjectConstants ;
import com.fr.workspace.WorkContext ;
import com.fr.workspace.resource.WorkResource ;
import com.fr.workspace.server.vcs.VcsFileUtils ;
import com.fr.workspace.server.vcs.VcsOperator ;
import com.fr.workspace.server.vcs.v2.VcsTaskResult ;
@ -29,6 +35,7 @@ import javax.swing.JComponent;
import javax.swing.JOptionPane ;
import javax.swing.JTable ;
import javax.swing.SwingWorker ;
import javax.swing.UIManager ;
import java.awt.* ;
import java.awt.event.MouseAdapter ;
import java.awt.event.MouseEvent ;
@ -179,9 +186,12 @@ public class VcsNewPane extends RecyclePane {
@Override
protected VcsTaskResult doInBackground ( ) throws Exception {
String path = VcsHelper . getInstance ( ) . getFilePath ( entity ) ;
if ( ! ResourceIOUtils . exist ( path ) ) {
if ( ! WorkContext . getCurrent ( ) . get ( WorkResource . class ) . exist ( path ) ) {
return new VcsTaskResult ( false , new FileNotFoundException ( ) ) ;
}
if ( checkLock ( entity . getFilename ( ) ) ) {
return new VcsTaskResult ( false , new InconsistentLockException ( ) ) ;
}
//step1.设置还原的用户名
entity . setUsername ( VcsHelper . getInstance ( ) . getCurrentUsername ( ) ) ;
//step2.rollback到指定版本
@ -206,7 +216,11 @@ public class VcsNewPane extends RecyclePane {
}
DesignerContext . getDesignerFrame ( ) . openTemplate ( new FileNodeFILE ( new FileNode ( filePath , false ) ) ) ;
} else {
FineJOptionPane . showMessageDialog ( DesignerContext . getDesignerFrame ( ) , Toolkit . i18nText ( "Fine-Design_Basic_Warning_Template_Do_Not_Exsit" ) ) ;
if ( result . getException ( ) instanceof FileNotFoundException ) {
FineJOptionPane . showMessageDialog ( DesignerContext . getDesignerFrame ( ) , Toolkit . i18nText ( "Fine-Design_Basic_Warning_Template_Do_Not_Exsit" ) ) ;
} else {
FineJOptionPane . showMessageDialog ( DesignerContext . getDesignerFrame ( ) , Toolkit . i18nText ( "Fine-Design_Vcs_Open_Lock_Tip" ) , UIManager . getString ( "OptionPane.messageDialogTitle" ) , JOptionPane . ERROR_MESSAGE ) ;
}
}
} catch ( InterruptedException | ExecutionException e ) {
throw new RuntimeException ( e ) ;
@ -215,6 +229,19 @@ public class VcsNewPane extends RecyclePane {
} . execute ( ) ;
}
private boolean checkLock ( String filename ) {
String selectedFilePath = getTemplateTruePath ( filename ) ;
FileNode node = new FileNode ( getTemplateTruePath ( filename ) , false ) ;
String lock = node . getLock ( ) ;
return TemplateTreePane . needShowLockInfo ( lock , selectedFilePath , node ) ;
}
/ * *
* 获取模板的路径
* /
public String getTemplateTruePath ( String filename ) {
return StableUtils . pathJoin ( ProjectConstants . REPORTLETS_NAME , filename ) ;
}
private void initDeleteListener ( ) {
delete . addMouseListener ( new MouseAdapter ( ) {