Search in sources :

Example 66 with DatabaseModelBean

use of net.heartsome.cat.common.bean.DatabaseModelBean in project translationstudio8 by heartsome.

the class TmDbManagerDialog method addServerWithExistCheck.

/**
	 * 将当前操作的服务器配置信息添加到配置文件中<br>
	 * 在添加前,先判断该服务器是否已经存在,如果已经存在则更新
	 * @param currServer
	 *            需要处理的配置信息
	 * @param currDbTypeServers
	 *            当前数据库类型下的所有服务器,用于显示在界面上;
	 */
private void addServerWithExistCheck(DatabaseModelBean currServer, List<DatabaseModelBean> currDbTypeServers) {
    DatabaseModelBean bean = currServer.copyToOtherIntance(new DatabaseModelBean());
    String existSerId = configer.isServerExist(bean, getCurrDbMetaData());
    if (existSerId != null && !existSerId.equals("")) {
        if (!bean.getId().equals(existSerId)) {
            configer.deleteServerById(bean.getId());
            for (DatabaseModelBean temp : currDbTypeServers) {
                if (temp.getId().equals(bean.getId())) {
                    currDbTypeServers.remove(temp);
                    break;
                }
            }
        }
        bean.setId(existSerId);
        currServer.setId(existSerId);
        updateServer(bean, currDbTypeServers);
        return;
    }
    configer.addServerConfig(bean);
    currDbTypeServers.add(bean);
    setLastSelectedServer(bean.getId());
}
Also used : DatabaseModelBean(net.heartsome.cat.common.bean.DatabaseModelBean)

Example 67 with DatabaseModelBean

use of net.heartsome.cat.common.bean.DatabaseModelBean in project translationstudio8 by heartsome.

the class TermViewerBodyMenu method getDbOperator.

DBOperator getDbOperator(IProject project) {
    if (null == project) {
        return null;
    }
    ProjectConfiger projectConfiger = ProjectConfigerFactory.getProjectConfiger(project);
    List<DatabaseModelBean> termBaseDbs = projectConfiger.getTermBaseDbs(true);
    if (null == termBaseDbs || termBaseDbs.isEmpty()) {
        return null;
    }
    return DatabaseService.getDBOperator(termBaseDbs.get(0).toDbMetaData());
}
Also used : ProjectConfiger(net.heartsome.cat.ts.core.file.ProjectConfiger) DatabaseModelBean(net.heartsome.cat.common.bean.DatabaseModelBean)

Example 68 with DatabaseModelBean

use of net.heartsome.cat.common.bean.DatabaseModelBean in project translationstudio8 by heartsome.

the class ProjectConfiger method createTmNode.

private String createTmNode(List<DatabaseModelBean> dbList) {
    StringBuffer content = new StringBuffer();
    content.append("\n\t\t<tm>");
    for (int i = 0; i < dbList.size(); i++) {
        DatabaseModelBean dbModel = dbList.get(i);
        content.append(createDbNode(dbModel));
    }
    content.append("</tm>");
    return content.toString();
}
Also used : DatabaseModelBean(net.heartsome.cat.common.bean.DatabaseModelBean)

Example 69 with DatabaseModelBean

use of net.heartsome.cat.common.bean.DatabaseModelBean in project translationstudio8 by heartsome.

the class ProjectConfiger method getAllTmDbs.

/**
	 * 获取当前项目的所有翻译记忆库
	 * @return 数据库参数列表List<DatabaseModelBean> {@link DatabaseModelBean};
	 */
