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;
}
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;
}
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;
}
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;
}
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);
}
Aggregations