Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » ExpandBar - Table - scroll(Table in ExapndBar scroll problems)
ExpandBar - Table - scroll [message #518096] Wed, 03 March 2010 01:57 Go to next message
Jason Davis is currently offline Jason DavisFriend
Messages: 3
Registered: March 2010
Junior Member
Hello,
I add a Table to a Composite then place the Composite in an ExpandBar. The scroll bar appears to scroll the whole composite and not just the contents of the Table. This has the table column headers scroll out of view. Is it possible to have the column headers visible while scrolled to the bottom?

Thanks,
Jason


package generator;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ExpandEvent;
import org.eclipse.swt.events.ExpandListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.ExpandBar;
import org.eclipse.swt.widgets.ExpandItem;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;

import syspage.plugins.Plugin;

public class MeshCreator 
{
	Table table;
	
	public MeshCreator()
	{
		Display display = new Display();
		final Shell shell = new Shell(display, SWT.TITLE | SWT.RESIZE | SWT.MAX | SWT.MIN | SWT.CLOSE | SWT.ICON );
		shell.setLayout(Bag.layout());

		initUrlComposit(shell);
		final ExpandBar bar = new ExpandBar (shell, SWT.V_SCROLL);
		bar.setLayoutData(new Bag().fillBoth().get());
		bar.addExpandListener(new ExpandListener() {
			
			@Override
			public void itemExpanded(ExpandEvent arg0) 
			{
				int pref = table.computeSize(400, 350).y + 150;
				shell.setSize(400, pref);
			}
			
			@Override
			public void itemCollapsed(ExpandEvent arg0) 
			{
				shell.setSize(400, 150);
			}
		});
		
		
		Composite composite = initPluginList(bar);	
		
		ExpandItem item0 = new ExpandItem (bar, SWT.NONE, 0);
		item0.setText("Plugins");
		item0.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
		item0.setControl(composite);
		
		initActionsComposite(shell);
		
		shell.setSize(400, 150);
		shell.open();
		
		while (display.getShells().length > 0) if(!display.readAndDispatch()) display.sleep();
	}
	
	private void initUrlComposit(Shell shell)
	{
		Composite comp = Bag.compFillX(shell, 2);
		
		Label urlLabel = new Label(comp, SWT.HORIZONTAL);
		urlLabel.setText("Url");
		
		Text urlText = new Text(comp, SWT.BORDER);
		urlText.setLayoutData(new Bag().fillX().get());
	}
	
	private void initActionsComposite(Composite parent)
	{
		Composite comp = Bag.compFillX(parent , 3);
		
		Button iconButton = new Button(comp, SWT.CHECK);
		iconButton.setText("Icon");
		iconButton.setLayoutData(new Bag().fillX().right().vCenter().get());
		
		Button saveButton = new Button(comp, SWT.CHECK);
		saveButton.setText("Save");
		
		Button goButton = new Button(comp, SWT.PUSH);
		goButton.setText("Go");
	}
	
	private Composite initPluginList(Composite shell)
	{
		final Composite comp = Bag.compFillBoth(shell);
		
		table = new Table (comp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.CHECK);
		table.setLayoutData(new Bag().fillBoth().get());
		table.setBackgroundMode(SWT.INHERIT_DEFAULT);
		
		Plugin plugin = new Plugin();
		plugin.name = "FooPlugin";
		plugin.enabled = true;
		
		final TableColumn[] columns = new TableColumn[2];
		for (int i=0; i<2; i++) 
		{
			columns[i] = new TableColumn(table, SWT.NONE);
			columns[i].setResizable(true);
		}	
		
		comp.addControlListener(new ControlAdapter() 
		{
			
			public void controlResized(org.eclipse.swt.events.ControlEvent e) 
			{
			        columns[0].setWidth(comp.getClientArea().width - 80);
			}
		});
		
		columns[0].setWidth(300);
		columns[1].setWidth(50);
		
		columns[0].setText("Name");
		columns[1].setText("Config");
		
		table.setHeaderVisible(true);
		
		for(int i = 0; i< 10; i++)
		{
			TableItem ti = new TableItem(table, SWT.NONE);
			ti.setText(0,plugin.name);
			ti.setImage(1, new Image(shell.getDisplay(), MeshCreator.class.getResourceAsStream("config.png")));
		}
		
		return comp;
	}
	
	
	public static void main(String[] args) 
	{
		new MeshCreator();
	}
}

Re: ExpandBar - Table - scroll [message #518102 is a reply to message #518096] Wed, 03 March 2010 04:05 Go to previous message
Vijay RajFriend
Messages: 608
Registered: July 2009
Senior Member
The snippet provided is not runnable....

please provide a runnable snippet.....


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Previous Topic:Table row background
Next Topic:Marking points in Scroll bar
Goto Forum:
  


Current Time: Sun Dec 08 09:36:29 GMT 2024

Powered by FUDForum. Page generated in 0.02997 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top