public List<DatabaseModelBean> getAllTmDbs() {
    List<DatabaseModelBean> dbList = new ArrayList<DatabaseModelBean>();
    try {
        AutoPilot ap = new AutoPilot(vu.getVTDNav());
        ap.selectXPath("/projectDescription/hs/tm/db");
        while (ap.evalXPath() != -1) {
            DatabaseModelBean dbm = new DatabaseModelBean();
            String defaultAttr = vu.getCurrentElementAttribut("default", "N");
            if (defaultAttr.equals("Y")) {
                dbm.setDefault(true);
            } else {
                dbm.setDefault(false);
            }
            dbm.setDbType(vu.getChildContent("type"));
            dbm.setDbName(vu.getChildContent("name"));
            dbm.setItlDBLocation(vu.getChildContent("location"));
            dbm.setInstance(vu.getChildContent("instance"));
            dbm.setHost(vu.getChildContent("server"));
            dbm.setPort(vu.getChildContent("port"));
            dbm.setUserName(vu.getChildContent("user"));
            dbm.setPassword(DESImpl.decrypt(vu.getChildContent("password")));
            String hasMatch = vu.getChildContent("hasmatch");
            if (hasMatch.equals("true")) {
                dbm.setHasMatch(true);
            } else {
                dbm.setHasMatch(false);
            }
            if (dbm.isDefault()) {
                dbList.add(0, dbm);
            } else {
                dbList.add(dbm);
            }
        }
    } catch (Exception e) {
        logger.error(Messages.getString("file.ProjectConfiger.logger3"), e);
        return dbList;
    }
    return dbList;
}
Also used : AutoPilot(com.ximpleware.AutoPilot) DatabaseModelBean(net.heartsome.cat.common.bean.DatabaseModelBean) ArrayList(java.util.ArrayList) NavException(com.ximpleware.NavException) TranscodeException(com.ximpleware.TranscodeException) XPathEvalException(com.ximpleware.XPathEvalException) XPathParseException(com.ximpleware.XPathParseException) IOException(java.io.IOException) ModifyException(com.ximpleware.ModifyException) ParseException(com.ximpleware.ParseException)

Example 70 with DatabaseModelBean

use of net.heartsome.cat.common.bean.DatabaseModelBean in project translationstudio8 by heartsome.

the class ProjectConfiger method getReferrenceTMDbs.

/**
	 * 获取当前项目的所有参考翻译记忆库,default='N'
	 * @return 数据库参数列表List<DatabaseModelBean> {@link DatabaseModelBean};
	 */
public List<DatabaseModelBean> getReferrenceTMDbs() {
    List<DatabaseModelBean> dbList = new ArrayList<DatabaseModelBean>();
    try {
        AutoPilot ap = new AutoPilot(vu.getVTDNav());
        ap.selectXPath("/projectDescription/hs/tm/db[@default='N']");
        while (ap.evalXPath() != -1) {
            DatabaseModelBean dbm = new DatabaseModelBean();
            dbm.setDefault(false);
            dbm.setDbType(vu.getChildContent("type"));
            dbm.setDbName(vu.getChildContent("name"));
            dbm.setItlDBLocation(vu.getChildContent("location"));
            dbm.setInstance(vu.getChildContent("instance"));
            dbm.setHost(vu.getChildContent("server"));
            dbm.setPort(vu.getChildContent("port"));
            dbm.setUserName(vu.getChildContent("user"));
            dbm.setPassword(DESImpl.decrypt(vu.getChildContent("password")));
            String hasMatch = vu.getChildContent("hasmatch");
            if (hasMatch.equals("true")) {
                dbm.setHasMatch(true);
            } else {
                dbm.setHasMatch(false);
            }
            dbList.add(dbm);
        }
    } catch (Exception e) {
        logger.error(Messages.getString("file.ProjectConfiger.logger5"), e);
        return dbList;
    }
    return dbList;
}
Also used : AutoPilot(com.ximpleware.AutoPilot) DatabaseModelBean(net.heartsome.cat.common.bean.DatabaseModelBean) ArrayList(java.util.ArrayList) NavException(com.ximpleware.NavException) TranscodeException(com.ximpleware.TranscodeException) XPathEvalException(com.ximpleware.XPathEvalException) XPathParseException(com.ximpleware.XPathParseException) IOException(java.io.IOException) ModifyException(com.ximpleware.ModifyException) ParseException(com.ximpleware.ParseException)

Aggregations

DatabaseModelBean (net.heartsome.cat.common.bean.DatabaseModelBean)71 ArrayList (java.util.ArrayList)27 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)16 SQLException (java.sql.SQLException)15 SelectionEvent (org.eclipse.swt.events.SelectionEvent)14 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)12 MenuItem (org.eclipse.swt.widgets.MenuItem)12 List (java.util.List)11 Point (org.eclipse.swt.graphics.Point)11 File (java.io.File)10 GridData (org.eclipse.swt.layout.GridData)10 GridLayout (org.eclipse.swt.layout.GridLayout)10 Button (org.eclipse.swt.widgets.Button)10 Composite (org.eclipse.swt.widgets.Composite)10 Label (org.eclipse.swt.widgets.Label)10 Menu (org.eclipse.swt.widgets.Menu)10 Iterator (java.util.Iterator)8 Map (java.util.Map)8 MetaData (net.heartsome.cat.common.bean.MetaData)8 HSDropDownButton (net.heartsome.cat.common.ui.HSDropDownButton)8