use of com.ximpleware.NavException in project translationstudio8 by heartsome.
the class LanguageConfiger method parseFile.
private void parseFile() {
VTDGen vg = new VTDGen();
try {
if (vg.parseFile(langConfigFile.getPath(), true)) {
vu = new VTDUtils(vg.getNav());
ap = new AutoPilot(vu.getVTDNav());
} else {
throw new ParseException();
}
} catch (NavException e) {
LOGGER.error("", e);
} catch (ParseException e) {
LOGGER.error("", e);
}
}
use of com.ximpleware.NavException in project translationstudio8 by heartsome.
the class DatabaseConfiger method getAllServerConfig.
/**
* 获取数据库服务器配置文件中保存的所有服务器信息
* @return Map<数据库类型,List<数据库配置信息> 参考{@link DatabaseModelBean};
*/
public Map<String, List<DatabaseModelBean>> getAllServerConfig() {
Map<String, List<DatabaseModelBean>> map = new HashMap<String, List<DatabaseModelBean>>();
try {
AutoPilot tempAp = new AutoPilot(vu.getVTDNav());
tempAp.selectXPath("/servers/server");
while (tempAp.evalXPath() != -1) {
String type = vu.getCurrentElementAttribut("type", "");
if (map.containsKey(type)) {
continue;
} else {
map.put(type, getServersConfigByType(type));
}
}
} catch (XPathParseException e) {
logger.error("", e);
} catch (XPathEvalException e) {
logger.error("", e);
} catch (NavException e) {
logger.error("", e);
}
return map;
}
use of com.ximpleware.NavException in project translationstudio8 by heartsome.
the class ExportFilterStoreConfiger method getFilterRule.
/**
* 获取过滤规则
* @param ruleType
* "TMX" 或者 "TBX"
* @return 空的集合或者带有内容的集合;
*/
public List<ExportFilterBean> getFilterRule(String ruleType) {
Assert.isLegal(ruleType.equals("TMX") || ruleType.equals("TBX"), Messages.getString("core.ExportFilterStoreConfiger.msg1"));
List<ExportFilterBean> filterList = new ArrayList<ExportFilterBean>();
try {
AutoPilot tempAp = new AutoPilot(vu.getVTDNav());
tempAp.selectXPath("/filter/" + ruleType + "/content");
while (tempAp.evalXPath() != -1) {
Hashtable<String, String> attrs = vu.getCurrentElementAttributs();
ExportFilterBean bean = new ExportFilterBean();
bean.setFilterType(ruleType);
bean.setFilterName(attrs.get("name"));
bean.setFilterConnector(attrs.get("type"));
AutoPilot ap = new AutoPilot(vu.getVTDNav());
ap.selectXPath("./option");
List<ExportFilterComponentBean> cBeanList = new ArrayList<ExportFilterComponentBean>();
while (ap.evalXPath() != -1) {
Hashtable<String, String> oAttrs = vu.getCurrentElementAttributs();
ExportFilterComponentBean cBean = new ExportFilterComponentBean(ruleType);
cBean.setOptionName(oAttrs.get("name"));
cBean.setCurrentExpression(oAttrs.get("operator"));
cBean.setFilterVlaue(oAttrs.get("value"));
cBeanList.add(cBean);
}
if (cBeanList.size() == 0) {
// deleteFilterRuleByName(bean.getFilterName(),ruleType);
continue;
}
bean.setFilterOption(cBeanList);
filterList.add(bean);
}
} catch (XPathParseException e) {
logger.error("", e);
} catch (XPathEvalException e) {
logger.error("", e);
} catch (NavException e) {
logger.error("", e);
}
return filterList;
}
use of com.ximpleware.NavException in project translationstudio8 by heartsome.
the class ExportFilterStoreConfiger method isFilterNameExist.
/**
* 检查filterName是否已经存在
* @param filterName
* @param ruleType
* "TMX" 或者 "TBX"
* @return ;
*/
public boolean isFilterNameExist(String filterName, String ruleType) {
Assert.isLegal(ruleType.equals("TMX") || ruleType.equals("TBX"), Messages.getString("core.ExportFilterStoreConfiger.msg1"));
try {
AutoPilot tempAp = new AutoPilot(vu.getVTDNav());
tempAp.selectXPath("/filter/" + ruleType + "/content[@name='" + filterName + "']");
if (tempAp.evalXPath() != -1) {
return true;
}
} catch (XPathParseException e) {
logger.error("", e);
} catch (XPathEvalException e) {
logger.error("", e);
} catch (NavException e) {
logger.error("", e);
}
return false;
}
use of com.ximpleware.NavException in project translationstudio8 by heartsome.
the class MouseEditAction method run.
public void run(NatTable natTable, MouseEvent event) {
XLIFFEditorImplWithNatTable xliffEditor = XLIFFEditorImplWithNatTable.getCurrent();
if (xliffEditor == null) {
return;
}
int columnPosition = natTable.getColumnPositionByX(event.x);
int rowPosition = natTable.getRowPositionByY(event.y);
boolean withShiftMask = (event.stateMask & SWT.SHIFT) != 0;
boolean withCtrlMask = (event.stateMask & SWT.CTRL) != 0;
if (!xliffEditor.isHorizontalLayout() && rowPosition != HsMultiActiveCellEditor.targetRowPosition && (rowPosition != HsMultiActiveCellEditor.sourceRowPosition || columnPosition != xliffEditor.getSrcColumnIndex())) {
HsMultiActiveCellEditor.commit(true);
natTable.doCommand(new SelectCellCommand(natTable, columnPosition, rowPosition, withShiftMask, withCtrlMask));
if (columnPosition == xliffEditor.getTgtColumnIndex()) {
HsMultiCellEditorControl.activeSourceAndTargetCell(xliffEditor);
}
} else if (rowPosition != HsMultiActiveCellEditor.targetRowPosition || columnPosition != xliffEditor.getSrcColumnIndex() || columnPosition != xliffEditor.getTgtColumnIndex()) {
HsMultiActiveCellEditor.commit(true);
natTable.doCommand(new SelectCellCommand(natTable, columnPosition, rowPosition, withShiftMask, withCtrlMask));
if (columnPosition == xliffEditor.getSrcColumnIndex() || columnPosition == xliffEditor.getTgtColumnIndex()) {
HsMultiCellEditorControl.activeSourceAndTargetCell(xliffEditor);
}
}
// 点击批注图片时打开编辑批注对话框
Image image = XliffEditorGUIHelper.getImage(ImageName.HAS_NOTE);
// int columnPosition = natTable.getColumnPositionByX(event.x);
// int rowPosition = natTable.getRowPositionByY(event.y);
LayerCell cell = natTable.getCellByPosition(columnPosition, rowPosition);
Rectangle imageBounds = image.getBounds();
if (cell == null) {
return;
}
Rectangle cellBounds = cell.getBounds();
int x = cellBounds.x + imageBounds.width * 3 + 20;
int y = cellBounds.y + CellStyleUtil.getVerticalAlignmentPadding(CellStyleUtil.getCellStyle(cell, natTable.getConfigRegistry()), cellBounds, imageBounds.height);
if (columnPosition == xliffEditor.getStatusColumnIndex() && event.x >= x && event.x <= (x + imageBounds.width) && event.y >= y && event.y <= (y + imageBounds.height)) {
if ((xliffEditor.isHorizontalLayout() && columnPosition == 2) || (!xliffEditor.isHorizontalLayout() && columnPosition == 1)) {
Vector<NoteBean> noteBeans = null;
try {
int rowIndex = natTable.getRowIndexByPosition(rowPosition);
if (!xliffEditor.isHorizontalLayout()) {
rowIndex = rowIndex / VerticalNatTableConfig.ROW_SPAN;
}
noteBeans = xliffEditor.getXLFHandler().getNotes(xliffEditor.getXLFHandler().getRowId(rowIndex));
if (noteBeans != null && noteBeans.size() > 0) {
UpdateNoteDialog dialog = new UpdateNoteDialog(xliffEditor.getSite().getShell(), xliffEditor, rowIndex);
dialog.open();
}
} catch (NavException e) {
e.printStackTrace();
} catch (XPathParseException e) {
e.printStackTrace();
} catch (XPathEvalException e) {
e.printStackTrace();
}
}
}
}
Aggregations