1 //package org.argeo.eclipse.ui.workbench.osgi;
2 //public class BundlesView {}
4 package org
.argeo
.cms
.e4
.monitoring
;
6 import org
.argeo
.eclipse
.ui
.ColumnViewerComparator
;
7 import org
.eclipse
.e4
.ui
.di
.Focus
;
8 import org
.eclipse
.jface
.viewers
.ColumnLabelProvider
;
9 import org
.eclipse
.jface
.viewers
.IStructuredContentProvider
;
10 import org
.eclipse
.jface
.viewers
.TableViewer
;
11 import org
.eclipse
.jface
.viewers
.TableViewerColumn
;
12 import org
.eclipse
.jface
.viewers
.Viewer
;
13 import org
.eclipse
.swt
.SWT
;
14 import org
.eclipse
.swt
.widgets
.Composite
;
15 import org
.osgi
.framework
.Bundle
;
16 import org
.osgi
.framework
.BundleContext
;
17 import org
.osgi
.framework
.FrameworkUtil
;
19 import jakarta
.annotation
.PostConstruct
;
22 * Overview of the bundles as a table. Equivalent to Equinox 'ss' console
25 public class BundlesView
{
26 private final static BundleContext bc
= FrameworkUtil
.getBundle(BundlesView
.class).getBundleContext();
27 private TableViewer viewer
;
30 public void createPartControl(Composite parent
) {
31 viewer
= new TableViewer(parent
);
32 viewer
.setContentProvider(new BundleContentProvider());
33 viewer
.getTable().setHeaderVisible(true);
35 //EclipseUiSpecificUtils.enableToolTipSupport(viewer);
38 TableViewerColumn column
= new TableViewerColumn(viewer
, SWT
.NONE
);
39 column
.getColumn().setWidth(30);
40 column
.getColumn().setText("ID");
41 column
.getColumn().setAlignment(SWT
.RIGHT
);
42 column
.setLabelProvider(new ColumnLabelProvider() {
43 private static final long serialVersionUID
= -3122136344359358605L;
45 public String
getText(Object element
) {
46 return Long
.toString(((Bundle
) element
).getBundleId());
49 new ColumnViewerComparator(column
);
52 column
= new TableViewerColumn(viewer
, SWT
.NONE
);
53 column
.getColumn().setWidth(18);
54 column
.getColumn().setText("State");
55 column
.setLabelProvider(new StateLabelProvider());
56 new ColumnViewerComparator(column
);
59 column
= new TableViewerColumn(viewer
, SWT
.NONE
);
60 column
.getColumn().setWidth(250);
61 column
.getColumn().setText("Symbolic Name");
62 column
.setLabelProvider(new ColumnLabelProvider() {
63 private static final long serialVersionUID
= -4280840684440451080L;
65 public String
getText(Object element
) {
66 return ((Bundle
) element
).getSymbolicName();
69 new ColumnViewerComparator(column
);
72 column
= new TableViewerColumn(viewer
, SWT
.NONE
);
73 column
.getColumn().setWidth(250);
74 column
.getColumn().setText("Version");
75 column
.setLabelProvider(new ColumnLabelProvider() {
76 private static final long serialVersionUID
= 6871926308708629989L;
78 public String
getText(Object element
) {
79 Bundle bundle
= (org
.osgi
.framework
.Bundle
) element
;
80 return bundle
.getVersion().toString();
83 new ColumnViewerComparator(column
);
90 public void setFocus() {
92 viewer
.getControl().setFocus();
95 /** Content provider managing the array of bundles */
96 private static class BundleContentProvider
implements IStructuredContentProvider
{
97 private static final long serialVersionUID
= -8533792785725875977L;
99 public Object
[] getElements(Object inputElement
) {
100 if (inputElement
instanceof BundleContext
) {
101 BundleContext bc
= (BundleContext
) inputElement
;
102 return bc
.getBundles();
107 public void dispose() {
110 public void inputChanged(Viewer viewer
, Object oldInput
, Object newInput
) {