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();
}
}
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());
}
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();
}
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);
}
Aggregations