|
|
|
@ -3,8 +3,8 @@
|
|
|
|
|
*/ |
|
|
|
|
package com.fr.design.actions.server; |
|
|
|
|
|
|
|
|
|
import com.fr.base.*; |
|
|
|
|
import com.fr.dav.LocalEnv; |
|
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
|
import com.fr.config.Configuration; |
|
|
|
|
import com.fr.design.DesignModelAdapter; |
|
|
|
|
import com.fr.design.actions.UpdateAction; |
|
|
|
|
import com.fr.design.data.DesignTableDataManager; |
|
|
|
@ -16,9 +16,13 @@ import com.fr.design.dialog.DialogActionAdapter;
|
|
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
|
import com.fr.design.mainframe.DesignerFrame; |
|
|
|
|
import com.fr.design.menu.MenuKeySet; |
|
|
|
|
import com.fr.file.DatasourceManager; |
|
|
|
|
import com.fr.file.DatasourceManagerProvider; |
|
|
|
|
import com.fr.file.ProcedureConfig; |
|
|
|
|
import com.fr.file.TableDataConfig; |
|
|
|
|
import com.fr.general.Inter; |
|
|
|
|
import com.fr.locale.InterProviderFactory; |
|
|
|
|
import com.fr.stable.ListMap; |
|
|
|
|
import com.fr.transaction.Configurations; |
|
|
|
|
import com.fr.transaction.Worker; |
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
@ -61,15 +65,24 @@ public class GlobalTableDataAction extends UpdateAction implements ResponseDataS
|
|
|
|
|
*/ |
|
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
|
final DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); |
|
|
|
|
final DatasourceManagerProvider datasourceManager = DatasourceManager.getProviderInstance(); |
|
|
|
|
final DatasourceManager backupManager = datasourceManager.getBackUpManager(); |
|
|
|
|
final TableDataConfig tableDataConfig = TableDataConfig.getInstance(); |
|
|
|
|
final TableDataManagerPane globalTableDataPane = new TableDataManagerPane() { |
|
|
|
|
public void complete() { |
|
|
|
|
populate(datasourceManager); |
|
|
|
|
populate((TableDataConfig) tableDataConfig.clone()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected void renameConnection(String oldName, String newName) { |
|
|
|
|
datasourceManager.getConnectionLocalModifyTable().rename(oldName, newName); |
|
|
|
|
protected void renameConnection(final String oldName, final String newName) { |
|
|
|
|
Configurations.update(new Worker() { |
|
|
|
|
@Override |
|
|
|
|
public void run() { |
|
|
|
|
tableDataConfig.renameTableData(oldName, newName); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Class<? extends Configuration>[] targets() { |
|
|
|
|
return new Class[]{TableDataConfig.class, ProcedureConfig.class}; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
final BasicDialog globalTableDataDialog = globalTableDataPane.showLargeWindow(designerFrame, null); |
|
|
|
@ -78,102 +91,113 @@ public class GlobalTableDataAction extends UpdateAction implements ResponseDataS
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void doOk() { |
|
|
|
|
Configurations.update(new Worker() { |
|
|
|
|
@Override |
|
|
|
|
public void run() { |
|
|
|
|
if (!globalTableDataPane.isNamePermitted()) { |
|
|
|
|
globalTableDataDialog.setDoOKSucceed(false); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
DesignTableDataManager.clearGlobalDs(); |
|
|
|
|
globalTableDataPane.update(datasourceManager); |
|
|
|
|
if (!doWithDatasourceManager(datasourceManager, backupManager, globalTableDataPane, globalTableDataDialog)) { |
|
|
|
|
globalTableDataPane.update(tableDataConfig); |
|
|
|
|
if (!doWithDatasourceManager(tableDataConfig, globalTableDataPane, globalTableDataDialog)) { |
|
|
|
|
//如果更新失败,则不关闭对话框,也不写xml文件,并且将对话框定位在请重命名的那个对象页面
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
writeFile(datasourceManager); |
|
|
|
|
// 刷新共有数据集
|
|
|
|
|
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); |
|
|
|
|
fireDSChanged(globalTableDataPane.getDsChangedNameMap()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void doCancel() { |
|
|
|
|
datasourceManager.synchronizedWithServer(); |
|
|
|
|
@Override |
|
|
|
|
public Class<? extends Configuration>[] targets() { |
|
|
|
|
return new Class[]{TableDataConfig.class}; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
globalTableDataDialog.setVisible(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void writeFile(DatasourceManagerProvider datasourceManager) { |
|
|
|
|
|
|
|
|
|
Env currentEnv = FRContext.getCurrentEnv(); |
|
|
|
|
try { |
|
|
|
|
boolean isSuccess = currentEnv.writeResource(datasourceManager); |
|
|
|
|
if (!isSuccess) { |
|
|
|
|
throw new RuntimeException(Inter.getLocText("FR-Designer_Already_exist")); |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
throw new RuntimeException(Inter.getLocText("FR-Designer_Already_exist")); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
globalTableDataDialog.setVisible(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 是否正常更新完datasourceManager |
|
|
|
|
* |
|
|
|
|
* @param datasourceManager |
|
|
|
|
* @param databaseManagerPane |
|
|
|
|
* @param tableDataManagerPane |
|
|
|
|
* @param databaseListDialog |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private boolean doWithDatasourceManager(DatasourceManagerProvider datasourceManager, DatasourceManager backupManager, |
|
|
|
|
TableDataManagerPane tableDataManagerPane, BasicDialog databaseListDialog) { |
|
|
|
|
HashMap<String, TableData> modifyDetails = datasourceManager.getTableDataModifyDetails(); |
|
|
|
|
modifyDetails.clear(); |
|
|
|
|
Env currentEnv = FRContext.getCurrentEnv(); |
|
|
|
|
ModifiedTable localModifiedTable = datasourceManager.checkTableDataModifyTable(backupManager, currentEnv.getUserID()); |
|
|
|
|
private boolean doWithDatasourceManager(TableDataConfig datasourceManager, TableDataManagerPane tableDataManagerPane, BasicDialog databaseListDialog) { |
|
|
|
|
// HashMap<String, TableData> modifyDetails = datasourceManager.getTableDataModifyDetails();
|
|
|
|
|
// modifyDetails.clear();
|
|
|
|
|
// Env currentEnv = FRContext.getCurrentEnv();
|
|
|
|
|
// ModifiedTable localModifiedTable = datasourceManager.checkTableDataModifyTable(backupManager, currentEnv.getUserID());
|
|
|
|
|
boolean isFailed = false; |
|
|
|
|
if (currentEnv.isSupportLocalFileOperate() && !((LocalEnv) currentEnv).isNoRemoteUser()) { |
|
|
|
|
//如果是本地,并且有远程用户时则更新自己的修改表
|
|
|
|
|
datasourceManager.updateSelfTableDataTotalModifiedTable(localModifiedTable, ModifiedTable.LOCAL_MODIFIER); |
|
|
|
|
} else { |
|
|
|
|
if (!currentEnv.isSupportLocalFileOperate()) { |
|
|
|
|
//如果是远程,则去取服务器的最新的修改表,检查有没有冲突
|
|
|
|
|
ModifiedTable currentServerModifyTable = currentEnv.getDataSourceModifiedTables(DatasourceManager.TABLEDATA); |
|
|
|
|
if (localModifiedTable.checkModifiedTableConflictWithServer(currentServerModifyTable, currentEnv.getUserID())) { |
|
|
|
|
//有冲突,进行提示
|
|
|
|
|
String title = Inter.getLocText(new String[]{"Select", "Single", "Setting"}); |
|
|
|
|
int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), localModifiedTable.getWaringMessage(), title, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); |
|
|
|
|
if (returnVal == JOptionPane.YES_OPTION) { |
|
|
|
|
//点击是,进行相应刷新去冲突
|
|
|
|
|
datasourceManager.synchronizedWithServer(backupManager, DatasourceManager.TABLEDATA); |
|
|
|
|
//要是有重命名冲突的,则对详细的修改表先进行修改
|
|
|
|
|
datasourceManager.doWithTableDataConfilct(localModifiedTable); |
|
|
|
|
localModifiedTable.removeConfilct(); |
|
|
|
|
modifyDetails.clear(); |
|
|
|
|
//更新面板
|
|
|
|
|
tableDataManagerPane.populate(datasourceManager); |
|
|
|
|
} else { |
|
|
|
|
//更新失败,继续停留页面
|
|
|
|
|
isFailed = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// if (currentEnv.isSupportLocalFileOperate() && !((LocalEnv) currentEnv).isNoRemoteUser()) {
|
|
|
|
|
// //如果是本地,并且有远程用户时则更新自己的修改表
|
|
|
|
|
// datasourceManager.updateSelfTableDataTotalModifiedTable(localModifiedTable, ModifiedTable.LOCAL_MODIFIER);
|
|
|
|
|
// } else {
|
|
|
|
|
// if (!currentEnv.isSupportLocalFileOperate()) {
|
|
|
|
|
// //如果是远程,则去取服务器的最新的修改表,检查有没有冲突
|
|
|
|
|
// ModifiedTable currentServerModifyTable = currentEnv.getDataSourceModifiedTables(DatasourceManager.TABLEDATA);
|
|
|
|
|
// if (localModifiedTable.checkModifiedTableConflictWithServer(currentServerModifyTable, currentEnv.getUserID())) {
|
|
|
|
|
// //有冲突,进行提示
|
|
|
|
|
// String title = Inter.getLocText(new String[]{"Select", "Single", "Setting"});
|
|
|
|
|
// int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), localModifiedTable.getWaringMessage(), title, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
|
|
|
|
|
// if (returnVal == JOptionPane.YES_OPTION) {
|
|
|
|
|
// //点击是,进行相应刷新去冲突
|
|
|
|
|
// datasourceManager.synchronizedWithServer(backupManager, DatasourceManager.TABLEDATA);
|
|
|
|
|
// //要是有重命名冲突的,则对详细的修改表先进行修改
|
|
|
|
|
// datasourceManager.doWithTableDataConfilct(localModifiedTable);
|
|
|
|
|
// localModifiedTable.removeConfilct();
|
|
|
|
|
// modifyDetails.clear();
|
|
|
|
|
// //更新面板
|
|
|
|
|
// tableDataManagerPane.populate(datasourceManager);
|
|
|
|
|
// } else {
|
|
|
|
|
// //更新失败,继续停留页面
|
|
|
|
|
// isFailed = true;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//存在请重命名则不能更新
|
|
|
|
|
int index = datasourceManager.isTableDataMapContainsRename(); |
|
|
|
|
int index = isTableDataMapContainsRename(datasourceManager); |
|
|
|
|
if (index != -1) { |
|
|
|
|
isFailed = true; |
|
|
|
|
tableDataManagerPane.setSelectedIndex(index); |
|
|
|
|
} |
|
|
|
|
databaseListDialog.setDoOKSucceed(!isFailed); |
|
|
|
|
//如果修改成功,则去远程端增量修改修改表
|
|
|
|
|
if (!isFailed && !currentEnv.isSupportLocalFileOperate()) { |
|
|
|
|
currentEnv.writeDataSourceModifiedTables(localModifiedTable, DatasourceManager.TABLEDATA); |
|
|
|
|
localModifiedTable.clear(); |
|
|
|
|
modifyDetails.clear(); |
|
|
|
|
} |
|
|
|
|
// if (!isFailed && !currentEnv.isSupportLocalFileOperate()) {
|
|
|
|
|
// currentEnv.writeDataSourceModifiedTables(localModifiedTable, DatasourceManager.TABLEDATA);
|
|
|
|
|
// localModifiedTable.clear();
|
|
|
|
|
// modifyDetails.clear();
|
|
|
|
|
// }
|
|
|
|
|
return !isFailed; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 是否包含重命名key |
|
|
|
|
* |
|
|
|
|
* @return 包含则返回序列 ,若返回-1则说明不包含重命名key |
|
|
|
|
*/ |
|
|
|
|
public int isTableDataMapContainsRename(TableDataConfig datasourceManager) { |
|
|
|
|
ListMap tableDataMap = (ListMap) datasourceManager.getTableDatas(); |
|
|
|
|
String rename = InterProviderFactory.getProvider().getLocText("FR-Engine_Please_Rename") + "!"; |
|
|
|
|
if (tableDataMap.containsKey(rename)) { |
|
|
|
|
return tableDataMap.indexOf(rename); |
|
|
|
|
} |
|
|
|
|
//todo 这边同上面和远程修改数据集属性有关先屏蔽
|
|
|
|
|
// for (int i = tableDataRenameIndex; i >= 1; i--) {
|
|
|
|
|
// rename = InterProviderFactory.getProvider().getLocText("FR-Engine_Please_Rename") + i + "!";
|
|
|
|
|
// if (nameTableDataMap.map.containsKey(rename)) {
|
|
|
|
|
// return nameTableDataMap.map.indexOf(rename);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void update() { |
|
|
|
|
this.setEnabled(true); |
|
|
|
|