@ -57,6 +57,8 @@ import java.util.Enumeration;
import java.util.Objects ;
import java.util.Observable ;
import java.util.Observer ;
import org.jetbrains.annotations.Nullable ;
import static javax.swing.JOptionPane.WARNING_MESSAGE ;
import static javax.swing.JOptionPane.YES_NO_OPTION ;
@ -226,17 +228,17 @@ public class TemplateTreePane extends JPanel implements FileOperations {
}
String reportPath = reportletsTree . getSelectedTemplatePath ( ) ;
final String selectedFilePath = StableUtils . pathJoin ( ProjectConstants . REPORTLETS_NAME , reportPath ) ;
if ( hasOpenedTemplate ( selectedFilePath ) ) {
FineLoggerFactory . getLogger ( ) . info ( "{} has been opened in designer tab" , selectedFilePath ) ;
return ;
}
String lock = node . getLock ( ) ;
boolean showLockInfo = LockInfoUtils . isCompatibleOperator ( ) | | LockInfoUtils . unableGetLockInfo ( )
boolean showLockInfo = LockInfoUtils . isCompatibleOperator ( )
| | LockInfoUtils . unableGetLockInfo ( )
| | WorkContext . getCurrent ( ) . get ( LockInfoOperator . class ) . isTplUnLocked ( selectedFilePath )
? ( lock ! = null & & ! lock . equals ( node . getUserID ( ) ) )
: WorkContext . getCurrent ( ) . get ( LockInfoOperator . class ) . isTplLocked ( selectedFilePath ) ;
if ( showLockInfo ) {
UserInfo userInfo = WorkContext . getCurrent ( ) . get ( LockInfoOperator . class ) . getUserInfo ( selectedFilePath ) ;
node . setLock ( UUID . randomUUID ( ) . toString ( ) ) ;
// 对于开发者预览占位锁定 定位到tab中
checkDevelopForBiddenTemplate ( selectedFilePath ) ;
LockInfoDialog . show ( userInfo ) ;
return ;
} else {
@ -245,14 +247,21 @@ public class TemplateTreePane extends JPanel implements FileOperations {
DesignerContext . getDesignerFrame ( ) . openTemplate ( new FileNodeFILE ( new FileNode ( selectedFilePath , false ) ) ) ;
}
private void checkDevelopForBiddenTemplate ( String selectedFilePath ) {
JTemplate < ? , ? > template = getOpenedTemplate ( selectedFilePath ) ;
if ( template ! = null & & template . isForbidden ( ) ) {
DesignerContext . getDesignerFrame ( ) . openTemplate ( new FileNodeFILE ( new FileNode ( selectedFilePath , false ) ) ) ;
}
}
private boolean hasOpenedTemplate ( String path ) {
@Nullable
private JTemplate < ? , ? > getOpenedTemplate ( String path ) {
for ( JTemplate < ? , ? > template : HistoryTemplateListCache . getInstance ( ) . getHistoryList ( ) ) {
if ( ComparatorUtils . equals ( template . getEditingFILE ( ) . getPath ( ) , path ) ) {
return true ;
return templat e;
}
}
return false ;
return null ;
}
/ * *