Search in sources :

Example 6 with ExtendedTableModel

use of org.talend.commons.ui.swt.extended.table.ExtendedTableModel in project tdi-studio-se by Talend.

the class ExtractionFieldsWithJSONXPathEditorView method initToolBar.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.commons.ui.swt.advanced.dataeditor.AbstractDataTableEditorView#initToolBar()
     */
@Override
protected ExtendedToolbarView initToolBar() {
    return new ExtendedToolbarView(getMainComposite(), SWT.NONE, getExtendedTableViewer()) {

        @Override
        protected AddPushButtonForExtendedTable createAddPushButton() {
            return new AddPushButtonForExtendedTable(this.toolbar, getExtendedTableViewer()) {

                @Override
                protected Object getObjectToAdd() {
                    UniqueStringGenerator<SchemaTarget> generator = new UniqueStringGenerator<SchemaTarget>("column", getModel().getBeansList()) {

                        @Override
                        protected String getBeanString(SchemaTarget bean) {
                            // TODO Auto-generated method stub
                            return bean.getRelativeXPathQuery();
                        }
                    };
                    SchemaTarget tarhe = getModel().createNewSchemaTarget();
                    tarhe.setRelativeXPathQuery(generator.getUniqueString());
                    tarhe.setTagName(generator.getUniqueString());
                    return tarhe;
                }
            };
        }

        /*
             * (non-Javadoc)
             * 
             * @see org.talend.core.ui.extended.ExtendedToolbarView#createPastePushButton()
             */
        @Override
        protected PastePushButton createPastePushButton() {
            return new PastePushButtonForExtendedTable(toolbar, extendedTableViewer) {

                @Override
                protected Command getCommandToExecute(ExtendedTableModel extendedTableModel, Integer indexWhereInsert) {
                    return new ExtendedTablePasteCommand(extendedTableModel, indexWhereInsert) {

                        @Override
                        public List createPastableBeansList(ExtendedTableModel extendedTableModel, List copiedObjectsList) {
                            ArrayList list = new ArrayList();
                            JSONExtractorFieldModel fieldsModel = (JSONExtractorFieldModel) extendedTableModel;
                            for (Object current : copiedObjectsList) {
                                if (current instanceof SchemaTarget) {
                                    SchemaTarget original = (SchemaTarget) current;
                                    SchemaTarget copy = fieldsModel.createNewSchemaTarget();
                                    copy.setRelativeXPathQuery(original.getRelativeXPathQuery());
                                    copy.setTagName(original.getTagName());
                                    list.add(copy);
                                }
                            }
                            return list;
                        }
                    };
                }
            };
        }
    };
}
Also used : AddPushButtonForExtendedTable(org.talend.commons.ui.swt.advanced.dataeditor.button.AddPushButtonForExtendedTable) ExtendedTablePasteCommand(org.talend.commons.ui.swt.advanced.dataeditor.commands.ExtendedTablePasteCommand) ArrayList(java.util.ArrayList) PastePushButtonForExtendedTable(org.talend.commons.ui.swt.advanced.dataeditor.button.PastePushButtonForExtendedTable) SchemaTarget(org.talend.repository.model.json.SchemaTarget) UniqueStringGenerator(org.talend.commons.utils.data.list.UniqueStringGenerator) ArrayList(java.util.ArrayList) List(java.util.List) ExtendedTableModel(org.talend.commons.ui.swt.extended.table.ExtendedTableModel) ExtendedToolbarView(org.talend.commons.ui.swt.advanced.dataeditor.ExtendedToolbarView)

Example 7 with ExtendedTableModel

use of org.talend.commons.ui.swt.extended.table.ExtendedTableModel in project tdi-studio-se by Talend.

the class MapperManager method getSelectedInputTreeSchemaModel.

public ExtendedTableModel<TreeSchemaTableEntry> getSelectedInputTreeSchemaModel(InputXmlTree inputXmlTree) {
    if (inputXmlTree == null && !getExternalData().getInputTrees().isEmpty()) {
        inputXmlTree = getExternalData().getInputTrees().get(0);
    }
    List<TreeSchemaTableEntry> treeSchemaEntrys = new ArrayList<TreeSchemaTableEntry>();
    ExtendedTableModel<TreeSchemaTableEntry> tableModel = new ExtendedTableModel<TreeSchemaTableEntry>("Tree Schema", treeSchemaEntrys);
    if (inputXmlTree != null) {
        tableModel.setName(inputXmlTree.getName());
        EList<TreeNode> nodes = inputXmlTree.getNodes();
        for (TreeNode node : nodes) {
            if (XmlMapUtil.DOCUMENT.equals(node.getType())) {
                addTreeSchemaEnties(tableModel, node.getChildren());
            }
        }
    }
    return tableModel;
}
Also used : OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) ArrayList(java.util.ArrayList) ExtendedTableModel(org.talend.commons.ui.swt.extended.table.ExtendedTableModel) TreeSchemaTableEntry(org.talend.designer.xmlmap.ui.tabs.table.TreeSchemaTableEntry)

Example 8 with ExtendedTableModel

use of org.talend.commons.ui.swt.extended.table.ExtendedTableModel in project tdi-studio-se by Talend.

the class MapperManager method getSelectedOutputTreeSchemaModel.

