Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » best way to create a tablefolder with lots of button(No more handles problem)
best way to create a tablefolder with lots of button [message #509049] Thu, 21 January 2010 09:43 Go to next message
No real name is currently offline No real name
Messages: 64
Registered: July 2009
Member
hi, I have problems to create a tablefolder with lots of element (more than 1000).

there is my code (that I simplified)
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.TableEditor;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;

public class testframe {

	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		shell.setLayout(new FillLayout());
		Table table = new Table(shell, SWT.BORDER | SWT.V_SCROLL);
		table.setLinesVisible(true);
		table.setHeaderVisible(true);
		table.setBounds(0, 0, 800, 500);

		for (int i = 1; i < 11; i++) {
			TableColumn tc = new TableColumn(table, SWT.NONE);
			tc.setText("col :" + i);
			tc.setWidth(100);
		}

		for (int line = 0; line < 10000; line++) {
			System.out.println("line" + line);
			TableItem NCurItem = new TableItem(table, SWT.NONE);
			for (int col = 0; col < 10; col++) {
				TableEditor editor = new TableEditor(table);
				Button button = new Button(table, SWT.CHECK | SWT.CENTER);
				button.pack();
				editor.minimumWidth = button.getSize().x;
				editor.horizontalAlignment = SWT.CENTER;
				editor.setEditor(button, NCurItem, col);
				NCurItem.setData(Integer.toString(col), editor);
			}
		}

		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();

	}
}



I have 2 problem.
first, I have a no more handles problem .
is there a better way to create button (text, spinner)without create a table editor for each column. (but with a listener of cause).

second thing, if I put only 100 lines (replacing 10000).
I have enough handles, but it's very slow to use and it take lot of time to si it.

is there any way to pass trough these problem (slow and no more handles ?) thank you



a++


Re: best way to create a tablefolder with lots of button [message #509099 is a reply to message #509049] Thu, 21 January 2010 11:55 Go to previous messageGo to next message
Daniel Krügler is currently offline Daniel Krügler
Messages: 853
Registered: July 2009
Senior Member
On 21.01.2010 10:43, elekis@gmail.com wrote:
> hi, I have problems to create a tablefolder with lots of element (more
> than 1000).

[..]

> I have 2 problem.
> first, I have a no more handles problem .
> is there a better way to create button (text, spinner)without create a
> table editor for each column. (but with a listener of cause).
>
> second thing, if I put only 100 lines (replacing 10000). I have enough
> handles, but it's very slow to use and it take lot of time to si it.
>
> is there any way to pass trough these problem (slow and no more handles
> ?) thank you

I recommend to use a jface TableViewer with check box editors. Check
out

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.s nippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippet s/viewers/Snippet056BooleanCellEditor.java?view=markup

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.s nippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippet s/viewers/Snippet061FakedNativeCellEditor.java?view=markup

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.s nippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippet s/viewers/Snippet048TreeViewerTabWithCheckboxFor3_3.java?vie w=markup

You can replace the TreeViewer by a Tableviewer.

HTH & Greetings from Bremen,

Daniel Krügler
Re: best way to create a tablefolder with lots of button [message #509133 is a reply to message #509049] Thu, 21 January 2010 13:29 Go to previous message
No real name is currently offline No real name
Messages: 64
Registered: July 2009
Member
thanks,I ll try that

a++
Previous Topic:Problem on eclipse startup:org.eclipse.swt.SWTError: Cannot initialize Drop
Next Topic:Popup location of context menu contributed by a MenuManager
Goto Forum:
  


Current Time: Sat Sep 20 02:03:44 GMT 2014

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

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