Search in sources :

Example 6 with NontransElementBean

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();
}
Also used : NonTransElementOperate(net.heartsome.cat.ts.ui.qa.nonTransElement.NonTransElementOperate) NontransElementBean(net.heartsome.cat.ts.ui.qa.model.NontransElementBean)

Example 7 with NontransElementBean

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();
    }
}
Also used : NontransElementBean(net.heartsome.cat.ts.ui.qa.model.NontransElementBean) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Point(org.eclipse.swt.graphics.Point)

Example 8 with NontransElementBean

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;
}
Also used : NontransElementBean(net.heartsome.cat.ts.ui.qa.model.NontransElementBean) ArrayList(java.util.ArrayList) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Point(org.eclipse.swt.graphics.Point)

Example 9 with NontransElementBean

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();
    }
}
Also used : NontransElementBean(net.heartsome.cat.ts.ui.qa.model.NontransElementBean) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 10 with NontransElementBean

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;
}
Also used : NontransElementBean(net.heartsome.cat.ts.ui.qa.model.NontransElementBean)

Aggregations

NontransElementBean (net.heartsome.cat.ts.ui.qa.model.NontransElementBean)10 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 ISelection (org.eclipse.jface.viewers.ISelection)4 Point (org.eclipse.swt.graphics.Point)4 ArrayList (java.util.ArrayList)2 AddOrEditNontransElementDialog (net.heartsome.cat.ts.ui.qa.dialogs.AddOrEditNontransElementDialog)2 NonTransElementOperate (net.heartsome.cat.ts.ui.qa.nonTransElement.NonTransElementOperate)2 Map (java.util.Map)1 QAResultBean (net.heartsome.cat.ts.ui.qa.model.QAResultBean)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 SelectionListener (org.eclipse.swt.events.SelectionListener)1