public String getText(Object element) {
return ""; //$NON-NLS-1$
}
@Override
public Image getImage(Object element) {
final HotlinkDescriptor descriptor = (HotlinkDescriptor) element;
switch (descriptor.getType()) {
case FILE:
return PlatformUI.getWorkbench().getSharedImages()
.getImage(ISharedImages.IMG_OBJ_FILE);
case WEB:
return InfoPlugin.getDefault().getImageRegistry()
.get(InfoPlugin.IMG_OBJ_LINK);
case ACTION:
return InfoPlugin.getDefault().getImageRegistry()
.get(InfoPlugin.IMG_OBJ_ACTION);
default:
break;
}
return PlatformUI.getWorkbench().getSharedImages()
.getImage(ISharedImages.IMG_OBJ_ELEMENT);
}
});
columnLayout.setColumnData(column.getColumn(), new ColumnWeightData(8, 0, false));
column = new TableViewerColumn(hotlinkViewer, SWT.NONE);
column.getColumn().setText(Messages.Document_Label_Column);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
final HotlinkDescriptor descriptor = (HotlinkDescriptor) element;
return descriptor.getLabel();
}
});
columnLayout.setColumnData(column.getColumn(), new ColumnWeightData(25, 0, true));
column = new TableViewerColumn(hotlinkViewer, SWT.NONE);
column.getColumn().setText(Messages.Document_Attribute_Column);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
HotlinkDescriptor descriptor = (HotlinkDescriptor) element;
return descriptor.getAttributeName();
}
});
columnLayout.setColumnData( column.getColumn(), new ColumnWeightData( 25, 0, true ));
column = new TableViewerColumn(hotlinkViewer, SWT.NONE);
column.getColumn().setText(Messages.Document_Hotlink_Column);
column.getColumn().setAlignment(SWT.CENTER);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
HotlinkDescriptor descriptor = (HotlinkDescriptor) element;
return DocUtils.toCamelCase(descriptor.getType().toString());
}
});
columnLayout.setColumnData( column.getColumn(), new ColumnWeightData( 15, 0, true ));
column = new TableViewerColumn(hotlinkViewer, SWT.NONE);
column.getColumn().setText(Messages.Document_Action_Column);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
HotlinkDescriptor descriptor = (HotlinkDescriptor) element;
if( descriptor.getConfig() == null ){
return Messages.DocumentPropertyPage_Open;
}
return descriptor.getConfig();
}
});
columnLayout.setColumnData( column.getColumn(), new ColumnWeightData( 30, 0, true ));
hotlinkViewer.getTable().setHeaderVisible(true);
hotlinkViewer.getTable().setLinesVisible(true);
hotlinkViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection sel = event.getSelection();
editHotlink.setEnabled(!sel.isEmpty());
removeButton.setEnabled(!sel.isEmpty());
}
});
hotlinkViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
final StructuredSelection selection = (StructuredSelection) hotlinkViewer.getSelection();
final HotlinkDescriptor descriptor = (HotlinkDescriptor) selection.getFirstElement();
editDescriptor(descriptor);
}
});
}