use of org.talend.commons.ui.swt.tableviewer.TableViewerCreator in project tdi-studio-se by Talend.
the class TabFolderEditors method addListenersToInputButtons.
/**
* DOC amaumont Comment method "addListenersToInputButtons".
*/
private void addListenersToInputButtons() {
MetadataToolbarEditorView toolBar = inputMetaEditor.getToolBar();
inputToolBarButtons = toolBar.getButtons();
beforeCommandListenerForInputButtons = new IExtendedButtonListener() {
public void handleEvent(ExtendedButtonEvent event) {
TableViewerCreator tableViewerCreator = mapperManager.getUiManager().getCurrentSelectedInputTableView().getTableViewerCreatorForColumns();
if (tableViewerCreator != null) {
tableViewerCreator.applyActivatedCellEditor();
}
}
};
for (ExtendedPushButton extendedPushButton : inputToolBarButtons) {
extendedPushButton.addListener(beforeCommandListenerForInputButtons, true);
}
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 : inputToolBarButtons) {
extendedPushButton.removeListener(beforeCommandListenerForInputButtons, true);
}
}
});
}
use of org.talend.commons.ui.swt.tableviewer.TableViewerCreator in project tdi-studio-se by Talend.
the class TableByRowController method updateContextList.
private void updateContextList(IElementParameter param) {
List<String> contextParameterNamesList = new ArrayList<String>();
IElementParameter processTypeParam = elem.getElementParameterFromField(EParameterFieldType.PROCESS_TYPE);
if (processTypeParam == null) {
processTypeParam = elem.getElementParameterFromField(EParameterFieldType.ROUTE_INPUT_PROCESS_TYPE);
if (processTypeParam == null) {
return;
}
}
boolean haveContextParamList = false;
for (Object valueParam : param.getListItemsValue()) {
if (valueParam instanceof IElementParameter) {
IElementParameter vParam = (IElementParameter) valueParam;
if (vParam.getFieldType() == EParameterFieldType.CONTEXT_PARAM_NAME_LIST) {
haveContextParamList = true;
break;
}
}
}
if (!haveContextParamList) {
return;
}
IElementParameter jobElemParam = processTypeParam.getChildParameters().get(EParameterName.PROCESS_TYPE_PROCESS.getName());
IElementParameter jobVersionParam = processTypeParam.getChildParameters().get(EParameterName.PROCESS_TYPE_VERSION.getName());
IElementParameter contextElemParam = processTypeParam.getChildParameters().get(EParameterName.PROCESS_TYPE_CONTEXT.getName());
// get context list
String processId = (String) jobElemParam.getValue();
String contextName = (String) contextElemParam.getValue();
if (contextName == null) {
contextName = new String();
}
if (processId == null || contextName == null) {
revertToolBarButtonState(false);
return;
}
ProcessItem processItem = ItemCacheManager.getProcessItem(processId, (String) jobVersionParam.getValue());
Process process = null;
String[] contextParameterNames = null;
if (processItem != null) {
// achen modify to fix bug 0006107
IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
process = (Process) service.getProcessFromItem(processItem);
// process = new Process(processItem.getProperty());
// process.loadXmlFile();
IContext context = process.getContextManager().getContext(contextName);
for (IContextParameter contextParam : context.getContextParameterList()) {
contextParameterNamesList.add(contextParam.getName());
}
contextParameterNames = contextParameterNamesList.toArray(new String[0]);
} else {
contextParameterNames = new String[0];
}
// update table values
TableViewerCreator tableViewerCreator = (TableViewerCreator) hashCurControls.get(param.getName());
Object[] itemsValue = param.getListItemsValue();
if (tableViewerCreator != null) {
List colList = tableViewerCreator.getColumns();
for (int j = 0; j < itemsValue.length; j++) {
if ((j + 1) >= colList.size()) {
break;
}
if (itemsValue[j] instanceof IElementParameter) {
IElementParameter tmpParam = (IElementParameter) itemsValue[j];
if (tmpParam.getFieldType() == EParameterFieldType.CONTEXT_PARAM_NAME_LIST) {
tmpParam.setListItemsDisplayCodeName(contextParameterNames);
tmpParam.setListItemsDisplayName(contextParameterNames);
tmpParam.setListItemsValue(contextParameterNames);
if (contextParameterNames.length > 0) {
tmpParam.setDefaultClosedListValue(contextParameterNames[0]);
} else {
//$NON-NLS-1$
tmpParam.setDefaultClosedListValue("");
}
// j + 1 because first column is masked
TableViewerCreatorColumnNotModifiable column = (TableViewerCreatorColumnNotModifiable) colList.get(j + 1);
CCombo combo = (CCombo) column.getCellEditor().getControl();
String[] oldItems = combo.getItems();
combo.setItems(contextParameterNames);
List<Map<String, Object>> paramValues = (List<Map<String, Object>>) param.getValue();
String[] items = param.getListItemsDisplayCodeName();
for (int currentIndex = 0; currentIndex < paramValues.size(); currentIndex++) {
Map<String, Object> currentLine = paramValues.get(currentIndex);
Object o = currentLine.get(items[j]);
if (o instanceof Integer) {
Integer nb = (Integer) o;
if ((nb >= oldItems.length) || (nb == -1)) {
currentLine.put(items[j], tmpParam.getDefaultClosedListValue());
} else {
currentLine.put(items[j], oldItems[nb]);
}
} else {
if (o instanceof String) {
Integer nb = new Integer(tmpParam.getIndexOfItemFromList((String) o));
if (nb == -1) {
currentLine.put(items[j], tmpParam.getDefaultClosedListValue());
}
}
}
}
}
}
}
}
// (bug 3740)
boolean checked = contextParameterNames != null && contextParameterNames.length > 0;
if (!checked) {
Object value = param.getValue();
if (value != null && value instanceof List) {
if (!((List) value).isEmpty()) {
((List) value).clear();
if (part != null && part.getTalendEditor() != null) {
part.getTalendEditor().setDirty(true);
}
}
}
}
revertToolBarButtonState(checked);
}
use of org.talend.commons.ui.swt.tableviewer.TableViewerCreator in project tdi-studio-se by Talend.
the class TableByRowController method updateComponentList.
private void updateComponentList(IElementParameter param) {
// update table values
TableViewerCreator tableViewerCreator = (TableViewerCreator) hashCurControls.get(param.getName());
Object[] itemsValue = param.getListItemsValue();
if (tableViewerCreator != null && itemsValue != null) {
List colList = tableViewerCreator.getColumns();
for (int j = 0; j < itemsValue.length; j++) {
if ((j + 1) >= colList.size()) {
break;
}
if (itemsValue[j] instanceof IElementParameter) {
IElementParameter tmpParam = (IElementParameter) itemsValue[j];
if (tmpParam.getFieldType() == EParameterFieldType.COMPONENT_LIST) {
String[] contextParameterNames = null;
ComponentListController.updateComponentList(elem, tmpParam);
contextParameterNames = tmpParam.getListItemsDisplayName();
tmpParam.setListItemsDisplayCodeName(contextParameterNames);
// tmpParam.setListItemsValue(contextParameterNames);
if (contextParameterNames.length > 0) {
tmpParam.setDefaultClosedListValue(contextParameterNames[0]);
} else {
//$NON-NLS-1$
tmpParam.setDefaultClosedListValue("");
}
// j + 1 because first column is masked
TableViewerCreatorColumnNotModifiable column = (TableViewerCreatorColumnNotModifiable) colList.get(j + 1);
CCombo combo = (CCombo) column.getCellEditor().getControl();
String[] oldItems = combo.getItems();
combo.setItems(contextParameterNames);
List<Map<String, Object>> paramValues = (List<Map<String, Object>>) param.getValue();
String[] items = param.getListItemsDisplayCodeName();
for (int currentIndex = 0; currentIndex < paramValues.size(); currentIndex++) {
Map<String, Object> currentLine = paramValues.get(currentIndex);
Object o = currentLine.get(items[j]);
if (o instanceof Integer) {
Integer nb = (Integer) o;
if ((nb >= oldItems.length) || (nb == -1)) {
nb = new Integer(tmpParam.getIndexOfItemFromList((String) tmpParam.getDefaultClosedListValue()));
currentLine.put(items[j], nb);
} else {
nb = new Integer(tmpParam.getIndexOfItemFromList(oldItems[nb]));
currentLine.put(items[j], nb);
}
}
}
}
}
}
}
}
use of org.talend.commons.ui.swt.tableviewer.TableViewerCreator in project tdi-studio-se by Talend.
the class SearchZoneMapper method getSelectedKeyAtSelectedTableItem.
public Integer getSelectedKeyAtSelectedTableItem(Map<Integer, Map<Integer, ITableEntry>> searchMaps) {
Integer selectKey = 0;
TableViewerCreator tableViewerCreator = null;
if (uiManager.getCurrentSelectedInputTableView() != null) {
tableViewerCreator = uiManager.getCurrentSelectedInputTableView().getTableViewerCreatorForColumns();
if (tableViewerCreator != null && tableViewerCreator.getTableViewer() != null) {
ISelection selection = tableViewerCreator.getTableViewer().getSelection();
if (selection == null || selection.isEmpty()) {
if (uiManager.getCurrentSelectedOutputTableView() != null) {
tableViewerCreator = uiManager.getCurrentSelectedOutputTableView().getTableViewerCreatorForColumns();
}
}
}
} else if (uiManager.getCurrentSelectedOutputTableView() != null) {
tableViewerCreator = uiManager.getCurrentSelectedOutputTableView().getTableViewerCreatorForColumns();
}
if (tableViewerCreator != null && tableViewerCreator.getTableViewer() != null) {
ISelection selection = tableViewerCreator.getTableViewer().getSelection();
if (selection != null && !selection.isEmpty()) {
List<ITableEntry> list = uiManager.extractSelectedTableEntries(selection);
if (list != null && !list.isEmpty()) {
ITableEntry tableEntry = list.get(0);
if (tableEntry != null) {
Iterator iter = searchMaps.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
Map<Integer, ITableEntry> map = (Map<Integer, ITableEntry>) entry.getValue();
if (map.containsValue(tableEntry)) {
Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry e = (Map.Entry) it.next();
if (e.getValue() != null && e.getValue() instanceof ITableEntry) {
ITableEntry tableEntryTemp = (ITableEntry) e.getValue();
if (tableEntry.equals(tableEntryTemp)) {
tableViewerCreator.getTableViewer().getTable().deselectAll();
return (Integer) entry.getKey();
}
}
}
}
}
}
}
}
}
return selectKey;
}
use of org.talend.commons.ui.swt.tableviewer.TableViewerCreator in project tdi-studio-se by Talend.
the class UIManager method processColumnNameChanged.
/**
* DOC amaumont Comment method "processNewProcessColumnName".
*
* @param previousColumnName TODO
* @param dataMapTableView
* @param text
* @param entry
*/
public void processColumnNameChanged(final String previousColumnName, final String newColumnName, final DataMapTableView dataMapTableView, final ITableEntry currentModifiedITableEntry) {
mapperManager.changeColumnName(currentModifiedITableEntry, previousColumnName, newColumnName);
Collection<DataMapTableView> tableViews = mapperManager.getTablesView();
boolean atLeastOneLinkHasBeenRemoved = false;
for (DataMapTableView view : tableViews) {
IDataMapTable dataMapTable = view.getDataMapTable();
List<IColumnEntry> metadataTableEntries = dataMapTable.getColumnEntries();
for (IColumnEntry entry : metadataTableEntries) {
if (parseExpression(entry.getExpression(), entry, true, true, false).isAtLeastOneLinkRemoved()) {
atLeastOneLinkHasBeenRemoved = true;
}
}
// for the input/output table expression filter
if (dataMapTable instanceof AbstractInOutTable) {
ExpressionFilterEntry expressionFilterEntry = ((AbstractInOutTable) dataMapTable).getExpressionFilter();
if (expressionFilterEntry != null && expressionFilterEntry.getExpression() != null) {
if (parseExpression(expressionFilterEntry.getExpression(), expressionFilterEntry, true, true, false).isAtLeastOneLinkRemoved()) {
atLeastOneLinkHasBeenRemoved = true;
}
}
}
}
mapperManager.getUiManager().refreshBackground(false, false);
dataMapTableView.getTableViewerCreatorForColumns().getTableViewer().refresh(currentModifiedITableEntry);
if (atLeastOneLinkHasBeenRemoved) {
new AsynchronousThreading(20, false, dataMapTableView.getDisplay(), new Runnable() {
public void run() {
TableViewerCreator tableViewerCreatorForColumns = dataMapTableView.getTableViewerCreatorForColumns();
boolean propagate = MessageDialog.openQuestion(tableViewerCreatorForColumns.getTable().getShell(), //$NON-NLS-1$
Messages.getString("UIManager.propagateTitle"), //$NON-NLS-1$
Messages.getString("UIManager.propagateMessage"));
if (propagate) {
TableEntryLocation previousLocation = new TableEntryLocation(currentModifiedITableEntry.getParentName(), previousColumnName);
TableEntryLocation newLocation = new TableEntryLocation(currentModifiedITableEntry.getParentName(), newColumnName);
mapperManager.replacePreviousLocationInAllExpressions(previousLocation, newLocation);
}
}
}).start();
}
}
Aggregations