java - Multiple Data Binding Objects in Eclipse Jface MVC -


i'm facint problems regarding jface tableviewer , bindings. i'm using following example code tableviewer:

public class apppersonviewer extends tableviewer {     public table table;      public apppersonviewer(composite parent, int style)      {         super(parent, style);         table = gettable();         griddata griddata = new griddata(swt.fill, swt.fill, true, true);         table.setlayoutdata(griddata);         createcolumns();         table.setheadervisible(true);         table.setlinesvisible(true);         setcontentprovider(new appcontentprovider());     }      private void createcolumns()     {         string[] titles = { "first name", "second name", "age", "country", "likes so" };         int[] bounds = { 150, 150, 100, 150, 100 };          tableviewercolumn column = createtableviewercolumn(titles[0], bounds[0], 0);         column.setlabelprovider(new columnlabelprovider(){             public string gettext(object element) {                 if(element instanceof person)                     return ((person)element).getfirst();                 return super.gettext(element);             }         });          column = createtableviewercolumn(titles[1], bounds[1], 1);         column.setlabelprovider(new columnlabelprovider(){             public string gettext(object element) {                 if(element instanceof person)                     return ((person)element).getsecond();                 return super.gettext(element);             }         });          column = createtableviewercolumn(titles[2], bounds[2], 2);         column.setlabelprovider(new columnlabelprovider(){             public string gettext(object element) {                 if(element instanceof person)                     return ""+((person)element).getage();                 return super.gettext(element);             }         });          column = createtableviewercolumn(titles[3], bounds[3], 3);         column.setlabelprovider(new columnlabelprovider(){             public string gettext(object element) {                 if(element instanceof person)                     return ((person)element).getcountry();                 return super.gettext(element);             }         });          column = createtableviewercolumn(titles[4], bounds[4], 4);         column.setlabelprovider(new columnlabelprovider(){             public image getimage(object element) {                     return ((person)element).getimage();             }              public string gettext(object element) {                   return null;  // no string representation, want display image                 }          });       }      private tableviewercolumn createtableviewercolumn(string header, int width, int idx)      {         tableviewercolumn column = new tableviewercolumn(this, swt.left, idx);         column.getcolumn().settext(header);         column.getcolumn().setwidth(width);         column.getcolumn().setresizable(true);         column.getcolumn().setmoveable(true);          return column;     } } 

the person object used here data binding:

import java.util.random;  import org.eclipse.swt.swt; import org.eclipse.swt.graphics.image; import org.eclipse.swt.widgets.display;  public class person  {     private static final string[]   first = {"favonius", "tim", "brad", "scott", "linda"};     private static final string[]   second = {"cruise", "temp", "abbey", "adam", "albert", "thomas"};     private static final string[]   country = {"india", "usa", "russia", "uk", "france", "germany"};     private static final int[]      age = {22, 23, 24, 25, 26, 27, 28, 29, 30};      private static random random = new random(system.currenttimemillis());      private string first;     private string second;     private string country;     private string likes;      private int age;      public person(string first, string second, string country, string likes, int age)      {         super();         this.first = first;         this.second = second;         this.country = country;         this.likes = likes;         this.age = age;     }     public string getfirst() {         return first;     }     public string getsecond() {         return second;     }     public string getcountry() {         return country;     }     public string getlikes() {         return likes;     }     public int getage() {         return age;     }     public void setlikes(string likes) {         this.likes = likes;     }      public image getimage(){         return display.getdefault().getsystemimage(swt.icon_error);     }      public static person createrandomperson(){         return new  person(first[random.nextint(first.length)],                  second[random.nextint(second.length)], country[random.nextint(country.length)],                  "y", age[random.nextint(age.length)]);     } } 

the example binds 1 object tableviewer. problem want bind multiple objects tableviewer. example column 1 of tableviewer should hold attribute test of object a, , column 2 of tableviewer should hold attribute newtest of object b.

is possible? help.

each row in table uses single object provided content provider.

so if need values different objects need return composite class containing objects content provider.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -