Search in sources :

Example 1 with IExpressionBuilderDialogService

use of org.talend.core.runtime.services.IExpressionBuilderDialogService in project tdi-studio-se by Talend.

the class XmlMapFilterContainer method addButtonListener.

@Override
protected void addButtonListener() {
    IService expressionBuilderDialogService = GlobalServiceRegister.getDefault().getService(IExpressionBuilderDialogService.class);
    final IExpressionBuilderDialogController dialog = ((IExpressionBuilderDialogService) expressionBuilderDialogService).getExpressionBuilderInstance(parent, null, null);
    button.addMouseListener(new MouseListener() {

        @Override
        public void mousePressed(MouseEvent me) {
            if (dialog instanceof TrayDialog) {
                TrayDialog parentDialog = (TrayDialog) dialog;
                // if press the button ,should apply ExpressionCellEditor value
                MapperManager mapperManger = (MapperManager) tableManager.getMapperManger();
                mapperManger.fireCurrentDirectEditApply();
                dialog.setDefaultExpression(tableManager.getExpressionFilter());
                if (Window.OK == parentDialog.open()) {
                    String expressionForTable = dialog.getExpressionForTable();
                    tableManager.setExpressionFilter(expressionForTable);
                    tableManager.getEditPart().getViewer().getEditDomain().getCommandStack().execute(getFilterChangeCommand(tableManager.getModel(), expressionForTable));
                }
            }
        }

        @Override
        public void mouseReleased(MouseEvent me) {
        // TODO Auto-generated method stub
        }

        @Override
        public void mouseDoubleClicked(MouseEvent me) {
        // TODO Auto-generated method stub
        }
    });
}
Also used : IExpressionBuilderDialogService(org.talend.core.runtime.services.IExpressionBuilderDialogService) MouseListener(org.eclipse.draw2d.MouseListener) MouseEvent(org.eclipse.draw2d.MouseEvent) MapperManager(org.talend.designer.xmlmap.ui.tabs.MapperManager) IExpressionBuilderDialogController(org.talend.commons.ui.runtime.expressionbuilder.IExpressionBuilderDialogController) TrayDialog(org.eclipse.jface.dialogs.TrayDialog) IService(org.talend.core.IService)

Example 2 with IExpressionBuilderDialogService

use of org.talend.core.runtime.services.IExpressionBuilderDialogService in project tdi-studio-se by Talend.

the class XmlMapNodeDirectEditManager method createCellEditorOn.

