Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » TableViwer Alternating rows Colors (whene extending ObservableMapLabelProvider)
TableViwer Alternating rows Colors [message #1065514] Wed, 26 June 2013 09:14 Go to next message
AIT YAHIA Idir is currently offline AIT YAHIA IdirFriend
Messages: 39
Registered: April 2013
Member
Hello

i have implemented alternating rows color on my TableViewer, i have made some test with 30 000 rows :

without Color alternating i take 20 sec to load the table and 1 m 40 sec with colors alternating.

so my algorithm is not optimized for a table of this size,i would like to implement a méthode demonstrated in this snippet

but it's not the same case, me i have extented ObservableMapLabelProvider (i have used a DataBinding,

public class CompteEntrysLabelProvider extends ObservableMapLabelProvider
		implements IColorProvider {

@Override
	public Color getBackground(Object element) {
	   
           WritableList list = new WritableList() ;
	   list= (WritableList) this.tableViewer.getInput();
	
	   int index = list.indexOf(element);
		
          if ((index % 2) == 0) {
			
			return gray; // color
			
		} else {
			return null;
		}

	
	}



}

where can i initialize the even variable in my case, or there is an other way to implement a more efficient algorithm.




with my thanks
icon14.gif  Re: TableViwer Alternating rows Colors [message #1065797 is a reply to message #1065514] Thu, 27 June 2013 13:52 Go to previous message
AIT YAHIA Idir is currently offline AIT YAHIA IdirFriend
Messages: 39
Registered: April 2013
Member
I have implemented my own method, what do you think about? I reduced the loading time of my TableViewer by half

public class CompteEntrysLabelProvider extends ObservableMapLabelProvider
		implements IColorProvider {

private boolean isEven = true;

public String getColumnText(Object element, int columnIndex) {

switch (columnIndex) {
	case 0:
		isEven = !isEven; //toggle isEven value each first column

		//get column 3 text
		
	
	case 1:
		//get column 2 text
		
	case 2:
		//get column 3 text
		
	case 3:
        
         default: return "";

}

@Override
 public Color getBackground(Object element) {
	
	//based on IsEven value we alternate the row color	
       if (isEven) {  return gray;} else {return null;	}

	
   }

}


I hope it will help more than one
Previous Topic:Data binding with validation and empty WritableValue
Next Topic:treeviewer resize issue
Goto Forum:
  


Current Time: Wed May 08 21:30:30 GMT 2024

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

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

Back to the top