2009年7月20日

Show Eclipse SharedImages

Using Images in the Eclipse UI
Eclipse User Interface Guidelines
Eclipse Tips - Old: Eclipse icons

// New Plug-in Project with a view Templement
public void createPartControl(Composite parent) {
viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
Table table = viewer.getTable();

Field[] fields = ISharedImages.class.getFields();
for (Field field : fields) {
try {
String name = (String) field.get(sharedImages);
if (name.endsWith("_HOVER")) {
continue;
}
TableItem ti = new TableItem(table, SWT.NONE);
ti.setText(name);
ti.setImage(sharedImages.getImage(name));
} catch (Exception e) {
e.printStackTrace();
}
}
}

沒有留言:

網誌存檔