Search in sources :

Example 86 with NavException

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);
    }
}
Also used : VTDUtils(net.heartsome.xml.vtdimpl.VTDUtils) AutoPilot(com.ximpleware.AutoPilot) NavException(com.ximpleware.NavException) VTDGen(com.ximpleware.VTDGen) XPathParseException(com.ximpleware.XPathParseException) ParseException(com.ximpleware.ParseException)

Example 87 with NavException

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;
}
Also used : XPathParseException(com.ximpleware.XPathParseException) HashMap(java.util.HashMap) AutoPilot(com.ximpleware.AutoPilot) DatabaseModelBean(net.heartsome.cat.common.bean.DatabaseModelBean) XPathEvalException(com.ximpleware.XPathEvalException) NavException(com.ximpleware.NavException) ArrayList(java.util.ArrayList) List(java.util.List)

Example 88 with NavException

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;
}
Also used : ExportFilterComponentBean(net.heartsome.cat.database.bean.ExportFilterComponentBean) XPathParseException(com.ximpleware.XPathParseException) AutoPilot(com.ximpleware.AutoPilot) ArrayList(java.util.ArrayList) XPathEvalException(com.ximpleware.XPathEvalException) NavException(com.ximpleware.NavException) ExportFilterBean(net.heartsome.cat.database.bean.ExportFilterBean)

Example 89 with NavException

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;
}
Also used : XPathParseException(com.ximpleware.XPathParseException) AutoPilot(com.ximpleware.AutoPilot) XPathEvalException(com.ximpleware.XPathEvalException) NavException(com.ximpleware.NavException)

Example 90 with NavException

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();
            }
        }
    }
}
Also used : XLIFFEditorImplWithNatTable(net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable) SelectCellCommand(net.sourceforge.nattable.selection.command.SelectCellCommand) LayerCell(net.sourceforge.nattable.layer.cell.LayerCell) Rectangle(org.eclipse.swt.graphics.Rectangle) NavException(com.ximpleware.NavException) XPathEvalException(com.ximpleware.XPathEvalException) Image(org.eclipse.swt.graphics.Image) XPathParseException(com.ximpleware.XPathParseException) NoteBean(net.heartsome.cat.ts.core.bean.NoteBean) UpdateNoteDialog(net.heartsome.cat.ts.ui.xliffeditor.nattable.dialog.UpdateNoteDialog)

Aggregations

NavException (com.ximpleware.NavException)93 AutoPilot (com.ximpleware.AutoPilot)70 XPathParseException (com.ximpleware.XPathParseException)70 XPathEvalException (com.ximpleware.XPathEvalException)67 VTDNav (com.ximpleware.VTDNav)63 VTDUtils (net.heartsome.xml.vtdimpl.VTDUtils)58 XMLModifier (com.ximpleware.XMLModifier)31 ModifyException (com.ximpleware.ModifyException)29 ArrayList (java.util.ArrayList)22 IOException (java.io.IOException)21 VTDGen (com.ximpleware.VTDGen)17 UnsupportedEncodingException (java.io.UnsupportedEncodingException)13 HashMap (java.util.HashMap)13 TranscodeException (com.ximpleware.TranscodeException)12 ParseException (com.ximpleware.ParseException)11 FileOutputStream (java.io.FileOutputStream)11 List (java.util.List)10 LinkedList (java.util.LinkedList)9 FileNotFoundException (java.io.FileNotFoundException)8 LinkedHashMap (java.util.LinkedHashMap)8