use of org.bndtools.utils.eclipse.CategorisedPrioritisedConfigurationElementTreeContentProvider in project bndtools by bndtools.
the class AbstractTemplateSelectionWizardPage method createControl.
@Override
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
setControl(container);
container.setLayout(new GridLayout(1, false));
new Label(container, SWT.NONE).setText("Select Template:");
tree = new Tree(container, SWT.BORDER | SWT.FULL_SELECTION);
GridData gd_table = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
gd_table.heightHint = 100;
tree.setLayoutData(gd_table);
viewer = new TreeViewer(tree);
Label lblNewLabel = new Label(container, SWT.NONE);
lblNewLabel.setText("Description:");
Composite cmpDescription = new Composite(container, SWT.BORDER);
cmpDescription.setBackground(tree.getBackground());
txtDescription = new ScrolledFormText(cmpDescription, SWT.V_SCROLL | SWT.H_SCROLL, false);
FormText formText = new FormText(txtDescription, SWT.NO_FOCUS);
txtDescription.setFormText(formText);
txtDescription.setBackground(tree.getBackground());
formText.setBackground(tree.getBackground());
formText.setForeground(tree.getForeground());
formText.setFont("fixed", JFaceResources.getTextFont());
formText.setFont("italic", JFaceResources.getFontRegistry().getItalic(""));
GridData gd_cmpDescription = new GridData(SWT.FILL, SWT.FILL, true, true);
gd_cmpDescription.heightHint = 100;
cmpDescription.setLayoutData(gd_cmpDescription);
GridLayout layout_cmpDescription = new GridLayout(1, false);
cmpDescription.setLayout(layout_cmpDescription);
GridData gd_txtDescription = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
gd_txtDescription.heightHint = 100;
txtDescription.setLayoutData(gd_txtDescription);
viewer.setContentProvider(new CategorisedPrioritisedConfigurationElementTreeContentProvider(true));
viewer.setLabelProvider(new ConfigElementLabelProvider(parent.getDisplay(), "icons/template.gif"));
loadData();
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
Object selected = ((IStructuredSelection) viewer.getSelection()).getFirstElement();
if (selected instanceof IConfigurationElement)
setSelectionFromConfigElement((IConfigurationElement) selected);
else
setSelectionFromConfigElement(null);
updateUI();
}
});
txtDescription.getFormText().addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent event) {
IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
try {
IWebBrowser externalBrowser = browserSupport.getExternalBrowser();
externalBrowser.openURL(new URL((String) event.getHref()));
} catch (PartInitException e) {
logger.logError("Error opening external browser.", e);
} catch (MalformedURLException e) {
// Ignore
}
}
});
updateUI();
}
Aggregations