use of net.heartsome.cat.ts.ui.qa.model.NontransElementBean in project translationstudio8 by heartsome.
the class NonTranslationQAPage method initValue.
/**
* 初始化相关数据
*/
public void initValue() {
operate = new NonTransElementOperate();
operate.openNonTransDB();
internalElementList = QAModel.getInterNonTransElements();
defaultTipList.add(new NontransElementBean(null, Messages.getString("qa.preference.NonTranslationQAPage.addInterElement"), null, null));
dataList = operate.getNonTransElements();
}
use of net.heartsome.cat.ts.ui.qa.model.NontransElementBean in project translationstudio8 by heartsome.
the class NonTranslationQAPage method addInternalElement.
/**
* 添加内置非译元素
*/
public void addInternalElement() {
ISelection selection = comboViewer.getSelection();
if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
NontransElementBean interBean = (NontransElementBean) structuredSelection.getFirstElement();
if (interBean.getId() == null) {
return;
}
int eleSum = tableViewer.getTable().getItemCount();
for (int i = 0; i < eleSum; i++) {
NontransElementBean curBean = new NontransElementBean();
if (tableViewer.getElementAt(i) instanceof NontransElementBean) {
curBean = (NontransElementBean) tableViewer.getElementAt(i);
if (curBean.getId().equals(interBean.getId())) {
MessageDialog.openWarning(getShell(), Messages.getString("qa.all.dialog.warning"), MessageFormat.format(Messages.getString("qa.preference.NonTranslationQAPage.tip5"), interBean.getName()));
return;
}
}
}
dataList.add(interBean);
tableViewer.refresh();
}
}
use of net.heartsome.cat.ts.ui.qa.model.NontransElementBean in project translationstudio8 by heartsome.
the class NonTranslationQAPage method performOk.
@Override
public boolean performOk() {
if (!isInit) {
return true;
}
// 遍历列表,获取出要添加的数据
List<NontransElementBean> addElementList = new ArrayList<NontransElementBean>();
NontransElementBean listViewerBean;
int listViewerNum = tableViewer.getTable().getItemCount();
for (int i = 0; i < listViewerNum; i++) {
if (tableViewer.getElementAt(i) instanceof NontransElementBean) {
listViewerBean = (NontransElementBean) tableViewer.getElementAt(i);
addElementList.add(listViewerBean);
}
}
// 删除所有非译元素
operate.deleteAllElement();
// 再进行相关操作,先添加
if (addElementList.size() > 0) {
operate.addNonTransElement(addElementList);
}
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
int oldValue = store.getInt(QAConstant.QA_PREF_nonTrans_changeTag);
store.setValue(QAConstant.QA_PREF_nonTrans_changeTag, ++oldValue);
return true;
}
use of net.heartsome.cat.ts.ui.qa.model.NontransElementBean in project translationstudio8 by heartsome.
the class NonTranslationQAPage method deleteElement.
/**
* 删除列表中的非译元素
*/
@SuppressWarnings("unchecked")
public void deleteElement() {
ISelection selection = tableViewer.getSelection();
if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
boolean confirm = MessageDialog.openConfirm(getShell(), Messages.getString("qa.preference.NonTranslationQAPage.enter"), Messages.getString("qa.preference.NonTranslationQAPage.enterDelete"));
if (!confirm) {
return;
}
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
Iterator<NontransElementBean> iter = structuredSelection.iterator();
while (iter.hasNext()) {
NontransElementBean selectElement = iter.next();
dataList.remove(selectElement);
}
tableViewer.refresh();
}
}
use of net.heartsome.cat.ts.ui.qa.model.NontransElementBean in project translationstudio8 by heartsome.
the class NonTransElementOperate method addNonTransElement.
/**
* 添加非译元素
* @return
*/
public boolean addNonTransElement(List<NontransElementBean> elementList) {
StringBuffer dataSB = new StringBuffer();
for (NontransElementBean bean : elementList) {
dataSB.append("\t<element id='" + bean.getId() + "'>\n");
dataSB.append("\t\t<name>" + bean.getName() + "</name>\n");
dataSB.append("\t\t<content>" + bean.getContent() + "</content>\n");
dataSB.append("\t\t<regular>" + TextUtil.cleanSpecialString(bean.getRegular()) + "</regular>\n");
dataSB.append("\t</element>\n");
}
if (elementList.size() > 0) {
return handler.addDataToXml(path, "/nonTrans", dataSB.substring(0, dataSB.length() - 1));
}
return false;
}
Aggregations