use of org.eclipse.swt.widgets.TableItem in project tdi-studio-se by Talend.
the class ShadowProcessPreview method refreshPreviewItem.
/**
* qzhang Comment method "refreshPreviewItem".
*
* @param xmlRows
*/
private void refreshPreviewItem(List<String[]> xmlRows) {
int existingItemCount = table.getItemCount();
int end = xmlRows.size();
for (int f = 0; f < end; f++) {
if (f >= existingItemCount) {
// create a new Item
TableItem row = new TableItem(table, SWT.NONE);
row.setText(xmlRows.get(f));
} else {
// update an existing Item
table.getItem(f).setText(xmlRows.get(f));
}
}
// remove the unused TableItem
if (end < existingItemCount) {
table.remove(end, existingItemCount - 1);
}
}
use of org.eclipse.swt.widgets.TableItem in project tdi-studio-se by Talend.
the class JSONShadowProcessPreview method refreshPreviewItem.
/**
* refresh the Item of Preview.
*
* @param csvRows
* @param firstRowIsLabel
*/
protected void refreshPreviewItem(final List<String[]> csvRows, final boolean firstRowIsLabel, int... selectedColumnIndex) {
int existingItemCount = table.getItemCount();
int end = csvRows.size();
if (firstRowIsLabel) {
end--;
}
for (int f = 0; f < end; f++) {
String[] csvFields;
if (firstRowIsLabel) {
csvFields = csvRows.get(f + 1);
} else {
csvFields = csvRows.get(f);
}
String[] values = csvFields;
if (f >= existingItemCount) {
// create a new Item
TableItem row = new TableItem(table, SWT.NONE);
row.setText(values);
} else {
// update an existing Item
table.getItem(f).setText(values);
}
}
table.setRedraw(true);
}
use of org.eclipse.swt.widgets.TableItem in project tdi-studio-se by Talend.
the class StatusConfirmSettingDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
TableViewer viewer = new TableViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
GridData data = new GridData(GridData.FILL_BOTH);
data.minimumHeight = 200;
data.heightHint = 200;
data.minimumWidth = 350;
data.widthHint = 350;
viewer.getControl().setLayoutData(data);
final Table table = viewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableColumn column = new TableColumn(table, SWT.NONE);
//$NON-NLS-1$
column.setText(Messages.getString("VersionManagementDialog.Items"));
column.setWidth(140);
column = new TableColumn(table, SWT.NONE);
//$NON-NLS-1$
column.setText(Messages.getString("StatusManagementDialog.Status"));
column.setWidth(120);
column = new TableColumn(table, SWT.NONE);
//$NON-NLS-1$
column.setText(Messages.getString("StatusManagementDialog.NewStatus"));
column.setWidth(90);
viewer.setContentProvider(ArrayContentProvider.getInstance());
viewer.setLabelProvider(new ITableLabelProvider() {
public Image getColumnImage(Object element, int columnIndex) {
RepositoryObject object = (RepositoryObject) element;
if (columnIndex == 0) {
ERepositoryObjectType itemType = object.getRepositoryObjectType();
return getItemsImage(CoreImageProvider.getIcon(itemType));
}
return null;
}
public String getColumnText(Object element, int columnIndex) {
RepositoryObject object = (RepositoryObject) element;
switch(columnIndex) {
case 0:
return object.getLabel();
case 1:
return statusHelper.getStatusLabel(object.getProperty().getOldStatusCode());
case 2:
if (object.getStatusCode().equals(object.getProperty().getOldStatusCode())) {
//$NON-NLS-1$
return "-";
}
return statusHelper.getStatusLabel(object.getStatusCode());
default:
}
return null;
}
public void addListener(ILabelProviderListener listener) {
}
public void dispose() {
}
public boolean isLabelProperty(Object element, String property) {
return false;
}
public void removeListener(ILabelProviderListener listener) {
}
});
viewer.setInput(modifiedVersionItems);
for (TableItem item : table.getItems()) {
RepositoryObject object = (RepositoryObject) item.getData();
// if (!object.getOldVersion().equals(object.getNewVersion())) {
item.setForeground(2, Display.getDefault().getSystemColor(SWT.COLOR_RED));
// }
}
return composite;
}
use of org.eclipse.swt.widgets.TableItem in project tdi-studio-se by Talend.
the class ImportCompatibleEcoComponentsComposite method removeItemElements.
private void removeItemElements(List<ComponentExtension> objects) {
table.setRedraw(false);
TableItem[] items = table.getItems();
for (TableItem item : items) {
removeTableItem(item);
}
table.setRedraw(true);
}
use of org.eclipse.swt.widgets.TableItem in project tdi-studio-se by Talend.
the class BusinessAssignmentComposite method createControls.
public void createControls(Composite parent) {
composite = widgetFactory.createFlatFormComposite(parent);
adapterFactory = new BusinessItemProviderAdapterFactory();
tableViewer = new TableViewer(composite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
tableViewer.setLabelProvider(new RepositoryFactoryProxyLabelProvider(adapterFactory));
Table table = tableViewer.getTable();
TableLayout tableLayout = new TableLayout();
table.setLayout(tableLayout);
table.setHeaderVisible(true);
table.setLinesVisible(true);
final String[] columnProperties = new String[] { Messages.getString("AssignmentPropertySection.Type"), Messages.getString("AssignmentPropertySection.Name"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Messages.getString("AssignmentPropertySection.Comment") };
TableColumn column1 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column1.setText(columnProperties[0]);
TableColumn column2 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column2.setText(columnProperties[1]);
TableColumn column3 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnWeightData(1, 150, true));
column3.setText(columnProperties[2]);
tableViewer.setColumnProperties(columnProperties);
final IItemPropertyDescriptor itemPropertyDescriptor = getItemPropertyDescriptor();
tableViewer.setCellModifier(new ICellModifier() {
@Override
public boolean canModify(Object element, String property) {
return property.equals(columnProperties[2]);
}
@Override
public Object getValue(Object element, String property) {
return EmfPropertyHelper.getValue(itemPropertyDescriptor, element);
}
@Override
public void modify(Object element, String property, Object value) {
if (element instanceof TableItem) {
TableItem tableItem = (TableItem) element;
itemPropertyDescriptor.setPropertyValue(tableItem.getData(), value);
}
}
});
CellEditor[] cellEditors = new CellEditor[3];
cellEditors[2] = new TextCellEditor(table);
tableViewer.setCellEditors(cellEditors);
// createKeyListener(table);
createSelectionListener();
createPopupMenu();
createDoubleClickListener();
handleLayout(parent, table, column1, column2, column3);
}
Aggregations