Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipse-dev] Eclipse viewer architecture is slower than MVC??

In our company we are evaluating netbeans and eclipse for future
development. We wrote a simple program on each of this program and in
eclipse it is taking more time than in netbeans.

The netbeans is using MVC architecture and eclipse's adapter
architecture(Viewers ) are slower than MVC.

The program consists of a tree and a 100x100 table. The tree has alphabets
as items. Whenever the user clicks the alphabet all the table cells will be
filled up with that alphabet. We implemented MVC in Netbeans and viewers in
Eclipse. In netbeans it is taking 10milliseconds and eclipse is taking

Can any one fine tune this program to work fast as in netbeans.

The program is

import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
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.Tree;
import org.eclipse.swt.widgets.TreeItem;

public class viewer {
TableViewer tv = null;
Tree tree = null;
class Dummy{
String[] values;
public Dummy(){
values = new String[100];

public String get(int i){
return values[i];
public void set(int i, String value){
values[i] = value;
class ContentProvider implements IStructuredContentProvider{
public void dispose() {}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput){

public Object[] getElements(Object inputElement){
Dummy dummy = (Dummy)inputElement;
return dummy.values;

class LabelProvider implements ITableLabelProvider{
public Image getColumnImage(Object element, int columnIndex) {
return null;
public String getColumnText(Object element, int columnIndex){
Dummy dummy = (Dummy)element;
return dummy.get(columnIndex);
public void addListener(ILabelProviderListener listener) {}
public void dispose() {}
public boolean isLabelProperty(Object element, String property){return
true; }
public void removeListener(ILabelProviderListener listener){}
public void run(){
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
tree = new Tree (shell, SWT.BORDER);
TreeItem root = new TreeItem (tree, 0);
for (int i= 65; i< 91; i++) {
TreeItem treeitem = new TreeItem (root, SWT.NONE);
byte[] data = "" byte[1];
data[0] = (byte)i;
treeitem.setText(new String(data));
Table t1 = new Table(shell, SWT.NONE);
for (int i = 0; i < 100; i++) {
TableColumn tableColumn = new TableColumn(t1, SWT.NULL);
tableColumn.setText("column "+i);
tv = new TableViewer(t1);
tv.setContentProvider(new ContentProvider());
tv.setLabelProvider(new LabelProvider());
for (int row = 0; row<100; row++){
Dummy foo = new Dummy();
for (int col=0; col<100; col++)
foo.set(col, "");
tree.addSelectionListener(new TreeSelectionListener());;
while (! shell.isDisposed()) {
if (! display.readAndDispatch()) display.sleep();
Class TreeSelectionListener implements SelectionListener{
public void widgetSelected(SelectionEvent e){
for (int row = 0; row<100; row++){
Dummy dummy = (Dummy) tv.getElementAt(row);
for (int col=0; col<100; col++)
dummy.set(col, tree.getSelection()[0].getText());
public void widgetDefaultSelected(SelectionEvent e){}
public static void main(String[] args) {
new viewer().run();


Back to the top