use of org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent in project tdi-studio-se by Talend.
the class TabFolderEditors method addListenersToOutputButtons.
/**
* DOC amaumont Comment method "addListenersToInputButtons".
*/
private void addListenersToOutputButtons() {
MetadataToolbarEditorView toolBar = outputMetaEditor.getToolBar();
outputToolBarButtons = toolBar.getButtons();
beforeCommandListenerForOutputButtons = new IExtendedButtonListener() {
public void handleEvent(ExtendedButtonEvent event) {
TableViewerCreator tableViewerCreator = mapperManager.getUiManager().getCurrentSelectedOutputTableView().getTableViewerCreatorForColumns();
if (tableViewerCreator != null) {
tableViewerCreator.applyActivatedCellEditor();
}
}
};
for (ExtendedPushButton extendedPushButton : outputToolBarButtons) {
extendedPushButton.addListener(beforeCommandListenerForOutputButtons, true);
if (extendedPushButton instanceof RemovePushButton && !mapperManager.componentIsReadOnly()) {
removeButton = (RemovePushButtonForExtendedTable) extendedPushButton;
}
}
if (removeButton != null) {
final TableViewerCreator tableViewerCreator = removeButton.getExtendedTableViewer().getTableViewerCreator();
tableViewerCreator.getSelectionHelper().addAfterSelectionListener(new ILineSelectionListener() {
public void handle(LineSelectionEvent e) {
for (TableItem item : tableViewerCreator.getTable().getSelection()) {
if (item.getData() instanceof MetadataColumn) {
MetadataColumn column = (MetadataColumn) item.getData();
removeButton.getButton().setEnabled(!column.isCustom());
break;
}
}
}
});
}
this.addDisposeListener(new DisposeListener() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
*/
public void widgetDisposed(DisposeEvent e) {
for (ExtendedPushButton extendedPushButton : outputToolBarButtons) {
extendedPushButton.removeListener(beforeCommandListenerForOutputButtons, true);
}
}
});
}
use of org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent in project tdi-studio-se by Talend.
the class UIManager method modifySelectionChangedListener.
private void modifySelectionChangedListener(final Zone currentZone, final MetadataTableEditorView metadataTableEditorViewFinal, final TableViewerCreator metadataTVCreator, final MetadataTableEditor metadataTableEditor, final DataMapTableView dataMapTableView, DataMapTableView previousSelectedTableView) {
final TableViewer tableViewer = dataMapTableView.getTableViewerCreatorForColumns().getTableViewer();
IModifiedBeanListener<IMetadataColumn> modifiedBeanListener = new IModifiedBeanListener<IMetadataColumn>() {
public void handleEvent(ModifiedBeanEvent<IMetadataColumn> event) {
if (AbstractMetadataTableEditorView.ID_COLUMN_NAME.equals(event.column.getId()) && !event.previousValue.equals(event.newValue)) {
IMetadataColumn modifiedObject = event.bean;
if (modifiedObject != null) {
TableEntryLocation tableEntryLocation = new TableEntryLocation(dataMapTableView.getDataMapTable().getName(), (String) event.previousValue);
final ITableEntry dataMapTableEntry = mapperManager.retrieveTableEntry(tableEntryLocation);
// see bug 7471,record the modification about the column value
String curConnName = null;
if (dataMapTableEntry != null) {
curConnName = dataMapTableEntry.getParentName();
}
List<? extends IConnection> curInConns = mapperManager.getAbstractMapComponent().getIncomingConnections();
List<? extends IConnection> curOutConns = mapperManager.getAbstractMapComponent().getOutgoingConnections();
for (IConnection curInConn : curInConns) {
if (curConnName.equals(curInConn.getUniqueName())) {
Map<String, String> changedNameInColumns = new HashMap<String, String>();
changedNameInColumns.put((String) event.newValue, (String) event.previousValue);
changedNameColumns.put(curInConn, changedNameInColumns);
}
}
for (IConnection curOutConn : curOutConns) {
if (curConnName.equals(curOutConn.getUniqueName())) {
Map<String, String> changedNameOutColumns = new HashMap<String, String>();
changedNameOutColumns.put((String) event.newValue, (String) event.previousValue);
changedNameColumns.put(curOutConn, changedNameOutColumns);
}
}
processColumnNameChanged((String) event.previousValue, (String) event.newValue, dataMapTableView, dataMapTableEntry);
// related tables
List<DataMapTableView> relatedOutputsTableView = getRelatedOutputsTableView(dataMapTableView);
for (DataMapTableView relatedView : relatedOutputsTableView) {
TableEntryLocation relatedEntryLocation = new TableEntryLocation(relatedView.getDataMapTable().getName(), (String) event.previousValue);
ITableEntry relatedTableEntry = mapperManager.retrieveTableEntry(relatedEntryLocation);
processColumnNameChanged((String) event.previousValue, (String) event.newValue, relatedView, relatedTableEntry);
}
}
// dataMapTableViewer.refresh(event.bean, true);
tableViewer.refresh(true);
} else if (AbstractMetadataTableEditorView.ID_COLUMN_KEY.equals(event.column.getId())) {
tableViewer.refresh(true);
IColumnEntry entry = dataMapTableView.getDataMapTable().getColumnEntries().get(event.index);
parseExpression(entry.getExpression(), entry, false, false, false);
} else if (AbstractMetadataTableEditorView.ID_COLUMN_TYPE.equals(event.column.getId()) || AbstractMetadataTableEditorView.ID_COLUMN_NULLABLE.equals(event.column.getId())) {
mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
}
}
};
ILineSelectionListener metadataEditorViewerSelectionChangedListener = new ILineSelectionListener() {
public void handle(LineSelectionEvent e) {
if (metadataTableEditorViewFinal.getTableViewerCreator() == e.source) {
if (metadataTableEditorViewFinal.getExtendedTableViewer().isExecuteSelectionEvent()) {
mapperManager.getUiManager().selectLinkedTableEntries(metadataTableEditor.getMetadataTable(), metadataTVCreator.getTable().getSelectionIndices());
}
} else {
// if (dataMapTableView.getExtendedTableViewerForColumns().isExecuteSelectionEvent()) {
// int[] selectionIndices =
// dataMapTableView.getTableViewerCreatorForColumns().getTable().getSelectionIndices();
// mapperManager.getUiManager().selectLinkedMetadataEditorEntries(dataMapTableView,
// selectionIndices);
// }
}
}
};
// ISelectionChangedListener previousSelectionChangedListener = null;
ILineSelectionListener previousSelectionChangedListener = null;
IModifiedBeanListener<IMetadataColumn> previousModifiedBeanListener = null;
if (currentZone == Zone.INPUTS) {
previousSelectionChangedListener = inputsSelectionChangedListener;
previousModifiedBeanListener = inputModifiedBeanListener;
} else if (currentZone == Zone.OUTPUTS) {
previousSelectionChangedListener = outputsSelectionChangedListener;
previousModifiedBeanListener = outputModifiedBeanListener;
}
if (previousSelectionChangedListener != null) {
// metadataTVCreator.removeSelectionChangedListener(previousSelectionChangedListener);
metadataTVCreator.getSelectionHelper().removeAfterSelectionListener(previousSelectionChangedListener);
if (previousSelectedTableView != null) {
previousSelectedTableView.getTableViewerCreatorForColumns().getSelectionHelper().removeAfterSelectionListener(previousSelectionChangedListener);
}
}
if (previousModifiedBeanListener != null) {
metadataTableEditor.removeModifiedBeanListener(previousModifiedBeanListener);
}
if (currentZone == Zone.INPUTS) {
inputsSelectionChangedListener = metadataEditorViewerSelectionChangedListener;
inputModifiedBeanListener = modifiedBeanListener;
} else if (currentZone == Zone.OUTPUTS) {
outputsSelectionChangedListener = metadataEditorViewerSelectionChangedListener;
outputModifiedBeanListener = modifiedBeanListener;
}
// metadataTVCreator.addSelectionChangedListener(metadataEditorViewerSelectionChangedListener);
metadataTVCreator.getSelectionHelper().addAfterSelectionListener(metadataEditorViewerSelectionChangedListener);
dataMapTableView.getTableViewerCreatorForColumns().getSelectionHelper().addAfterSelectionListener(metadataEditorViewerSelectionChangedListener);
metadataTableEditor.addModifiedBeanListener(modifiedBeanListener);
if (this.commonMetadataDisposeListener == null) {
this.commonMetadataDisposeListener = new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
if (inputsSelectionChangedListener != null) {
getMetadataEditorView(Zone.INPUTS).getTableViewerCreator().getSelectionHelper().removeAfterSelectionListener(inputsSelectionChangedListener);
}
if (outputsSelectionChangedListener != null) {
getMetadataEditorView(Zone.OUTPUTS).getTableViewerCreator().getSelectionHelper().removeAfterSelectionListener(outputsSelectionChangedListener);
}
if (inputModifiedBeanListener != null) {
MetadataTableEditor metadataTableEditor = getMetadataEditorView(Zone.INPUTS).getMetadataTableEditor();
if (metadataTableEditor != null) {
metadataTableEditor.removeModifiedBeanListener(inputModifiedBeanListener);
}
}
if (outputModifiedBeanListener != null) {
MetadataTableEditor metadataTableEditor = getMetadataEditorView(Zone.OUTPUTS).getMetadataTableEditor();
if (metadataTableEditor != null) {
metadataTableEditor.removeModifiedBeanListener(outputModifiedBeanListener);
}
}
}
};
metadataTVCreator.getTable().addDisposeListener(this.commonMetadataDisposeListener);
}
}
use of org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent in project tdi-studio-se by Talend.
the class JSONToXPathLinker method initLoopListeners.
/**
* DOC amaumont Comment method "initListeners".
*/
private void initLoopListeners() {
JSONExtractorLoopModel loopModel = this.loopTableEditorView.getModel();
final Table loopTable = this.loopTableEditorView.getTableViewerCreator().getTable();
loopModelModifiedBeanListener = new IModifiedBeanListener<JSONXPathLoopDescriptor>() {
@Override
public void handleEvent(ModifiedBeanEvent<JSONXPathLoopDescriptor> event) {
handleModifiedBeanEvent(event);
}
private void handleModifiedBeanEvent(ModifiedBeanEvent<JSONXPathLoopDescriptor> event) {
if (event.column == loopTableEditorView.getXPathColumn()) {
onXPathValueChanged(loopTable, (String) event.newValue, event.index);
}
}
};
loopModel.addModifiedBeanListener(loopModelModifiedBeanListener);
loopTableExtendedControlListener = new IExtendedControlListener() {
@Override
public void handleEvent(ExtendedControlEvent event) {
if (event.getType() == EVENT_TYPE.MODEL_CHANGED) {
nodeRetriever.setCurrentLoopXPath(getCurrentLoopXPath());
}
}
};
this.loopTableEditorView.getExtendedTableViewer().addListener(loopTableExtendedControlListener);
SelectionHelper selectionHelper = this.loopTableEditorView.getTableViewerCreator().getSelectionHelper();
afterLineSelectionListener = new ILineSelectionListener() {
@Override
public void handle(LineSelectionEvent e) {
updateLinksStyleAndControlsSelection(e.source.getTable(), true);
}
};
selectionHelper.addAfterSelectionListener(afterLineSelectionListener);
}
use of org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent in project tdi-studio-se by Talend.
the class ConnectionsListComposite method setConnectionsFormComposite.
public void setConnectionsFormComposite(ConnectionFormComposite connectionsFormComposite) {
this.connectionsFormComposite = connectionsFormComposite;
table.getTableViewerCreator().getSelectionHelper().addAfterSelectionListener(new ILineSelectionListener() {
@Override
public void handle(LineSelectionEvent e) {
ISelection sel = e.source.getTableViewer().getSelection();
IStructuredSelection sel2 = (IStructuredSelection) sel;
ConnectionBean selected = (ConnectionBean) sel2.getFirstElement();
setSelectedConnection(selected);
}
});
if (!list.isEmpty()) {
for (int i = 0; i < list.size(); i++) {
setSelectedConnection(list.get(i));
}
setSelectedConnection(list.get(0));
}
}
use of org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent 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