Search in sources :

Example 1 with MultiLineTextCellEditor

use of org.eclipse.nebula.widgets.nattable.edit.editor.MultiLineTextCellEditor in project nebula.widgets.nattable by eclipse.

the class EditorConfiguration method registerColumnFourMultiLineEditor.

private void registerColumnFourMultiLineEditor(IConfigRegistry configRegistry) {
    // configure the multi line text editor for column four
    configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, new MultiLineTextCellEditor(false), DisplayMode.NORMAL, EditorExample.COLUMN_FOUR_LABEL);
    // configure the multi line text editor to always open in a subdialog
    configRegistry.registerConfigAttribute(EditConfigAttributes.OPEN_IN_DIALOG, Boolean.TRUE, DisplayMode.EDIT, EditorExample.COLUMN_FOUR_LABEL);
    Style cellStyle = new Style();
    cellStyle.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, HorizontalAlignmentEnum.LEFT);
    configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.NORMAL, EditorExample.COLUMN_FOUR_LABEL);
    configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.EDIT, EditorExample.COLUMN_FOUR_LABEL);
    // configure custom dialog settings
    Display display = Display.getCurrent();
    Map<String, Object> editDialogSettings = new HashMap<>();
    editDialogSettings.put(ICellEditDialog.DIALOG_SHELL_TITLE, "My custom value");
    editDialogSettings.put(ICellEditDialog.DIALOG_SHELL_ICON, display.getSystemImage(SWT.ICON_WARNING));
    editDialogSettings.put(ICellEditDialog.DIALOG_SHELL_RESIZABLE, Boolean.TRUE);
    Point size = new Point(400, 300);
    editDialogSettings.put(ICellEditDialog.DIALOG_SHELL_SIZE, size);
    int screenWidth = display.getBounds().width;
    int screenHeight = display.getBounds().height;
    Point location = new Point((screenWidth / (2 * display.getMonitors().length)) - (size.x / 2), (screenHeight / 2) - (size.y / 2));
    editDialogSettings.put(ICellEditDialog.DIALOG_SHELL_LOCATION, location);
    // add custum message
    editDialogSettings.put(ICellEditDialog.DIALOG_MESSAGE, "Enter some free text in here:");
    configRegistry.registerConfigAttribute(EditConfigAttributes.EDIT_DIALOG_SETTINGS, editDialogSettings, DisplayMode.EDIT, EditorExample.COLUMN_FOUR_LABEL);
}
Also used : MultiLineTextCellEditor(org.eclipse.nebula.widgets.nattable.edit.editor.MultiLineTextCellEditor) HashMap(java.util.HashMap) Style(org.eclipse.nebula.widgets.nattable.style.Style) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) Display(org.eclipse.swt.widgets.Display)

Aggregations

HashMap (java.util.HashMap)1 MultiLineTextCellEditor (org.eclipse.nebula.widgets.nattable.edit.editor.MultiLineTextCellEditor)1 Style (org.eclipse.nebula.widgets.nattable.style.Style)1 Point (org.eclipse.swt.graphics.Point)1 Display (org.eclipse.swt.widgets.Display)1