Search in sources :

Example 51 with Hashtable

use of java.util.Hashtable in project XobotOS by xamarin.

the class LexerCore method addLexer.

protected Hashtable addLexer(String lexerName) {
    currentLexer = (Hashtable) lexerTables.get(lexerName);
    if (currentLexer == null) {
        currentLexer = new Hashtable();
        lexerTables.put(lexerName, currentLexer);
    }
    return currentLexer;
}
Also used : Hashtable(java.util.Hashtable)

Example 52 with Hashtable

use of java.util.Hashtable in project translationstudio8 by heartsome.

the class TextUtil method plugin_loadCoutries.

/**
	 * 加载国家名称,针对插件开发模块 robert 2012-03-15
	 * @param langXMlLC
	 * @param _languages
	 * @throws Exception
	 */
public static Hashtable<String, String> plugin_loadCoutries() throws Exception {
    // 国家文件位置
    String countryXmlLC = CoreActivator.ISO3166_1_PAHT;
    Hashtable<String, String> _countries = new Hashtable<String, String>();
    VTDGen vg = new VTDGen();
    vg.setDoc(readBytesFromIS(CoreActivator.getConfigurationFileInputStream(countryXmlLC)));
    vg.parse(true);
    VTDNav vn = vg.getNav();
    AutoPilot ap = new AutoPilot(vn);
    AutoPilot childAP = new AutoPilot(vn);
    ap.selectXPath("/ISO_3166-1_List_en/ISO_3166-1_Entry");
    while (ap.evalXPath() != -1) {
        String code = "";
        String name = "";
        int index;
        vn.push();
        childAP.selectXPath("./ISO_3166-1_Alpha-2_Code_element");
        if (childAP.evalXPath() != -1) {
            if ((index = vn.getText()) != -1) {
                code = vn.toString(index).trim().toUpperCase();
            }
        }
        vn.pop();
        vn.push();
        childAP.selectXPath("./ISO_3166-1_Country_name");
        if (childAP.evalXPath() != -1) {
            if ((index = vn.getText()) != -1) {
                name = vn.toString(index).trim();
            }
        }
        vn.pop();
        if (!"".equals(code) && !"".equals(name)) {
            _countries.put(code, name);
        }
    }
    return _countries;
}
Also used : Hashtable(java.util.Hashtable) AutoPilot(com.ximpleware.AutoPilot) VTDGen(com.ximpleware.VTDGen) VTDNav(com.ximpleware.VTDNav)

Example 53 with Hashtable

use of java.util.Hashtable in project translationstudio8 by heartsome.

the class DeleteToEndOrToTagHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    IEditorPart editor = HandlerUtil.getActiveEditor(event);
    if (editor instanceof XLIFFEditorImplWithNatTable) {
        XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
        String deleteType = event.getParameter("DeleteContent");
        if (deleteType == null) {
            return null;
        }
        StyledTextCellEditor cellEditor = HsMultiActiveCellEditor.getFocusCellEditor();
        if (cellEditor == null || !cellEditor.getCellType().equals(NatTableConstant.TARGET)) {
            return null;
        }
        if (!cellEditor.isEditable()) {
            // cellEditor.showUneditableMessage();
            MessageDialog.openInformation(HandlerUtil.getActiveShell(event), Messages.getString("handler.DeleteToEndOrToTagHandler.msgTitle"), cellEditor.getEditableManager().getUneditableMessage());
            return null;
        }
        StyledText styledText = cellEditor.getSegmentViewer().getTextWidget();
        int offset = styledText.getCaretOffset();
        Point p = styledText.getSelection();
        if (p != null) {
            int len = styledText.getText().length();
            String preText = "";
            String nextText = "";
            SegmentViewer viewer = (SegmentViewer) cellEditor.getSegmentViewer();
            if (offset > 0) {
                preText = styledText.getText(0, offset - 1);
                preText = viewer.convertDisplayTextToOriginalText(preText);
            }
            // 删除标记前所有内容
            if (deleteType.equals("DeleteToTag") && offset < len) {
                nextText = styledText.getText(offset, len - 1);
                Matcher matcher = PATTERN.matcher(nextText);
                if (matcher.find()) {
                    int index = matcher.start();
                    nextText = nextText.substring(index);
                } else {
                    // 选择删除标记前所有内容时,如果当前光标之后没有标记,则删除光标之后的所有内容
                    nextText = "";
                }
            }
            nextText = viewer.convertDisplayTextToOriginalText(nextText);
            String newText = preText + nextText;
            Hashtable<String, String> map = new Hashtable<String, String>();
            // Fix Bug #2883 删除光标后内容--同时选择多个文本段进行操作时,界面出错 By Jason
            // for (String rowId : xliffEditor.getSelectedRowIds()) {
            // map.put(rowId, newText);
            // }
            int index = cellEditor.getRowIndex();
            String rowId = xliffEditor.getXLFHandler().getRowId(index);
            map.put(rowId, newText);
            xliffEditor.updateSegments(map, xliffEditor.getTgtColumnIndex(), null, null);
            // 定位光标
            styledText.setCaretOffset(offset);
        }
    }
    return null;
}
Also used : XLIFFEditorImplWithNatTable(net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable) StyledText(org.eclipse.swt.custom.StyledText) SegmentViewer(net.heartsome.cat.ts.ui.innertag.SegmentViewer) Matcher(java.util.regex.Matcher) Hashtable(java.util.Hashtable) IEditorPart(org.eclipse.ui.IEditorPart) Point(org.eclipse.swt.graphics.Point) StyledTextCellEditor(net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.StyledTextCellEditor) Point(org.eclipse.swt.graphics.Point)

Example 54 with Hashtable

use of java.util.Hashtable in project translationstudio8 by heartsome.

