@ -24,9 +24,11 @@ import java.awt.BorderLayout;
public class CellWidgetPropertyPane extends BasicPane {
private static CellWidgetPropertyPane singleton ;
//当前控件板对应的单元格
private TemplateCellElement cellElement ;
//右侧控件板
private WidgetPane cellEditorDefPane ;
//左侧单元格板
private ElementCasePane ePane ;
public static CellWidgetPropertyPane getInstance ( ) {
@ -79,6 +81,11 @@ public class CellWidgetPropertyPane extends BasicPane {
}
/ * *
* 重初始化 。 选中单元格会走到这
*
* @param ePane 单元格板
* /
public void reInit ( ElementCasePane ePane ) {
this . ePane = ePane ;
cellEditorDefPane = new WidgetPane ( ePane ) ;
@ -101,14 +108,43 @@ public class CellWidgetPropertyPane extends BasicPane {
editingSelection . populateWidgetPropertyPane ( ePane ) ;
}
/ * *
* 将控件板中的内容更新到当前选择的单元格项中
* /
public void update ( ) {
if ( ePane = = null ) {
return ;
}
//当前单元格板选中的单元格
CellSelection finalCS = ( CellSelection ) ePane . getSelection ( ) ;
if ( cellElement = = null | | ! cellEditorDefPane . isShouldFireSelectedEvent ( ) ) {
return ;
}
final CellSelection finalCS = ( CellSelection ) ePane . getSelection ( ) ;
doUpdate ( finalCS ) ;
}
/ * *
* 将控件板中的内容更新到指定单元格项中
* ( js事件的提交入库事件选择单元格时 , ePane . getSelection ( ) 是左侧选择的单元格 , 不是右侧控件板对应的单元格 。 这时候假如走无参的方法就有问题 )
*
* @param selection 当前选中项
* /
public void update ( Selection selection ) {
if ( cellElement = = null | | ! cellEditorDefPane . isShouldFireSelectedEvent ( ) ) {
return ;
}
CellSelection finalCS = ( CellSelection ) selection ;
//假如指定单元格项和当前控件板对应的单元格不同,则跳过
if ( finalCS . getColumn ( ) ! = cellElement . getColumn ( ) | | finalCS . getRow ( ) ! = cellElement . getRow ( ) ) {
return ;
}
doUpdate ( finalCS ) ;
}
private void doUpdate ( CellSelection finalCS ) {
final TemplateElementCase tplEC = ePane . getEditingElementCase ( ) ;
final Widget cellWidget = cellEditorDefPane . update ( ) ;
if ( cellWidget = = null ) {
if ( cellWidget = = null ) {
return ;
}
if ( finalCS . isSelectedOneCell ( ePane ) ) {
@ -122,15 +158,13 @@ public class CellWidgetPropertyPane extends BasicPane {
}
setCellWidget ( cellWidget , cellElement ) ;
} else {
ReportActionUtils . actionIterateWithCellSelection ( finalCS , tplEC , new ReportActionUtils . IterAction ( ) {
public void dealWith ( CellElement editCellElement ) {
// p:最后把这个cellEditorDef设置到CellGUIAttr.
TemplateCellElement templateCellElement = ( TemplateCellElement ) editCellElement ;
try {
setCellWidget ( ( Widget ) cellWidget . clone ( ) , templateCellElement ) ;
} catch ( CloneNotSupportedException e ) {
FineLoggerFactory . getLogger ( ) . error ( "InternalError: " + e . getMessage ( ) ) ;
}
ReportActionUtils . actionIterateWithCellSelection ( finalCS , tplEC , editCellElement - > {
// p:最后把这个cellEditorDef设置到CellGUIAttr.
TemplateCellElement templateCellElement = ( TemplateCellElement ) editCellElement ;
try {
setCellWidget ( ( Widget ) cellWidget . clone ( ) , templateCellElement ) ;
} catch ( CloneNotSupportedException e ) {
FineLoggerFactory . getLogger ( ) . error ( "InternalError: " + e . getMessage ( ) ) ;
}
} ) ;
}
@ -139,42 +173,7 @@ public class CellWidgetPropertyPane extends BasicPane {
}
}
public void update ( Selection selection ) {
if ( cellElement = = null | | ! cellEditorDefPane . isShouldFireSelectedEvent ( ) ) {
return ;
}
final CellSelection finalCS = ( CellSelection ) selection ;
final TemplateElementCase tplEC = ePane . getEditingElementCase ( ) ;
final Widget cellWidget = cellEditorDefPane . update ( ) ;
if ( cellWidget = = null ) {
return ;
}
if ( finalCS . isSelectedOneCell ( ePane ) ) {
if ( tplEC . getTemplateCellElement ( cellElement . getColumn ( ) , cellElement . getRow ( ) ) = = null ) { //cellElement未加入到report中时要添加进去
tplEC . addCellElement ( cellElement ) ;
} else {
cellElement = tplEC . getTemplateCellElement ( finalCS . getColumn ( ) , finalCS . getRow ( ) ) ;
}
setCellWidget ( cellWidget , cellElement ) ;
} else {
ReportActionUtils . actionIterateWithCellSelection ( finalCS , tplEC , new ReportActionUtils . IterAction ( ) {
public void dealWith ( CellElement editCellElement ) {
// p:最后把这个cellEditorDef设置到CellGUIAttr.
TemplateCellElement templateCellElement = ( TemplateCellElement ) editCellElement ;
try {
setCellWidget ( ( Widget ) cellWidget . clone ( ) , templateCellElement ) ;
} catch ( CloneNotSupportedException e ) {
FineLoggerFactory . getLogger ( ) . error ( "InternalError: " + e . getMessage ( ) ) ;
}
}
} ) ;
}
if ( DesignerContext . getDesignerFrame ( ) . getSelectedJTemplate ( ) ! = null ) {
DesignerContext . getDesignerFrame ( ) . getSelectedJTemplate ( ) . fireTargetModified ( ) ;
}
}
private void setCellWidget ( Widget cellWidget , TemplateCellElement cellElement ) {
private void setCellWidget ( Widget cellWidget , TemplateCellElement cellElement ) {
if ( cellWidget instanceof NoneWidget ) {
cellElement . setWidget ( null ) ;
} else {
@ -185,7 +184,10 @@ public class CellWidgetPropertyPane extends BasicPane {
}
}
public void reInitAllListener ( ) {
/ * *
* 刷新所有监听器
* /
public void reInitAllListener ( ) {
cellEditorDefPane . registerListener ( ) ;
}