use of org.eclipse.jface.viewers.CellEditor in project tdi-studio-se by Talend.
the class UIManager method changeSchemasDetailView.
/**
*
* cLi Comment method "refreshSchemasDetailView".
*
* refresh schema details view by different provider.
*/
public void changeSchemasDetailView(final TreeViewer schemaDetailsViewer, boolean model) {
if (schemaDetailsViewer == null || schemaDetailsViewer.getTree().isDisposed()) {
return;
}
final Tree tree = schemaDetailsViewer.getTree();
// removed all columns
final TreeColumn[] columns = tree.getColumns();
for (TreeColumn col : columns) {
col.dispose();
}
if (columnTreeEditor != null) {
columnTreeEditor.dispose();
final Control editor = columnTreeEditor.getEditor();
if (editor != null && !editor.isDisposed()) {
editor.setVisible(false);
editor.dispose();
}
columnTreeEditor = null;
}
if (columnMouseListener != null) {
tree.removeMouseListener(columnMouseListener);
columnMouseListener = null;
}
SchemaDetailsProvider provider = null;
if (model) {
// is properties model
provider = new SchemaDetailsPropertiesProvider(this);
List<String> columnProperties = new ArrayList<String>();
List<CellEditor> cellEidors = new ArrayList<CellEditor>();
for (EPropertyName pName : EPropertyName.values()) {
columnProperties.add(pName.name());
TreeColumn pColumn = new TreeColumn(tree, SWT.NONE);
pColumn.setWidth(100);
pColumn.setText(pName.getName());
final CellEditor cellEditor;
switch(pName) {
case NAME:
case LENGTH:
case TAGLEVEL:
// case CARD:
case PATTERN:
cellEditor = new SchemaDetailsTextCellEditor(schemaDetailsViewer, pName);
break;
case KEY:
pColumn.setToolTipText("Only one column can be set as key.");
cellEditor = new SchemaDetailsCheckBoxCellEditor(tree);
break;
// break;
case TYPE:
cellEditor = new ComboBoxCellEditor(tree, MultiSchemasUtil.getTalendTypeLabel(), SWT.READ_ONLY);
break;
default:
cellEditor = null;
}
if (cellEditor != null) {
cellEidors.add(cellEditor);
}
}
schemaDetailsViewer.setColumnProperties(columnProperties.toArray(new String[0]));
schemaDetailsViewer.setCellEditors(cellEidors.toArray(new CellEditor[0]));
schemaDetailsViewer.setCellModifier(new SchemaDetailsPropertiesCellModifier(schemaDetailsViewer, this));
// set sorter
TreeColumn sorterColumn = tree.getColumn(0);
sorterColumn.addListener(SWT.Selection, new SchemaDetailsViewerSorterListener(schemaDetailsViewer));
tree.setSortColumn(sorterColumn);
tree.setSortDirection(SWT.UP);
schemaDetailsViewer.setSorter(new SchemaDetailsViewerSorter(schemaDetailsViewer, sorterColumn, tree.getSortDirection() == SWT.UP));
} else {
// is column model
provider = new SchemaDetailsColumnsProvider(this);
// first columm is fixed.
TreeColumn propertyColumn = new TreeColumn(tree, SWT.NONE);
propertyColumn.setWidth(80);
propertyColumn.setResizable(false);
//
columnTreeEditor = new TreeEditor(tree);
columnTreeEditor.horizontalAlignment = SWT.LEFT;
columnTreeEditor.grabHorizontal = true;
columnMouseListener = new SchemaDetailsColumnMouseAdapter(schemaDetailsViewer, columnTreeEditor, this);
tree.addMouseListener(columnMouseListener);
}
schemaDetailsViewer.setContentProvider(provider);
schemaDetailsViewer.setLabelProvider(provider);
//
}
use of org.eclipse.jface.viewers.CellEditor in project tdi-studio-se by Talend.
the class MultiSchemasUI method createHeaderSashForm.
private void createHeaderSashForm(Composite headerComposite) {
GridLayout layout;
headerSashForm = new SashForm(headerComposite, SWT.NONE);
headerSashForm.setLayout(new FillLayout());
headerSashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
headerSashForm.setSashWidth(ExternalMultiSchemasUIProperties.SASHFORM_WIDTH);
//
multiSchemasFilePreview = new MultiSchemasShadowProcessPreview(this, headerSashForm);
multiSchemasFilePreview.newTablePreview();
Composite struComp = new Composite(headerSashForm, SWT.NONE);
layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
struComp.setLayout(layout);
headerSashForm.setWeights(ExternalMultiSchemasUIProperties.getHeaderSashformWeights());
//
fetchBtn = new Button(struComp, SWT.PUSH);
fetchBtn.setText(ExternalMultiSchemasUIProperties.FETCH_LABEL);
fetchBtn.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
//
schemaTreeViewer = new TreeViewer(struComp, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
Tree tree = schemaTreeViewer.getTree();
tree.setLayoutData(new GridData(GridData.FILL_BOTH));
tree.setHeaderVisible(true);
tree.setLinesVisible(true);
schemaTreeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
// SchemasTreeDnD dnd = new SchemasTreeDnD(schemaTreeViewer);
// dnd.addDragAndDrop();
schemaTreeViewer.setContentProvider(new SchemasTreeContentProvider());
schemaTreeViewer.setLabelProvider(new SchemasTreeLabelProvider());
// schemaTreeViewer.setSorter(new ViewerSorter() {
//
// @SuppressWarnings("unchecked")
// @Override
// public int compare(Viewer viewer, Object e1, Object e2) {
// if (e1 instanceof SchemasKeyData && e2 instanceof SchemasKeyData) {
// return getComparator().compare(((SchemasKeyData) e1).getKeyName(), ((SchemasKeyData) e2).getKeyName());
// }
// return super.compare(viewer, e1, e2);
// }
//
// });
TreeColumn column = new TreeColumn(tree, SWT.LEFT);
column.setWidth(55);
//$NON-NLS-1$
column.setText("Schema");
column.setResizable(true);
column = new TreeColumn(tree, SWT.LEFT);
column.setWidth(100);
//$NON-NLS-1$
column.setText("Record");
column.setResizable(true);
column = new TreeColumn(tree, SWT.LEFT);
column.setWidth(20);
//$NON-NLS-1$
column.setText("Separator");
column.setResizable(true);
schemaTreeViewer.setColumnProperties(new String[] { ExternalMultiSchemasUIProperties.COLUMN_KEY, ExternalMultiSchemasUIProperties.COLUMN_RECORD, ExternalMultiSchemasUIProperties.COLUMN_SEPARATOR });
// hywang for 10263
int columnCount = schemaTreeViewer.getTree().getColumnCount();
CellEditor[] editors = new CellEditor[columnCount];
for (int i = 0; i < columnCount; i++) {
editors[i] = new TextCellEditor(schemaTreeViewer.getTree());
}
schemaTreeViewer.setCellEditors(editors);
schemaTreeViewer.setCellModifier(new ICellModifier() {
public void modify(Object element, String property, Object value) {
if (element != null) {
if (element instanceof TreeItem) {
TreeItem item = (TreeItem) element;
if (item.getData() != null) {
if (item.getData() instanceof SchemasKeyData) {
SchemasKeyData key = (SchemasKeyData) item.getData();
if (property.equals(ExternalMultiSchemasUIProperties.COLUMN_KEY)) {
final boolean flag = checkKeyValue(key.getUniqueRecord(), value.toString());
if (flag) {
key.setUniqueRecord(value.toString());
}
}
if (property.equals(ExternalMultiSchemasUIProperties.COLUMN_RECORD)) {
key.setRecordType(value.toString());
}
if (property.equals(ExternalMultiSchemasUIProperties.COLUMN_SEPARATOR)) {
key.setSeparator(value.toString());
}
// Object input = schemaTreeViewer.getInput();
// SchemasKeyData in = (SchemasKeyData) input;
// if (in.getChildren().contains(key)) {
// in.getChildren().remove(in.getChildren().indexOf(key));
// List<MultiMetadataColumn> colums = multiSchemaManager.createPropertiesColumns(key);
// key.setMetadataColumns(colums);
// in.getChildren().add(key);
// }
}
schemaTreeViewer.refresh();
}
}
}
}
public Object getValue(Object element, String property) {
String record = "";
if (element != null) {
if (element instanceof SchemasKeyData) {
SchemasKeyData key = (SchemasKeyData) element;
if (property.equals(ExternalMultiSchemasUIProperties.COLUMN_KEY)) {
record = key.getUniqueRecord();
}
if (property.equals(ExternalMultiSchemasUIProperties.COLUMN_RECORD)) {
record = key.getRecordType();
}
if (property.equals(ExternalMultiSchemasUIProperties.COLUMN_SEPARATOR)) {
record = key.getSeparator();
}
}
}
return record;
}
public boolean canModify(Object element, String property) {
return true;
}
});
Composite operateTreeComposite = new Composite(struComp, SWT.NONE);
operateTreeComposite.setLayout(new GridLayout(3, false));
operateTreeComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
addRow = new Button(operateTreeComposite, SWT.NONE);
addRow.setText("Add");
removeRow = new Button(operateTreeComposite, SWT.NONE);
removeRow.setText("Remove");
removeRow.setEnabled(false);
editSchema = new Button(operateTreeComposite, SWT.NONE);
editSchema.setText("Edit Columns");
editSchema.setEnabled(false);
Composite operation = new Composite(struComp, SWT.NONE);
operation.setLayout(new GridLayout(2, false));
operation.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
leftBtn = new Button(operation, SWT.PUSH);
leftBtn.setToolTipText("Left");
leftBtn.setImage(ImageProvider.getImage(EImage.LEFT_ICON));
leftBtn.setEnabled(false);
rightBtn = new Button(operation, SWT.PUSH);
rightBtn.setToolTipText("Right");
rightBtn.setImage(ImageProvider.getImage(EImage.RIGHT_ICON));
rightBtn.setEnabled(false);
}
use of org.eclipse.jface.viewers.CellEditor in project tdi-studio-se by Talend.
the class ExtractionLoopWithJSONXPathEditorView method createColumns.
/*
* (non-Javadoc)
*
* @see
* org.talend.commons.ui.swt.advanced.macrotable.AbstractExtendedTableViewer#createColumns(org.talend.commons.ui
* .swt.tableviewer.TableViewerCreator, org.eclipse.swt.widgets.Table)
*/
@Override
protected void createColumns(TableViewerCreator<JSONXPathLoopDescriptor> tableViewerCreator, final Table table) {
CellEditorValueAdapter intValueAdapter = new CellEditorValueAdapter() {
@Override
public Object getOriginalTypedValue(final CellEditor cellEditor, Object value) {
try {
return new Integer(value.toString());
} catch (Exception ex) {
return null;
}
}
@Override
public Object getCellEditorTypedValue(final CellEditor cellEditor, Object value) {
if (value != null) {
return String.valueOf(value);
}
//$NON-NLS-1$
return "";
}
};
// //////////////////////////////////////////////////////////////////////////////////////
// column for mouse selection
TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
//$NON-NLS-1$
column.setTitle("");
//$NON-NLS-1$
column.setDefaultInternalValue("");
column.setWidth(15);
// //////////////////////////////////////////////////////////////////////////////////////
// X Path Query
column = new TableViewerCreatorColumn(tableViewerCreator);
xPathColumn = column;
column.setTitle("Absolute path expression");
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<JSONXPathLoopDescriptor, String>() {
@Override
public String get(JSONXPathLoopDescriptor bean) {
return bean.getAbsoluteXPathQuery();
}
@Override
public void set(JSONXPathLoopDescriptor bean, String value) {
String currentFlag = ConvertJSONString.getCurrentFlag();
bean.setAbsoluteXPathQuery(value);
bean.setFlag(currentFlag);
}
});
xPathCellEditor = new TextCellEditorWithProposal(tableViewerCreator.getTable(), SWT.NONE, column);
column.setCellEditor(xPathCellEditor);
xPathCellEditor.addListener(new DialogErrorForCellEditorListener(xPathCellEditor, column) {
@Override
public void newValidValueTyped(int itemIndex, Object previousValue, Object newValue, CELL_EDITOR_STATE state) {
if (state == CELL_EDITOR_STATE.APPLYING) {
// linker.onXPathValueChanged(table, newValue.toString(), itemIndex);
}
}
@Override
public String validateValue(String newValue, int beanPosition) {
return linker.validateXPathExpression(newValue);
}
});
column.setModifiable(true);
column.setWeight(30);
column.setMinimumWidth(50);
//$NON-NLS-1$
column.setDefaultInternalValue("");
// //////////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////////////
// Loop limit
column = new TableViewerCreatorColumn(tableViewerCreator);
column.setTitle("Loop limit");
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<JSONXPathLoopDescriptor, Integer>() {
@Override
public Integer get(JSONXPathLoopDescriptor bean) {
return bean.getLimitBoucle();
}
@Override
public void set(JSONXPathLoopDescriptor bean, Integer value) {
if (value != null) {
bean.setLimitBoucle(value.intValue());
} else {
bean.setLimitBoucle(0);
}
}
});
column.setModifiable(true);
column.setWidth(59);
column.setCellEditor(new TextCellEditor(table), intValueAdapter);
}
use of org.eclipse.jface.viewers.CellEditor in project tdi-studio-se by Talend.
the class TableByRowController method updateColumnList.
private void updateColumnList(IElementParameter param) {
if (elem instanceof Node) {
ColumnListController.updateColumnList((Node) elem, null);
} else if (elem instanceof Connection) {
ColumnListController.updateColumnList(((Connection) elem).getSource(), null);
}
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 (itemsValue[j] instanceof IElementParameter) {
IElementParameter tmpParam = (IElementParameter) itemsValue[j];
if (tmpParam.getFieldType() == EParameterFieldType.COLUMN_LIST || tmpParam.getFieldType() == EParameterFieldType.PREV_COLUMN_LIST || tmpParam.getFieldType() == EParameterFieldType.LOOKUP_COLUMN_LIST) {
if ((j + 1) >= colList.size()) {
break;
}
TableViewerCreatorColumnNotModifiable column = (TableViewerCreatorColumnNotModifiable) colList.get(j + 1);
CellEditor cellEditor = column.getCellEditor();
String[] oldItems = null;
if (cellEditor instanceof ComboBoxCellEditor) {
CCombo combo = (CCombo) cellEditor.getControl();
oldItems = combo.getItems();
combo.setItems(tmpParam.getListItemsDisplayName());
}
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.eclipse.jface.viewers.CellEditor in project tdi-studio-se by Talend.
the class AddArrayIndexForParentsDialog method createDialogArea.
protected Control createDialogArea(Composite parent) {
Composite createDialogArea = (Composite) super.createDialogArea(parent);
FillLayout layout = new FillLayout();
// layout.horizontalSpacing = 1;
// layout.numColumns = 1;
GridData data = new GridData(GridData.FILL_BOTH);
createDialogArea.setLayout(layout);
createDialogArea.setLayoutData(data);
table = new TableViewer(createDialogArea, SWT.FULL_SELECTION | SWT.BORDER);
new TableColumn(table.getTable(), SWT.LEFT).setText(COLUMN_NAME[0]);
table.getTable().getColumn(0).pack();
new TableColumn(table.getTable(), SWT.LEFT).setText(COLUMN_NAME[1]);
table.getTable().getColumn(1).pack();
table.getTable().setHeaderVisible(true);
table.getTable().setLinesVisible(true);
table.setContentProvider(new IndexContentProvider());
table.setLabelProvider(new IndexLabelProvider());
table.setInput(arrayIndexList);
table.setColumnProperties(COLUMN_NAME);
CellEditor[] editors = new CellEditor[2];
editors[0] = null;
editors[1] = new TextCellEditor(table.getTable());
table.setCellEditors(editors);
table.setCellModifier(new ICellModifier() {
public boolean canModify(Object element, String property) {
if (property.equals(COLUMN_NAME[0]))
return false;
return true;
}
public Object getValue(Object element, String property) {
ArrayIndexList index = (ArrayIndexList) element;
if (property.equals(COLUMN_NAME[1])) {
if (index.getIndexNum() != null) {
return index.getIndexNum();
} else {
return "";
}
}
return null;
}
public void modify(Object element, String property, Object value) {
if (element instanceof Item)
element = ((Item) element).getData();
ArrayIndexList index = (ArrayIndexList) element;
if (property.equals(COLUMN_NAME[1]))
index.setIndexNum((String) value);
table.refresh();
}
});
return createDialogArea;
}
Aggregations