Search in sources :

Example 1 with IService

use of org.talend.core.IService 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 IService

use of org.talend.core.IService 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)

Example 3 with IService

use of org.talend.core.IService in project tdi-studio-se by Talend.

the class FunParaTableView2 method createColumns.

@Override
protected void createColumns(TableViewerCreator<Parameter> tableViewerCreator, final Table table) {
    this.tableViewerCreator = tableViewerCreator;
    IService expressionBuilderDialogService = GlobalServiceRegister.getDefault().getService(IExpressionBuilderDialogService.class);
    TableViewerCreatorColumn column;
    column = new TableViewerCreatorColumn(tableViewerCreator);
    //$NON-NLS-1$
    column.setTitle(Messages.getString("FunParaTableView2.Parameter"));
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<Parameter, Object>() {

        public String get(Parameter bean) {
            return bean.getName();
        }

        public void set(Parameter bean, Object value) {
        }
    });
    column.setModifiable(false);
    column.setWidth(115);
    // column.setCellEditor(new
    // TextCellEditor(tableViewerCreator.getTable()));
    // ////////////////////////////////////////////////////////
    column = new TableViewerCreatorColumn(tableViewerCreator);
    //$NON-NLS-1$
    column.setTitle(Messages.getString("FunParaTableView2.Value"));
    column.setId(VALUE_PROPERTY);
    CellEditorDialogBehavior behavior = new CellEditorDialogBehavior();
    cellEditor = new ExtendedTextCellEditorWithProposal(tableViewerCreator.getTable(), SWT.MULTI | SWT.BORDER, column, behavior);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<Parameter, Object>() {

        public String get(Parameter bean) {
            StringBuffer id = new StringBuffer();
            //$NON-NLS-1$
            id.append(component.getLabel() + "=>");
            TableItem[] item = rowGenTableEditor2.getTable().getSelection();
            if (item.length == 1) {
                //$NON-NLS-1$
                id.append(((MetadataColumnExt) item[0].getData()).getLabel() + "=>");
            }
            cellEditor.setOwnerId(id.append(bean.getName()).toString());
            cellEditor.setExpressionType(bean.getType());
            String valueTemp = bean.getValue();
            if (valueTemp != null && !valueTemp.endsWith(" ")) {
                bean.setValue(valueTemp + " ");
            }
            return bean.getValue();
        }

        public void set(Parameter bean, Object value) {
            if (value == null) {
                return;
            }
            String valueTemp = value.toString();
            if (!valueTemp.endsWith(" ")) {
                value = value + " ";
            }
            bean.setValue(value.toString());
            if (ext != null) {
                ext.setChanged(true);
            }
            if (!rowGenTableEditor2.getTableViewerCreator().getTableViewer().isCellEditorActive()) {
                rowGenTableEditor2.getTableViewerCreator().getTableViewer().refresh();
            }
        }
    });
    column.setModifiable(true);
    column.setWidth(115);
    dialog = ((IExpressionBuilderDialogService) expressionBuilderDialogService).getExpressionBuilderInstance(mainComposite, cellEditor, component);
    behavior.setCellEditorDialog(dialog);
    cellEditor.setContentProposalProvider(getProcessProposals());
    //$NON-NLS-1$
    cellEditor.setExpressionType("String");
    column.setCellEditor(cellEditor);
    // ////////////////////////////////////////////////////////
    column = new TableViewerCreatorColumn(tableViewerCreator);
    //$NON-NLS-1$
    column.setTitle(Messages.getString("FunParaTableView2.Comment"));
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<Parameter, Object>() {

        public String get(Parameter bean) {
            return bean.getComment();
        }

        public void set(Parameter bean, Object value) {
        }
    });
    column.setModifiable(false);
    column.setWidth(155);
// column.setCellEditor(new
// TextCellEditor(tableViewerCreator.getTable()));
// ////////////////////////////////////////////////////////
}
Also used : ExtendedTextCellEditorWithProposal(org.talend.commons.ui.swt.proposal.ExtendedTextCellEditorWithProposal) CellEditorDialogBehavior(org.talend.commons.ui.runtime.swt.tableviewer.celleditor.CellEditorDialogBehavior) Parameter(org.talend.designer.rowgenerator.data.Parameter) ListParameter(org.talend.designer.rowgenerator.data.ListParameter) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn) IService(org.talend.core.IService)

Aggregations

IService (org.talend.core.IService)3 IExpressionBuilderDialogController (org.talend.commons.ui.runtime.expressionbuilder.IExpressionBuilderDialogController)2 CellEditorDialogBehavior (org.talend.commons.ui.runtime.swt.tableviewer.celleditor.CellEditorDialogBehavior)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 ExtendedTextCellEditor (org.talend.commons.ui.runtime.swt.tableviewer.celleditor.ExtendedTextCellEditor)1 ExtendedTextCellEditorWithProposal (org.talend.commons.ui.swt.proposal.ExtendedTextCellEditorWithProposal)1 TableViewerCreatorColumn (org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)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