use of net.heartsome.cat.common.bean.DatabaseModelBean in project translationstudio8 by heartsome.
the class ProjectSettingTBPage method setProjectInfoBean.
@Override
public void setProjectInfoBean(ProjectInfoBean projInfoBean) {
super.projectInfoBean = projInfoBean;
this.curDbList = projInfoBean.getTbDb();
for (DatabaseModelBean bean : this.curDbList) {
checkDbHashMatch(bean);
}
}
use of net.heartsome.cat.common.bean.DatabaseModelBean in project translationstudio8 by heartsome.
the class ArchiveFileExportOperation2 method getProjectSQLiteFiles.
/**
* @param project
* @param type
* @return ;
*/
private List<File> getProjectSQLiteFiles(IProject project, int type) {
ProjectConfiger projectConfiger = ProjectConfigerFactory.getProjectConfiger(project);
ProjectInfoBean currentProjectConfig = projectConfiger.getCurrentProjectConfig();
List<DatabaseModelBean> sqlDbs = null;
if (TM == type) {
sqlDbs = currentProjectConfig.getTmDb();
} else if (TB == type) {
sqlDbs = currentProjectConfig.getTbDb();
}
List<File> files = new ArrayList<File>();
for (DatabaseModelBean bean : sqlDbs) {
if ("SQLite".equals(bean.getDbType())) {
File file = new File(getSqliteFilePath(bean));
if (file.exists() && file.isFile()) {
files.add(file);
}
}
}
return files;
}
use of net.heartsome.cat.common.bean.DatabaseModelBean in project translationstudio8 by heartsome.
the class WordsFA method createFAResultHtml.
/**
* 生成字数分析结果html文件
* @return html文件的路径
*/
public String createFAResultHtml() {
allFolderList = new LinkedList<IContainer>();
Date createDate = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String createTime = formatter.format(createDate);
formatter = new SimpleDateFormat("yyyyMMdd-HHmmss");
String htmlNameTime = formatter.format(createDate);
IProject curProject = model.getAnalysisIFileList().get(0).getProject();
String htmlName = "WordLog" + htmlNameTime + ".html";
String htmlPath = curProject.getLocation().append("Intermediate").append("Report").append(htmlName).toOSString();
File htmlFile = new File(htmlPath);
if (!htmlFile.getParentFile().exists()) {
htmlFile.getParentFile().mkdirs();
}
FileOutputStream output;
try {
output = new FileOutputStream(htmlPath);
output.write(QAConstant.FA_HtmlDoctype.getBytes("UTF-8"));
output.write("<html>\n".getBytes("UTF-8"));
String headerNode = QAConstant.FA_htmlHeader;
headerNode = headerNode.replace("###Title###", Messages.getString("qa.fileAnalysis.WordsFA.name1"));
output.write(headerNode.getBytes("UTF-8"));
output.write("\t<body>\n".getBytes("UTF-8"));
output.write(("<p class=\"title\">" + Messages.getString("qa.all.fa.WordsFA") + "</p>").getBytes("UTF-8"));
// ----------------<<<<<<start-- 下面是相关信息提示部份---------------------
output.write("\t<div>\n".getBytes("UTF-8"));
output.write("\t\t<table class=\"infoTableStyle\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n".getBytes("UTF-8"));
// 记忆库
String title = Messages.getString("qa.fa.info.tm");
ProjectConfiger projectConfiger = ProjectConfigerFactory.getProjectConfiger(curProject);
List<DatabaseModelBean> tmBeanList = projectConfiger.getAllTmDbs();
StringBuffer tmInfoSB = new StringBuffer();
if (tmBeanList.size() > 0) {
for (DatabaseModelBean bean : tmBeanList) {
tmInfoSB.append("\t\t\t<div style=\"margin-bottom: 2px;\">");
String dbType = bean.getDbType();
if ("MySQL 5.x".equals(dbType)) {
dbType = "MySQL";
} else if ("MsSQL2005".equals(dbType)) {
dbType = "SQL Server";
}
tmInfoSB.append(dbType);
String location = "";
if ("Internal DB".equals(dbType) || "SQLite".equals(dbType)) {
location = bean.getItlDBLocation();
} else {
location = bean.getHost() + ":" + bean.getPort();
if (":".equals(location)) {
location = "";
}
}
if (location != null && !"".equals(location.trim()) && !" : ".equals(location)) {
tmInfoSB.append(" ( " + location + " ) ");
}
tmInfoSB.append(": ");
tmInfoSB.append(MessageFormat.format("{0}" + bean.getDbName() + "{1}", new Object[] { bean.isDefault() ? "<b>" : "", bean.isDefault() ? "</b>" : "" }));
tmInfoSB.append("</div>\n");
}
} else {
tmInfoSB.append("\t\t\t<div style=\"margin-bottom: 2px;\">");
tmInfoSB.append("N/A");
tmInfoSB.append("</div>\n");
}
String infoStr = QAConstant.FA_Report_Info.replace("###Title###", title).replace("###Content###", tmInfoSB.toString());
output.write(infoStr.getBytes("UTF-8"));
// 最底匹配率
title = Messages.getString("qa.fa.info.newWordMatch");
String content = newWordsMaxMatchRate + "%";
infoStr = QAConstant.FA_Report_Info.replace("###Title###", title).replace("###Content###", content);
output.write(infoStr.getBytes("UTF-8"));
// 分析文件总数
title = Messages.getString("qa.fa.info.fileSum");
content = "" + model.getSubFileNum();
infoStr = QAConstant.FA_Report_Info.replace("###Title###", title).replace("###Content###", content);
output.write(infoStr.getBytes("UTF-8"));
// 分析失败文件
title = Messages.getString("qa.fa.info.errorFiles");
StringBuffer errorFileSB = new StringBuffer();
errorFileSB.append("\t\t\t<div style=\"margin-bottom: 2px;\">");
errorFileSB.append(model.getErrorIFileList().size());
errorFileSB.append("</div>");
for (IFile iFile : model.getErrorIFileList()) {
errorFileSB.append("\t\t\t<div style=\"margin-bottom: 2px;\">");
errorFileSB.append(iFile.getFullPath().toOSString());
errorFileSB.append("</div>");
}
infoStr = QAConstant.FA_Report_Info.replace("###Title###", title).replace("###Content###", errorFileSB.toString());
output.write(infoStr.getBytes("UTF-8"));
// 报告生成时间
title = Messages.getString("qa.fa.info.createTime");
infoStr = QAConstant.FA_Report_Info.replace("###Title###", title).replace("###Content###", createTime);
output.write(infoStr.getBytes("UTF-8"));
output.write("</table></div><br>\n".getBytes("UTF-8"));
// ---------------->>>>>>end-- 报表信息提示部分结束---------------------
int paddLeft = 6;
String folderId = curProject.getFullPath().toOSString();
getAllFolder(curProject, allFolderList);
// 向所有的文件夹传值
setDataToFolder(curProject);
// 首先写下项目
WordsFAResult proFaResult = WordsFAResultMap.get(curProject.getLocation().toOSString());
// --------------数据库匹配率区间---------------------
output.write(("\t\t<div class=\"legendStyle\"><b>" + Messages.getString("qa.fileAnalysis.WordsFA.wordsFA") + "</b></div>").getBytes("UTF-8"));
StringBuffer exterFAdata = new StringBuffer();
//"100-101:0.5;89-99:0.4"
String[] equivArray = equivStr.split(";");
int length = equivArray.length;
// 是否有 上下文匹配
boolean hasExter101 = equivStr.indexOf("external101") != -1;
int interMathNum = 0;
if (interRepeat && !interMatch) {
interMathNum = 1;
} else if (interRepeat && interMatch) {
interMathNum = length - (hasExter101 ? 2 : 1);
}
//要显示列的总数(文件列是普通列的三倍)
int columLength = length - 1 + interMathNum + 3 + 4;
float width = (float) 100 / columLength;
//开始创建表头
exterFAdata.append("\t<table class='tableStyle' cellpadding='0' cellspacing='1'> \n");
// 表头
exterFAdata.append("\t\t<tr>\n");
exterFAdata.append("\t\t\t<td class='headerTd' rowSpan='2' width='" + 3 * width + "%'>" + Messages.getString("qa.all.fa.fileName") + "</td>\n");
exterFAdata.append("\t\t\t<td class='headerTd' colSpan='" + (length - 1) + "' width='" + (length - 1) * width + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.exterMatch") + "</td>\n");
if (interRepeat) {
exterFAdata.append("\t\t\t<td class='headerTd' colSpan='" + interMathNum + "' width='" + interMathNum * width + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.interMatch") + "</td>\n");
}
exterFAdata.append("\t\t\t<td class='headerTd' rowSpan='2' width='" + width + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.newWordsNum") + "</td>\n");
exterFAdata.append("\t\t\t<td class='headerTd' rowSpan='2' width='" + width + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.equivWordsNum") + "</td>\n");
exterFAdata.append("\t\t\t<td class='headerTd' rowSpan='2' width='" + width + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.lockWordsNum") + "</td>\n");
exterFAdata.append("\t\t\t<td class='headerTd' rowSpan='2' width='" + width + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.wordsSum") + "</td>\n");
exterFAdata.append("\t\t</tr>\n");
exterFAdata.append("\t\t<tr>\n");
//这是创建显示结果的外部匹配部份
for (int i = 0; i < length; i++) {
String matchPair = equivArray[i].substring(0, equivArray[i].indexOf(":"));
String className = "headerTd";
if (QAConstant._External101.equals(matchPair)) {
exterFAdata.append("\t\t\t<td class='" + className + "' width='" + width + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.contentMath") + "</td>\n");
} else if (QAConstant._External100.equals(matchPair)) {
exterFAdata.append("\t\t\t<td class='" + className + "' width='" + width + "%'>" + "100%" + "</td>\n");
} else if (!QAConstant._InternalRepeat.equals(matchPair)) {
matchPair = matchPair.substring(0, matchPair.indexOf("-")) + "%" + matchPair.substring(matchPair.indexOf("-"), matchPair.length()) + "%";
exterFAdata.append("\t\t\t<td class='" + className + "' width='" + width + "%'>" + matchPair + "</td>\n");
}
}
//这是创建显示结果的内部匹配部份
for (int i = 0; i < length; i++) {
String matchPair = equivArray[i].substring(0, equivArray[i].indexOf(":"));
String className = "headerTd";
if (interRepeat && QAConstant._InternalRepeat.equals(matchPair)) {
exterFAdata.append("\t\t\t<td class='" + className + "' width='" + width + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.contentRepeat") + "</td>\n");
} else if (interMatch && matchPair.indexOf("external") == -1) {
matchPair = matchPair.substring(0, matchPair.indexOf("-")) + "%" + matchPair.substring(matchPair.indexOf("-"), matchPair.length()) + "%";
exterFAdata.append("\t\t\t<td class='" + className + "' width='" + width + "%'>" + matchPair + "</td>\n");
}
}
exterFAdata.append("\t\t</tr>\n");
// 首先写下项目
exterFAdata.append("<tr onmouseover= \"this.bgColor= '#F1F1FC'\" onmouseout= \"this.bgColor='#FFFFFF'\" bgcolor='#FFFFFF'>\n" + "<td class='folderTd' style='padding-left: 6'><a href='javascript:void(0)' id='" + folderId + "' name='allExter' class='link' " + "title='" + Messages.getString("qa.all.fa.clickToShrink") + "' onclick='clickFolder(id, name)' >" + "<span id='" + folderId + "_span'>-</span> " + curProject.getName() + "</a></td>\n");
//项目的外部匹配部份
for (int i = 0; i < length; i++) {
String matchPair = equivArray[i].substring(0, equivArray[i].indexOf(":"));
String className = "folderTd";
if (QAConstant._External101.equals(matchPair)) {
exterFAdata.append("\t\t\t<td class='" + className + "' align='right'>" + proFaResult.getExterMatch("101") + "</td>\n");
} else if (QAConstant._External100.equals(matchPair)) {
exterFAdata.append("\t\t\t<td class='" + className + "' align='right'>" + proFaResult.getExterMatch("100") + "</td>\n");
} else if (!QAConstant._InternalRepeat.equals(matchPair)) {
exterFAdata.append("\t\t\t<td class='" + className + "' align='right'>" + proFaResult.getExterMatch(matchPair) + "</td>\n");
}
}
//项目的内部匹配部份
for (int i = 0; i < length; i++) {
String matchPair = equivArray[i].substring(0, equivArray[i].indexOf(":"));
String className = "folderTd";
if (interRepeat && QAConstant._InternalRepeat.equals(matchPair)) {
exterFAdata.append("\t\t\t<td class='" + className + "' align='right'>" + proFaResult.getInterMatch("100-101") + "</td>\n");
} else if (interMatch && matchPair.indexOf("external") == -1) {
exterFAdata.append("\t\t\t<td class='" + className + "' align='right'>" + proFaResult.getInterMatch(matchPair) + "</td>\n");
}
}
//新字数,锁定字数,总字数
exterFAdata.append("\t\t\t<td class='folderTd' align='right'>" + proFaResult.getNewWords() + "</td>\n");
exterFAdata.append("\t\t\t<td class='folderTd' align='right'>" + proFaResult.getEqalWords(equivStr) + "</td>\n");
exterFAdata.append("\t\t\t<td class='folderTd' align='right'>" + proFaResult.getLockedWords() + "</td>\n");
exterFAdata.append("\t\t\t<td class='folderTd' align='right'>" + proFaResult.getTotalWords() + "</td>\n");
exterFAdata.append("</tr>");
allExterMatchSetInputData(curProject, exterFAdata, paddLeft, equivArray);
exterFAdata.append("\t</table>\n");
output.write(exterFAdata.toString().getBytes("UTF-8"));
// --------------文本段---------------------
output.write("<br/>\n".getBytes("UTF-8"));
output.write(("\t\t\t<div class=\"legendStyle\"><b>" + Messages.getString("qa.fileAnalysis.WordsFA.paragraph") + "</b></div>").getBytes("UTF-8"));
StringBuffer paraFAdata = new StringBuffer();
int paraTableColumnNum = 4 + 3;
if (interRepeat && !interMatch) {
// 文件名列占两个单位的长度
paraTableColumnNum = 5 + 3;
} else if (interRepeat && interMatch) {
paraTableColumnNum = 6 + 3;
}
float paraCloumnWidth = (float) 100 / paraTableColumnNum;
// 创建一个表
paraFAdata.append("\t<table class='tableStyle' cellpadding='0' cellspacing='1'> \n");
// 表头
paraFAdata.append("\t\t<tr>\n");
paraFAdata.append("\t\t\t<td class='headerTd' width='" + 2 * paraCloumnWidth + "%'>" + Messages.getString("qa.all.fa.fileName") + "</td>\n");
paraFAdata.append("\t\t\t<td class='headerTd' width='" + paraCloumnWidth + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.newPara") + "</td>\n");
if (interMatch) {
paraFAdata.append("\t\t\t<td class='headerTd' width='" + paraCloumnWidth + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.interMatchPara") + "</td>\n");
}
paraFAdata.append("\t\t\t<td class='headerTd' width='" + paraCloumnWidth + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.exterMatchPara") + "</td>\n");
if (interRepeat) {
paraFAdata.append("\t\t\t<td class='headerTd' width='" + paraCloumnWidth + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.interRepeatPara") + "</td>\n");
}
paraFAdata.append("\t\t\t<td class='headerTd' width='" + paraCloumnWidth + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.exterRepeatPara") + "</td>\n");
paraFAdata.append("\t\t\t<td class='headerTd' width='" + paraCloumnWidth + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.lockedPara") + "</td>\n");
paraFAdata.append("\t\t\t<td class='headerTd' width='" + paraCloumnWidth + "%'>" + Messages.getString("qa.fileAnalysis.WordsFA.paraSum") + "</td>\n");
paraFAdata.append("\t\t</tr>\n");
// 首先写下项目
paddLeft = 6;
paraFAdata.append("<tr onmouseover= \"this.bgColor= '#F1F1FC'\" onmouseout= \"this.bgColor='#FFFFFF'\" bgcolor='#FFFFFF'>\n" + "<td class='folderTd' style='padding-left: 6'><a href='javascript:void(0)' id='" + folderId + "' name='paras' class='link' " + "title='" + Messages.getString("qa.all.fa.clickToShrink") + "' onclick='clickFolder(id, name)' ><span id='" + folderId + "_span'>-</span> " + curProject.getName() + "</a></td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getNewPara() + "</td>\n" + (interMatch ? "<td class='folderTd' align='right'>" + proFaResult.getInterMatchPara() + "</td>\n" : "") + "<td class='folderTd' align='right'>" + proFaResult.getExterMatchPara() + "</td>\n" + (interRepeat ? "<td class='folderTd' align='right'>" + proFaResult.getInterRepeatPara() + "</td>\n" : "") + "<td class='folderTd' align='right'>" + proFaResult.getExterRepeatPara() + "</td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getLockedPara() + "</td>\n" + "<td class='folderTd' align='right'>" + proFaResult.getTotalPara() + "</td>\n" + "</tr>");
paraSetInputData(curProject, paraFAdata, paddLeft);
paraFAdata.append("\t</table>\n");
output.write(paraFAdata.toString().getBytes("UTF-8"));
// output.write("\t\t</fieldset><br/>\n".getBytes("UTF-8"));
/* String htmlPathDiv = "<div style='width:100%;font-size:14;color:blue;'>"
+ Messages.getString("qa.all.fa.fileLocation")
+ curProject.getFullPath().append("Report").append(htmlName).toOSString() + "</div>";
output.write(htmlPathDiv.getBytes("UTF-8"));*/
output.write("\t</body>\n".getBytes("UTF-8"));
output.write("</html>".getBytes("UTF-8"));
output.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
logger.error(Messages.getString("qa.fileAnalysis.WordsFA.log6"), e);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
logger.error(Messages.getString("qa.fileAnalysis.WordsFA.log7"), e);
} catch (IOException e) {
e.printStackTrace();
logger.error(Messages.getString("qa.fileAnalysis.WordsFA.log8"), e);
}
return htmlPath;
}
use of net.heartsome.cat.common.bean.DatabaseModelBean in project translationstudio8 by heartsome.
the class ProjectSettingTMPage method addToCurrDbList.
/**
* 将选中的内容添加到列表中
* @param selection
* ;
*/
private void addToCurrDbList(List<DatabaseModelBean> hasSelection) {
StringBuffer dbNames = new StringBuffer();
for (int i = 0; i < hasSelection.size(); i++) {
DatabaseModelBean dbModel = hasSelection.get(i);
checkDbHashMatch(dbModel);
if (!checkDbIsExist(curDbList, dbModel)) {
if (curDbList.size() == 0) {
// 第一个添加的库为默认库
dbModel.setDefault(true);
}
curDbList.add(dbModel);
this.tableViewer.add(dbModel);
} else {
dbNames.append(dbModel.getDbName());
dbNames.append("\n");
}
}
if (dbNames.length() != 0) {
MessageDialog.openInformation(getShell(), Messages.getString("projectsetting.ProjectSettingTMPage.msgTitle"), Messages.getString("projectsetting.ProjectSettingTMPage.msg3") + dbNames.toString());
}
}
use of net.heartsome.cat.common.bean.DatabaseModelBean in project translationstudio8 by heartsome.
the class ProjectSettingTMPage method createColumn.
/**
* 创建Table列
* @param viewer
* ;
*/
private void createColumn(final TableViewer viewer) {
String[] clmnTitles = { Messages.getString("projectsetting.ProjectSettingTMPage.clmnTitles1"), Messages.getString("projectsetting.ProjectSettingTMPage.clmnTitles2"), Messages.getString("projectsetting.ProjectSettingTMPage.clmnTitles3"), Messages.getString("projectsetting.ProjectSettingTMPage.clmnTitles4"), Messages.getString("projectsetting.ProjectSettingTMPage.clmnTitles5") };
int[] clmnBounds = { 100, 100, 200, 90, 70 };
TableViewerColumn col = createTableViewerColumn(viewer, clmnTitles[0], clmnBounds[0], 0);
col.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
DatabaseModelBean dbModel = (DatabaseModelBean) element;
return dbModel.getDbName();
}
});
col = createTableViewerColumn(viewer, clmnTitles[1], clmnBounds[1], 1);
col.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
DatabaseModelBean dbModel = (DatabaseModelBean) element;
String dbType = dbModel.getDbType();
if (dbType.equals(Constants.DBTYPE_MYSQL)) {
dbType = Constants.DBTYPE_MYSQL_FOR_UI;
} else if (dbType.equals(Constants.DBTYPE_MSSQL2005)) {
dbType = Constants.DBTYPE_MSSQL2005_FOR_UI;
} else if (dbType.equals(Constants.DBTYPE_SQLITE)) {
dbType = Messages.getString("tm.dbtype.sqlite");
}
return dbType;
}
});
col = createTableViewerColumn(viewer, clmnTitles[2], clmnBounds[2], 2);
col.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
DatabaseModelBean dbModel = (DatabaseModelBean) element;
if (dbModel.getDbType().equals("Internal DB") || dbModel.getDbType().equals("SQLite")) {
return dbModel.getItlDBLocation();
}
return dbModel.getHost();
}
});
col = createTableViewerColumn(viewer, clmnTitles[3], clmnBounds[3], 3);
col.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
DatabaseModelBean dbModel = (DatabaseModelBean) element;
if (dbModel.isHasMatch()) {
return Messages.getString("projectsetting.ProjectSettingTMPage.yes");
} else {
return Messages.getString("projectsetting.ProjectSettingTMPage.no");
}
}
});
col = createTableViewerColumn(viewer, clmnTitles[4], clmnBounds[4], 4);
col.setLabelProvider(new ColumnLabelProvider() {
public Image getImage(Object element) {
DatabaseModelBean dbModel = (DatabaseModelBean) element;
if (dbModel.isDefault()) {
return checkedImage;
} else {
return uncheckedImage;
}
}
public String getText(Object element) {
return null;
}
});
col.setEditingSupport(new ReadableEditingSupport(viewer));
}
Aggregations