use of org.eclipse.jface.viewers.ILabelProviderListener 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.ILabelProviderListener in project tdi-studio-se by Talend.
the class TOSLoginComposite method createTosActionArea.
private void createTosActionArea(Composite parent) {
tosActionComposite = toolkit.createComposite(parent);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = 140;
tosActionComposite.setLayoutData(gd);
tosActionComposite.setLayout(new FormLayout());
tosActionComposite.setBackgroundMode(SWT.INHERIT_DEFAULT);
// tosActionComposite.setBackground(GREY_COLOR);
FormData data;
Label projectLabel = toolkit.createLabel(tosActionComposite, Messages.getString("TOSLoginComposite.projectLabel"));
projectLabel.setFont(font);
GC gc = new GC(projectLabel);
Point labelSize = gc.stringExtent(Messages.getString("TOSLoginComposite.projectLabel"));
gc.dispose();
data = new FormData();
data.top = new FormAttachment(0, 10);
data.left = new FormAttachment(0, 50);
// data.right = new FormAttachment(0, 20 + labelSize.x);
data.bottom = new FormAttachment(0, 30);
projectLabel.setBackground(tosActionComposite.getBackground());
projectLabel.setLayoutData(data);
openButton = toolkit.createButton(tosActionComposite, null, SWT.PUSH);
data = new FormData();
data.top = new FormAttachment(projectLabel, 0, SWT.TOP);
gc = new GC(openButton);
Point labelSizeOpenButton = gc.stringExtent(Messages.getString("TOSLoginComposite.openButton"));
gc.dispose();
int width = OPEN_IMAGE.getBounds().width;
gc = new GC(openButton);
Point labelSizeDeleteButton = gc.stringExtent(Messages.getString("TOSLoginComposite.deleteButton"));
gc.dispose();
if (labelSizeOpenButton.x + width > labelSizeDeleteButton.x) {
data.left = new FormAttachment(100, -20 - labelSizeOpenButton.x - width - 10);
} else {
data.left = new FormAttachment(100, -20 - labelSizeDeleteButton.x - 10);
}
data.right = new FormAttachment(100, -10);
// if (Platform.getOS().equals(Platform.OS_WIN32)) {
// data.bottom = new FormAttachment(projectLabel, 0, SWT.BOTTOM);
// } else if (Platform.getOS().equals(Platform.OS_LINUX)) {
// data.bottom = new FormAttachment(projectLabel, 5, SWT.BOTTOM);
// } else {
// data.bottom = new FormAttachment(projectLabel, 5, SWT.BOTTOM);
// }
openButton.setText(Messages.getString("TOSLoginComposite.openButton"));
openButton.setFont(font);
openButton.setLayoutData(data);
openButton.setImage(OPEN_IMAGE);
Composite projectListViewerContainer = new Composite(tosActionComposite, SWT.NONE);
projectListViewerContainer.setLayout(new FillLayout());
this.projectListViewer = new ListViewer(projectListViewerContainer);
this.projectListViewer.setContentProvider(new TableViewerContentProvider());
this.projectListViewer.setLabelProvider(new ILabelProvider() {
@Override
public void removeListener(ILabelProviderListener listener) {
}
@Override
public boolean isLabelProperty(Object element, String property) {
return false;
}
@Override
public void dispose() {
}
@Override
public void addListener(ILabelProviderListener listener) {
}
@Override
public String getText(Object element) {
if (element != null) {
return element.toString();
}
return null;
}
@Override
public Image getImage(Object element) {
return null;
}
});
this.projectListViewer.setSorter(new ViewerSorter());
data = new FormData();
data.top = new FormAttachment(projectLabel, 0, SWT.TOP);
data.left = new FormAttachment(projectLabel, 10, SWT.RIGHT);
data.right = new FormAttachment(openButton, -10, SWT.LEFT);
data.bottom = new FormAttachment(0, 100);
projectListViewerContainer.setLayoutData(data);
deleteButton = toolkit.createButton(tosActionComposite, null, SWT.PUSH);
data = new FormData();
data.top = new FormAttachment(openButton, 5, SWT.BOTTOM);
data.left = new FormAttachment(openButton, 0, SWT.LEFT);
data.right = new FormAttachment(openButton, 0, SWT.RIGHT);
deleteButton.setText(Messages.getString("TOSLoginComposite.deleteButton"));
deleteButton.setFont(font);
deleteButton.setLayoutData(data);
createButton = toolkit.createButton(tosActionComposite, null, SWT.PUSH);
data = new FormData();
data.top = new FormAttachment(projectListViewerContainer, 10, SWT.BOTTOM);
data.left = new FormAttachment(projectListViewerContainer, 0, SWT.LEFT);
data.right = new FormAttachment(projectListViewerContainer, 65, SWT.LEFT);
createButton.setText(Messages.getString("TOSLoginComposite.createButton"));
createButton.setFont(font);
createButton.setLayoutData(data);
importButton = toolkit.createButton(tosActionComposite, null, SWT.PUSH);
data = new FormData();
data.top = new FormAttachment(createButton, 0, SWT.TOP);
data.left = new FormAttachment(createButton, 10, SWT.RIGHT);
importButton.setText(Messages.getString("TOSLoginComposite.importButton"));
importButton.setFont(font);
importButton.setLayoutData(data);
demoProjectButton = toolkit.createButton(tosActionComposite, null, SWT.PUSH);
data = new FormData();
data.top = new FormAttachment(importButton, 0, SWT.TOP);
data.left = new FormAttachment(importButton, 10, SWT.RIGHT);
data.right = new FormAttachment(100, -10);
demoProjectButton.setText(Messages.getString("TOSLoginComposite.demoProjectButton"));
demoProjectButton.setFont(font);
demoProjectButton.setLayoutData(data);
enableOpenAndDelete(false);
}
use of org.eclipse.jface.viewers.ILabelProviderListener in project eclipse.platform.text by eclipse.
the class AbstractControlContentAssistSubjectAdapter method setContentAssistCueProvider.
/**
* Sets the visual feedback provider for content assist.
* The given {@link ILabelProvider} methods are called with
* {@link #getControl()} as argument.
*
* <ul>
* <li><code>getImage(Object)</code> provides the visual cue image.
* The image can maximally be 5 pixels wide and 8 pixels high.
* If <code>getImage(Object)</code> returns <code>null</code>, a default image is used.
* </li>
* <li><code>getText(Object)</code> provides the hover info text.
* It is shown when hovering over the cue image or the adapted {@link Control}.
* No info text is shown if <code>getText(Object)</code> returns <code>null</code>.
* </li>
* </ul>
* <p>
* The given {@link ILabelProvider} becomes owned by the {@link AbstractControlContentAssistSubjectAdapter},
* i.e. it gets disposed when the adapted {@link Control} is disposed
* or when another {@link ILabelProvider} is set.
* </p>
*
* @param labelProvider a {@link ILabelProvider}, or <code>null</code>
* if no visual feedback should be shown
*/
public void setContentAssistCueProvider(final ILabelProvider labelProvider) {
if (fCueLabelProvider != null) {
fCueLabelProvider.dispose();
}
fCueLabelProvider = labelProvider;
if (labelProvider == null) {
if (fControlDecoration != null) {
fControlDecoration.dispose();
fControlDecoration = null;
}
} else {
if (fControlDecoration == null) {
fControlDecoration = new ControlDecoration(getControl(), (SWT.TOP | SWT.LEFT));
getControl().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
if (fCueLabelProvider != null) {
fCueLabelProvider.dispose();
fCueLabelProvider = null;
}
if (fControlDecoration != null) {
fControlDecoration.dispose();
fControlDecoration = null;
}
if (fCachedDefaultCueImage != null) {
fCachedDefaultCueImage.dispose();
fCachedDefaultCueImage = null;
}
}
});
fControlDecoration.setShowHover(true);
fControlDecoration.setShowOnlyOnFocus(true);
}
ILabelProviderListener listener = new ILabelProviderListener() {
@Override
public void labelProviderChanged(LabelProviderChangedEvent event) {
fControlDecoration.setDescriptionText(labelProvider.getText(getControl()));
Image image = labelProvider.getImage(getControl());
if (image == null)
image = getDefaultCueImage();
fControlDecoration.setImage(image);
}
};
labelProvider.addListener(listener);
// initialize control decoration:
listener.labelProviderChanged(new LabelProviderChangedEvent(labelProvider));
}
}
Aggregations