Module omix.api

Interface TypeEditHandlerInterface


public interface TypeEditHandlerInterface
This interface allows to implement management of arbitrary data types in the property editor (see image below).

TypeEditHandlerInterface

The property editor is able to display and edit a comprehensive but limited set of class types like 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
  • Method Details

    • paintCell

      Paint an object of specific type inside the table cell.
      If the class type is not supported, the method must return null.
      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 be null.
      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 return null.

      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 dialog
      fieldInfo - information about the value to be edited. FieldInfo.getValue() may be null.
      utilities - helpful utilities for creating editors
      Returns:
      an instance of EditResponse if object type is supported, null otherwise.