use of org.eclipse.wst.server.ui.internal.viewers.RuntimeTableLabelProvider in project webtools.servertools by eclipse.
the class ServerClasspathContainerPage method createControl.
public void createControl(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
comp.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
comp.setLayout(layout);
Label label = new Label(comp, SWT.NONE);
label.setText(Messages.classpathContainerRuntimeList);
Table table = new Table(comp, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION);
table.setLayoutData(new GridData(GridData.FILL_BOTH));
table.setHeaderVisible(false);
TableViewer tableViewer = new TableViewer(table);
tableViewer.setContentProvider(new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
Object[] obj = runtimeMap.keySet().toArray();
return obj;
}
public void dispose() {
// ignore
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// ignore
}
});
tableViewer.setLabelProvider(new RuntimeTableLabelProvider());
tableViewer.setInput("root");
if (selection != null) {
Set<IRuntime> set = runtimeMap.keySet();
IRuntime rt;
for (Iterator<IRuntime> i = set.iterator(); i.hasNext(); ) {
rt = i.next();
if (runtimeMap.get(rt).getPath().equals(selection.getPath())) {
tableViewer.setSelection(new StructuredSelection(new Object[] { rt }));
setPageComplete(true);
break;
}
}
}
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
try {
IStructuredSelection sel = (IStructuredSelection) event.getSelection();
selection = runtimeMap.get(sel.getFirstElement());
setPageComplete(true);
} catch (Exception e) {
selection = null;
setPageComplete(false);
}
}
});
if (tableViewer.getTable().getItemCount() != 0)
tableViewer.getTable().setFocus();
setControl(comp);
}
Aggregations