use of net.heartsome.cat.database.SystemDBOperator in project translationstudio8 by heartsome.
the class NewTmDbWizard method performFinish.
/**
* (non-Javadoc)
* @see org.eclipse.jface.wizard.Wizard#performFinish()
*/
@Override
public boolean performFinish() {
final String tmxFile = importPage.getTMXFile();
final SystemDBOperator dbOp = createDbPage.getCurrDbOp();
if (dbOp.getDBConfig().getDefaultType().equals(Constants.DBTYPE_SQLITE)) {
String dbName = dbOp.getMetaData().getDatabaseName();
dbName += ".hstm";
dbOp.getMetaData().setDatabaseName(dbName);
}
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
importPage.performFinish(tmxFile, dbOp, monitor);
}
};
try {
getContainer().run(true, true, runnable);
} catch (InvocationTargetException e) {
e.printStackTrace();
return false;
} catch (InterruptedException e) {
e.printStackTrace();
return false;
}
return true;
}
use of net.heartsome.cat.database.SystemDBOperator in project translationstudio8 by heartsome.
the class TmDbManagerDialog method searchCurrServerDatabase.
private List<DatabaseManagerDbListBean> searchCurrServerDatabase(SystemDBOperator sysDbOp, DatabaseModelBean currServer) {
List<DatabaseManagerDbListBean> temp = new ArrayList<DatabaseManagerDbListBean>();
// 检查是否创建了系统库
if (!sysDbOp.checkSysDb()) {
// MessageDialog.openInformation(getShell(), "提示信息",
// "当前服务器上没有创建任何库");
setLastSelectedServer(null);
return null;
}
// 检查是否创建了库
List<String> dbNames = sysDbOp.getSysDbNames(Constants.DB_TYPE_TM);
if (dbNames.size() == 0) {
// MessageDialog.openInformation(getShell(), "提示信息",
// "当前服务器上没有创建任何库");
setLastSelectedServer(null);
return null;
}
// 获取数据库相关资料,封装了库名称和语言
MetaData metaData = currServer.toDbMetaData();
DBOperator dbop = DatabaseService.getDBOperator(metaData);
for (int i = 0; i < dbNames.size(); i++) {
DatabaseManagerDbListBean bean = new DatabaseManagerDbListBean();
String dbName = dbNames.get(i);
bean.setIndex(i + 1 + "");
bean.setDbName(dbName);
metaData.setDatabaseName(dbName);
dbop.setMetaData(metaData);
String lang = "";
try {
dbop.start();
List<String> langs = dbop.getLanguages();
for (int j = 0; j < langs.size(); j++) {
lang += langs.get(j);
if (j != langs.size() - 1) {
lang += ", ";
}
}
} catch (Exception e1) {
logger.error("", e1);
continue;
} finally {
try {
if (dbop != null) {
dbop.end();
}
} catch (SQLException e) {
logger.error("", e);
}
}
if (lang.equals("")) {
bean.setLangs(Messages.getString("dialog.TmDbManagerDialog.msg10"));
} else {
bean.setLangs(lang);
}
temp.add(bean);
}
return temp;
}
Aggregations