Skip to main content



      Home
Home » Eclipse Projects » Nebula » Grid row headers
Grid row headers [message #46954] Thu, 17 January 2008 15:09 Go to next message
Eclipse UserFriend
I called setRowHeaderVisible(true) and I get a row header. Now how can I
specify what the values for the row headers are? I don't want numbers, I
want text labels that I can specify.

Thanks,

- Jason
Re: Grid row headers [message #46984 is a reply to message #46954] Thu, 17 January 2008 15:46 Go to previous messageGo to next message
Eclipse UserFriend
Ah...I think I found it. I extended GridColumnLabelProvider and used
GridViewerColumns to add the label provider to each column. Not very
intuitive this way since the row header isn't really a column, but it
seems to work.

Should GridViewer.setRowHeaderLabelProvider() do this as well? I tried
that but it didn't seem to work for me. Might have been something I did
wrong though - I've only been using the Grid API for 30 minutes or so... :)
Re: Grid row headers [message #47704 is a reply to message #46984] Sun, 27 January 2008 10:09 Go to previous messageGo to next message
Eclipse UserFriend
Hi Jason,

setRowHeaderLabelProvider should work. Alternately you can do as you
did (although you should only need to actually implement
getRowHeaderText on one provider).

Tom - do you know why this might not be working?

regards,
-Chris

Jason wrote:
>
> Ah...I think I found it. I extended GridColumnLabelProvider and used
> GridViewerColumns to add the label provider to each column. Not very
> intuitive this way since the row header isn't really a column, but it
> seems to work.
>
> Should GridViewer.setRowHeaderLabelProvider() do this as well? I tried
> that but it didn't seem to work for me. Might have been something I did
> wrong though - I've only been using the Grid API for 30 minutes or so... :)
>
Re: Grid row headers [message #47847 is a reply to message #47704] Mon, 28 January 2008 08:23 Go to previous message
Eclipse UserFriend
This is a multi-part message in MIME format.
--------------040906080009050107080508
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Chris Gross schrieb:
> Hi Jason,
>
> setRowHeaderLabelProvider should work. Alternately you can do as you
> did (although you should only need to actually implement
> getRowHeaderText on one provider).
>
> Tom - do you know why this might not be working?
>

Just tried it and for me it works but I think the naming is not 100%
correct and we should rename it to RowLabelProvider?

I've attached my test-snippet.

Tom

--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------

--------------040906080009050107080508
Content-Type: text/plain;
name="GridColumnLabelProvider.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="GridColumnLabelProvider.java"

/*********************************************************** ********************
* Copyright (c) 2007 Tom Schindl and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tom Schindl - initial API and implementation
************************************************************ *******************/

package org.eclipse.nebula.jface.gridviewer;

import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ViewerCell;
import org.eclipse.nebula.widgets.grid.GridItem;

/**
* A label provider that provides hooks for extra functionality in the {@link Grid}. This is currently
* limited to supplying the row header text.
* <p>
* <b> Only one from all {@link GridColumnLabelProvider} in a viewer should
* return a none <code>null</code></b>
* </p>
*/
public class GridColumnLabelProvider extends ColumnLabelProvider {

/**
* Returns the row header text for this element.
*
* @param element
* the model element
* @return the text displayed in the row-header or <code>null</code> if
* this label provider would not like to modify the default text
*/
public String getRowHeaderText(Object element) {
return null;
}

public void update(ViewerCell cell) {
super.update(cell);
String rowText = getRowHeaderText(cell.getElement());

if (rowText != null) {
((GridItem) cell.getViewerRow().getItem()).setHeaderText(rowText);
}
}

}

--------------040906080009050107080508--
Re: Grid row headers [message #587809 is a reply to message #46954] Thu, 17 January 2008 15:46 Go to previous message
Eclipse UserFriend
Ah...I think I found it. I extended GridColumnLabelProvider and used
GridViewerColumns to add the label provider to each column. Not very
intuitive this way since the row header isn't really a column, but it
seems to work.

Should GridViewer.setRowHeaderLabelProvider() do this as well? I tried
that but it didn't seem to work for me. Might have been something I did
wrong though - I've only been using the Grid API for 30 minutes or so... :)
Re: Grid row headers [message #588042 is a reply to message #46984] Sun, 27 January 2008 10:09 Go to previous message
Eclipse UserFriend
Hi Jason,

setRowHeaderLabelProvider should work. Alternately you can do as you
did (although you should only need to actually implement
getRowHeaderText on one provider).

Tom - do you know why this might not be working?

regards,
-Chris

Jason wrote:
>
> Ah...I think I found it. I extended GridColumnLabelProvider and used
> GridViewerColumns to add the label provider to each column. Not very
> intuitive this way since the row header isn't really a column, but it
> seems to work.
>
> Should GridViewer.setRowHeaderLabelProvider() do this as well? I tried
> that but it didn't seem to work for me. Might have been something I did
> wrong though - I've only been using the Grid API for 30 minutes or so... :)
>
Re: Grid row headers [message #588092 is a reply to message #47704] Mon, 28 January 2008 08:23 Go to previous message
Eclipse UserFriend
This is a multi-part message in MIME format.
--------------040906080009050107080508
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Chris Gross schrieb:
> Hi Jason,
>
> setRowHeaderLabelProvider should work. Alternately you can do as you
> did (although you should only need to actually implement
> getRowHeaderText on one provider).
>
> Tom - do you know why this might not be working?
>

Just tried it and for me it works but I think the naming is not 100%
correct and we should rename it to RowLabelProvider?

I've attached my test-snippet.

Tom

--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------

--------------040906080009050107080508
Content-Type: text/plain;
name="GridColumnLabelProvider.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="GridColumnLabelProvider.java"

/*********************************************************** ********************
* Copyright (c) 2007 Tom Schindl and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tom Schindl - initial API and implementation
************************************************************ *******************/

package org.eclipse.nebula.jface.gridviewer;

import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ViewerCell;
import org.eclipse.nebula.widgets.grid.GridItem;

/**
* A label provider that provides hooks for extra functionality in the {@link Grid}. This is currently
* limited to supplying the row header text.
* <p>
* <b> Only one from all {@link GridColumnLabelProvider} in a viewer should
* return a none <code>null</code></b>
* </p>
*/
public class GridColumnLabelProvider extends ColumnLabelProvider {

/**
* Returns the row header text for this element.
*
* @param element
* the model element
* @return the text displayed in the row-header or <code>null</code> if
* this label provider would not like to modify the default text
*/
public String getRowHeaderText(Object element) {
return null;
}

public void update(ViewerCell cell) {
super.update(cell);
String rowText = getRowHeaderText(cell.getElement());

if (rowText != null) {
((GridItem) cell.getViewerRow().getItem()).setHeaderText(rowText);
}
}

}

--------------040906080009050107080508--
Previous Topic:Problem with shell closing after the grid drag detection mechanism being enabled and some grid colum
Next Topic:GridViewer and GridColumnGroup
Goto Forum:
  


Current Time: Thu May 08 02:44:49 EDT 2025

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

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

Back to the top