Search in sources :

Example 1 with XmlTreeSchemaTableView

use of org.talend.designer.xmlmap.ui.tabs.table.XmlTreeSchemaTableView in project tdi-studio-se by Talend.

the class MapperManager method onEntitySelection.

private void onEntitySelection(IStructuredSelection selection, AbstractInOutTree selectedTree) {
    // do selection in metadata schema editor
    EList<? extends TreeNode> nodes = null;
    if (selectedTree instanceof InputXmlTree) {
        nodes = ((InputXmlTree) selectedTree).getNodes();
    } else {
        nodes = ((OutputXmlTree) selectedTree).getNodes();
    }
    List<Integer> selectionIndices = new ArrayList<Integer>();
    List<TreeNode> selectedDocChild = new ArrayList<TreeNode>();
    Iterator iterator = selection.iterator();
    while (iterator.hasNext()) {
        Object obj = iterator.next();
        if (obj instanceof TreeNodeEditPart) {
            TreeNode model = (TreeNode) ((TreeNodeEditPart) obj).getModel();
            if (model.eContainer() == selectedTree) {
                selectionIndices.add(nodes.indexOf(model));
            } else {
                AbstractInOutTree abstractInOutTree = XmlMapUtil.getAbstractInOutTree(model);
                if (abstractInOutTree == selectedTree) {
                    selectedDocChild.add(model);
                }
            }
        }
    }
    int[] selections = new int[selectionIndices.size()];
    for (int i = 0; i < selectionIndices.size(); i++) {
        selections[i] = selectionIndices.get(i);
    }
    MetadataTableEditorView metaEditorView = null;
    XmlTreeSchemaTableView treeEditorView = null;
    if (selectedTree instanceof InputXmlTree) {
        metaEditorView = mapperUI.getTabFolderEditors().getInputMetaEditorView();
        treeEditorView = mapperUI.getTabFolderEditors().getInputTreeSchemaEditor();
    } else {
        metaEditorView = mapperUI.getTabFolderEditors().getOutputMetaEditorView();
        treeEditorView = mapperUI.getTabFolderEditors().getOutputTreeSchemaEditor();
    }
    metaEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(false);
    metaEditorView.getExtendedTableViewer().getTableViewerCreator().getSelectionHelper().setSelection(selections);
    metaEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(true);
    metaEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
    // if no, change page
    if (!selectedDocChild.isEmpty()) {
        treeEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(false);
        TreeNode firstSelection = null;
        if (selectedDocChild.size() > 1) {
            selectionIndices = new ArrayList<Integer>();
            List<TreeNode> allList = new ArrayList<TreeNode>();
            for (TreeNode schemaNodes : nodes) {
                if (XmlMapUtil.DOCUMENT.equals(schemaNodes.getType())) {
                    allList.addAll(SchemaTableUtils.getTreeSchemaEnties(schemaNodes));
                }
            }
            int minIndex = allList.size();
            for (TreeNode selected : selectedDocChild) {
                int indexOf = allList.indexOf(selected);
                if (indexOf != -1 && indexOf < minIndex) {
                    firstSelection = selected;
                }
            }
        } else {
            firstSelection = selectedDocChild.get(0);
        }
        treeEditorView.getExtendedTableModel().changePageIfNeeded(firstSelection);
        // update selection
        selectionIndices = new ArrayList<Integer>();
        for (TreeNode selected : selectedDocChild) {
            int indexOf = treeEditorView.getExtendedTableModel().getBeansList().indexOf(selected);
            if (indexOf != -1) {
                selectionIndices.add(indexOf);
            }
        }
        selections = new int[selectionIndices.size()];
        for (int i = 0; i < selectionIndices.size(); i++) {
            selections[i] = selectionIndices.get(i);
        }
        treeEditorView.getExtendedTableViewer().getTableViewerCreator().getSelectionHelper().setSelection(selections);
        treeEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(true);
        treeEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
    }
}
Also used : ArrayList(java.util.ArrayList) AbstractInOutTree(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree) TreeNodeEditPart(org.talend.designer.xmlmap.parts.TreeNodeEditPart) InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) XmlTreeSchemaTableView(org.talend.designer.xmlmap.ui.tabs.table.XmlTreeSchemaTableView) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) Iterator(java.util.Iterator) MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView) AbstractMetadataTableEditorView(org.talend.core.ui.metadata.editor.AbstractMetadataTableEditorView)

