use of org.eclipse.jface.viewers.ITreeContentProvider in project webtools.sourceediting by eclipse.
the class TaglibIndexDeltaTraceView method showSelectionDetail.
void showSelectionDetail(final Composite composite) {
IStructuredSelection selection = (IStructuredSelection) fViewer.getSelection();
if (!selection.isEmpty()) {
final TaglibIndexDelta selectedDelta = (TaglibIndexDelta) selection.getFirstElement();
final ITableLabelProvider tableLabelProvider = ((ITableLabelProvider) fViewer.getLabelProvider());
String columnText = tableLabelProvider.getColumnText(selectedDelta, 1);
columnText = columnText + ":" + tableLabelProvider.getColumnText(selectedDelta, 2);
new Dialog(composite.getShell()) {
public void create() {
setShellStyle(getShellStyle() | SWT.RESIZE);
super.create();
}
protected Control createDialogArea(final Composite parent) {
final Composite inner = new Composite(parent, SWT.NONE);
inner.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
final Sash sash = new Sash(inner, SWT.HORIZONTAL);
final TreeViewer treeViewer = new TreeViewer(inner);
treeViewer.setContentProvider(new ITreeContentProvider() {
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
public void dispose() {
}
public Object[] getElements(Object inputElement) {
return getChildren(inputElement);
}
public boolean hasChildren(Object element) {
return getChildren(element).length > 0;
}
public Object getParent(Object element) {
return selectedDelta;
}
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof TaglibIndexDelta) {
TaglibIndexDelta taglibIndexDelta = ((TaglibIndexDelta) parentElement);
if (taglibIndexDelta.getTrigger() != null) {
List combined = new ArrayList();
combined.add(taglibIndexDelta.getTrigger());
combined.addAll(Arrays.asList(taglibIndexDelta.getAffectedChildren()));
return combined.toArray();
}
return taglibIndexDelta.getAffectedChildren();
}
return new Object[0];
}
});
treeViewer.setLabelProvider(new LabelProvider() {
public String getText(Object element) {
if (element instanceof ITaglibIndexDelta) {
ITaglibIndexDelta taglibIndexDelta = ((ITaglibIndexDelta) element);
if (taglibIndexDelta.getTaglibRecord() != null)
return taglibIndexDelta.toString();
String text = tableLabelProvider.getColumnText(selectedDelta, 1);
text = text + ":" + tableLabelProvider.getColumnText(selectedDelta, 2);
return text;
}
return StringUtils.firstLineOf(super.getText(element));
}
});
treeViewer.setInput(selectedDelta);
final Text text = new Text(inner, SWT.MULTI);
treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection2 = (IStructuredSelection) treeViewer.getSelection();
if (!selection2.isEmpty())
text.setText("" + (selection2).getFirstElement());
else
text.setText("");
}
});
final FormLayout form = new FormLayout();
inner.setLayout(form);
FormData firstData = new FormData();
firstData.top = new FormAttachment(0, 0);
firstData.bottom = new FormAttachment(sash, 2);
firstData.left = new FormAttachment(0, 0);
firstData.right = new FormAttachment(100, 0);
treeViewer.getControl().setLayoutData(firstData);
FormData secondData = new FormData();
secondData.top = new FormAttachment(sash, 2);
secondData.left = new FormAttachment(0, 0);
secondData.right = new FormAttachment(100, 0);
secondData.bottom = new FormAttachment(100, 0);
text.setLayoutData(secondData);
final FormData sashData = new FormData();
sashData.top = new FormAttachment(60, 0);
sashData.left = new FormAttachment(0, 0);
sashData.right = new FormAttachment(100, 0);
sash.setLayoutData(sashData);
sash.addListener(SWT.Selection, new org.eclipse.swt.widgets.Listener() {
public void handleEvent(Event e) {
sashData.top = new FormAttachment(0, e.y);
inner.layout();
}
});
return sash;
}
}.open();
}
}
use of org.eclipse.jface.viewers.ITreeContentProvider in project webtools.sourceediting by eclipse.
the class JSONSyntaxColoringPage method createStylesViewer.
/**
* Creates the List viewer where we see the various syntax element display
* names--would it ever be a Tree like JDT's?
*
* @param parent
* @return
*/
private StructuredViewer createStylesViewer(Composite parent) {
StructuredViewer stylesViewer = new ListViewer(parent, SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
stylesViewer.setComparator(new ViewerComparator(Collator.getInstance()));
stylesViewer.setLabelProvider(new LabelProvider() {
public String getText(Object element) {
Object description = fStyleToDescriptionMap.get(element);
if (description != null)
return description.toString();
return super.getText(element);
}
});
stylesViewer.setContentProvider(new ITreeContentProvider() {
public void dispose() {
}
public Object[] getChildren(Object parentElement) {
return getStylePreferenceKeys().toArray();
}
public Object[] getElements(Object inputElement) {
return getChildren(inputElement);
}
public Object getParent(Object element) {
return getStylePreferenceKeys();
}
public boolean hasChildren(Object element) {
return false;
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
return stylesViewer;
}
use of org.eclipse.jface.viewers.ITreeContentProvider in project webtools.sourceediting by eclipse.
the class JSPSyntaxColoringPage method createStylesViewer.
/**
* Creates the List viewer where we see the various syntax element display
* names--would it ever be a Tree like JDT's?
*
* @param parent
* @return
*/
private StructuredViewer createStylesViewer(Composite parent) {
StructuredViewer stylesViewer = new ListViewer(parent, SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
stylesViewer.setComparator(new ViewerComparator(Collator.getInstance()));
stylesViewer.setLabelProvider(new LabelProvider() {
public String getText(Object element) {
Object description = fStyleToDescriptionMap.get(element);
if (description != null)
return description.toString();
return super.getText(element);
}
});
stylesViewer.setContentProvider(new ITreeContentProvider() {
public void dispose() {
}
public Object[] getChildren(Object parentElement) {
return getStylePreferenceKeys().toArray();
}
public Object[] getElements(Object inputElement) {
return getChildren(inputElement);
}
public Object getParent(Object element) {
return getStylePreferenceKeys();
}
public boolean hasChildren(Object element) {
return false;
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
return stylesViewer;
}
use of org.eclipse.jface.viewers.ITreeContentProvider in project webtools.sourceediting by eclipse.
the class XSLSyntaxColoringPage method createStylesViewer.
/**
* Creates the List viewer where we see the various syntax element display
* names--would it ever be a Tree like JDT's?
*
* @param parent
* @return
*/
private StructuredViewer createStylesViewer(Composite parent) {
StructuredViewer stylesViewer = new ListViewer(parent, SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
stylesViewer.setComparator(new ViewerComparator(Collator.getInstance()));
stylesViewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
Object description = styleToDescriptionMap.get(element);
if (description != null)
return description.toString();
return super.getText(element);
}
});
stylesViewer.setContentProvider(new ITreeContentProvider() {
public void dispose() {
}
public Object[] getChildren(Object parentElement) {
return getStylePreferenceKeys().toArray();
}
public Object[] getElements(Object inputElement) {
return getChildren(inputElement);
}
public Object getParent(Object element) {
return getStylePreferenceKeys();
}
public boolean hasChildren(Object element) {
return false;
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
return stylesViewer;
}
use of org.eclipse.jface.viewers.ITreeContentProvider in project bndtools by bndtools.
the class ResolutionFailurePanel method copyUnresolvedToClipboard.
// private void switchFailureViewMode() {
// Object input = unresolvedViewer.getInput();
// unresolvedViewer.setInput(null);
// setFailureViewMode();
// unresolvedViewer.setInput(input);
// unresolvedViewer.expandToLevel(2);
// }
private void copyUnresolvedToClipboard() {
StringBuilder builder = new StringBuilder();
Object input = unresolvedViewer.getInput();
if (input == null)
return;
ITreeContentProvider contentProvider = (ITreeContentProvider) unresolvedViewer.getContentProvider();
Object[] roots = contentProvider.getElements(input);
ViewerSorter sorter = unresolvedViewer.getSorter();
if (sorter != null)
Arrays.sort(roots, new SorterComparatorAdapter(unresolvedViewer, sorter));
for (Object root : roots) {
appendLabels(root, contentProvider, builder, 0);
}
/*
* TODO if (result != null) { StringBuilder buffer = new StringBuilder(); List<Reason> unresolved =
* result.getUnresolved(); if (unresolved != null) for (Iterator<Reason> iter = unresolved.iterator();
* iter.hasNext(); ) { Reason reason = iter.next();
* buffer.append(unresolvedLabelProvider.getLabel(reason.getRequirement ()).getString()); buffer.append('\t');
* buffer.append(unresolvedLabelProvider .getLabel(reason.getResource())); if (iter.hasNext())
* buffer.append('\n'); } }
*/
Clipboard clipboard = new Clipboard(composite.getDisplay());
TextTransfer transfer = TextTransfer.getInstance();
clipboard.setContents(new Object[] { builder.toString() }, new Transfer[] { transfer });
clipboard.dispose();
}
Aggregations