|
|
@ -17,10 +17,13 @@ import com.fr.design.data.datapane.ESDStrategyConfigPane; |
|
|
|
import com.fr.design.data.datapane.connect.ConnectionTableProcedurePane; |
|
|
|
import com.fr.design.data.datapane.connect.ConnectionTableProcedurePane; |
|
|
|
import com.fr.design.data.datapane.preview.PreviewTablePane; |
|
|
|
import com.fr.design.data.datapane.preview.PreviewTablePane; |
|
|
|
import com.fr.design.data.datapane.sqlpane.SQLEditPane; |
|
|
|
import com.fr.design.data.datapane.sqlpane.SQLEditPane; |
|
|
|
|
|
|
|
import com.fr.design.data.tabledata.tabledatapane.db.ServerStrategyConfigHandler; |
|
|
|
|
|
|
|
import com.fr.design.data.tabledata.tabledatapane.db.StrategyConfigFrom; |
|
|
|
|
|
|
|
import com.fr.design.data.tabledata.tabledatapane.db.StrategyConfigHandler; |
|
|
|
|
|
|
|
import com.fr.design.data.tabledata.tabledatapane.db.TemplateStrategyConfigHandler; |
|
|
|
import com.fr.design.dialog.BasicDialog; |
|
|
|
import com.fr.design.dialog.BasicDialog; |
|
|
|
import com.fr.design.dialog.BasicPane; |
|
|
|
import com.fr.design.dialog.BasicPane; |
|
|
|
import com.fr.design.dialog.DialogActionAdapter; |
|
|
|
import com.fr.design.dialog.DialogActionAdapter; |
|
|
|
import com.fr.design.file.HistoryTemplateListCache; |
|
|
|
|
|
|
|
import com.fr.design.fun.DBTableDataMenuHandler; |
|
|
|
import com.fr.design.fun.DBTableDataMenuHandler; |
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
import com.fr.design.gui.icheckbox.UICheckBox; |
|
|
|
import com.fr.design.gui.icheckbox.UICheckBox; |
|
|
@ -39,11 +42,8 @@ import com.fr.design.menu.ToolBarDef; |
|
|
|
import com.fr.design.utils.ParameterUtils; |
|
|
|
import com.fr.design.utils.ParameterUtils; |
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
import com.fr.esd.core.strategy.config.StrategyConfig; |
|
|
|
import com.fr.esd.core.strategy.config.StrategyConfig; |
|
|
|
import com.fr.esd.core.strategy.config.StrategyConfigHelper; |
|
|
|
import com.fr.esd.core.strategy.config.service.StrategyConfigService; |
|
|
|
import com.fr.esd.event.DSMapping; |
|
|
|
import com.fr.esd.query.StrategicTableData; |
|
|
|
import com.fr.esd.event.DsNameTarget; |
|
|
|
|
|
|
|
import com.fr.esd.event.StrategyEventsNotifier; |
|
|
|
|
|
|
|
import com.fr.esd.event.xml.XMLSavedHook; |
|
|
|
|
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
import com.fr.general.IOUtils; |
|
|
|
import com.fr.general.IOUtils; |
|
|
|
import com.fr.general.sql.SqlUtils; |
|
|
|
import com.fr.general.sql.SqlUtils; |
|
|
@ -52,7 +52,6 @@ import com.fr.script.Calculator; |
|
|
|
import com.fr.stable.ArrayUtils; |
|
|
|
import com.fr.stable.ArrayUtils; |
|
|
|
import com.fr.stable.ParameterProvider; |
|
|
|
import com.fr.stable.ParameterProvider; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.workspace.WorkContext; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
import javax.swing.BorderFactory; |
|
|
|
import javax.swing.Box; |
|
|
|
import javax.swing.Box; |
|
|
@ -89,20 +88,26 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> { |
|
|
|
private UITableEditorPane<ParameterProvider> editorPane; |
|
|
|
private UITableEditorPane<ParameterProvider> editorPane; |
|
|
|
private DBTableDataMenuHandler dbTableDataMenuHandler; |
|
|
|
private DBTableDataMenuHandler dbTableDataMenuHandler; |
|
|
|
private SQLEditPane sqlTextPane; |
|
|
|
private SQLEditPane sqlTextPane; |
|
|
|
UIComboBox configFromList; |
|
|
|
|
|
|
|
UICheckBox esdEnabled; |
|
|
|
|
|
|
|
private UIButton esdSettingsBtn; |
|
|
|
|
|
|
|
private UILabel barErrorTips; |
|
|
|
|
|
|
|
private String pageQuery; |
|
|
|
private String pageQuery; |
|
|
|
private DBTableData dbTableData; |
|
|
|
private DBTableData dbTableData; |
|
|
|
StrategyConfig strategyConfig; |
|
|
|
|
|
|
|
|
|
|
|
//ESD
|
|
|
|
|
|
|
|
private UILabel esdSettingsLabel; |
|
|
|
|
|
|
|
private UIComboBox esdConfigOption; |
|
|
|
|
|
|
|
private UICheckBox esdEnabled; |
|
|
|
|
|
|
|
private UIButton esdSettingsBtn; |
|
|
|
|
|
|
|
private UILabel barErrorTips; |
|
|
|
|
|
|
|
//配置
|
|
|
|
|
|
|
|
private StrategyConfig strategyConfig; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private StrategyConfigHandler configHandler; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public DBTableDataPane() { |
|
|
|
public DBTableDataPane() { |
|
|
|
init(); |
|
|
|
init(); |
|
|
|
initMainSplitPane(); |
|
|
|
initMainSplitPane(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void init() { |
|
|
|
private void init() { |
|
|
|
setLayout(new BorderLayout(4, 4)); |
|
|
|
setLayout(new BorderLayout(4, 4)); |
|
|
|
|
|
|
|
|
|
|
@ -182,7 +187,6 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initMainSplitPane() { |
|
|
|
private void initMainSplitPane() { |
|
|
|
Box box = new Box(BoxLayout.Y_AXIS); |
|
|
|
Box box = new Box(BoxLayout.Y_AXIS); |
|
|
|
|
|
|
|
|
|
|
@ -223,7 +227,6 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> { |
|
|
|
add(mainSplitPane, BorderLayout.CENTER); |
|
|
|
add(mainSplitPane, BorderLayout.CENTER); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean isPreviewOrRefreshButton(FocusEvent e) { |
|
|
|
private boolean isPreviewOrRefreshButton(FocusEvent e) { |
|
|
|
if (e.getOppositeComponent() != null) { |
|
|
|
if (e.getOppositeComponent() != null) { |
|
|
|
String name = e.getOppositeComponent().getName(); |
|
|
|
String name = e.getOppositeComponent().getName(); |
|
|
@ -232,13 +235,11 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected String title4PopupWindow() { |
|
|
|
protected String title4PopupWindow() { |
|
|
|
return Toolkit.i18nText("Fine-Design_Basic_DS-Database_Query"); |
|
|
|
return Toolkit.i18nText("Fine-Design_Basic_DS-Database_Query"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void refreshParameters() { |
|
|
|
private void refreshParameters() { |
|
|
|
String[] paramTexts = new String[2]; |
|
|
|
String[] paramTexts = new String[2]; |
|
|
|
paramTexts[0] = SqlUtils.tryPureSqlText(this.sqlTextPane.getText()); |
|
|
|
paramTexts[0] = SqlUtils.tryPureSqlText(this.sqlTextPane.getText()); |
|
|
@ -249,7 +250,6 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> { |
|
|
|
this.editorPane.populate(ParameterUtils.analyzeAndUnionParameters(paramTexts, ps)); |
|
|
|
this.editorPane.populate(ParameterUtils.analyzeAndUnionParameters(paramTexts, ps)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private JToolBar createToolBar() { |
|
|
|
private JToolBar createToolBar() { |
|
|
|
ToolBarDef toolBarDef = new ToolBarDef(); |
|
|
|
ToolBarDef toolBarDef = new ToolBarDef(); |
|
|
|
toolBarDef.addShortCut(new PreviewAction()); |
|
|
|
toolBarDef.addShortCut(new PreviewAction()); |
|
|
@ -261,26 +261,34 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> { |
|
|
|
toolBarDef.addShortCut(this.dbTableDataMenuHandler.createQueryAction()); |
|
|
|
toolBarDef.addShortCut(this.dbTableDataMenuHandler.createQueryAction()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UILabel esdSettingsLabel = new UILabel(Toolkit.i18nText("Fine-Design_ESD_Cache_Settings")); |
|
|
|
UIToolbar editToolBar = ToolBarDef.createJToolBar(); |
|
|
|
this.configFromList = new UIComboBox(ConfigFrom.values()); |
|
|
|
toolBarDef.updateToolBar(editToolBar); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//esd相关组件初始化
|
|
|
|
|
|
|
|
createToolbarEsdComponents(editToolBar); |
|
|
|
|
|
|
|
return editToolBar; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void createToolbarEsdComponents(final UIToolbar editToolBar) { |
|
|
|
|
|
|
|
this.esdSettingsLabel = new UILabel(Toolkit.i18nText("Fine-Design_ESD_Cache_Settings")); |
|
|
|
|
|
|
|
this.esdConfigOption = new UIComboBox(StrategyConfigFrom.values()); |
|
|
|
this.esdEnabled = new UICheckBox(Toolkit.i18nText("Fine-Design_ESD_Enable_Cache")); |
|
|
|
this.esdEnabled = new UICheckBox(Toolkit.i18nText("Fine-Design_ESD_Enable_Cache")); |
|
|
|
this.barErrorTips = new UILabel(); |
|
|
|
this.barErrorTips = new UILabel(); |
|
|
|
this.barErrorTips.setForeground(Color.RED); |
|
|
|
this.barErrorTips.setForeground(Color.RED); |
|
|
|
this.barErrorTips.setVisible(false); |
|
|
|
this.barErrorTips.setVisible(false); |
|
|
|
|
|
|
|
|
|
|
|
esdSettingsBtn = new UIButton(Toolkit.i18nText("Fine-Design_ESD_Strategy_Config")); |
|
|
|
esdSettingsBtn = new UIButton(Toolkit.i18nText("Fine-Design_ESD_Strategy_Config")); |
|
|
|
|
|
|
|
|
|
|
|
esdSettingsBtn.addActionListener(new ActionListener() { |
|
|
|
esdSettingsBtn.addActionListener(new ActionListener() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
final boolean global = (DBTableDataPane.this.configFromList.getSelectedIndex() == DBTableDataPane.ConfigFrom.GLOBAL.getIndex()); |
|
|
|
final boolean global = globalOptionSelected(); |
|
|
|
|
|
|
|
|
|
|
|
final ESDStrategyConfigPane strategyConfigPane = new ESDStrategyConfigPane(global); |
|
|
|
final ESDStrategyConfigPane strategyConfigPane = new ESDStrategyConfigPane(global); |
|
|
|
|
|
|
|
|
|
|
|
StrategyConfig populateStrategyConfig = null; |
|
|
|
StrategyConfig populateStrategyConfig; |
|
|
|
if (global) { |
|
|
|
if (global) { |
|
|
|
populateStrategyConfig = StrategyConfigHelper.getGlobalStrategyConfig(); |
|
|
|
populateStrategyConfig = StrategyConfigService.getGlobalConfig(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
populateStrategyConfig = strategyConfig; |
|
|
|
populateStrategyConfig = strategyConfig; |
|
|
|
} |
|
|
|
} |
|
|
@ -295,6 +303,7 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> { |
|
|
|
if (!global) { |
|
|
|
if (!global) { |
|
|
|
//点击策略配置面板的确定,重新设置策略配置
|
|
|
|
//点击策略配置面板的确定,重新设置策略配置
|
|
|
|
strategyConfig = strategyConfigPane.updateBean(); |
|
|
|
strategyConfig = strategyConfigPane.updateBean(); |
|
|
|
|
|
|
|
// TODO: 2021/3/12 这个直接使用不太好
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -303,56 +312,49 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> { |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.configFromList.setSelectedIndex(DBTableDataPane.ConfigFrom.GLOBAL.getIndex()); |
|
|
|
this.esdConfigOption.setSelectedIndex(StrategyConfigFrom.GLOBAL.getIndex()); |
|
|
|
this.configFromList.addActionListener(e -> setEsdEnabled()); |
|
|
|
this.esdConfigOption.addActionListener(e -> setEsdEnabled()); |
|
|
|
|
|
|
|
|
|
|
|
UIToolbar editToolBar = ToolBarDef.createJToolBar(); |
|
|
|
|
|
|
|
toolBarDef.updateToolBar(editToolBar); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
editToolBar.add(esdSettingsLabel); |
|
|
|
//工具栏加上esd相关组件
|
|
|
|
editToolBar.add(this.configFromList); |
|
|
|
editToolBar.add(this.esdSettingsLabel); |
|
|
|
|
|
|
|
editToolBar.add(this.esdConfigOption); |
|
|
|
editToolBar.add(this.esdEnabled); |
|
|
|
editToolBar.add(this.esdEnabled); |
|
|
|
editToolBar.add(this.esdSettingsBtn); |
|
|
|
editToolBar.add(this.esdSettingsBtn); |
|
|
|
editToolBar.add(this.barErrorTips); |
|
|
|
editToolBar.add(this.barErrorTips); |
|
|
|
return editToolBar; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean globalOptionSelected() { |
|
|
|
/* private void showBarError(String errorTips) { |
|
|
|
return esdConfigOption.getSelectedIndex() == StrategyConfigFrom.GLOBAL.getIndex(); |
|
|
|
this.barErrorTips.setText(errorTips); |
|
|
|
|
|
|
|
this.barErrorTips.setVisible(true); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean checkQuery(String errorTips) { |
|
|
|
private void setEsdEnableStatus(boolean selected, boolean enabled) { |
|
|
|
if (StringUtils.isEmpty(this.sqlTextPane.getText())) { |
|
|
|
this.esdEnabled.setSelected(selected); |
|
|
|
showBarError(errorTips); |
|
|
|
this.esdEnabled.setEnabled(enabled); |
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
private void setEsdEnabled() { |
|
|
|
}*/ |
|
|
|
boolean useIndividualConfig = !this.globalOptionSelected(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 设置是否开启 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
protected void setEsdEnabled() { |
|
|
|
|
|
|
|
boolean useIndividualConfig = configFromList.getSelectedIndex() == ConfigFrom.INDIVIDUAL.getIndex(); |
|
|
|
|
|
|
|
if (useIndividualConfig) { |
|
|
|
if (useIndividualConfig) { |
|
|
|
if (this.strategyConfig == null) { |
|
|
|
if (this.strategyConfig == null) { |
|
|
|
//新建的数据集,选择单独时,可用但是不勾选
|
|
|
|
//新建的数据集,选择单独时,可用但是不勾选
|
|
|
|
this.esdEnabled.setSelected(false); |
|
|
|
setEsdEnableStatus(false, true); |
|
|
|
this.esdEnabled.setEnabled(true); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.esdEnabled.setSelected(!this.strategyConfig.isUseGlobal() && this.strategyConfig.enabled()); |
|
|
|
setEsdEnableStatus(!this.strategyConfig.isUseGlobal() && this.strategyConfig.enabled(), true); |
|
|
|
this.esdEnabled.setEnabled(true); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.esdEnabled.setSelected(DesignerStrategyConfigUtils.isEditingTemplateRecommended()); |
|
|
|
//判断是不是模版数据集
|
|
|
|
this.esdEnabled.setEnabled(false); |
|
|
|
switch (this.dbTableData.getScope()) { |
|
|
|
|
|
|
|
case TEMPLATE: |
|
|
|
|
|
|
|
setEsdEnableStatus(DesignerStrategyConfigUtils.isEditingTemplateRecommended(), false); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case SERVER: |
|
|
|
|
|
|
|
//不会走到这里
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public StrategyConfig updateStrategyConfig() { |
|
|
|
public StrategyConfig updateStrategyConfig() { |
|
|
|
return this.strategyConfig; |
|
|
|
return this.strategyConfig; |
|
|
@ -386,7 +388,6 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> { |
|
|
|
refreshParameters(); |
|
|
|
refreshParameters(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void populateBean(DBTableData dbTableData) { |
|
|
|
public void populateBean(DBTableData dbTableData) { |
|
|
|
this.dbTableData = dbTableData; |
|
|
|
this.dbTableData = dbTableData; |
|
|
@ -410,56 +411,60 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> { |
|
|
|
this.sqlTextPane.moveCaretPosition(this.sqlTextPane.getCaretPosition()); |
|
|
|
this.sqlTextPane.moveCaretPosition(this.sqlTextPane.getCaretPosition()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (dbTableData.getScope()) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case TEMPLATE: |
|
|
|
|
|
|
|
this.configHandler = new TemplateStrategyConfigHandler(dbTableData); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case SERVER: |
|
|
|
|
|
|
|
//服务器数据集
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
//新建服务器数据集
|
|
|
|
|
|
|
|
this.configHandler = new ServerStrategyConfigHandler(dbTableData); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//设置esd相关组件显示状态
|
|
|
|
|
|
|
|
populateESDComponents(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void populateESDComponents() { |
|
|
|
//查找映射的配置
|
|
|
|
//查找映射的配置
|
|
|
|
this.strategyConfig = mapStrategyConfig(dbTableData); |
|
|
|
this.strategyConfig = configHandler.find(); |
|
|
|
|
|
|
|
|
|
|
|
boolean shouldEnable = false; |
|
|
|
boolean shouldEnable = false; |
|
|
|
ConfigFrom from = ConfigFrom.GLOBAL; |
|
|
|
StrategyConfigFrom from = StrategyConfigFrom.GLOBAL; |
|
|
|
|
|
|
|
|
|
|
|
if (this.strategyConfig != null) { |
|
|
|
if (this.strategyConfig != null) { |
|
|
|
if (this.strategyConfig.enabled()) { |
|
|
|
if (this.strategyConfig.enabled()) { |
|
|
|
shouldEnable = true; |
|
|
|
shouldEnable = true; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!this.strategyConfig.isUseGlobal()) { |
|
|
|
if (!this.strategyConfig.isUseGlobal()) { |
|
|
|
from = ConfigFrom.INDIVIDUAL; |
|
|
|
from = StrategyConfigFrom.INDIVIDUAL; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
this.esdEnabled.setSelected(shouldEnable); |
|
|
|
|
|
|
|
this.configFromList.setSelectedIndex(from.getIndex()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//服务器数据集不允许设置来源,只能单独配置
|
|
|
|
protected StrategyConfig mapStrategyConfig(DBTableData dbTableData) { |
|
|
|
if (dbTableData.getScope() != StrategicTableData.Scope.TEMPLATE) { |
|
|
|
//获取配置,如果是模版数据集,dbTableData实例应该是DBTableData,如果是服务器数据集是DBTableData
|
|
|
|
from = StrategyConfigFrom.INDIVIDUAL; |
|
|
|
StrategyConfig strategyConfig = null; |
|
|
|
this.esdConfigOption.setEnabled(false); |
|
|
|
if (dbTableData != null) { |
|
|
|
|
|
|
|
//设置保存数据集的事件检查钩子
|
|
|
|
|
|
|
|
String tplPath = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getEditingFILE().getPath(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//新建模版此时不存在,不需要注册钩子
|
|
|
|
|
|
|
|
if (dbTableData.getXmlSavedHook() == null && WorkContext.getWorkResource().exist(tplPath)) { |
|
|
|
|
|
|
|
dbTableData.setXmlSavedHook(new DBTableDataSavedHook(tplPath, dbTableData)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取当前的缓存配置,没有就创建一份
|
|
|
|
|
|
|
|
String dsName = this.dbTableData.getDsName(); |
|
|
|
|
|
|
|
strategyConfig = DesignerStrategyConfigUtils.getStrategyConfig(dsName); |
|
|
|
|
|
|
|
if (strategyConfig == null && dbTableData.isShare()) { |
|
|
|
|
|
|
|
strategyConfig = StrategyConfigHelper.createStrategyConfig(true, false, true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
this.esdEnabled.setSelected(shouldEnable); |
|
|
|
return strategyConfig; |
|
|
|
this.esdConfigOption.setSelectedIndex(from.getIndex()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public DBTableData updateBean() { |
|
|
|
public DBTableData updateBean() { |
|
|
|
|
|
|
|
|
|
|
|
updateDBTableData(); |
|
|
|
updateDBTableData(); |
|
|
|
|
|
|
|
internalUpdateStrategyConfig(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return this.dbTableData; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void internalUpdateStrategyConfig() { |
|
|
|
//这边只修改enable和useGlobal
|
|
|
|
//这边只修改enable和useGlobal
|
|
|
|
boolean global = DBTableDataPane.this.configFromList.getSelectedIndex() == DBTableDataPane.ConfigFrom.GLOBAL.getIndex(); |
|
|
|
boolean global = globalOptionSelected(); |
|
|
|
boolean enable = DBTableDataPane.this.esdEnabled.isSelected(); |
|
|
|
boolean enable = this.esdEnabled.isSelected(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//未开启缓存的,如果选择了单独配置,需要创建配置
|
|
|
|
//未开启缓存的,如果选择了单独配置,需要创建配置
|
|
|
@ -473,10 +478,10 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> { |
|
|
|
this.strategyConfig.setUseGlobal(global); |
|
|
|
this.strategyConfig.setUseGlobal(global); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return this.dbTableData; |
|
|
|
//保存
|
|
|
|
|
|
|
|
this.configHandler.save(this.dbTableData, this.strategyConfig); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void updateDBTableData() { |
|
|
|
private void updateDBTableData() { |
|
|
|
String dbName = this.connectionTableProcedurePane.getSelectedDatabaseConnnectonName(); |
|
|
|
String dbName = this.connectionTableProcedurePane.getSelectedDatabaseConnnectonName(); |
|
|
|
if (StringUtils.isBlank(dbName) || StringUtils.isBlank(this.sqlTextPane.getText())) { |
|
|
|
if (StringUtils.isBlank(dbName) || StringUtils.isBlank(this.sqlTextPane.getText())) { |
|
|
@ -524,9 +529,7 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private class PreviewAction extends UpdateAction { |
|
|
|
private class PreviewAction |
|
|
|
|
|
|
|
extends UpdateAction { |
|
|
|
|
|
|
|
public PreviewAction() { |
|
|
|
public PreviewAction() { |
|
|
|
setName(PREVIEW_BUTTON); |
|
|
|
setName(PREVIEW_BUTTON); |
|
|
|
setMnemonic('P'); |
|
|
|
setMnemonic('P'); |
|
|
@ -600,79 +603,4 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> { |
|
|
|
return this.title; |
|
|
|
return this.title; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum ConfigFrom { |
|
|
|
|
|
|
|
GLOBAL(0, Toolkit.i18nText("Fine-Design_ESD_Use_Global_Settings")), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INDIVIDUAL(1, Toolkit.i18nText("Fine-Design_ESD_Use_Individual_Settings")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int index; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String displayText; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ConfigFrom(int index, String displayText) { |
|
|
|
|
|
|
|
this.index = index; |
|
|
|
|
|
|
|
this.displayText = displayText; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int parse(StrategyConfig config) { |
|
|
|
|
|
|
|
return (config == null || config.isUseGlobal()) ? ConfigFrom.GLOBAL.getIndex() : ConfigFrom.INDIVIDUAL.getIndex(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int getIndex() { |
|
|
|
|
|
|
|
return this.index; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getDisplayText() { |
|
|
|
|
|
|
|
return this.displayText; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String toString() { |
|
|
|
|
|
|
|
return getDisplayText(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static class DBTableDataSavedHook implements XMLSavedHook<DBTableData> { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final long serialVersionUID = 4925391747683335372L; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final String tplPath; |
|
|
|
|
|
|
|
private String origName; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String origConnection; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String origQuery; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public DBTableDataSavedHook(String tplPath, DBTableData origDBTableData) { |
|
|
|
|
|
|
|
this.tplPath = tplPath; |
|
|
|
|
|
|
|
this.origName = origDBTableData.getDsName(); |
|
|
|
|
|
|
|
this.origConnection = origDBTableData.getDatabase().toString(); |
|
|
|
|
|
|
|
this.origQuery = origDBTableData.getQuery(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void doAfterSaved(DBTableData saved) { |
|
|
|
|
|
|
|
String dsName = saved.getDsName(); |
|
|
|
|
|
|
|
String conn = saved.getDatabase().toString(); |
|
|
|
|
|
|
|
String query = saved.getQuery(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//检查数据集名称、数据链接和sql是否修改,如果修改需要触发缓存监听事件
|
|
|
|
|
|
|
|
if (!dsName.equals(origName) || !conn.equals(origConnection) || !query.equals(origQuery)) { |
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(tplPath) && StringUtils.isNotEmpty(origName)) { |
|
|
|
|
|
|
|
//新建数据集的origName为null,不用触发
|
|
|
|
|
|
|
|
StrategyEventsNotifier.modifyDataSet(new DSMapping(tplPath, new DsNameTarget(origName))); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.origName = dsName; |
|
|
|
|
|
|
|
this.origConnection = conn; |
|
|
|
|
|
|
|
this.origQuery = query; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|