use of com.cubrid.common.ui.cubrid.table.dialog.imp.TableConfig in project cubrid-manager by CUBRID.
the class FavoriteQueryNavigatorView method executeSql.
/**
* Execute selected queries
*/
private void executeSql() {
CubridDatabase cubridDatabase = getCurrentDatabase();
if (cubridDatabase == null || cubridDatabase.getDatabaseInfo() == null) {
CommonUITool.openErrorBox(com.cubrid.common.ui.query.Messages.errNoConnectionBatchRun);
return;
}
// Judge the file is exist
int[] indexes = tv.getTable().getSelectionIndices();
List<Map<String, String>> list = FavoriteQueryPersistUtil.getInstance().getListData();
for (int i = 0; i < indexes.length; i++) {
Map<String, String> item = list.get(indexes[i]);
String filename = item.get("1");
String fullpath = item.get("4") + File.separator + filename;
if (!new File(fullpath).exists()) {
String msg = Messages.bind(com.cubrid.common.ui.query.Messages.errFileNotExist, fullpath);
CommonUITool.openErrorBox(msg);
return;
}
}
String targetDbName = cubridDatabase.getDatabaseInfo().getDbName() + "@" + cubridDatabase.getServer().getServerInfo().getHostAddress();
String msg = Messages.bind(com.cubrid.common.ui.query.Messages.msgDoYouWantExecuteSql, targetDbName);
if (!CommonUITool.openConfirmBox(msg)) {
return;
}
String charset = StringUtil.getDefaultCharset();
ImportConfig importConfig = new ImportConfig();
importConfig.setImportType(ImportConfig.IMPORT_FROM_SQL);
importConfig.setThreadCount(1);
importConfig.setCommitLine(100);
Set<String> charsets = new HashSet<String>();
for (int i = 0; i < indexes.length; i++) {
Map<String, String> item = list.get(indexes[i]);
String filename = item.get("1");
String fullpath = item.get("4") + File.separator + filename;
charset = item.get("5");
if (StringUtil.isEmpty(charset)) {
charset = StringUtil.getDefaultCharset();
} else {
charsets.add(charset);
}
TableConfig fileConfig = new TableConfig(filename);
fileConfig.setFilePath(fullpath);
fileConfig.setFileType(TableConfig.TYPE_DATA);
importConfig.addTableConfig(fileConfig);
}
importConfig.setFilesCharset(charset);
if (charsets.size() > 1) {
msg = Messages.bind(com.cubrid.common.ui.query.Messages.msgDoYouWantExecuteWithNotSameCharset, charset);
if (!CommonUITool.openConfirmBox(msg)) {
return;
}
}
ImportDataEditorInput input = new ImportDataEditorInput();
input.setDatabase(cubridDatabase);
input.setImportConfig(importConfig);
try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, ImportDataViewPart.ID);
} catch (Exception e) {
CommonUITool.openErrorBox(Display.getCurrent().getActiveShell(), e.getMessage());
}
}
use of com.cubrid.common.ui.cubrid.table.dialog.imp.TableConfig in project cubrid-manager by CUBRID.
the class ImportDataProgressManager method computeTaskCount.
/**
* parse get total data number
*
* @return
*/
public void computeTaskCount() {
//Import SQL file
if (importConfig.getImportType() == ImportConfig.IMPORT_FROM_SQL) {
for (TableConfig config : importConfig.getSelectedMap().values()) {
File file = new File(config.getFilePath());
if (file.exists()) {
totalRecordCount += file.length();
}
if (TableConfig.TYPE_DATA.equals(config.getFileType())) {
totalDataTaskCount++;
}
totalTaskCount++;
}
} else {
for (TableConfig config : importConfig.getSelectedMap().values()) {
int count = 0;
if (config != null) {
count = config.getLineCount();
}
totalRecordCount += count;
totalDataTaskCount++;
totalTaskCount++;
}
}
pmLength = (int) (totalRecordCount);
progressIndicator.beginTask(pmLength);
setInitSuccess(true);
}
Aggregations