@ -50,9 +50,9 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.TableModelEvent ;
import javax.swing.event.TableModelListener ;
import javax.swing.table.TableCellEditor ;
import javax.swing.table.TableCellRenderer ;
import java.awt.BorderLayout ;
import java.awt.CardLayout ;
import java.awt.Color ;
import java.awt.Component ;
import java.awt.event.ActionEvent ;
import java.awt.event.ActionListener ;
@ -86,6 +86,7 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
private static final String CUSTOM = "custom" ;
private static final String CURRENT_TEMPLATE = "cur" ;
private static final String OTHER_TEMPLATE = "other" ;
private static final UILabel EMPTY_LABEL = new UILabel ( ) ;
static {
EXPORT_TYPES_MAP . put ( ExportJavaScript . EXPORT_PDF , Toolkit . i18nText ( "Fine-Design_Basic_Export_JS_PDF" ) ) ;
@ -245,14 +246,16 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
ParameterSettingButton . class
} ) ;
this . setDefaultEditor ( ExportTemplateChooser . class , new ExportTemplateChooser ( ) ) ;
this . setDefaultRenderer ( ExportTemplateChooser . class , new ExportTemplateChooser ( ) ) ;
this . setDefaultEditor ( ExportTypeCombobox . class , new ExportTypeCombobox ( ) ) ;
this . setDefaultEditor ( FileNameCombobox . class , new FileNameCombobox ( ) ) ;
this . setDefaultEditor ( FileNameFormulaEditor . class , new FileNameFormulaEditor ( ) ) ;
this . setDefaultEditor ( ParameterCombobox . class , new ParameterCombobox ( ) ) ;
this . setDefaultEditor ( ParameterSettingButton . class , new ParameterSettingButton ( ) ) ;
this . setDefaultRenderer ( ParameterSettingButton . class , new ParameterSettingButton ( ) ) ;
this . createTable ( ) . getColumnModel ( ) . getColumn ( 2 ) . setMaxWidth ( 60 ) ;
this . createTable ( ) . getColumnModel ( ) . getColumn ( 4 ) . setMaxWidth ( 60 ) ;
this . createTable ( ) . getColumnModel ( ) . getColumn ( 5 ) . setMaxWidth ( 4 0) ;
this . createTable ( ) . getColumnModel ( ) . getColumn ( 5 ) . setMaxWidth ( 5 0) ;
}
@Override
@ -286,10 +289,6 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
// 命名详情
return this . getList ( ) . get ( row ) ! = null & & ! this . getList ( ) . get ( row ) . isDefaultFileName ( ) ;
}
if ( col = = 5 ) {
// 参数设置按钮
return this . getList ( ) . get ( row ) ! = null & & ! this . getList ( ) . get ( row ) . isExtendParameters ( ) ;
}
return true ;
}
@ -318,7 +317,7 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
}
// 导出文件选择
class ExportTemplateChooser extends AbstractCellEditor implements TableCellEditor {
class ExportTemplateChooser extends AbstractCellEditor implements TableCellEditor , TableCellRenderer {
private static final long serialVersionUID = - 9112506131272704717L ;
private JPanel reportletNamePane ;
@ -387,6 +386,12 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
public Object getCellEditorValue ( ) {
return reportPathTextField . getText ( ) ;
}
@Override
public Component getTableCellRendererComponent ( JTable table , Object value , boolean isSelected , boolean hasFocus , int row , int column ) {
reportPathTextField . setText ( ( String ) value ) ;
return reportletNamePane ;
}
}
// 导出方式下拉框
@ -531,6 +536,22 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
public ParameterCombobox ( ) {
parameterSetting = getComboBoxWithModel ( new String [ ] { DEFAULT , CUSTOM } , PARAMETER_TYPE_MAP ) ;
parameterSetting . addItemListener ( e - > {
if ( e . getStateChange ( ) = = ItemEvent . SELECTED ) {
final int row = table . getSelectedRow ( ) ;
if ( row = = - 1 ) {
return ;
}
SingleJavaScript js = getList ( ) . get ( row ) ;
Object ob = parameterSetting . getSelectedItem ( ) ;
if ( ob ! = null ) {
String value = ob . toString ( ) ;
js . setExtendParameters ( StringUtils . equals ( value , DEFAULT ) ) ;
}
// 单纯为了刷新表格,使某些联动生效
table . repaint ( ) ;
}
} ) ;
this . addCellEditorListener ( new CellEditorListener ( ) {
@Override
@ -540,15 +561,7 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
@Override
public void editingStopped ( ChangeEvent e ) {
if ( table . getSelectedRow ( ) = = - 1 ) {
return ;
}
SingleJavaScript js = getList ( ) . get ( table . getSelectedRow ( ) ) ;
Object ob = parameterSetting . getSelectedItem ( ) ;
if ( ob ! = null ) {
String value = ob . toString ( ) ;
js . setExtendParameters ( StringUtils . equals ( value , DEFAULT ) ) ;
}
// 这里重新触发是为了触发某些编辑后事件
fireTableDataChanged ( ) ;
}
} ) ;
@ -567,7 +580,7 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
}
// 参数设置按钮
class ParameterSettingButton extends AbstractCellEditor implements TableCellEditor {
class ParameterSettingButton extends AbstractCellEditor implements TableCellEditor , TableCellRenderer {
private static final long serialVersionUID = 4021592871993049137L ;
private UIButton paraButton ;
@ -576,8 +589,7 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
public ParameterSettingButton ( ) {
paraSettingPane = new ParameterSettingPane ( ) ;
paraButton = new UIButton ( ) ;
paraButton . setBackground ( Color . GRAY ) ;
paraButton = new UIButton ( Toolkit . i18nText ( "Fine-Design_Report_Set" ) ) ;
paraButton . addMouseListener ( new MouseAdapter ( ) {
@Override
@ -616,7 +628,13 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
@Override
public Component getTableCellEditorComponent ( JTable table , Object value , boolean isSelected , int row , int column ) {
paraSettingPane . refresh ( new ArrayList < > ( Arrays . asList ( ( ParameterProvider [ ] ) value ) ) ) ;
if ( getList ( ) . get ( row ) = = null | | getList ( ) . get ( row ) . isExtendParameters ( ) ) {
return EMPTY_LABEL ;
}
ParameterProvider [ ] providers = ( ParameterProvider [ ] ) value ;
if ( providers ! = null ) {
paraSettingPane . refresh ( Arrays . asList ( providers ) ) ;
}
return paraButton ;
}
@ -624,6 +642,14 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
public Object getCellEditorValue ( ) {
return paraSettingPane . getParameterList ( ) ;
}
@Override
public Component getTableCellRendererComponent ( JTable table , Object value , boolean isSelected , boolean hasFocus , int row , int column ) {
if ( getList ( ) . get ( row ) = = null | | getList ( ) . get ( row ) . isExtendParameters ( ) ) {
return EMPTY_LABEL ;
}
return paraButton ;
}
}
// 参数设置弹出框
@ -747,11 +773,13 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
currentTemplatePane . extendParametersCheckBox . setSelected ( true ) ;
} else {
currentTemplatePane . extendParametersCheckBox . setSelected ( false ) ;
if ( this . parameterViewPane ! = null ) {
List < ParameterProvider > parameterList = this . parameterViewPane . update ( ) ;
parameterList . clear ( ) ;
ParameterProvider [ ] parameters = js . getParameters ( ) ;
this . parameterViewPane . populate ( parameters ) ;
}
}
} else {
OtherTemplatePane pane = ( OtherTemplatePane ) this . templatePanel . getComponent ( 1 ) ;
pane . editorPane . populate ( ob . getJsList ( ) . toArray ( new SingleJavaScript [ ob . getJsList ( ) . size ( ) ] ) ) ;