public ExtendedTableModel<TreeSchemaTableEntry> getSelectedOutputTreeSchemaModel(OutputXmlTree outputXmlTree) {
    if (outputXmlTree == null && !getExternalData().getOutputTrees().isEmpty()) {
        outputXmlTree = getExternalData().getOutputTrees().get(0);
    }
    List<TreeSchemaTableEntry> treeSchemaEntrys = new ArrayList<TreeSchemaTableEntry>();
    ExtendedTableModel<TreeSchemaTableEntry> tableModel = new ExtendedTableModel<TreeSchemaTableEntry>("Tree Schema", treeSchemaEntrys);
    if (outputXmlTree != null) {
        tableModel.setName(outputXmlTree.getName());
        EList<OutputTreeNode> nodes = outputXmlTree.getNodes();
        for (TreeNode node : nodes) {
            if (XmlMapUtil.DOCUMENT.equals(node.getType())) {
                addTreeSchemaEnties(tableModel, node.getChildren());
            }
        }
    }
    return tableModel;
}
Also used : OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) ArrayList(java.util.ArrayList) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) ExtendedTableModel(org.talend.commons.ui.swt.extended.table.ExtendedTableModel) TreeSchemaTableEntry(org.talend.designer.xmlmap.ui.tabs.table.TreeSchemaTableEntry)

Example 9 with ExtendedTableModel

use of org.talend.commons.ui.swt.extended.table.ExtendedTableModel in project tdi-studio-se by Talend.

the class AutoConversionTypesEditorView method initToolBar.

@Override
protected ExtendedToolbarView initToolBar() {
    return new ExtendedToolbarView(getMainComposite(), SWT.NONE, getExtendedTableViewer()) {

        @Override
        protected AddPushButtonForExtendedTable createAddPushButton() {
            return new AddPushButtonForExtendedTable(this.toolbar, getExtendedTableViewer()) {

                @Override
                protected Object getObjectToAdd() {
                    AutoConversionType bean = new AutoConversionType();
                    bean.setSourceDataType(JavaTypesManager.getDefaultJavaType().getId());
                    bean.setTargetDataType(JavaTypesManager.getDefaultJavaType().getId());
                    //$NON-NLS-1$
                    bean.setConversionFunction("String.valueOf(${0})");
                    return bean;
                }
            };
        }

        @Override
        protected PastePushButton createPastePushButton() {
            return new PastePushButtonForExtendedTable(toolbar, extendedTableViewer) {

                @Override
                protected Command getCommandToExecute(ExtendedTableModel extendedTableModel, Integer indexWhereInsert) {
                    return new ExtendedTablePasteCommand(extendedTableModel, indexWhereInsert) {

                        @Override
                        public List<AutoConversionType> createPastableBeansList(ExtendedTableModel extendedTableModel, List copiedObjectsList) {
                            List<AutoConversionType> beans = new ArrayList<>();
                            beans.addAll(copiedObjectsList);
                            return beans;
                        }
                    };
                }
            };
        }
    };
}
Also used : AddPushButtonForExtendedTable(org.talend.commons.ui.swt.advanced.dataeditor.button.AddPushButtonForExtendedTable) AutoConversionType(org.talend.core.model.metadata.types.AutoConversionType) ExtendedTablePasteCommand(org.talend.commons.ui.swt.advanced.dataeditor.commands.ExtendedTablePasteCommand) ArrayList(java.util.ArrayList) PastePushButtonForExtendedTable(org.talend.commons.ui.swt.advanced.dataeditor.button.PastePushButtonForExtendedTable) ArrayList(java.util.ArrayList) List(java.util.List) ExtendedTableModel(org.talend.commons.ui.swt.extended.table.ExtendedTableModel) ExtendedToolbarView(org.talend.commons.ui.swt.advanced.dataeditor.ExtendedToolbarView)

Aggregations

ExtendedTableModel (org.talend.commons.ui.swt.extended.table.ExtendedTableModel)9 ArrayList (java.util.ArrayList)6 List (java.util.List)5 PastePushButtonForExtendedTable (org.talend.commons.ui.swt.advanced.dataeditor.button.PastePushButtonForExtendedTable)4 Command (org.eclipse.gef.commands.Command)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 Table (org.eclipse.swt.widgets.Table)2 ExtendedToolbarView (org.talend.commons.ui.swt.advanced.dataeditor.ExtendedToolbarView)2 AddPushButtonForExtendedTable (org.talend.commons.ui.swt.advanced.dataeditor.button.AddPushButtonForExtendedTable)2 ExtendedTablePasteCommand (org.talend.commons.ui.swt.advanced.dataeditor.commands.ExtendedTablePasteCommand)2 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)2 MetadataEmfTableEditor (org.talend.core.ui.metadata.editor.MetadataEmfTableEditor)2 ExtendedTableResetDBTypesCommand (org.talend.core.ui.metadata.extended.command.ExtendedTableResetDBTypesCommand)2 MetadataEmfExportXmlCommand (org.talend.core.ui.metadata.extended.command.MetadataEmfExportXmlCommand)2 MetadataEmfImportXmlCommand (org.talend.core.ui.metadata.extended.command.MetadataEmfImportXmlCommand)2 MetadataEmfPasteCommand (org.talend.core.ui.metadata.extended.command.MetadataEmfPasteCommand)2 IModel (org.talend.designer.hl7.model.IModel)2 HL7MultiSchemaUI (org.talend.designer.hl7.ui.HL7MultiSchemaUI)2 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)2 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)2