public interface TypeEditHandlerInterface
This interface allows to implement management of arbitrary
data types in the property editor (see image below).
String
, Integer
, Double
, List
etc.
In order to extend this set with specific class types available in plugin bundles or libraries
this interface can be implemented.
Example implementation:
public class MyTypeEditHandler implements TypeEditHandlerInterface {
public PaintResponse paintCell(paintCell(FieldInfo fieldInfo, PaintValueUtilities utilities){
if(fieldInfo.getValue() instanceof Integer) {
PaintResponse response = new PaintResponse();
response.setText(fieldInfo.getValue().toString());
return response;
} else {
return null;
}
}
public EditorResponse createEditor(QWidget parent, Class<?> type, FieldInfo fieldInfo, CreateEditorUtilities utilities) {
if(type==Integer.class) {
MySpinBox spinBox = new MySpinBox(parent);
if(fieldInfo.getValue() instanceof Integer) {
int value = (Integer)fieldInfo.getValue();
spinBox.setValue(value);
}
return new CellEditorResponse(spinBox);
} else if(type==MyCustomType.class) {
MyCustomDialog dialog = new MyCustomDialog(parent);
dialog.setValue((MyCustomType)fieldInfo.getValue());
return new DialogEditorResponse(dialog);
} else {
return null;
}
}
class MyCustomDialog extends QDialog implements TypeEditHandlerInterface.DialogEditorInterface {
MyCustomDialog(QWidget parent){
super(parent);
};
public Object getEditedValue() {
return //.....//;
}
}
class MySpinBox extends QSpinBox implements TypeEditHandlerInterface.ObjectEditorInterface {
MySpinBox(QWidget parent){
super(parent);
};
public Object getEditedValue() {
return value();
}
}
}
- Since:
- Omix 1.3.11
- Author:
- Dr. Peter Droste, Omix Visualization
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
TypeEditHandlerInterface.CellEditorResponse
This class returns a cell editor widget.static interface
TypeEditHandlerInterface.CellPainterInterface
This interface can be implemented in order to paint a table cell of the property editor according a specific object content.static interface
TypeEditHandlerInterface.DialogEditorInterface
The editor dialog is executed viaTypeEditHandlerInterface.DialogEditorInterface.exec()
.static class
TypeEditHandlerInterface.DialogEditorResponse
This class returns a dialog editor as user interface for property editing.static class
TypeEditHandlerInterface.EditResponse
Generalizes all possible results ofcreateEditor(QWidget, FieldInfo, CreateEditorUtilities)
.static class
TypeEditHandlerInterface.NoEditorResponse
This class can be used when an field must not be edited.static interface
TypeEditHandlerInterface.ObjectEditorInterface
This interface must be implemented by a valid cell editor widget.static class
TypeEditHandlerInterface.PaintResponse
Answer of apaintCell(FieldInfo, PaintValueUtilities)
request. -
Method Summary
Modifier and Type Method Description TypeEditHandlerInterface.EditResponse
createEditor(QWidget parent, FieldInfo fieldInfo, CreateEditorUtilities utilities)
Creates an editor for a specific class type as cell widget or as editor dialog.
This method is invoked when the user makes a click on a table cell in the property editor.TypeEditHandlerInterface.PaintResponse
paintCell(FieldInfo fieldInfo, PaintValueUtilities utilities)
Paint an object of specific type inside the table cell.
If the class type is not supported, the method must returnnull
.
Omix iterates the list of installed TypeEditHandlers ordered by time of installation.
-
Method Details
-
paintCell
TypeEditHandlerInterface.PaintResponse paintCell(FieldInfo fieldInfo, PaintValueUtilities utilities)Paint an object of specific type inside the table cell.
If the class type is not supported, the method must returnnull
.
Omix iterates the list of installed TypeEditHandlers ordered by time of installation. The first handler returning a PaintResponse is used for value painting. All other supporting handlers are skipped.- Parameters:
fieldInfo
- an value of a specific type.FieldInfo.getValue()
will never benull
.utilities
- helpful utilities for painting- Returns:
- an instance of PaintResponse if object type is supported,
null
otherwise.
-
createEditor
TypeEditHandlerInterface.EditResponse createEditor(QWidget parent, FieldInfo fieldInfo, CreateEditorUtilities utilities)Creates an editor for a specific class type as cell widget or as editor dialog.
This method is invoked when the user makes a click on a table cell in the property editor. If the class type is not supported, the method must returnnull
.
Omix iterates the list of installed TypeEditHandlers ordered by time of installation. The first handler returning an EditResponse is used for creating the editor. All other supporting handlers are skipped.- Parameters:
parent
- parent widget for the editor cell or editor dialogfieldInfo
- information about the value to be edited.FieldInfo.getValue()
may benull
.utilities
- helpful utilities for creating editors- Returns:
- an instance of EditResponse if object type is supported,
null
otherwise.
-