use of org.bndtools.core.ui.ConfigElementLabelProvider in project bndtools by bndtools.
the class RunExportSelectionPage method createControl.
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
setControl(container);
container.setLayout(new GridLayout(1, false));
table = new Table(container, SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE);
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
viewer = new TableViewer(table);
viewer.setContentProvider(ArrayContentProvider.getInstance());
viewer.setLabelProvider(new ConfigElementLabelProvider(table.getDisplay(), null));
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
ISelection sel = viewer.getSelection();
if (sel.isEmpty())
setSelectedNode(null);
else {
IConfigurationElement elem = (IConfigurationElement) ((IStructuredSelection) sel).getFirstElement();
IWizardNode node = nodeCache.get(elem);
if (node == null) {
node = new RunExportWizardNode(getShell(), elem, model, bndProject);
nodeCache.put(elem, node);
}
setSelectedNode(node);
}
}
});
viewer.addOpenListener(new IOpenListener() {
public void open(OpenEvent event) {
IWizardPage nextPage = getNextPage();
if (nextPage != null)
getContainer().showPage(nextPage);
}
});
viewer.setInput(elements);
}
use of org.bndtools.core.ui.ConfigElementLabelProvider 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