Skip to main content



      Home
Home » Eclipse Projects » JFace » CheckboxCellEditor but no Checkbox
CheckboxCellEditor but no Checkbox [message #1607] Thu, 07 May 2009 06:18 Go to next message
Eclipse UserFriend
Hey,

desperately trying to use a CheckboxCellEditor in a table column. The
checkbox behaviour works, but I don't get a visible checkbox control.
I'm somehow irritated by what the CheckboxCellEditor API description says:

Note that this implementation simply fakes it and does does not create
any new controls. The mere activation of this editor means that the value
of the check box is being toggled by the end users; the listener method
<code>applyEditorValue</code> is immediately called to signal the change.

Is this what I'm experiencing? In an intent to actually create a
checkboxControl I created a subclass of CheckboxCellEditor, but that
doesn't work either..

I'm using eclipse 3.3.

@Override
public void createPartControl(Composite parent) {

Table table = new Table(parent, SWT.MULTI | SWT.BORDER |
SWT.FULL_SELECTION);
viewer = new TableViewer(table);

String[] header = new String[] {"", "A", "B", "B" };
int[] width = new int [] { 10, 200, 200, 200 };

for (int i = 0; i < header.length; i++){
TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
column.getColumn().setText(header[i]);
column.getColumn().setWidth(width[i]);
if (i == 0){
column.setEditingSupport(new LaunchcontrolEditingSupport());
}
}
initializeProviders();
viewer.getTable().setHeaderVisible(true);
viewer.getTable().setLinesVisible(true);
viewer.setInput(project);
}

protected void initializeProviders(){
viewer.setContentProvider(new ProjectContentProvider());
viewer.setLabelProvider(new ProjectLabelProvider());
}

public Collection<Element> getChecked(){
if (checked == null){
checked = new HashSet<Element>();
}
return Collections.unmodifiableCollection(checked);
}

@Override
public void setFocus() {
viewer.getTable().setFocus();
}

protected void updateView(){
viewer.setInput(project);
}

class LaunchcontrolEditingSupport extends EditingSupport {

private CellEditor editor;

public LaunchcontrolEditingSupport() {
super(viewer);
editor = new RealEditor(viewer.getTable(), SWT.CHECK);
}

@Override
protected boolean canEdit(Object element) {
return true;
}

@Override
protected CellEditor getCellEditor(Object element) {
return editor;
}

@Override
protected Object getValue(Object element) {
Boolean result;
if (checked == null){
result = Boolean.FALSE;
} else {
result = checked.contains(element);
}
return result;
}

@Override
protected void setValue(Object element, Object value) {
if (value == Boolean.TRUE){
if (checked == null){
checked = new HashSet<Element>();
}
checked.add((Element)element);
} else if (checked != null){
checked.remove(element);
}
viewer.update(element, null);
}

class RealEditor extends CheckboxCellEditor {
public RealEditor(Composite parent, int style){
super(parent, style);
}
@Override
public Control createControl(Composite parent){
Button b = new Button(parent, SWT.TOGGLE);
b.setText("haha");
return b;
}
}
}
Re: CheckboxCellEditor but no Checkbox [message #1633 is a reply to message #1607] Thu, 07 May 2009 06:25 Go to previous messageGo to next message
Eclipse UserFriend
Felix Dorner wrote:

In this tutotrial, a control is simulated by simply displaying a
different image based on the model state:

http://www.vogella.de/articles/EclipseJFaceTable/article.htm l#jfaceeditor

The idea is nice, but is this really the way to go?

Felix
Re: CheckboxCellEditor but no Checkbox [message #1658 is a reply to message #1633] Thu, 07 May 2009 08:21 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

https://bugs.eclipse.org/bugs/show_bug.cgi?id=260061

Is the best thing you could get today other versions with e.g. using
checked/unchecked images should also work but in the end you need to
fake the appearance of the check box somehow (using Image/Text returned
from your LabelProvider)

Tom

Felix Dorner schrieb:
> Felix Dorner wrote:
>
> In this tutotrial, a control is simulated by simply displaying a
> different image based on the model state:
>
> http://www.vogella.de/articles/EclipseJFaceTable/article.htm l#jfaceeditor
>
> The idea is nice, but is this really the way to go?
>
> Felix
Re: CheckboxCellEditor but no Checkbox [message #2742 is a reply to message #1658] Thu, 07 May 2009 08:56 Go to previous messageGo to next message
Eclipse UserFriend
Hey Tom,

okay. I've simply adapted the solution from lars's tutorial, faking the
checkboxes with images that the label provider returns.

What is a CQ?


Felix



Tom Schindl wrote:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=260061
>
> Is the best thing you could get today other versions with e.g. using
> checked/unchecked images should also work but in the end you need to
> fake the appearance of the check box somehow (using Image/Text returned
> from your LabelProvider)
Re: CheckboxCellEditor but no Checkbox [message #2787 is a reply to message #2742] Thu, 07 May 2009 16:05 Go to previous message
Eclipse UserFriend
Hi Felix,

"Felix Dorner" <felix_do@web.de> wrote in message
news:gtulmn$1ev$1@build.eclipse.org...
> Hey Tom,
>
> okay. I've simply adapted the solution from lars's tutorial, faking the
> checkboxes with images that the label provider returns.
>
> What is a CQ?

It's short for "contribution questionnaire", used by the Eclipse Foundation
for tracing and approving IP (intellectual property) contributed by third
parties. In the bug mentioned by Tom, a CQ had to be filed for traceability
reasons so that we can copy code from one Eclipse project to another.

Boris
Previous Topic:Single Item Checkable CheckboxTableViewer
Next Topic:GridLayoutFactory vs GridLayout
Goto Forum:
  


Current Time: Thu May 08 09:17:59 EDT 2025

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

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

Back to the top