Can we set the text in the RowHeader column in the nebulla grid in Eclipse RCP?

My question is: I have a nebulla Grid element (org.eclipse.nebula.widgets.grid.Grid), in my opinion, in Eclipse RCP. I can make the RowHeader of this grid visible with this code: Grid grdTable = new grid (compParent, SWT.BORDER | SWT.H_SCROLL); grdTable.setRowHeaderVisible (true); so at runtime it displays rowan berries, for example the following photo:

enter image description here

Now my requirement is that I want to display the text / char in the RowHeader column, for example, other column headers. Full name, designation, etc. How can I achieve this on a nebulla grid? Or, is it possible to manage the nebulla network? What could be my alternative?

+4
source share
2 answers

Finally, I achieved the required functionality in the nebulla grid by implementing the method: public void paint (GC paramGC, Object paramObject) {implementation code} internal interface: setTopLeftRenderer (new IRenderer () {// interface methods} as follows:

grdTable.setTopLeftRenderer(new IRenderer() { @Override public void setSize(int paramInt1, int paramInt2) { // TODO Auto-generated method stub } @Override public void setSize(Point paramPoint) { // TODO Auto-generated method stub } @Override public void setSelected(boolean paramBoolean) { // TODO Auto-generated method stub } @Override public void setMouseDown(boolean paramBoolean) { // TODO Auto-generated method stub } @Override public void setLocation(int paramInt1, int paramInt2) { // TODO Auto-generated method stub } @Override public void setLocation(Point paramPoint) { // TODO Auto-generated method stub } @Override public void setHover(boolean paramBoolean) { // TODO Auto-generated method stub } @Override public void setFocus(boolean paramBoolean) { // TODO Auto-generated method stub } @Override public void setExpanded(boolean paramBoolean) { // TODO Auto-generated method stub } @Override public void setDisplay(Display paramDisplay) { // TODO Auto-generated method stub } @Override public void setBounds(int paramInt1, int paramInt2, int paramInt3, int paramInt4) { // TODO Auto-generated method stub } @Override public void setBounds(Rectangle paramRectangle) { // TODO Auto-generated method stub } @Override public void paint(GC paramGC, Object paramObject) { // TODO Auto-generated method stub //paramGC.setAntialias(1); paramGC.setBackground(SWTResourceManager.getColor(240, 240, 240)); Rectangle rect=new Rectangle(0, 0, 20, 2*(grdTable.getGroupHeaderHeight())); paramGC.fillRectangle(rect); //making foreground color of the Rectangle to be of text in ColumnHeaders paramGC.setForeground(SWTResourceManager.getColor(0, 0, 0)); //drawing appropriate text on the topLeftCorner of Grid paramGC.drawText("#",5,10,false); } @Override public Point computeSize(GC paramGC, int paramInt1, int paramInt2, Object paramObject) { // TODO Auto-generated method stub return null; } }); 

Where, grdTable is the grid used in the view.

+3
source

A more convenient way is to use the GridTableViewer:

  GridTableViewer grid = new GridTableViewer(parent, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); grid.getGrid().setRowHeaderVisible(true); grid.setContentProvider(new ArrayContentProvider()); grid.setRowHeaderLabelProvider(new CellLabelProvider() { @Override public void update(ViewerCell cell) { cell.setText(cell.getElement().toString()); } }); 
+1
source

Source: https://habr.com/ru/post/1379439/


All Articles