Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » TableViewer in Editor: only one column of date via TableLabelProvider?
TableViewer in Editor: only one column of date via TableLabelProvider? [message #289528] Sun, 07 August 2005 19:40 Go to next message
Eclipse UserFriend
Originally posted by: sean.stewthecat.com

Hi,
I'm missing something basic, but can't seem to find out what. I have a
tableviewer in a multipage editor. I have added columns to the table
object, and they show up with proper headings.

My content provider returns a list of dom4j elements in the
getElements() method. The first column of data shows up perfectly. The
other three columns are blank. It seems that
myTableLabelProvider.getColumnText(Object element, int columnIndex)
is only getting called for the first (i.e. columnIndex==0) column. Where
/how do I set the column count?

BTW: I have successfully implemented several views with multi-column
tableviewers. Either I am having a senior moment, and forgetting some
critical step, or there is something special about putting a tableviewer
in a multipage editor?
Thanks

Sean
Re: TableViewer in Editor: only one column of date via TableLabelProvider? [message #289580 is a reply to message #289528] Mon, 08 August 2005 14:10 Go to previous messageGo to next message
Kalman Hazins is currently offline Kalman HazinsFriend
Messages: 76
Registered: July 2009
Member
What is the code for your label provider?

--
- Kalman (http://www.zikal.com/)


"Sean O'Connor" <sean@stewthecat.com> wrote in message
news:dd5o2e$ir7$1@news.eclipse.org...
> Hi,
> I'm missing something basic, but can't seem to find out what. I have a
> tableviewer in a multipage editor. I have added columns to the table
> object, and they show up with proper headings.
>
> My content provider returns a list of dom4j elements in the getElements()
> method. The first column of data shows up perfectly. The other three
> columns are blank. It seems that
> myTableLabelProvider.getColumnText(Object element, int columnIndex)
> is only getting called for the first (i.e. columnIndex==0) column. Where
> /how do I set the column count?
>
> BTW: I have successfully implemented several views with multi-column
> tableviewers. Either I am having a senior moment, and forgetting some
> critical step, or there is something special about putting a tableviewer
> in a multipage editor?
> Thanks
>
> Sean
Re: TableViewer in Editor: only one column of date via TableLabelProvider? [message #289608 is a reply to message #289580] Mon, 08 August 2005 19:24 Go to previous message
Eclipse UserFriend
Originally posted by: sean.stewthecat.com

Hi, thanks for the reply. Below is my label provider code. This is part
of a sample plugin I hope to post on sourceforge which will show a few
techniques/solutions I had trouble with.

---------- CODE -----------------------
/**
*
*/
package com.stewthecat.kittyplug.views;

import org.apache.log4j.Logger;
import org.dom4j.Element;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE.SharedImages;

public class KittyTableViewLabelProvider extends LabelProvider
implements ITableLabelProvider {
private final KittyTableView myView;


/**
* @param view
*/
KittyTableViewLabelProvider(KittyTableView view) {
myView = view;
}

private final Logger logger =
Logger.getLogger(KittyTableViewLabelProvider.class);


public String getColumnText(Object obj, int index) {
logger.debug("getColumnText(Object, int) - start");

// return getText(obj);
if (obj instanceof Element) {
Element node = (Element) obj;
String s = null;

switch (index) {
case KittyTableView.COL_PRIORITY:
s = node.attributeValue("priority");
return s == null ? "" : s;

case KittyTableView.COL_NAME:
s = node.attributeValue("name");
if (s == null) {
s = "n.a.";
}
return s;

case KittyTableView.COL_CATEGORY:
s = node.attributeValue("category");
return s == null ? "" : s;

case KittyTableView.COL_DUE:
s = node.attributeValue("due");
return s == null ? "n.a." : s;

default:
return "Unknown";
}
} else if (obj instanceof String[]) {
String l[] = (String[]) obj;
return l[index];

} else if (obj instanceof String) {
return (String) obj;

} else {
logger.warn("Object passed in was not a dom4j Element");
return "";
}
}


public Image getColumnImage(Object obj, int index) {
logger.debug("getColumnImage(Object, int) - start");
if (index == 0) {
return getPriorityImage(obj);
} else if (index == KittyTableView.COL_CATEGORY) {
return getCategoryImage(obj);
} else {
return null;
}
}


public Image getPriorityImage(Object obj) {
logger.debug("getImage(Object) - start");
ISharedImages shImages =
PlatformUI.getWorkbench().getSharedImages();
Image img = null;


if(obj instanceof String) {
Integer priority = new Integer((String)obj);
if(priority!=null) {
int p = priority.intValue();
if(p < 3) {
img =
shImages.getImage(ISharedImages.IMG_OBJS_BKMRK_TSK);
} else {
img = shImages.getImage(ISharedImages.IMG_OBJ_PROJECT);
}
} else {
img = shImages.getImage(ISharedImages.IMG_OBJ_ELEMENT);
}
}
return img;
}

public Image getCategoryImage(Object obj) {
logger.debug("getImage(Object) - start");

return
PlatformUI.getWorkbench().getSharedImages().getImage(IShared Images.IMG_OBJ_ELEMENT);
}
}

---------- CODE -----------------------


Kalman wrote:
> What is the code for your label provider?
>
Previous Topic:Create an editor in the views area?
Next Topic:File -> Print is not available (under Linux)
Goto Forum:
  


Current Time: Thu Apr 25 12:52:30 GMT 2024

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

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

Back to the top