@Override
protected CellEditor createCellEditorOn(Composite composite) {
    Composite parent = (Composite) source.getViewer().getControl();
    CellEditor cellEditor = null;
    Figure figure = null;
    if (this.locator instanceof XmlMapNodeCellEditorLocator) {
        XmlMapNodeCellEditorLocator lo = (XmlMapNodeCellEditorLocator) locator;
        figure = lo.getFigure();
    }
    if (figure instanceof IComboCell) {
        try {
            // tree setting can be edit or not
            if (source instanceof InputXmlTreeEditPart) {
                InputXmlTree inputTree = (InputXmlTree) ((InputXmlTreeEditPart) source).getModel();
                if (DirectEditType.JOIN_MODEL.equals(((IComboCell) figure).getDirectEditType())) {
                    if (!XmlMapUtil.hasAtLeastOneHashKey(inputTree)) {
                        return null;
                    }
                }
                if (DirectEditType.PERSISTENT_MODEL.equals(((IComboCell) figure).getDirectEditType())) {
                    if (LOOKUP_MODE.CACHE_OR_RELOAD.toString().equals(inputTree.getLookupMode())) {
                        return null;
                    }
                }
            }
            if (source instanceof OutputXmlTreeEditPart) {
                OutputXmlTree outputTree = (OutputXmlTree) ((OutputXmlTreeEditPart) source).getModel();
                if (DirectEditType.ALL_IN_ONE.equals(((IComboCell) figure).getDirectEditType())) {
                    if (!XmlMapUtil.hasDocument(outputTree)) {
                        return null;
                    }
                    boolean hasAggregate = false;
                    for (int i = 0; i < outputTree.getNodes().size(); i++) {
                        OutputTreeNode outputTreeNode = outputTree.getNodes().get(i);
                        hasAggregate = hasAggreage(outputTreeNode);
                        if (hasAggregate) {
                            break;
                        }
                    }
                    if (hasAggregate) {
                        return null;
                    }
                } else if (DirectEditType.ENABLE_EMPTY_ELEMENT.equals(((IComboCell) figure).getDirectEditType())) {
                    if (!XmlMapUtil.hasDocument(outputTree)) {
                        return null;
                    }
                }
            }
            cellEditor = new XmlComboCellEditor();
            cellEditor.create(composite);
            ((XmlComboCellEditor) cellEditor).setItems(getComboItemsByType(((IComboCell) figure).getDirectEditType()));
            cellAndType.put(cellEditor, ((IComboCell) figure).getDirectEditType());
        } catch (Exception e) {
            return null;
        }
    } else if (figure instanceof ITextCell) {
        // this one is created for direct doc child name , no use anymore...
        cellEditor = new TextCellEditor(composite);
        cellAndType.put(cellEditor, ((ITextCell) figure).getDirectEditType());
        // for the search
        XmlMapNodeCellEditorLocator lo = (XmlMapNodeCellEditorLocator) locator;
        if (lo.getFigure() != null && lo.getFigure() instanceof VarNodeTextLabel) {
            figure = (VarNodeTextLabel) lo.getFigure();
            if (figure.getParent() != null && figure.getParent() instanceof XmlMapSearchZoneToolBar) {
                XmlMapSearchZoneToolBar searchZone = (XmlMapSearchZoneToolBar) figure.getParent();
                if (searchZone.getSearchMaps().size() > 0) {
                    searchZone.getSearchZoneMapper().hightlightAll(searchZone.getSearchMaps(), false);
                    searchZone.getSearchZoneMapper().setHightlightAll(false);
                    searchZone.getSearchMaps().clear();
                    searchZone.hightLightAll.setSelected(false);
                }
            }
        }
    } else if (figure instanceof IExpressionBuilderCell && model instanceof AbstractNode) {
        IService expressionBuilderDialogService = GlobalServiceRegister.getDefault().getService(IExpressionBuilderDialogService.class);
        CellEditorDialogBehavior behavior = new CellEditorDialogBehavior();
        cellEditor = new ExpressionCellEditor(composite, behavior, source, DirectEditType.EXPRESSION);
        ((ExpressionCellEditor) cellEditor).setOwnerId(((AbstractNode) model).getExpression());
        IExpressionBuilderDialogController dialog = ((IExpressionBuilderDialogService) expressionBuilderDialogService).getExpressionBuilderInstance(parent, (ExpressionCellEditor) cellEditor, null);
        cellAndType.put(cellEditor, DirectEditType.EXPRESSION);
        behavior.setCellEditorDialog(dialog);
    } else if (figure instanceof ITextAreaCell) {
        TextAreaBehavior behavior = new TextAreaBehavior();
        cellEditor = new ExpressionCellEditor(composite, behavior, source, DirectEditType.EXPRESSION_FILTER);
        cellAndType.put(cellEditor, DirectEditType.EXPRESSION_FILTER);
    } else if (figure instanceof IExpressionBuilderCell && model instanceof InputXmlTree) {
        IService expressionBuilderDialogService = GlobalServiceRegister.getDefault().getService(IExpressionBuilderDialogService.class);
        CellEditorDialogBehavior behavior = new CellEditorDialogBehavior();
        cellEditor = new ExpressionCellEditor(composite, behavior, source, DirectEditType.EXPRESSION);
        ((ExpressionCellEditor) cellEditor).setOwnerId(((InputXmlTree) model).getLookupMode());
        IExpressionBuilderDialogController dialog = ((IExpressionBuilderDialogService) expressionBuilderDialogService).getExpressionBuilderInstance(parent, (ExpressionCellEditor) cellEditor, null);
        cellAndType.put(cellEditor, DirectEditType.EXPRESSION);
        behavior.setCellEditorDialog(dialog);
    }
    // }
    return cellEditor;
}
Also used : IExpressionBuilderDialogService(org.talend.core.runtime.services.IExpressionBuilderDialogService) AbstractNode(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode) CellEditor(org.eclipse.jface.viewers.CellEditor) ExtendedTextCellEditor(org.talend.commons.ui.runtime.swt.tableviewer.celleditor.ExtendedTextCellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) IExpressionBuilderDialogController(org.talend.commons.ui.runtime.expressionbuilder.IExpressionBuilderDialogController) OutputXmlTreeEditPart(org.talend.designer.xmlmap.parts.OutputXmlTreeEditPart) InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) XmlMapSearchZoneToolBar(org.talend.designer.xmlmap.figures.treetools.zone.XmlMapSearchZoneToolBar) ITextAreaCell(org.talend.designer.gefabstractmap.figures.cells.ITextAreaCell) XmlMapNodeCellEditorLocator(org.talend.designer.gefabstractmap.part.directedit.XmlMapNodeCellEditorLocator) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) ITextCell(org.talend.designer.gefabstractmap.figures.cells.ITextCell) IService(org.talend.core.IService) Composite(org.eclipse.swt.widgets.Composite) IExpressionBuilderCell(org.talend.designer.gefabstractmap.figures.cells.IExpressionBuilderCell) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) Figure(org.eclipse.draw2d.Figure) VarNodeTextLabel(org.talend.designer.gefabstractmap.figures.VarNodeTextLabel) CellEditorDialogBehavior(org.talend.commons.ui.runtime.swt.tableviewer.celleditor.CellEditorDialogBehavior) InputXmlTreeEditPart(org.talend.designer.xmlmap.parts.InputXmlTreeEditPart) ExtendedTextCellEditor(org.talend.commons.ui.runtime.swt.tableviewer.celleditor.ExtendedTextCellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) IComboCell(org.talend.designer.gefabstractmap.figures.cells.IComboCell)

