|
|
|
|
|
|
|
|
|
Re: DirectEdit checkbox [message #900972 is a reply to message #900928] |
Thu, 09 August 2012 09:25 |
Rui Domingues Messages: 194 Registered: October 2010 |
Senior Member |
|
|
Hi.
I checked that option, but I wasn't successful to make DirectEditFeature to extend org.eclipse.graphiti.ui.platform.ICellEditorProvider, doing getEditingType()=TYPE_CUSTOM.
I tried with org.eclipse.jface.viewers.CheckboxCellEditor, but I got a NullPointerException.
!STACK 0
java.lang.NullPointerException
at org.eclipse.gef.tools.DirectEditManager.hookListeners(DirectEditManager.java:287)
at org.eclipse.gef.tools.DirectEditManager.setCellEditor(DirectEditManager.java:353)
at org.eclipse.gef.tools.DirectEditManager.show(DirectEditManager.java:397)
Ok. Mathias. I was not using Editor's Transactional editing domain. My bad. I was using another one. Now it works and I just change visibility of images' shape (image_checked and image_not_checked).
If some has some sppinet to use Celleditor, it would be great
Thanks a lot.
[Updated on: Thu, 09 August 2012 09:26] Report message to a moderator
|
|
|
|
|
|
|
Re: DirectEdit checkbox [message #901203 is a reply to message #901163] |
Fri, 10 August 2012 10:14 |
Matthias Gorning Messages: 81 Registered: April 2010 Location: Germany |
Member |
|
|
Here is an example with the org.eclipse.jface.viewers.ColorCellEditor which works for a direct editing feature.
But I have extended this editor, so that I can fulfill the interface ICellEditorProvider.
That's the implementation of MyColorCellEditor. Internal the cell editor works with an RGB value. But the interface between direct editing feature and cell editor is a String. In this specific case the string format is "RGB {r, g, b}".
import java.util.StringTokenizer;
import org.eclipse.jface.viewers.ColorCellEditor;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.ColorDialog;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
public class MyColorCellEditor extends ColorCellEditor {
public MyColorCellEditor(Composite parent) {
super(parent);
}
@Override
protected void doSetValue(Object value) {
if (value instanceof String) {
value = stringToRGB((String) value);
}
super.doSetValue(value);
}
@Override
protected Object doGetValue() {
Object value = super.doGetValue();
if (value instanceof RGB) {
value = ((RGB) value).toString();
}
return value;
}
protected Object openDialogBox(Control cellEditorWindow) {
ColorDialog dialog = new ColorDialog(cellEditorWindow.getShell());
Object value = super.doGetValue();
if (value != null) {
dialog.setRGB((RGB) value);
}
value = dialog.open();
return dialog.getRGB();
}
private RGB stringToRGB(String value) {
StringTokenizer st = new StringTokenizer(value, "RGB {,}");
int red = Integer.parseInt(st.nextToken());
int green = Integer.parseInt(st.nextToken());
int blue = Integer.parseInt(st.nextToken());
RGB rgb = new RGB(red, green, blue);
return rgb;
}
}
My direct editing feature simply contains these lines:
public int getEditingType() {
return TYPE_CUSTOM;
}
public CellEditor createCellEditor(Composite parent) {
ColorCellEditor ce = new MyColorCellEditor(parent);
return ce;
}
public void relocate(CellEditor cellEditor, IFigure figure) {
cellEditor.getControl().setBounds(40, 40, 200, 50);
}
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04530 seconds