Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Nested scrollable items?(Both parent control and List item are scrollable, but only parent control allows scrolling)
Nested scrollable items? [message #893262] |
Tue, 03 July 2012 11:54 |
Jasper Spaans Messages: 3 Registered: July 2012 |
Junior Member |
|
|
I'm creating a plugin for eclipse, and using a Property page for some of it's settings.
The problem I'm faced with is that the property page contains (a couple of) lists that I want to have scrollable, but I can't seem to make that work.
Instead, (one of) the surrounding parent composit's is made scrollable.
I'm posting the parts of my program that I think are relevant here:
import org.eclipse.jface.preference.ColorFieldEditor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbenchPropertyPage;
public class ContentPropertyPage extends org.eclipse.ui.dialogs.PropertyPage implements IWorkbenchPropertyPage {
private String[] lstDataNames;
private List dataNamesObject;
private ColorFieldEditor dataNamesColorObject;
@Override
protected Control createContents(Composite parent) {
Composite myComposite = new Composite(parent, SWT.BORDER);
myComposite.setLayout(new FillLayout());
TabFolder maintabs = new TabFolder(myComposite,SWT.BORDER);
Composite lst = makeTab(maintabs,"LST");
lst.setLayout(new FillLayout());
TabFolder subtabs = new TabFolder(lst,SWT.BORDER);
lstDataNames = convert(getProperty(LST_DATANAMES));
Composite comp = addTab(subtabs,"Data Names");
dataNamesObject = addList(comp,lstDataNames);
dataNamesColorObject = createPane(comp,LST_DATANAMES_COLOR,dataNamesObject);
return myComposite;
}
private List addList(Composite comp,String[] items){
List lstList = new List(comp,SWT.V_SCROLL);
lstList.setItems(items);
return lstList;
}
private Composite addTab(TabFolder tabs, String tabName){
Composite comp = makeTab(tabs,tabName);
comp.setLayout(new GridLayout());
return comp;
}
private Composite makeTab(TabFolder tabs,String tabName){
TabItem tabItem = new TabItem(tabs, SWT.BORDER);
tabItem.setText(tabName);
Composite comp = new Composite(tabs,SWT.BORDER);
tabItem.setControl(comp);
return comp;
}
private ColorFieldEditor createPane(Composite shell,String color,final List list){
GridLayout layout = new GridLayout(4, false);
shell.setLayout(layout);
list.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 5));
Canvas can = new Canvas(shell,SWT.NONE);
ColorFieldEditor colorEditor = new ColorFieldEditor(color,"Highlight Color",can);
can.setLayoutData(new GridData(SWT.FILL,SWT.TOP,false,false,3,1));
final Text newEntryText = new Text(shell, SWT.NONE);
newEntryText.setLayoutData(new GridData(SWT.FILL,SWT.TOP,true,false,2,1));
Button b = new Button(shell, SWT.PUSH);
b.setText("Add to List");
b.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
list.add(newEntryText.getText(), list.getItemCount());
}
});
b.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
b = new Button(shell, SWT.PUSH );
b.setText("Remove Selection"); //$NON-NLS-1$
b.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if(list.getSelectionIndex()>0){
list.remove(list.getSelectionIndex());
}
}
});
b.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false, 1, 1));
Label la = new Label(shell,SWT.NONE);
la.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true,2,1));
la = new Label(shell,SWT.NONE);
la.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true,3,2));
la = new Label(shell,SWT.NONE);
la.setLayoutData(new GridData(SWT.LEFT,SWT.FILL,true,true,1,1));
b = new Button(shell, SWT.PUSH);
b.setText("Export List");
b.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, false, false, 1, 1));
b = new Button(shell, SWT.PUSH);
b.setText("Import List");
b.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, false, false, 1, 1));
return colorEditor;
}
Can anyone tell me what I'm doing wrong?
(also, if this is the wrong place to ask this, or you need more info, please tell me where to go/what to add)
edit: also providing screenshot of how it currently looks. Instead of the scrollbar on the right, the list should be shorter and have a scrollbar
[Updated on: Tue, 03 July 2012 11:58] Report message to a moderator
|
|
| | | | | |
Goto Forum:
Current Time: Fri Mar 29 07:49:35 GMT 2024
Powered by FUDForum. Page generated in 0.04409 seconds
|