| package org.eclipse.nebula.widgets.nattable.renderer.swt |
| |
| import org.eclipse.nebula.widgets.nattable.core.layer.impl.DummyLayer |
| import org.eclipse.nebula.widgets.nattable.core.layer.impl.viewport.ViewportLayer |
| import org.eclipse.nebula.widgets.nattable.renderer.swt.geometry.SWTControlPixelArea |
| import org.eclipse.swt.SWT |
| import org.eclipse.swt.layout.FillLayout |
| import org.eclipse.swt.widgets.Display |
| import org.eclipse.swt.widgets.Shell |
| |
| class SWTExample { |
| |
| def static void main(String[] args) { |
| run(400, 300) |
| } |
| |
| static def void run(int shellWidth, int shellHeight) { |
| val display = Display::getDefault |
| val shell = new Shell(display, SWT::SHELL_TRIM) |
| shell.setLayout(new FillLayout) |
| shell.setSize(shellWidth, shellHeight) |
| shell.setText("NatTable -> SWT") |
| |
| // Create example control |
| val natTable = shell.SWTNatTable |
| |
| // Start |
| shell.open |
| |
| while (!shell.disposed) { |
| if (!display.readAndDispatch) { |
| display.sleep |
| } |
| } |
| |
| // Stop |
| natTable.dispose |
| |
| shell.dispose |
| display.dispose |
| } |
| |
| static def getSWTNatTable(Shell shell) { |
| val natTable = new SWTNatTable(shell) |
| |
| val layer = new ViewportLayer(new DummyLayer(4, 4, 200, 100), new SWTControlPixelArea(natTable)) |
| natTable.layer = layer |
| |
| natTable |
| } |
| |
| } |