@ -24,9 +24,11 @@ import java.awt.BorderLayout;
public class CellWidgetPropertyPane extends BasicPane {
public class CellWidgetPropertyPane extends BasicPane {
private static CellWidgetPropertyPane singleton ;
private static CellWidgetPropertyPane singleton ;
//当前控件板对应的单元格
private TemplateCellElement cellElement ;
private TemplateCellElement cellElement ;
//右侧控件板
private WidgetPane cellEditorDefPane ;
private WidgetPane cellEditorDefPane ;
//左侧单元格板
private ElementCasePane ePane ;
private ElementCasePane ePane ;
public static CellWidgetPropertyPane getInstance ( ) {
public static CellWidgetPropertyPane getInstance ( ) {
@ -79,6 +81,11 @@ public class CellWidgetPropertyPane extends BasicPane {
}
}
/ * *
* 重初始化 。 选中单元格会走到这
*
* @param ePane 单元格板
* /
public void reInit ( ElementCasePane ePane ) {
public void reInit ( ElementCasePane ePane ) {
this . ePane = ePane ;
this . ePane = ePane ;
cellEditorDefPane = new WidgetPane ( ePane ) ;
cellEditorDefPane = new WidgetPane ( ePane ) ;
@ -101,14 +108,43 @@ public class CellWidgetPropertyPane extends BasicPane {
editingSelection . populateWidgetPropertyPane ( ePane ) ;
editingSelection . populateWidgetPropertyPane ( ePane ) ;
}
}
/ * *
* 将控件板中的内容更新到当前选择的单元格项中
* /
public void update ( ) {
public void update ( ) {
if ( ePane = = null ) {
return ;
}
//当前单元格板选中的单元格
CellSelection finalCS = ( CellSelection ) ePane . getSelection ( ) ;
if ( cellElement = = null | | ! cellEditorDefPane . isShouldFireSelectedEvent ( ) ) {
if ( cellElement = = null | | ! cellEditorDefPane . isShouldFireSelectedEvent ( ) ) {
return ;
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 TemplateElementCase tplEC = ePane . getEditingElementCase ( ) ;
final Widget cellWidget = cellEditorDefPane . update ( ) ;
final Widget cellWidget = cellEditorDefPane . update ( ) ;
if ( cellWidget = = null ) {
if ( cellWidget = = null ) {
return ;
return ;
}
}
if ( finalCS . isSelectedOneCell ( ePane ) ) {
if ( finalCS . isSelectedOneCell ( ePane ) ) {
@ -122,8 +158,7 @@ public class CellWidgetPropertyPane extends BasicPane {
}
}
setCellWidget ( cellWidget , cellElement ) ;
setCellWidget ( cellWidget , cellElement ) ;
} else {
} else {
ReportActionUtils . actionIterateWithCellSelection ( finalCS , tplEC , new ReportActionUtils . IterAction ( ) {
ReportActionUtils . actionIterateWithCellSelection ( finalCS , tplEC , editCellElement - > {
public void dealWith ( CellElement editCellElement ) {
// p:最后把这个cellEditorDef设置到CellGUIAttr.
// p:最后把这个cellEditorDef设置到CellGUIAttr.
TemplateCellElement templateCellElement = ( TemplateCellElement ) editCellElement ;
TemplateCellElement templateCellElement = ( TemplateCellElement ) editCellElement ;
try {
try {
@ -131,7 +166,6 @@ public class CellWidgetPropertyPane extends BasicPane {
} catch ( CloneNotSupportedException e ) {
} catch ( CloneNotSupportedException e ) {
FineLoggerFactory . getLogger ( ) . error ( "InternalError: " + e . getMessage ( ) ) ;
FineLoggerFactory . getLogger ( ) . error ( "InternalError: " + e . getMessage ( ) ) ;
}
}
}
} ) ;
} ) ;
}
}
if ( DesignerContext . getDesignerFrame ( ) . getSelectedJTemplate ( ) ! = null ) {
if ( DesignerContext . getDesignerFrame ( ) . getSelectedJTemplate ( ) ! = null ) {
@ -139,42 +173,7 @@ public class CellWidgetPropertyPane extends BasicPane {
}
}
}
}
public void update ( Selection selection ) {
private void setCellWidget ( Widget cellWidget , TemplateCellElement cellElement ) {
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 ) {
if ( cellWidget instanceof NoneWidget ) {
if ( cellWidget instanceof NoneWidget ) {
cellElement . setWidget ( null ) ;
cellElement . setWidget ( null ) ;
} else {
} else {
@ -185,7 +184,10 @@ public class CellWidgetPropertyPane extends BasicPane {
}
}
}
}
public void reInitAllListener ( ) {
/ * *
* 刷新所有监听器
* /
public void reInitAllListener ( ) {
cellEditorDefPane . registerListener ( ) ;
cellEditorDefPane . registerListener ( ) ;
}
}