Search in sources :

Example 6 with ExportFilterComponentBean

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

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

the class ExportFilterComposite method handleEvent.

public void handleEvent(Event event) {
    Composite parent = this.getParent();
    Composite topParent = parent.getParent();
    if (event.widget == addButton) {
        // add button
        ExportFilterComponentBean bean = new ExportFilterComponentBean(this.ruleType);
        bean.setOptionName(this.baseDataBean.getOptionName());
        bean.setCurrentExpression(this.baseDataBean.getCurrentExpression());
        addComponent(parent, bean);
    } else if (event.widget == deleteButton) {
        // delete button
        this.dispose();
        Integer number = (Integer) parent.getData("currentNumber") - 1;
        parent.setData("currentNumber", number);
        if (number == 1) {
            Control c = parent.getChildren()[0];
            if (c instanceof ExportFilterComposite) {
                ExportFilterComposite temp = (ExportFilterComposite) c;
                temp.setDeleteButtonEnabled(false);
            }
        }
    }
    if (topParent instanceof ScrolledComposite) {
        ((ScrolledComposite) topParent).setMinSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    }
    parent.layout(true);
}
Also used : ExportFilterComponentBean(net.heartsome.cat.database.bean.ExportFilterComponentBean) Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite)

Example 8 with ExportFilterComponentBean

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

ExportFilterComponentBean (net.heartsome.cat.database.bean.ExportFilterComponentBean)8 Control (org.eclipse.swt.widgets.Control)3 ArrayList (java.util.ArrayList)2 ExportFilterBean (net.heartsome.cat.database.bean.ExportFilterBean)2 Point (org.eclipse.swt.graphics.Point)2 AutoPilot (com.ximpleware.AutoPilot)1 NavException (com.ximpleware.NavException)1 XPathEvalException (com.ximpleware.XPathEvalException)1 XPathParseException (com.ximpleware.XPathParseException)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 DBOperator (net.heartsome.cat.database.DBOperator)1 ExportDatabaseBean (net.heartsome.cat.database.bean.ExportDatabaseBean)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 GridData (org.eclipse.swt.layout.GridData)1 Composite (org.eclipse.swt.widgets.Composite)1