Search in sources :

Example 1 with VarNodeTextLabel

use of org.talend.designer.gefabstractmap.figures.VarNodeTextLabel 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 2 with VarNodeTextLabel

use of org.talend.designer.gefabstractmap.figures.VarNodeTextLabel in project tdi-studio-se by Talend.

the class XmlMapNodeDirectEditManager method commit.

@Override
public void commit() {
    DirectEditType directEditType = cellAndType.get(getCellEditor());
    if (directEditType != null) {
        switch(directEditType) {
            case SERACH:
                VarNodeTextLabel figure = null;
                if (this.locator instanceof XmlMapNodeCellEditorLocator) {
                    XmlMapNodeCellEditorLocator lo = (XmlMapNodeCellEditorLocator) locator;
                    if (lo.getFigure() != null && lo.getFigure() instanceof VarNodeTextLabel) {
                        figure = (VarNodeTextLabel) lo.getFigure();
                        Object searchTextObject = getDirectEditRequest().getCellEditor().getValue();
                        if (searchTextObject != null) {
                            if (figure.getParent() != null && figure.getParent() instanceof XmlMapSearchZoneToolBar) {
                                XmlMapSearchZoneToolBar searchZone = (XmlMapSearchZoneToolBar) figure.getParent();
                                searchZone.search(searchTextObject.toString());
                                figure.setText(searchTextObject.toString());
                            }
                        }
                    }
                }
        }
    }
    super.commit();
}
Also used : XmlMapSearchZoneToolBar(org.talend.designer.xmlmap.figures.treetools.zone.XmlMapSearchZoneToolBar) VarNodeTextLabel(org.talend.designer.gefabstractmap.figures.VarNodeTextLabel) XmlMapNodeCellEditorLocator(org.talend.designer.gefabstractmap.part.directedit.XmlMapNodeCellEditorLocator) DirectEditType(org.talend.designer.gefabstractmap.part.directedit.DirectEditType)

Example 3 with VarNodeTextLabel

use of org.talend.designer.gefabstractmap.figures.VarNodeTextLabel in project tdi-studio-se by Talend.

the class XmlMapSearchZoneToolBar method createZoneContent.

@Override
public void createZoneContent() {
    super.createZoneContent();
    Label findLabel = new Label("Find :");
    add(findLabel);
    searchText = new VarNodeTextLabel();
    searchText.setDirectEditType(DirectEditType.SERACH);
    // searchText.setText("Enter search text prefix or pattern(*,?)");
    searchText.setLabelAlignment(PositionConstants.LEFT);
    searchText.setBorder(new LineBorder(ColorConstants.gray));
    searchText.setOpaque(true);
    searchText.setBackgroundColor(ColorConstants.white);
    add(searchText);
    this.add(move_down);
    this.add(move_up);
    this.add(hightLightAll);
    move_down.setEnabled(true);
    move_up.setEnabled(true);
}
Also used : VarNodeTextLabel(org.talend.designer.gefabstractmap.figures.VarNodeTextLabel) LineBorder(org.eclipse.draw2d.LineBorder) VarNodeTextLabel(org.talend.designer.gefabstractmap.figures.VarNodeTextLabel) Label(org.eclipse.draw2d.Label)

Example 4 with VarNodeTextLabel

use of org.talend.designer.gefabstractmap.figures.VarNodeTextLabel in project tdi-studio-se by Talend.

the class VarEntityFigure method createVariableContainer.

protected Figure createVariableContainer() {
    Figure container = new Figure();
    // container.setBorder(new RowBorder());
    ToolbarLayout manager = new ToolbarLayout() {

        @Override
        public void layout(IFigure parent) {
            super.layout(parent);
            List children = parent.getChildren();
            if (children.size() == 2) {
                Figure checkImageFigure = (Figure) children.get(0);
                Figure variableFigure = (Figure) children.get(1);
                Rectangle varFigureBounds = variableFigure.getBounds().getCopy();
                int avialableWith = parent.getBounds().width - checkImageFigure.getBounds().width;
                if (avialableWith > varFigureBounds.width) {
                    varFigureBounds.width = avialableWith;
                }
                variableFigure.setBounds(varFigureBounds);
            }
        }
    };
    manager.setVertical(false);
    manager.setStretchMinorAxis(false);
    container.setLayoutManager(manager);
    // if(varNode.)
    Label nullableToolTip = new Label("Nullable");
    if (!isNullable()) {
        checkImage = new ImageFigure(ImageProvider.getImage(EImage.UNCHECKED_ICON));
    } else {
        checkImage = new ImageFigure(ImageProvider.getImage(EImage.CHECKED_ICON));
    }
    checkImage.setToolTip(nullableToolTip);
    variableLabel = new VarNodeTextLabel();
    variableLabel.setText(getVarName());
    variableLabel.setLabelAlignment(PositionConstants.LEFT);
    variableLabel.setBorder(new MarginBorder(2, 5, 2, -1));
    container.add(checkImage);
    container.add(variableLabel);
    addCheckListener();
    return container;
}
Also used : ToolbarLayout(org.eclipse.draw2d.ToolbarLayout) VarNodeTextLabel(org.talend.designer.gefabstractmap.figures.VarNodeTextLabel) MarginBorder(org.eclipse.draw2d.MarginBorder) Rectangle(org.eclipse.draw2d.geometry.Rectangle) VarNodeTextLabel(org.talend.designer.gefabstractmap.figures.VarNodeTextLabel) ComboCellLabel(org.talend.designer.gefabstractmap.figures.ComboCellLabel) Label(org.eclipse.draw2d.Label) List(java.util.List) ImageFigure(org.eclipse.draw2d.ImageFigure) IFigure(org.eclipse.draw2d.IFigure) ImageFigure(org.eclipse.draw2d.ImageFigure) TableEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableEntityFigure) Figure(org.eclipse.draw2d.Figure) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

VarNodeTextLabel (org.talend.designer.gefabstractmap.figures.VarNodeTextLabel)4 Figure (org.eclipse.draw2d.Figure)2 Label (org.eclipse.draw2d.Label)2 XmlMapNodeCellEditorLocator (org.talend.designer.gefabstractmap.part.directedit.XmlMapNodeCellEditorLocator)2 XmlMapSearchZoneToolBar (org.talend.designer.xmlmap.figures.treetools.zone.XmlMapSearchZoneToolBar)2 List (java.util.List)1 IFigure (org.eclipse.draw2d.IFigure)1 ImageFigure (org.eclipse.draw2d.ImageFigure)1 LineBorder (org.eclipse.draw2d.LineBorder)1 MarginBorder (org.eclipse.draw2d.MarginBorder)1 ToolbarLayout (org.eclipse.draw2d.ToolbarLayout)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)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 IExpressionBuilderDialogController (org.talend.commons.ui.runtime.expressionbuilder.IExpressionBuilderDialogController)1 CellEditorDialogBehavior (org.talend.commons.ui.runtime.swt.tableviewer.celleditor.CellEditorDialogBehavior)1 ExtendedTextCellEditor (org.talend.commons.ui.runtime.swt.tableviewer.celleditor.ExtendedTextCellEditor)1 IService (org.talend.core.IService)1