Example 2 with XmlTreeSchemaTableView

use of org.talend.designer.xmlmap.ui.tabs.table.XmlTreeSchemaTableView in project tdi-studio-se by Talend.

the class MapperManager method refreshTreeSchemaEditor.

/**
     * 
     * DOC Administrator Comment method "refreshTreeSchemaEditor".
     * 
     * @param outputTree
     */
public void refreshTreeSchemaEditor(AbstractInOutTree outputTree) {
    XmlTreeSchemaTableView outputTreeSchemaEditor = null;
    if (outputTree instanceof InputXmlTree) {
        outputTreeSchemaEditor = mapperUI.getTabFolderEditors().getInputTreeSchemaEditor();
    } else {
        outputTreeSchemaEditor = mapperUI.getTabFolderEditors().getOutputTreeSchemaEditor();
    }
    TreeSchemaTableEditor editor = new TreeSchemaTableEditor(outputTree);
    outputTreeSchemaEditor.setExtendedTableModel(editor);
// editor.setModifiedBeanListenable(outputTreeSchemaEditor.getTableViewerCreator());
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) TreeSchemaTableEditor(org.talend.designer.xmlmap.ui.tabs.table.TreeSchemaTableEditor) XmlTreeSchemaTableView(org.talend.designer.xmlmap.ui.tabs.table.XmlTreeSchemaTableView)

Example 3 with XmlTreeSchemaTableView

use of org.talend.designer.xmlmap.ui.tabs.table.XmlTreeSchemaTableView in project tdi-studio-se by Talend.

the class MapperManager method beanListModified.

public void beanListModified(boolean input) {
    XmlTreeSchemaTableView outputTreeSchemaEditor = null;
    if (input) {
        outputTreeSchemaEditor = mapperUI.getTabFolderEditors().getInputTreeSchemaEditor();
    } else {
        outputTreeSchemaEditor = mapperUI.getTabFolderEditors().getOutputTreeSchemaEditor();
    }
    outputTreeSchemaEditor.getExtendedTableModel().beanListModified();
}
Also used : XmlTreeSchemaTableView(org.talend.designer.xmlmap.ui.tabs.table.XmlTreeSchemaTableView)

Example 4 with XmlTreeSchemaTableView

use of org.talend.designer.xmlmap.ui.tabs.table.XmlTreeSchemaTableView in project tdi-studio-se by Talend.

the class TabFolderEditors method createComponents.

/**
     * DOC amaumont Comment method "createComponents".
     */
