use of org.eclipse.jface.viewers.IOpenListener in project bndtools by bndtools.
the class ResolutionView method createPartControl.
@Override
public void createPartControl(Composite parent) {
this.display = parent.getDisplay();
SashForm splitPanel = new SashForm(parent, SWT.HORIZONTAL);
splitPanel.setLayout(new FillLayout());
Composite reqsPanel = new Composite(splitPanel, SWT.NONE);
reqsPanel.setBackground(parent.getBackground());
GridLayout reqsLayout = new GridLayout(1, false);
reqsLayout.marginWidth = 0;
reqsLayout.marginHeight = 0;
reqsLayout.verticalSpacing = 2;
reqsPanel.setLayout(reqsLayout);
new Label(reqsPanel, SWT.NONE).setText("Requirements:");
reqsTree = new Tree(reqsPanel, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
reqsTree.setHeaderVisible(false);
reqsTree.setLinesVisible(false);
reqsTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
reqsViewer = new TreeViewer(reqsTree);
ColumnViewerToolTipSupport.enableFor(reqsViewer);
reqsViewer.setLabelProvider(new RequirementWrapperLabelProvider(true));
reqsViewer.setContentProvider(new CapReqMapContentProvider());
Composite capsPanel = new Composite(splitPanel, SWT.NONE);
capsPanel.setBackground(parent.getBackground());
GridLayout capsLayout = new GridLayout(1, false);
capsLayout.marginWidth = 0;
capsLayout.marginHeight = 0;
capsLayout.verticalSpacing = 2;
capsPanel.setLayout(capsLayout);
new Label(capsPanel, SWT.NONE).setText("Capabilities:");
capsTable = new Table(capsPanel, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
capsTable.setHeaderVisible(false);
capsTable.setLinesVisible(false);
capsTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
capsViewer = new TableViewer(capsTable);
ColumnViewerToolTipSupport.enableFor(capsViewer);
capsViewer.setLabelProvider(new CapabilityLabelProvider(true));
capsViewer.setContentProvider(new CapReqMapContentProvider());
capsViewer.setFilters(new ViewerFilter[] { new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parent, Object element) {
return !filteredCapabilityNamespaces.contains(((Capability) element).getNamespace());
}
} });
hideSelfImportsFilter = new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof RequirementWrapper) {
RequirementWrapper rw = (RequirementWrapper) element;
return !rw.resolved;
}
return true;
}
};
reqsViewer.setFilters(new ViewerFilter[] { hideSelfImportsFilter });
reqsViewer.addDragSupport(DND.DROP_MOVE | DND.DROP_COPY, new Transfer[] { LocalSelectionTransfer.getTransfer() }, new LocalTransferDragListener(reqsViewer));
capsViewer.addDragSupport(DND.DROP_MOVE | DND.DROP_COPY, new Transfer[] { LocalSelectionTransfer.getTransfer() }, new LocalTransferDragListener(capsViewer));
reqsViewer.addOpenListener(new IOpenListener() {
@Override
public void open(OpenEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
for (Iterator<?> iter = selection.iterator(); iter.hasNext(); ) {
Object item = iter.next();
if (item instanceof Clazz) {
Clazz clazz = (Clazz) item;
String className = clazz.getFQN();
IType type = null;
if (!loaders.isEmpty()) {
IWorkspaceRoot wsroot = ResourcesPlugin.getWorkspace().getRoot();
for (CapReqLoader loader : loaders) {
if (loader instanceof BndBuilderCapReqLoader) {
File loaderFile = ((BndBuilderCapReqLoader) loader).getFile();
IFile[] wsfiles = wsroot.findFilesForLocationURI(loaderFile.toURI());
for (IFile wsfile : wsfiles) {
IJavaProject javaProject = JavaCore.create(wsfile.getProject());
try {
type = javaProject.findType(className);
if (type != null)
break;
} catch (JavaModelException e) {
ErrorDialog.openError(getSite().getShell(), "Error", "", new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, MessageFormat.format("Error opening Java class '{0}'.", className), e));
}
}
}
}
}
try {
if (type != null)
JavaUI.openInEditor(type, true, true);
} catch (PartInitException e) {
ErrorDialog.openError(getSite().getShell(), "Error", "", new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, MessageFormat.format("Error opening Java editor for class '{0}'.", className), e));
} catch (JavaModelException e) {
ErrorDialog.openError(getSite().getShell(), "Error", "", new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, MessageFormat.format("Error opening Java class '{0}'.", className), e));
}
}
}
}
});
fillActionBars();
getSite().getPage().addPostSelectionListener(this);
getSite().getPage().addPartListener(partAdapter);
ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);
// Current selection & part
IWorkbenchPart activePart = getSite().getPage().getActivePart();
ISelection activeSelection = getSite().getWorkbenchWindow().getSelectionService().getSelection();
selectionChanged(activePart, activeSelection);
}
use of org.eclipse.jface.viewers.IOpenListener 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.eclipse.jface.viewers.IOpenListener in project bndtools by bndtools.
the class EditableParametersPart method createControl.
public Control createControl(Composite parent) {
this.parent = parent;
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
composite.setLayout(layout);
Label titleLabel = new Label(composite, SWT.NONE);
titleLabel.setText(title);
titleLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1));
Table table = new Table(composite, SWT.BORDER | SWT.MULTI);
viewer = new TableViewer(table);
viewer.setContentProvider(ArrayContentProvider.getInstance());
final Image iconImg = imageDescriptor.createImage(parent.getDisplay());
viewer.setLabelProvider(new StyledCellLabelProvider() {
@Override
public void update(ViewerCell cell) {
@SuppressWarnings("unchecked") Pair<String, Attrs> entry = (Pair<String, Attrs>) cell.getElement();
StyledString label = new StyledString(entry.getFirst(), BoldStyler.INSTANCE_DEFAULT);
for (Entry<String, String> attribEntry : entry.getSecond().entrySet()) {
label.append("; " + attribEntry.getKey() + "=", StyledString.QUALIFIER_STYLER);
label.append(attribEntry.getValue());
}
cell.setText(label.toString());
cell.setStyleRanges(label.getStyleRanges());
cell.setImage(iconImg);
}
});
viewer.setInput(entries);
GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
gd.widthHint = 280;
gd.heightHint = 80;
table.setLayoutData(gd);
final AddRemoveButtonBarPart buttonBarPart = new AddRemoveButtonBarPart();
ToolBar buttonBar = buttonBarPart.createControl(composite, SWT.FLAT | SWT.VERTICAL);
buttonBar.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
final Image imgEdit = ImageDescriptor.createFromURL(BUNDLE.getEntry("icons/edit.gif")).createImage(parent.getDisplay());
final Image imgEditDisabled = ImageDescriptor.createFromURL(BUNDLE.getEntry("icons/edit-disabled.gif")).createImage(parent.getDisplay());
final ToolItem btnEdit = new ToolItem(buttonBar, SWT.PUSH);
btnEdit.setImage(imgEdit);
btnEdit.setDisabledImage(imgEditDisabled);
buttonBarPart.setRemoveEnabled(false);
btnEdit.setEnabled(false);
buttonBarPart.addListener(new AddRemoveListener() {
@Override
public void addSelected() {
doAdd();
}
@Override
public void removeSelected() {
doRemove();
}
});
btnEdit.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doEdit();
}
});
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
boolean enabled = !viewer.getSelection().isEmpty();
buttonBarPart.setRemoveEnabled(enabled);
btnEdit.setEnabled(enabled);
}
});
viewer.addOpenListener(new IOpenListener() {
@Override
public void open(OpenEvent event) {
doEdit();
}
});
table.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.keyCode == SWT.DEL && e.stateMask == 0)
doRemove();
}
});
composite.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent ev) {
iconImg.dispose();
imgEdit.dispose();
imgEditDisabled.dispose();
}
});
return composite;
}
use of org.eclipse.jface.viewers.IOpenListener in project bndtools by bndtools.
the class MapValuesContentProvider method createSelectedBundlesPanel.
Control createSelectedBundlesPanel(Composite parent) {
Composite panel = new Composite(parent, SWT.NONE);
new Label(panel, SWT.NONE).setText("Selected Bundles:");
Table selectedTable = new Table(panel, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
selectedViewer = new TableViewer(selectedTable);
selectedViewer.setContentProvider(new MapValuesContentProvider());
selectedViewer.setLabelProvider(new VersionedClauseLabelProvider());
selectedViewer.setInput(selectedBundles);
selectedViewer.addSelectionChangedListener(new ISelectionChangedListener() {
// Enable the remove button when a bundle is selected on the right
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection sel = selectedViewer.getSelection();
removeButton.setEnabled(!sel.isEmpty());
}
});
selectedViewer.addOpenListener(new IOpenListener() {
@Override
public void open(OpenEvent event) {
doRemove();
}
});
GridLayout layout;
GridData gd;
layout = new GridLayout(1, false);
panel.setLayout(layout);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.heightHint = 300;
gd.widthHint = 250;
selectedTable.setLayoutData(gd);
return panel;
}
use of org.eclipse.jface.viewers.IOpenListener in project bndtools by bndtools.
the class TemplateSelectionWizardPage method createControl.
@Override
public void createControl(Composite parent) {
//$NON-NLS-1$
setImageDescriptor(Plugin.imageDescriptorFromPlugin("icons/bndtools-wizban.png"));
GridData gd;
Composite composite = new Composite(parent, SWT.NULL);
setControl(composite);
composite.setLayout(new GridLayout(1, false));
Control headerControl = createHeaderControl(composite);
if (headerControl != null)
headerControl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
new Label(composite, SWT.NONE).setText("Select Template:");
tree = new Tree(composite, SWT.BORDER | SWT.FULL_SELECTION);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.heightHint = 150;
tree.setLayoutData(gd);
defaultTemplateImage = AbstractUIPlugin.imageDescriptorFromPlugin(Plugin.PLUGIN_ID, "icons/template.gif").createImage(parent.getDisplay());
viewer = new TreeViewer(tree);
contentProvider = new RepoTemplateContentProvider(false);
viewer.setContentProvider(contentProvider);
viewer.setLabelProvider(new RepoTemplateLabelProvider(loadedImages, defaultTemplateImage));
viewer.addFilter(latestFilter);
setTemplates(emptyTemplate != null ? Collections.singletonList(emptyTemplate) : Collections.<Template>emptyList());
btnLatestOnly = new Button(composite, SWT.CHECK);
btnLatestOnly.setText("Show latest versions only");
btnLatestOnly.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false));
btnLatestOnly.setSelection(true);
new Label(composite, SWT.NONE).setText("Description:");
Composite cmpDescription = new Composite(composite, 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 = 25;
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 = 25;
txtDescription.setLayoutData(gd_txtDescription);
Hyperlink linkRetina = new Hyperlink(composite, SWT.NONE);
linkRetina.setText("Why is this text blurred?");
linkRetina.setUnderlined(true);
linkRetina.setForeground(JFaceColors.getHyperlinkText(getShell().getDisplay()));
linkRetina.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false));
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
Object element = ((IStructuredSelection) viewer.getSelection()).getFirstElement();
setTemplate(element instanceof Template ? (Template) element : null);
getContainer().updateButtons();
}
});
viewer.addOpenListener(new IOpenListener() {
@Override
public void open(OpenEvent event) {
Object element = ((IStructuredSelection) viewer.getSelection()).getFirstElement();
setTemplate(element instanceof Template ? (Template) element : null);
getContainer().updateButtons();
IWizardPage nextPage = getNextPage();
if (nextPage != null && selected != null)
getContainer().showPage(nextPage);
}
});
btnLatestOnly.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean latestOnly = btnLatestOnly.getSelection();
if (latestOnly)
viewer.addFilter(latestFilter);
else
viewer.removeFilter(latestFilter);
}
});
linkRetina.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent ev) {
try {
IWorkbenchBrowserSupport browser = PlatformUI.getWorkbench().getBrowserSupport();
browser.getExternalBrowser().openURL(new URL("https://github.com/bndtools/bndtools/wiki/Blurry-Form-Text-on-High-Resolution-Displays"));
} catch (Exception e) {
log.log(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Browser open error", e));
}
}
});
txtDescription.getFormText().addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent ev) {
try {
PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(new URL((String) ev.getHref()));
} catch (Exception ex) {
log.log(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Browser open error", ex));
}
}
});
}
Aggregations