Search in sources :

Example 1 with SWTRepresentation

use of org.csstudio.display.builder.representation.swt.SWTRepresentation in project org.csstudio.display.builder by kasemir.

the class RepresentationDemoSWT method main.

public static void main(final String[] args) throws Exception {
    // final DisplayModel model = ExampleModels.getModel(1);
    final DisplayModel model = ExampleModels.createModel();
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText(model.getPropertyValue(propName));
    shell.setSize(model.getPropertyValue(propWidth), model.getPropertyValue(propHeight));
    final ToolkitRepresentation<Composite, Control> toolkit = new SWTRepresentation(display);
    toolkit.representModel(shell, model);
    final DummyRuntime runtime = new DummyRuntime(model);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    runtime.shutdown();
    toolkit.shutdown();
    display.dispose();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) DisplayModel(org.csstudio.display.builder.model.DisplayModel) SWTRepresentation(org.csstudio.display.builder.representation.swt.SWTRepresentation) Display(org.eclipse.swt.widgets.Display)

Example 2 with SWTRepresentation

use of org.csstudio.display.builder.representation.swt.SWTRepresentation in project org.csstudio.display.builder by kasemir.

the class RuntimeDemoSWT method run.

@Override
public void run() {
    final Display display = new Display();
    toolkit = new SWTRepresentation(display);
    RuntimeUtil.hookRepresentationListener(toolkit);
    // Load model in background
    RuntimeUtil.getExecutor().execute(() -> loadModel(display));
    while (!display.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    toolkit.shutdown();
    display.dispose();
    int refs = 0;
    for (final RefCountMap.ReferencedEntry<PV> ref : PVPool.getPVReferences()) {
        refs += ref.getReferences();
        logger.log(Level.SEVERE, "PV {0} left with {1} references", new Object[] { ref.getEntry().getName(), ref.getReferences() });
    }
    if (refs == 0)
        logger.log(Level.FINE, "All PV references were released, good job, get a cookie!");
    // JCA Context remains running, so need to exit() to really quit
    System.exit(0);
}
Also used : SWTRepresentation(org.csstudio.display.builder.representation.swt.SWTRepresentation) PV(org.csstudio.vtype.pv.PV) RefCountMap(org.csstudio.vtype.pv.RefCountMap) Display(org.eclipse.swt.widgets.Display)

Aggregations

SWTRepresentation (org.csstudio.display.builder.representation.swt.SWTRepresentation)2 Display (org.eclipse.swt.widgets.Display)2 DisplayModel (org.csstudio.display.builder.model.DisplayModel)1 PV (org.csstudio.vtype.pv.PV)1 RefCountMap (org.csstudio.vtype.pv.RefCountMap)1 Composite (org.eclipse.swt.widgets.Composite)1 Control (org.eclipse.swt.widgets.Control)1 Shell (org.eclipse.swt.widgets.Shell)1