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