Aggregations

IExpressionBuilderDialogController (org.talend.commons.ui.runtime.expressionbuilder.IExpressionBuilderDialogController)2 IService (org.talend.core.IService)2 IExpressionBuilderDialogService (org.talend.core.runtime.services.IExpressionBuilderDialogService)2 Figure (org.eclipse.draw2d.Figure)1 MouseEvent (org.eclipse.draw2d.MouseEvent)1 MouseListener (org.eclipse.draw2d.MouseListener)1 TrayDialog (org.eclipse.jface.dialogs.TrayDialog)1 CellEditor (org.eclipse.jface.viewers.CellEditor)1 ComboBoxCellEditor (org.eclipse.jface.viewers.ComboBoxCellEditor)1 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)1 Composite (org.eclipse.swt.widgets.Composite)1 CellEditorDialogBehavior (org.talend.commons.ui.runtime.swt.tableviewer.celleditor.CellEditorDialogBehavior)1 ExtendedTextCellEditor (org.talend.commons.ui.runtime.swt.tableviewer.celleditor.ExtendedTextCellEditor)1 VarNodeTextLabel (org.talend.designer.gefabstractmap.figures.VarNodeTextLabel)1 IComboCell (org.talend.designer.gefabstractmap.figures.cells.IComboCell)1 IExpressionBuilderCell (org.talend.designer.gefabstractmap.figures.cells.IExpressionBuilderCell)1 ITextAreaCell (org.talend.designer.gefabstractmap.figures.cells.ITextAreaCell)1 ITextCell (org.talend.designer.gefabstractmap.figures.cells.ITextCell)1 XmlMapNodeCellEditorLocator (org.talend.designer.gefabstractmap.part.directedit.XmlMapNodeCellEditorLocator)1 XmlMapSearchZoneToolBar (org.talend.designer.xmlmap.figures.treetools.zone.XmlMapSearchZoneToolBar)1