Search in sources :

Example 1 with UniqueStringGenerator

use of org.talend.commons.utils.data.list.UniqueStringGenerator 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)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 ExtendedToolbarView (org.talend.commons.ui.swt.advanced.dataeditor.ExtendedToolbarView)1 AddPushButtonForExtendedTable (org.talend.commons.ui.swt.advanced.dataeditor.button.AddPushButtonForExtendedTable)1 PastePushButtonForExtendedTable (org.talend.commons.ui.swt.advanced.dataeditor.button.PastePushButtonForExtendedTable)1 ExtendedTablePasteCommand (org.talend.commons.ui.swt.advanced.dataeditor.commands.ExtendedTablePasteCommand)1 ExtendedTableModel (org.talend.commons.ui.swt.extended.table.ExtendedTableModel)1 UniqueStringGenerator (org.talend.commons.utils.data.list.UniqueStringGenerator)1 SchemaTarget (org.talend.repository.model.json.SchemaTarget)1