use of org.eclipse.jface.viewers.ListViewer in project eclipse-integration-commons by spring-projects.
the class ChooseOneSection method createContents.
@Override
public void createContents(Composite page) {
Composite composite = new Composite(page, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = (labelText == null || vertical) ? 1 : 2;
layout.marginWidth = 0;
composite.setLayout(layout);
// .hint(SWT.DEFAULT, 150);
GridDataFactory grab = GridDataFactory.fillDefaults().grab(true, true);
grab.applyTo(composite);
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
if (labelText != null) {
Label label = new Label(composite, SWT.NONE);
label.setText(labelText);
if (!vertical) {
GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.BEGINNING).hint(UIConstants.fieldLabelWidthHint(label), SWT.DEFAULT).applyTo(label);
}
}
final ListViewer tv = new ListViewer(composite, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
grab.applyTo(tv.getList());
tv.setContentProvider(new ContentProvider());
tv.setLabelProvider(new SimpleLabelProvider());
tv.setInput(validChoices);
chosen.addListener(new ValueListener<T>() {
public void gotValue(LiveExpression<T> exp, T value) {
if (value == null) {
tv.setSelection(StructuredSelection.EMPTY);
} else {
tv.setSelection(new StructuredSelection(value));
}
}
});
if (DEBUG) {
chosen.addListener(new ValueListener<T>() {
public void gotValue(LiveExpression<T> exp, T value) {
System.out.println("starter: " + value);
}
});
}
tv.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
chosen.setValue(getSingleSelection(tv));
}
});
if (owner instanceof IPageWithOkButton) {
tv.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
((IPageWithOkButton) owner).clickOk();
}
});
}
}
use of org.eclipse.jface.viewers.ListViewer 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.ListViewer 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.ListViewer 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.ListViewer in project dbeaver by serge-rider.
the class ViewClasspathDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
getShell().setText(UIConnectionMessages.dialog_view_classpath_title);
Composite group = (Composite) super.createDialogArea(parent);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 300;
gd.widthHint = 400;
group.setLayoutData(gd);
{
ListViewer libsTable = new ListViewer(group, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
libsTable.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
// $NON-NLS-1$
String classPath = System.getProperty(StandardConstants.ENV_JAVA_CLASSPATH);
// $NON-NLS-1$
StringTokenizer st = new StringTokenizer(classPath, ";");
while (st.hasMoreTokens()) {
libsTable.getList().add(st.nextToken());
}
}
return group;
}
Aggregations