the class TmUtils method fuzzyResult2Alttransbean.

public static Vector<AltTransBean> fuzzyResult2Alttransbean(List<FuzzySearchResult> fuzzyResults) {
    Vector<AltTransBean> altTrans = new Vector<AltTransBean>();
    for (FuzzySearchResult result : fuzzyResults) {
        AltTransBean atb = new AltTransBean();
        //			Map<String, String> match = tu.getTuInfo();
        TmxTU tu = result.getTu();
        // 获取源节点内容、属性及纯文本
        atb.setSrcText(tu.getSource().getPureText());
        atb.setTgtText(tu.getTarget().getPureText());
        Hashtable<String, String> matchProps = new Hashtable<String, String>();
        matchProps.put("match-quality", result.getSimilarity() + "");
        matchProps.put("origin", result.getDbName());
        matchProps.put("tool-id", "Translation Memory");
        matchProps.put("hs:matchType", "TM");
        matchProps.put("xml:space", "default");
        atb.setMatchProps(matchProps);
        Hashtable<String, String> srcProps = new Hashtable<String, String>();
        srcProps.put("xml:lang", tu.getSource().getLangCode());
        atb.setSrcProps(srcProps);
        atb.setSrcContent(tu.getSource().getFullText());
        Hashtable<String, String> tgtProps = new Hashtable<String, String>();
        tgtProps.put("xml:lang", tu.getTarget().getLangCode());
        atb.setTgtProps(tgtProps);
        atb.setTgtContent(tu.getTarget().getFullText());
        Vector<PropGroupBean> pgs = new Vector<PropGroupBean>();
        Vector<PropBean> props = new Vector<PropBean>();
        PropBean pb = new PropBean("creationId", tu.getCreationUser());
        props.add(pb);
        pb = new PropBean("creationDate", tu.getCreationDate());
        props.add(pb);
        pb = new PropBean("changeId", tu.getChangeUser());
        props.add(pb);
        pb = new PropBean("changeDate", tu.getChangeDate());
        props.add(pb);
        List<TmxProp> attrValList = tu.getProps();
        for (TmxProp attr : attrValList) {
            String name = attr.getName();
            if (name == null || name.equals("")) {
                continue;
            }
            String value = attr.getValue();
            if (value == null || value.equals("")) {
                continue;
            }
            PropBean prop = new PropBean(name, value);
            props.add(prop);
        }
        PropGroupBean pg = new PropGroupBean(props);
        // 获取属性组名称。
        pg.setName("hs:prop-group");
        pgs.add(pg);
        atb.setPropGroups(pgs);
        atb.setFuzzyResult(result);
        altTrans.add(atb);
    }
    return altTrans;
}
Also used : Hashtable(java.util.Hashtable) PropBean(net.heartsome.cat.ts.core.bean.PropBean) TmxProp(net.heartsome.cat.common.bean.TmxProp) PropGroupBean(net.heartsome.cat.ts.core.bean.PropGroupBean) AltTransBean(net.heartsome.cat.ts.core.bean.AltTransBean) FuzzySearchResult(net.heartsome.cat.common.bean.FuzzySearchResult) TmxTU(net.heartsome.cat.common.bean.TmxTU) Vector(java.util.Vector)

Example 55 with Hashtable

use of java.util.Hashtable in project translationstudio8 by heartsome.

the class WizardExportResourcesPage2 method setupSelectionsBasedOnSelectedTypes.

/**
	 * Update the tree to only select those elements that match the selected types
	 */
private void setupSelectionsBasedOnSelectedTypes() {
    Runnable runnable = new Runnable() {

        public void run() {
            Map selectionMap = new Hashtable();
            // Only get the white selected ones
            Iterator resourceIterator = resourceGroup.getAllWhiteCheckedItems().iterator();
            while (resourceIterator.hasNext()) {
                // handle the files here - white checked containers require recursion
                IResource resource = (IResource) resourceIterator.next();
                if (resource.getType() == IResource.FILE) {
                    if (hasExportableExtension(resource.getName())) {
                        List resourceList = new ArrayList();
                        IContainer parent = resource.getParent();
                        if (selectionMap.containsKey(parent)) {
                            resourceList = (List) selectionMap.get(parent);
                        }
                        resourceList.add(resource);
                        selectionMap.put(parent, resourceList);
                    }
                } else {
                    setupSelectionsBasedOnSelectedTypes(selectionMap, (IContainer) resource);
                }
            }
            resourceGroup.updateSelections(selectionMap);
        }
    };
    BusyIndicator.showWhile(getShell().getDisplay(), runnable);
}
Also used : Hashtable(java.util.Hashtable) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IContainer(org.eclipse.core.resources.IContainer) Map(java.util.Map) IResource(org.eclipse.core.resources.IResource)

Aggregations

Hashtable (java.util.Hashtable)1752 Test (org.junit.Test)374 ArrayList (java.util.ArrayList)355 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)219 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)142 CompilationUnit (org.eclipse.jdt.core.dom.CompilationUnit)137 IPackageFragment (org.eclipse.jdt.core.IPackageFragment)136 HashMap (java.util.HashMap)104 IOException (java.io.IOException)91 Dictionary (java.util.Dictionary)91 Vector (java.util.Vector)88 File (java.io.File)86 Map (java.util.Map)84 Bundle (org.osgi.framework.Bundle)84 BundleContext (org.osgi.framework.BundleContext)78 Configuration (org.osgi.service.cm.Configuration)75 Enumeration (java.util.Enumeration)70 BundleDescription (org.eclipse.osgi.service.resolver.BundleDescription)70 State (org.eclipse.osgi.service.resolver.State)70 ServiceRegistration (org.osgi.framework.ServiceRegistration)65