@ -9,6 +9,7 @@ import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.UpdateAction ;
import com.fr.design.actions.UpdateAction ;
import com.fr.design.constants.UIConstants ;
import com.fr.design.constants.UIConstants ;
import com.fr.design.data.BasicTableDataTreePane ;
import com.fr.design.data.BasicTableDataTreePane ;
import com.fr.design.data.BasicTableDataUtils ;
import com.fr.design.data.DesignTableDataManager ;
import com.fr.design.data.DesignTableDataManager ;
import com.fr.design.data.tabledata.StoreProcedureWorkerListener ;
import com.fr.design.data.tabledata.StoreProcedureWorkerListener ;
import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane ;
import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane ;
@ -59,7 +60,7 @@ import java.util.Map;
public class TableDataTreePane extends BasicTableDataTreePane {
public class TableDataTreePane extends BasicTableDataTreePane {
private static TableDataTreePane singleton = new TableDataTreePane ( ) ;
private static TableDataTreePane singleton = new TableDataTreePane ( ) ;
public static final int PLUGIN_LISTENER_PRIORITY = 1 ;
public static final int PLUGIN_LISTENER_PRIORITY = 1 ;
public synchronized static BasicTableDataTreePane getInstance ( DesignModelAdapter < ? , ? > tc ) {
public synchronized static BasicTableDataTreePane getInstance ( DesignModelAdapter < ? , ? > tc ) {
@ -96,10 +97,10 @@ public class TableDataTreePane extends BasicTableDataTreePane {
addMenuDef . setIconPath ( IconPathConstants . ADD_POPMENU_ICON_PATH ) ;
addMenuDef . setIconPath ( IconPathConstants . ADD_POPMENU_ICON_PATH ) ;
createAddMenuDef ( ) ;
createAddMenuDef ( ) ;
// 创建插件监听
// 创建插件监听
createPluginListener ( ) ;
createPluginListener ( ) ;
editAction = new EditAction ( ) ;
editAction = new EditAction ( ) ;
removeAction = new RemoveAction ( ) ;
removeAction = new RemoveAction ( ) ;
previewTableDataAction = new PreviewTableDataAction ( dataTree ) ;
previewTableDataAction = new PreviewTableDataAction ( dataTree ) ;
@ -139,27 +140,27 @@ public class TableDataTreePane extends BasicTableDataTreePane {
new TableDataTreeDragSource ( dataTree , DnDConstants . ACTION_COPY ) ;
new TableDataTreeDragSource ( dataTree , DnDConstants . ACTION_COPY ) ;
checkButtonEnabled ( ) ;
checkButtonEnabled ( ) ;
}
}
private void createPluginListener ( ) {
private void createPluginListener ( ) {
//菜单栏监听
//菜单栏监听
GeneralContext . listenPluginRunningChanged ( new PluginEventListener ( PLUGIN_LISTENER_PRIORITY ) {
GeneralContext . listenPluginRunningChanged ( new PluginEventListener ( PLUGIN_LISTENER_PRIORITY ) {
@Override
@Override
public void on ( PluginEvent event ) {
public void on ( PluginEvent event ) {
addMenuDef . clearShortCuts ( ) ;
addMenuDef . clearShortCuts ( ) ;
createAddMenuDef ( ) ;
createAddMenuDef ( ) ;
}
}
} , new PluginFilter ( ) {
} , new PluginFilter ( ) {
@Override
@Override
public boolean accept ( PluginContext context ) {
public boolean accept ( PluginContext context ) {
return context . contain ( PluginModule . ExtraDesign ) ;
return context . contain ( PluginModule . ExtraDesign ) ;
}
}
} ) ;
} ) ;
//监听数据集插件
//监听数据集插件
GeneralContext . listenPluginRunningChanged ( new PluginEventListener ( ) {
GeneralContext . listenPluginRunningChanged ( new PluginEventListener ( ) {
@Override
@Override
@ -188,8 +189,8 @@ public class TableDataTreePane extends BasicTableDataTreePane {
}
}
} ) ;
} ) ;
}
}
protected void checkButtonEnabled ( ) {
protected void checkButtonEnabled ( ) {
super . checkButtonEnabled ( editAction , previewTableDataAction , removeAction , op , dataTree ) ;
super . checkButtonEnabled ( editAction , previewTableDataAction , removeAction , op , dataTree ) ;
}
}
@ -339,10 +340,11 @@ public class TableDataTreePane extends BasicTableDataTreePane {
/ * *
/ * *
* 合并数据集
* 合并数据集
* @param srcName 数据集来源 ( 比如报表块 , 就是报表块的名称 )
*
* @param srcName 数据集来源 ( 比如报表块 , 就是报表块的名称 )
* @param tableDataSource 数据集
* @param tableDataSource 数据集
* /
* /
public Map < String , String > addTableData ( String srcName , TableDataSource tableDataSource ) {
public Map < String , String > addTableData ( String srcName , TableDataSource tableDataSource , boolean isCover ) {
Map < String , String > tdNameMap = new HashMap < > ( ) ;
Map < String , String > tdNameMap = new HashMap < > ( ) ;
allDSNames = DesignTableDataManager . getAllDSNames ( tc . getBook ( ) ) ;
allDSNames = DesignTableDataManager . getAllDSNames ( tc . getBook ( ) ) ;
DesignTableDataManager . setThreadLocal ( DesignTableDataManager . NO_PARAMETER ) ;
DesignTableDataManager . setThreadLocal ( DesignTableDataManager . NO_PARAMETER ) ;
@ -352,14 +354,8 @@ public class TableDataTreePane extends BasicTableDataTreePane {
String tdName = ( String ) tdIterator . next ( ) ;
String tdName = ( String ) tdIterator . next ( ) ;
String oldName = tdName ;
String oldName = tdName ;
TableData td = tableDataSource . getTableData ( tdName ) ;
TableData td = tableDataSource . getTableData ( tdName ) ;
if ( tds . getTableData ( tdName ) ! = null | | isDsNameRepeaded ( tdName ) ) { //如果有同名的就拼上来源名称
boolean isDsNameRepeaded = isDsNameRepeaded ( tdName ) ;
tdName = srcName + tdName ;
tdName = BasicTableDataUtils . getTableDataName ( isCover , tds , tdName , srcName , isDsNameRepeaded ) ;
}
int i = 0 ;
while ( tds . getTableData ( tdName ) ! = null ) {
i + + ; //如果拼上名字后依然已经存在就加编号
tdName + = i ;
}
tds . putTableData ( tdName , td ) ;
tds . putTableData ( tdName , td ) ;
if ( ! ComparatorUtils . equals ( oldName , tdName ) ) {
if ( ! ComparatorUtils . equals ( oldName , tdName ) ) {
tdNameMap . put ( oldName , tdName ) ;
tdNameMap . put ( oldName , tdName ) ;
@ -367,8 +363,19 @@ public class TableDataTreePane extends BasicTableDataTreePane {
}
}
tc . parameterChanged ( ) ;
tc . parameterChanged ( ) ;
dataTree . refresh ( ) ;
dataTree . refresh ( ) ;
return Collections . unmodifiableMap ( tdNameMap ) ;
return Collections . unmodifiableMap ( tdNameMap ) ;
}
}
@Override
public void removeTableData ( String sourceName ) {
TableDataSource tds = tc . getBook ( ) ;
tds . removeTableData ( sourceName ) ;
dataTree . refresh ( ) ;
}
public void addDataPane ( final AbstractTableDataPane < ? > uPanel , String paneName ) {
public void addDataPane ( final AbstractTableDataPane < ? > uPanel , String paneName ) {
final NamePane nPanel = uPanel . asNamePane ( ) ;
final NamePane nPanel = uPanel . asNamePane ( ) ;
nPanel . setObjectName ( paneName ) ;
nPanel . setObjectName ( paneName ) ;