private void createComponents() {
    setSimple(false);
    // TableEditorCompositeBase metaDatasDescriptorView3 = new TableEditorCompositeBase(tabFolder1);
    // item.setControl(metaDatasDescriptorView3);
    CTabItem item = new CTabItem(tabFolderEditors, SWT.BORDER);
    //$NON-NLS-1$
    item.setText(Messages.getString("TabFolderEditors.SchemaEditor.Title"));
    SashForm inOutMetaEditorContainer = new SashForm(tabFolderEditors, SWT.SMOOTH | SWT.HORIZONTAL | SWT.SHADOW_OUT);
    inOutMetaEditorContainer.setLayout(new RowLayout(SWT.HORIZONTAL));
    item.setControl(inOutMetaEditorContainer);
    // input metadata table view
    inputMetaEditor = new XmlMapMetadataTableEditorView(inOutMetaEditorContainer, SWT.BORDER);
    inputMetaEditor.initGraphicComponents();
    // inputMetaEditor.getExtendedTableViewer().setCommandStack(commandStack);
    ILineSelectionListener metadataEditorViewerSelectionChangedListener = new ILineSelectionListener() {

        @Override
        public void handle(LineSelectionEvent e) {
            if (inputMetaEditor.getTableViewerCreator() == e.source && mapperManage.getGraphicalViewer() != null) {
                if (inputMetaEditor.getExtendedTableViewer().isExecuteSelectionEvent()) {
                    mapperManage.selectLinkedInputTableEntries(inputMetaEditor.getTableViewerCreator().getTable().getSelectionIndices(), false);
                }
            }
        }
    };
    inputMetaEditor.getTableViewerCreator().getSelectionHelper().addAfterSelectionListener(metadataEditorViewerSelectionChangedListener);
    addListenersToInputButtons();
    // output metadata table view
    outputMetaEditor = new XmlMapMetadataTableEditorView(inOutMetaEditorContainer, SWT.BORDER);
    outputMetaEditor.initGraphicComponents();
    // outputMetaEditor.getExtendedTableViewer().setCommandStack(commandStack);
    metadataEditorViewerSelectionChangedListener = new ILineSelectionListener() {

        @Override
        public void handle(LineSelectionEvent e) {
            if (outputMetaEditor.getTableViewerCreator() == e.source && mapperManage.getGraphicalViewer() != null) {
                if (outputMetaEditor.getExtendedTableViewer().isExecuteSelectionEvent()) {
                    mapperManage.selectLinkedOutputTableEntries(outputMetaEditor.getTableViewerCreator().getTable().getSelectionIndices(), false);
                }
            }
        }
    };
    outputMetaEditor.getTableViewerCreator().getSelectionHelper().addAfterSelectionListener(metadataEditorViewerSelectionChangedListener);
    addListenersToOutputButtons();
    item = new CTabItem(tabFolderEditors, SWT.BORDER);
    //$NON-NLS-1$
    item.setText(Messages.getString("TabFolderEditors.TreeSchemaEditor.Title"));
    SashForm xmlTreeEditorContainer = new SashForm(tabFolderEditors, SWT.SMOOTH | SWT.HORIZONTAL | SWT.SHADOW_OUT);
    xmlTreeEditorContainer.setLayout(new RowLayout(SWT.HORIZONTAL));
    item.setControl(xmlTreeEditorContainer);
    // input tree schema table view
    inputTreeSchemaEditor = new XmlTreeSchemaTableView(xmlTreeEditorContainer, SWT.BORDER);
    inputTreeSchemaEditor.initGraphicComponents();
    metadataEditorViewerSelectionChangedListener = new ILineSelectionListener() {

        @Override
        public void handle(LineSelectionEvent e) {
            if (inputTreeSchemaEditor.getTableViewerCreator() == e.source && mapperManage.getGraphicalViewer() != null) {
                if (inputTreeSchemaEditor.getExtendedTableViewer().isExecuteSelectionEvent()) {
                    mapperManage.selectLinkedInputTableEntries(inputTreeSchemaEditor.getTableViewerCreator().getTable().getSelectionIndices(), true);
                }
            }
        }
    };
    inputTreeSchemaEditor.getTableViewerCreator().getSelectionHelper().addAfterSelectionListener(metadataEditorViewerSelectionChangedListener);
    // output tree schema table view
    outputTreeSchemaEditor = new OutputXmlTreeSchemaTableView(xmlTreeEditorContainer, SWT.BORDER);
    outputTreeSchemaEditor.initGraphicComponents();
    metadataEditorViewerSelectionChangedListener = new ILineSelectionListener() {

        @Override
        public void handle(LineSelectionEvent e) {
            if (outputTreeSchemaEditor.getTableViewerCreator() == e.source && mapperManage.getGraphicalViewer() != null) {
                if (outputTreeSchemaEditor.getExtendedTableViewer().isExecuteSelectionEvent()) {
                    mapperManage.selectLinkedOutputTableEntries(outputTreeSchemaEditor.getTableViewerCreator().getTable().getSelectionIndices(), true);
                }
            }
        }
    };
    outputTreeSchemaEditor.getTableViewerCreator().getSelectionHelper().addAfterSelectionListener(metadataEditorViewerSelectionChangedListener);
    item = new CTabItem(tabFolderEditors, SWT.BORDER);
    //$NON-NLS-1$
    item.setText(Messages.getString("TabFolderEditors.ExpressionEditor.Title"));
    StyledText styledText = createStyledText(item);
    this.styledTextHandler = new StyledTextHandler(styledText, mapperManage);
    tabFolderEditors.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            mapperManage.fireCurrentDirectEditApply();
            // TDI-18185
            if (styledTextHandler.getSelectedNode() != null && XmlMapUtil.DOCUMENT.equals(styledTextHandler.getSelectedNode().getType())) {
                styledTextHandler.setTextWithoutNotifyListeners("");
                styledTextHandler.getStyledText().setEnabled(false);
                styledTextHandler.getStyledText().setEditable(false);
                styledTextHandler.getStyledText().setText("");
            }
            lastSelectedTab = tabFolderEditors.getSelectionIndex();
        }
    });
    tabFolderEditors.setSelection(0);
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) UnnotifiableColorStyledText(org.talend.commons.ui.swt.colorstyledtext.UnnotifiableColorStyledText) DisposeListener(org.eclipse.swt.events.DisposeListener) IExtendedButtonListener(org.talend.commons.ui.swt.extended.table.IExtendedButtonListener) Listener(org.eclipse.swt.widgets.Listener) ILineSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener) ILineSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener) CTabItem(org.eclipse.swt.custom.CTabItem) SashForm(org.eclipse.swt.custom.SashForm) LineSelectionEvent(org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent) OutputXmlTreeSchemaTableView(org.talend.designer.xmlmap.ui.tabs.table.OutputXmlTreeSchemaTableView) XmlTreeSchemaTableView(org.talend.designer.xmlmap.ui.tabs.table.XmlTreeSchemaTableView) RowLayout(org.eclipse.swt.layout.RowLayout) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Event(org.eclipse.swt.widgets.Event) ExtendedButtonEvent(org.talend.commons.ui.swt.extended.table.ExtendedButtonEvent) LineSelectionEvent(org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent) XmlMapMetadataTableEditorView(org.talend.designer.xmlmap.ui.tabs.table.XmlMapMetadataTableEditorView) OutputXmlTreeSchemaTableView(org.talend.designer.xmlmap.ui.tabs.table.OutputXmlTreeSchemaTableView)

Aggregations

XmlTreeSchemaTableView (org.talend.designer.xmlmap.ui.tabs.table.XmlTreeSchemaTableView)4 InputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 CTabItem (org.eclipse.swt.custom.CTabItem)1 SashForm (org.eclipse.swt.custom.SashForm)1 StyledText (org.eclipse.swt.custom.StyledText)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1 RowLayout (org.eclipse.swt.layout.RowLayout)1 Event (org.eclipse.swt.widgets.Event)1 Listener (org.eclipse.swt.widgets.Listener)1 ILineSelectionListener (org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener)1 LineSelectionEvent (org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent)1 UnnotifiableColorStyledText (org.talend.commons.ui.swt.colorstyledtext.UnnotifiableColorStyledText)1 ExtendedButtonEvent (org.talend.commons.ui.swt.extended.table.ExtendedButtonEvent)1 IExtendedButtonListener (org.talend.commons.ui.swt.extended.table.IExtendedButtonListener)1 AbstractMetadataTableEditorView (org.talend.core.ui.metadata.editor.AbstractMetadataTableEditorView)1 MetadataTableEditorView (org.talend.core.ui.metadata.editor.MetadataTableEditorView)1 AbstractInOutTree (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree)1