@ -50,9 +50,9 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.TableModelEvent ;
import javax.swing.event.TableModelEvent ;
import javax.swing.event.TableModelListener ;
import javax.swing.event.TableModelListener ;
import javax.swing.table.TableCellEditor ;
import javax.swing.table.TableCellEditor ;
import javax.swing.table.TableCellRenderer ;
import java.awt.BorderLayout ;
import java.awt.BorderLayout ;
import java.awt.CardLayout ;
import java.awt.CardLayout ;
import java.awt.Color ;
import java.awt.Component ;
import java.awt.Component ;
import java.awt.event.ActionEvent ;
import java.awt.event.ActionEvent ;
import java.awt.event.ActionListener ;
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 CUSTOM = "custom" ;
private static final String CURRENT_TEMPLATE = "cur" ;
private static final String CURRENT_TEMPLATE = "cur" ;
private static final String OTHER_TEMPLATE = "other" ;
private static final String OTHER_TEMPLATE = "other" ;
private static final UILabel EMPTY_LABEL = new UILabel ( ) ;
static {
static {
EXPORT_TYPES_MAP . put ( ExportJavaScript . EXPORT_PDF , Toolkit . i18nText ( "Fine-Design_Basic_Export_JS_PDF" ) ) ;
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
ParameterSettingButton . class
} ) ;
} ) ;
this . setDefaultEditor ( ExportTemplateChooser . class , new ExportTemplateChooser ( ) ) ;
this . setDefaultEditor ( ExportTemplateChooser . class , new ExportTemplateChooser ( ) ) ;
this . setDefaultRenderer ( ExportTemplateChooser . class , new ExportTemplateChooser ( ) ) ;
this . setDefaultEditor ( ExportTypeCombobox . class , new ExportTypeCombobox ( ) ) ;
this . setDefaultEditor ( ExportTypeCombobox . class , new ExportTypeCombobox ( ) ) ;
this . setDefaultEditor ( FileNameCombobox . class , new FileNameCombobox ( ) ) ;
this . setDefaultEditor ( FileNameCombobox . class , new FileNameCombobox ( ) ) ;
this . setDefaultEditor ( FileNameFormulaEditor . class , new FileNameFormulaEditor ( ) ) ;
this . setDefaultEditor ( FileNameFormulaEditor . class , new FileNameFormulaEditor ( ) ) ;
this . setDefaultEditor ( ParameterCombobox . class , new ParameterCombobox ( ) ) ;
this . setDefaultEditor ( ParameterCombobox . class , new ParameterCombobox ( ) ) ;
this . setDefaultEditor ( ParameterSettingButton . class , new ParameterSettingButton ( ) ) ;
this . setDefaultEditor ( ParameterSettingButton . class , new ParameterSettingButton ( ) ) ;
this . setDefaultRenderer ( ParameterSettingButton . class , new ParameterSettingButton ( ) ) ;
this . createTable ( ) . getColumnModel ( ) . getColumn ( 2 ) . setMaxWidth ( 60 ) ;
this . createTable ( ) . getColumnModel ( ) . getColumn ( 2 ) . setMaxWidth ( 60 ) ;
this . createTable ( ) . getColumnModel ( ) . getColumn ( 4 ) . 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
@Override
@ -286,10 +289,6 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
// 命名详情
// 命名详情
return this . getList ( ) . get ( row ) ! = null & & ! this . getList ( ) . get ( row ) . isDefaultFileName ( ) ;
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 ;
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 static final long serialVersionUID = - 9112506131272704717L ;
private JPanel reportletNamePane ;
private JPanel reportletNamePane ;
@ -387,6 +386,12 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
public Object getCellEditorValue ( ) {
public Object getCellEditorValue ( ) {
return reportPathTextField . getText ( ) ;
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 ( ) {
public ParameterCombobox ( ) {
parameterSetting = getComboBoxWithModel ( new String [ ] { DEFAULT , CUSTOM } , PARAMETER_TYPE_MAP ) ;
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 ( ) {
this . addCellEditorListener ( new CellEditorListener ( ) {
@Override
@Override
@ -540,15 +561,7 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
@Override
@Override
public void editingStopped ( ChangeEvent e ) {
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 ( ) ;
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 static final long serialVersionUID = 4021592871993049137L ;
private UIButton paraButton ;
private UIButton paraButton ;
@ -576,8 +589,7 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
public ParameterSettingButton ( ) {
public ParameterSettingButton ( ) {
paraSettingPane = new ParameterSettingPane ( ) ;
paraSettingPane = new ParameterSettingPane ( ) ;
paraButton = new UIButton ( ) ;
paraButton = new UIButton ( Toolkit . i18nText ( "Fine-Design_Report_Set" ) ) ;
paraButton . setBackground ( Color . GRAY ) ;
paraButton . addMouseListener ( new MouseAdapter ( ) {
paraButton . addMouseListener ( new MouseAdapter ( ) {
@Override
@Override
@ -616,7 +628,13 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
@Override
@Override
public Component getTableCellEditorComponent ( JTable table , Object value , boolean isSelected , int row , int column ) {
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 ;
return paraButton ;
}
}
@ -624,6 +642,14 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
public Object getCellEditorValue ( ) {
public Object getCellEditorValue ( ) {
return paraSettingPane . getParameterList ( ) ;
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 ) ;
currentTemplatePane . extendParametersCheckBox . setSelected ( true ) ;
} else {
} else {
currentTemplatePane . extendParametersCheckBox . setSelected ( false ) ;
currentTemplatePane . extendParametersCheckBox . setSelected ( false ) ;
if ( this . parameterViewPane ! = null ) {
List < ParameterProvider > parameterList = this . parameterViewPane . update ( ) ;
List < ParameterProvider > parameterList = this . parameterViewPane . update ( ) ;
parameterList . clear ( ) ;
parameterList . clear ( ) ;
ParameterProvider [ ] parameters = js . getParameters ( ) ;
ParameterProvider [ ] parameters = js . getParameters ( ) ;
this . parameterViewPane . populate ( parameters ) ;
this . parameterViewPane . populate ( parameters ) ;
}
}
}
} else {
} else {
OtherTemplatePane pane = ( OtherTemplatePane ) this . templatePanel . getComponent ( 1 ) ;
OtherTemplatePane pane = ( OtherTemplatePane ) this . templatePanel . getComponent ( 1 ) ;
pane . editorPane . populate ( ob . getJsList ( ) . toArray ( new SingleJavaScript [ ob . getJsList ( ) . size ( ) ] ) ) ;
pane . editorPane . populate ( ob . getJsList ( ) . toArray ( new SingleJavaScript [ ob . getJsList ( ) . size ( ) ] ) ) ;