Search in sources :

Example 6 with ExportFilterBean

use of net.heartsome.cat.database.bean.ExportFilterBean in project translationstudio8 by heartsome.

the class ExportTmxDialog method initFilterStore.

/**
	 * 初始化过滤器列表 ;
	 */
private void initFilterStore() {
    this.filterList = filterStore.getFilterRule("TMX");
    ExportFilterBean empty = new ExportFilterBean();
    empty.setFilterName(Messages.getString("dialog.ExportTmxDialog.empty"));
    filterList.add(0, empty);
}
Also used : ExportFilterBean(net.heartsome.cat.database.bean.ExportFilterBean)

Example 7 with ExportFilterBean

use of net.heartsome.cat.database.bean.ExportFilterBean 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 8 with ExportFilterBean

use of net.heartsome.cat.database.bean.ExportFilterBean in project translationstudio8 by heartsome.

the class ExportFilterSettingDialog method okPressed.

@Override
protected void okPressed() {
    String filterName = this.filterNameText.getText();
    if (filterName == null || filterName.equals("")) {
        MessageDialog.openInformation(getShell(), Messages.getString("dialog.ExportFilterSettingDialog.msgTitle"), Messages.getString("dialog.ExportFilterSettingDialog.msg2"));
        return;
    }
    String filterConnector = "AND";
    if (isAnyCbtn.getSelection()) {
        filterConnector = "OR";
    }
    List<ExportFilterComponentBean> filterList = new ArrayList<ExportFilterComponentBean>();
    Control[] c = dynaComposite.getChildren();
    for (int i = 0; i < c.length; i++) {
        if (c[i] instanceof ExportFilterComposite) {
            ExportFilterComposite comp = (ExportFilterComposite) c[i];
            ExportFilterComponentBean bean = comp.getValue();
            if (bean.getFilterVlaue() != null && !bean.getFilterVlaue().equals("")) {
                filterList.add(bean);
            }
        }
    }
    if (currentFilter != null) {
        // 编辑状态,策略:删除原有的内容,重新执行添加
        filterStore.deleteFilterRuleByName(currentFilter.getFilterName(), currentFilter.getFilterType());
    }
    if (filterStore.isFilterNameExist(filterName, getRuleType())) {
        MessageDialog.openInformation(getShell(), Messages.getString("dialog.ExportFilterSettingDialog.msgTitle"), Messages.getString("dialog.ExportFilterSettingDialog.msg3"));
        return;
    }
    if (filterList.size() == 0) {
        logger.error(Messages.getString("dialog.ExportFilterSettingDialog.logger1"));
        MessageDialog.openInformation(getShell(), Messages.getString("dialog.ExportFilterSettingDialog.msgTitle"), Messages.getString("dialog.ExportFilterSettingDialog.msg4"));
        return;
    }
    currentFilter = new ExportFilterBean();
    currentFilter.setFilterName(filterName);
    currentFilter.setFilterOption(filterList);
    currentFilter.setFilterType(getRuleType());
    currentFilter.setFilterConnector(filterConnector);
    filterStore.saveFilterRule(currentFilter);
    super.okPressed();
}
Also used : ExportFilterComponentBean(net.heartsome.cat.database.bean.ExportFilterComponentBean) Control(org.eclipse.swt.widgets.Control) ArrayList(java.util.ArrayList) ExportFilterBean(net.heartsome.cat.database.bean.ExportFilterBean) Point(org.eclipse.swt.graphics.Point)

Aggregations

ExportFilterBean (net.heartsome.cat.database.bean.ExportFilterBean)8 File (java.io.File)4 ArrayList (java.util.ArrayList)4 ExportDatabaseBean (net.heartsome.cat.database.bean.ExportDatabaseBean)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 Iterator (java.util.Iterator)2 List (java.util.List)2 Map (java.util.Map)2 Entry (java.util.Map.Entry)2 DatabaseModelBean (net.heartsome.cat.common.bean.DatabaseModelBean)2 HSDropDownButton (net.heartsome.cat.common.ui.HSDropDownButton)2 ExportFilterComponentBean (net.heartsome.cat.database.bean.ExportFilterComponentBean)2 ExportAbstract (net.heartsome.cat.document.ExportAbstract)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)2 ComboViewer (org.eclipse.jface.viewers.ComboViewer)2 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 ListViewer (org.eclipse.jface.viewers.ListViewer)2 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)2 TableViewer (org.eclipse.jface.viewers.TableViewer)2