use of org.eclipse.swt.widgets.TableColumn in project tesb-studio-se by Talend.
the class ServiceMetadataCustomPropertiesTable method createTable.
private void createTable(Composite parent) {
int style = SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION;
table = new Table(parent, style);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1);
gridData.heightHint = 70;
gridData.minimumHeight = 50;
table.setLayoutData(gridData);
table.setLinesVisible(true);
table.setHeaderVisible(true);
TableColumn column = new TableColumn(table, SWT.LEFT, 0);
column.setText("Property Name");
column.setWidth(150);
column = new TableColumn(table, SWT.LEFT, 1);
column.setText("Property Value");
column.setWidth(150);
}
use of org.eclipse.swt.widgets.TableColumn in project tdi-studio-se by Talend.
the class VersionSection method createControls.
@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
super.createControls(parent, aTabbedPropertySheetPage);
composite = getWidgetFactory().createFlatFormComposite(parent);
tableViewer = new TableViewer(composite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
final Table table = tableViewer.getTable();
TableLayout tableLayout = new TableLayout();
table.setLayout(tableLayout);
table.setHeaderVisible(true);
table.setLinesVisible(true);
final String[] columnProperties = new String[] { //$NON-NLS-1$
Messages.getString("VersionSection.Version"), //$NON-NLS-1$
Messages.getString("VersionSection.CreationDate"), Messages.getString("VersionSection.ModificationDate"), //$NON-NLS-1$ //$NON-NLS-2$
Messages.getString("VersionSection.Status") };
final TableColumn column1 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column1.setText(columnProperties[0]);
final TableColumn column2 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column2.setText(columnProperties[1]);
final TableColumn column3 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column3.setText(columnProperties[2]);
final TableColumn column4 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnWeightData(1, 150, true));
column4.setText(columnProperties[3]);
tableViewer.setColumnProperties(columnProperties);
Object layoutData = parent.getLayoutData();
if (layoutData instanceof GridData) {
GridData gridData = (GridData) layoutData;
gridData.grabExcessVerticalSpace = true;
gridData.verticalAlignment = SWT.FILL;
}
FormData formData = new FormData();
formData.left = new FormAttachment(0);
formData.top = new FormAttachment(0);
formData.right = new FormAttachment(100);
formData.bottom = new FormAttachment(100);
table.setLayoutData(formData);
tableViewer.setContentProvider(new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
IRepositoryViewObject repositoryObject = ((IRepositoryViewObject) inputElement);
if (repositoryObject.getProperty() == null) {
return null;
}
RepositoryNode parentRepositoryNode = RepositoryNodeUtilities.getParentRepositoryNodeFromSelection(repositoryObject);
try {
List<IRepositoryViewObject> allVersion = ProxyRepositoryFactory.getInstance().getAllVersion(repositoryObject.getId());
Collections.sort(allVersion, new IRepositoryObjectComparator());
Object[] objects = new Object[allVersion.size()];
for (int i = 0; i < objects.length; i++) {
IRepositoryViewObject repositoryObjectVersion = allVersion.get(i);
RepositoryNode repositoryNode = createRepositoryNode(parentRepositoryNode, repositoryObjectVersion);
objects[i] = repositoryNode;
}
return objects;
} catch (PersistenceException e) {
return null;
}
}
private RepositoryNode createRepositoryNode(RepositoryNode parentRepositoryNode, IRepositoryViewObject repositoryObjectVersion) {
ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(repositoryObjectVersion.getProperty().getItem());
RepositoryNode repositoryNode = new RepositoryNode(repositoryObjectVersion, parentRepositoryNode, ENodeType.REPOSITORY_ELEMENT);
repositoryNode.setProperties(EProperties.CONTENT_TYPE, itemType);
repositoryNode.setProperties(EProperties.LABEL, repositoryObjectVersion.getLabel());
return repositoryNode;
}
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
tableViewer.setLabelProvider(new ITableLabelProvider() {
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
public String getColumnText(Object element, int columnIndex) {
RepositoryNode repositoryNode = (RepositoryNode) element;
switch(columnIndex) {
case 0:
return repositoryNode.getObject().getVersion();
case 1:
if (repositoryNode.getObject().getCreationDate() != null) {
return FORMATTER.format(repositoryNode.getObject().getCreationDate());
} else {
return null;
}
case 2:
if (repositoryNode.getObject().getModificationDate() != null) {
return FORMATTER.format(repositoryNode.getObject().getModificationDate());
} else {
return null;
}
case 3:
if (repositoryNode.getObject().getStatusCode() != null) {
return repositoryNode.getObject().getStatusCode();
} else {
return null;
}
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) {
}
});
//$NON-NLS-1$
MenuManager menuMgr = new MenuManager("#PopUp");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager mgr) {
ISelection selection = tableViewer.getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
List<ITreeContextualAction> contextualsActions = ActionsHelper.getRepositoryContextualsActions();
for (ITreeContextualAction action : contextualsActions) {
if (action.isReadAction() || action.isEditAction() || action.isPropertiesAction()) {
action.init(null, structuredSelection);
if (action.isVisible()) {
mgr.add(action);
}
}
}
}
}
});
Menu menu = menuMgr.createContextMenu(tableViewer.getControl());
tableViewer.getControl().setMenu(menu);
Listener sortListener = new Listener() {
private int direction = 1;
public void handleEvent(Event e) {
final TableColumn column = (TableColumn) e.widget;
if (column == table.getSortColumn()) {
direction = -direction;
}
if (direction == 1) {
table.setSortDirection(SWT.DOWN);
} else {
table.setSortDirection(SWT.UP);
}
table.setSortColumn(column);
tableViewer.setSorter(new ViewerSorter() {
int index = 0;
@Override
public void sort(Viewer viewer, Object[] elements) {
while (index < table.getColumns().length && table.getColumn(index) != column) {
index++;
}
super.sort(viewer, elements);
}
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
ITableLabelProvider labelProvider = (ITableLabelProvider) tableViewer.getLabelProvider();
String columnText = labelProvider.getColumnText(e1, index) != null ? labelProvider.getColumnText(e1, index) : //$NON-NLS-1$
"";
String columnText2 = labelProvider.getColumnText(e2, index) != null ? labelProvider.getColumnText(e2, index) : //$NON-NLS-1$
"";
return getComparator().compare(columnText, columnText2) * direction;
}
});
}
};
column1.addListener(SWT.Selection, sortListener);
column2.addListener(SWT.Selection, sortListener);
column3.addListener(SWT.Selection, sortListener);
column4.addListener(SWT.Selection, sortListener);
table.setSortColumn(column1);
table.setSortDirection(SWT.DOWN);
aTabbedPropertySheetPage.getSite().setSelectionProvider(this);
}
use of org.eclipse.swt.widgets.TableColumn in project tdi-studio-se by Talend.
the class LibraryField method createTable.
@Override
protected Table createTable(Composite parent) {
Table contextTable = new Table(parent, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
contextTable.setLinesVisible(false);
contextTable.setHeaderVisible(true);
TableColumn moduleNameColumn = new TableColumn(contextTable, SWT.LEFT);
//$NON-NLS-1$
moduleNameColumn.setText(Messages.getString("LibraryField.moduleColumn"));
moduleNameColumn.setWidth(120);
TableColumn colName = new TableColumn(contextTable, SWT.NONE);
//$NON-NLS-1$
colName.setText(Messages.getString("LibraryField.requiredColumn"));
colName.setWidth(70);
TableColumn descriptionColumn = new TableColumn(contextTable, SWT.NONE);
//$NON-NLS-1$
descriptionColumn.setText(Messages.getString("LibraryField.descriptionColumn"));
descriptionColumn.setWidth(200);
return contextTable;
}
use of org.eclipse.swt.widgets.TableColumn in project tdi-studio-se by Talend.
the class OperationsTab method configureTable.
/**
* Configure the table adding columns.
*/
private void configureTable() {
Table table = tableViewer.getTable();
if (table.isDisposed()) {
return;
}
table.setLinesVisible(true);
table.setHeaderVisible(true);
TableColumn column = new TableColumn(table, SWT.NONE);
column.setText(Messages.operationColumnLabel);
column.setWidth(300);
column.setToolTipText(Messages.operationColumnToolTip);
}
use of org.eclipse.swt.widgets.TableColumn in project tdi-studio-se by Talend.
the class DropContextAnalyzer method analyzeCursorOverExpressionCell.
/**
* .
*/
@SuppressWarnings("unchecked")
private void analyzeCursorOverExpressionCell() {
DataMapTableView dataMapTableView = mapperManager.retrieveDataMapTableView(currentTableTarget);
TableViewerCreator tableViewerCreatorForColumns = dataMapTableView.getTableViewerCreatorForColumns();
Point pointCursor = currentTableTarget.toControl(event.x, event.y);
if (tableViewerCreatorForColumns.getTable() != currentTableTarget) {
isCursorOverExpressionCell = false;
return;
}
int maxY = (WindowSystem.isWIN32() && currentTableTarget.getHeaderVisible() ? currentTableTarget.getHeaderHeight() : 0) + (currentTableTarget.getItemCount() * (currentTableTarget.getItemHeight() + currentTableTarget.getBorderWidth() + (WindowSystem.isGTK() ? 2 : 0)));
if (pointCursor.y < 0 || pointCursor.y >= maxY) {
isCursorOverExpressionCell = false;
return;
}
// searching current column index
int currentColumnIndex = 0;
TableColumn[] columns = currentTableTarget.getColumns();
for (int i = 0, width = 0; i < columns.length; i++) {
TableColumn column = columns[i];
int widthColumn = column.getWidth();
if (pointCursor.x >= width && pointCursor.x <= width + widthColumn) {
currentColumnIndex = i;
break;
}
width += widthColumn;
}
List<TableViewerCreatorColumnNotModifiable> viewerColumns = tableViewerCreatorForColumns.getColumns();
TableViewerCreatorColumnNotModifiable viewerColumn = viewerColumns.get(currentColumnIndex);
if (DataMapTableView.ID_EXPRESSION_COLUMN.equals(viewerColumn.getId())) {
isCursorOverExpressionCell = true;
} else {
isCursorOverExpressionCell = false;
}
}
Aggregations