use of org.eclipse.jface.viewers.ITableLabelProvider in project azure-tools-for-java by Microsoft.
the class ApplicationInsightsPreferencePage method createApplicationInsightsResourceTable.
public void createApplicationInsightsResourceTable(Composite parent) {
table = new Table(parent, SWT.BORDER | SWT.FULL_SELECTION);
table.setHeaderVisible(true);
table.setLinesVisible(true);
GridData gridData = new GridData();
gridData.heightHint = 360;
gridData.verticalIndent = 15;
gridData.horizontalAlignment = SWT.FILL;
gridData.grabExcessHorizontalSpace = false;
table.setLayoutData(gridData);
TableColumn strNameCol = new TableColumn(table, SWT.FILL);
strNameCol.setText(Messages.resrcName);
strNameCol.setWidth(150);
TableColumn strUrlDisCol = new TableColumn(table, SWT.FILL);
strUrlDisCol.setText(Messages.instrKey);
strUrlDisCol.setWidth(190);
tableViewer = new TableViewer(table);
tableViewer.setContentProvider(new IStructuredContentProvider() {
@Override
public void inputChanged(Viewer viewer, Object obj, Object obj1) {
}
@Override
public void dispose() {
}
@Override
public Object[] getElements(Object obj) {
return getTableContent();
}
});
tableViewer.setLabelProvider(new ITableLabelProvider() {
@Override
public void removeListener(ILabelProviderListener ilabelproviderlistener) {
}
@Override
public boolean isLabelProperty(Object element, String s) {
return false;
}
@Override
public void dispose() {
}
@Override
public void addListener(ILabelProviderListener ilabelproviderlistener) {
}
@Override
public String getColumnText(Object element, int i) {
ApplicationInsightsPageTableElement rowElement = (ApplicationInsightsPageTableElement) element;
String result = "";
switch(i) {
case 0:
result = rowElement.getResourceName();
break;
case 1:
result = rowElement.getInstrumentationKey();
break;
default:
break;
}
return result;
}
@Override
public Image getColumnImage(Object element, int i) {
return null;
}
});
tableViewer.setInput(getTableContent());
Composite containerButtons = new Composite(parent, SWT.NONE);
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 1;
gridData = new GridData();
gridData.horizontalAlignment = SWT.END;
gridData.verticalAlignment = GridData.BEGINNING;
gridData.verticalIndent = 15;
containerButtons.setLayout(gridLayout);
containerButtons.setLayoutData(gridData);
btnNew = new Button(containerButtons, SWT.PUSH);
btnNew.setText(Messages.btnNewLbl);
gridData = new GridData();
gridData.widthHint = 70;
btnNew.setLayoutData(gridData);
btnNew.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent arg0) {
newButtonListener();
}
@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
}
});
btnAdd = new Button(containerButtons, SWT.PUSH);
btnAdd.setText(Messages.btnAddLbl);
gridData = new GridData();
gridData.widthHint = 70;
btnAdd.setLayoutData(gridData);
btnAdd.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent arg0) {
addButtonListener();
}
@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
}
});
btnDetails = new Button(containerButtons, SWT.PUSH);
btnDetails.setEnabled(false);
btnDetails.setText(Messages.btnDtlsLbl);
gridData = new GridData();
gridData.widthHint = 70;
btnDetails.setLayoutData(gridData);
btnDetails.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent arg0) {
detailsButtonListener();
}
@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
}
});
btnRemove = new Button(containerButtons, SWT.PUSH);
btnRemove.setEnabled(false);
btnRemove.setText(Messages.btnRmvLbl);
gridData = new GridData();
gridData.widthHint = 70;
btnRemove.setLayoutData(gridData);
btnRemove.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent arg0) {
removeButtonListener();
}
@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
}
});
table.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent event) {
selIndex = tableViewer.getTable().getSelectionIndex();
btnDetails.setEnabled(true);
btnRemove.setEnabled(true);
}
@Override
public void widgetDefaultSelected(SelectionEvent event) {
}
});
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent selectionchangedevent) {
if (selectionchangedevent.getSelection().isEmpty()) {
btnDetails.setEnabled(false);
btnRemove.setEnabled(false);
}
}
});
}
use of org.eclipse.jface.viewers.ITableLabelProvider in project tdi-studio-se by Talend.
the class ItemsVersionConfirmDialog 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("ItemsVersionChangedDialog.OriginalVersion"));
column.setWidth(120);
column = new TableColumn(table, SWT.NONE);
//$NON-NLS-1$
column.setText(Messages.getString("VersionManagementDialog.NewVersion"));
column.setWidth(90);
viewer.setContentProvider(ArrayContentProvider.getInstance());
viewer.setLabelProvider(new ITableLabelProvider() {
public Image getColumnImage(Object element, int columnIndex) {
ItemVersionObject object = (ItemVersionObject) element;
if (columnIndex == 0) {
return ImageProvider.getImage(CoreImageProvider.getIcon(object.getItem()));
}
return null;
}
public String getColumnText(Object element, int columnIndex) {
ItemVersionObject object = (ItemVersionObject) element;
switch(columnIndex) {
case 0:
return object.getItem().getProperty().getLabel();
case 1:
return object.getOldVersion();
case 2:
if (object.getOldVersion().equals(object.getNewVersion())) {
//$NON-NLS-1$
return "-";
}
return object.getNewVersion();
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()) {
ItemVersionObject object = (ItemVersionObject) item.getData();
if (!object.getOldVersion().equals(object.getNewVersion())) {
item.setForeground(2, Display.getDefault().getSystemColor(SWT.COLOR_RED));
}
}
return composite;
}
use of org.eclipse.jface.viewers.ITableLabelProvider in project tdi-studio-se by Talend.
the class SchemaDetailsViewerSorter method compare.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object,
* java.lang.Object)
*/
@SuppressWarnings("unchecked")
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
if (sortViewer != null) {
ITableLabelProvider labelProvider = (ITableLabelProvider) sortViewer.getLabelProvider();
final String text1 = labelProvider.getColumnText(e1, index);
final String text2 = labelProvider.getColumnText(e2, index);
//$NON-NLS-1$ //$NON-NLS-2$
return getComparator().compare((text1 != null ? text1 : ""), (text2 != null ? text2 : "")) * direction;
}
return 0;
}
Aggregations