Search in sources :

Example 1 with JFX_SWT_Wrapper

use of org.csstudio.javafx.swt.JFX_SWT_Wrapper in project org.csstudio.display.builder by kasemir.

the class DataBrowserEditor method createPartControl.

/**
 * Create Plot GUI, connect to model via Controller
 *  {@inheritDoc}
 */
@Override
public void createPartControl(final Composite parent) {
    // Create GUI elements (Plot)
    parent.setLayout(new FillLayout());
    final JFX_SWT_Wrapper wrapper = new JFX_SWT_Wrapper(parent, () -> {
        try {
            plot = new ModelBasedPlot(true);
        } catch (Exception ex) {
            logger.log(Level.WARNING, "Cannot create plot", ex);
        }
        return new Scene(plot.getPlot());
    });
    final Control plot_canvas = wrapper.getFXCanvas();
    final Scene scene = wrapper.getScene();
    JFXCursorFix.apply(scene, parent.getDisplay());
    try {
        hookDragAndDrop(plot_canvas);
    } catch (Throwable ex) {
        // Adding D&D to FXCanvas involves some hacking
        // that might break as SWT internals get updated.
        logger.log(Level.WARNING, "Cannot initialize Drag&Drop", ex);
    }
    // Create and start controller
    controller = new ControllerSWT(parent.getShell(), model, plot);
    try {
        controller.start();
    } catch (Exception ex) {
        ExceptionDetailsErrorDialog.openError(parent.getShell(), Messages.Error, ex);
    }
    // Only the 'page' seems to know if a part is visible or not,
    // so use PartListener to update controller's redraw handling
    getSite().getPage().addPartListener(new IPartListener2() {

        private boolean isThisEditor(final IWorkbenchPartReference part) {
            return part.getPart(false) == DataBrowserEditor.this;
        }

        // Enable redraws...
        @Override
        public void partOpened(final IWorkbenchPartReference part) {
            if (isThisEditor(part))
                controller.suppressRedraws(false);
        }

        @Override
        public void partVisible(final IWorkbenchPartReference part) {
            if (isThisEditor(part))
                controller.suppressRedraws(false);
        }

        // Suppress redraws...
        @Override
        public void partHidden(final IWorkbenchPartReference part) {
            if (isThisEditor(part))
                controller.suppressRedraws(true);
        }

        @Override
        public void partClosed(final IWorkbenchPartReference part) {
            if (isThisEditor(part))
                controller.suppressRedraws(true);
        }

        // Ignore
        @Override
        public void partInputChanged(final IWorkbenchPartReference part) {
        /* NOP */
        }

        @Override
        public void partDeactivated(final IWorkbenchPartReference part) {
        /* NOP */
        }

        @Override
        public void partBroughtToTop(final IWorkbenchPartReference part) {
        /* NOP */
        }

        @Override
        public void partActivated(final IWorkbenchPartReference part) {
        /* NOP */
        }
    });
    toggle_legend = new ToggleLegendAction(plot.getPlot(), true);
    toggle_toolbar = new ToggleToolbarAction(plot.getPlot(), true);
    snapshot = new SnapshotAction(plot.getPlot(), parent.getShell());
    createContextMenu(plot_canvas);
}
Also used : FillLayout(org.eclipse.swt.layout.FillLayout) Scene(javafx.scene.Scene) PartInitException(org.eclipse.ui.PartInitException) IPartListener2(org.eclipse.ui.IPartListener2) ModelBasedPlot(org.csstudio.trends.databrowser3.ui.ModelBasedPlot) Control(org.eclipse.swt.widgets.Control) JFX_SWT_Wrapper(org.csstudio.javafx.swt.JFX_SWT_Wrapper) IWorkbenchPartReference(org.eclipse.ui.IWorkbenchPartReference) ControllerSWT(org.csstudio.trends.databrowser3.ui.ControllerSWT)

Example 2 with JFX_SWT_Wrapper

use of org.csstudio.javafx.swt.JFX_SWT_Wrapper in project org.csstudio.display.builder by kasemir.

the class WaveformView method doCreatePartControl.

/**
 * {@inheritDoc}
 */
@Override
protected void doCreatePartControl(final Composite parent) {
    // Arrange disposal
    parent.addDisposeListener((DisposeEvent e) -> {
        // Ignore current model after this view is disposed.
        if (model != null) {
            model.removeListener(model_listener);
            removeAnnotation();
        }
    });
    final GridLayout layout = new GridLayout(4, false);
    parent.setLayout(layout);
    // PV: .pvs..... [Refresh]
    // =====================
    // ======= Plot ========
    // =====================
    // <<<<<< Slider >>>>>>
    // Timestamp: __________ Sevr./Status: __________
    // PV: .pvs..... [Refresh]
    Label l = new Label(parent, 0);
    l.setText(Messages.SampleView_Item);
    l.setLayoutData(new GridData());
    pv_name = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
    pv_name.setLayoutData(new GridData(SWT.FILL, 0, true, false, layout.numColumns - 2, 1));
    pv_name.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        @Override
        public void widgetDefaultSelected(final SelectionEvent e) {
            // First item is "--select PV name--"
            if (pv_name.getSelectionIndex() == 0)
                selectPV(null);
            else
                selectPV(model.getItem(pv_name.getText()));
        }
    });
    final Button refresh = new Button(parent, SWT.PUSH);
    refresh.setText(Messages.SampleView_Refresh);
    refresh.setToolTipText(Messages.SampleView_RefreshTT);
    refresh.setLayoutData(new GridData());
    refresh.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            // First item is "--select PV name--"
            if (pv_name.getSelectionIndex() == 0)
                selectPV(null);
            else
                selectPV(model.getItem(pv_name.getText()));
        }
    });
    // =====================
    // ======= Plot ========
    // =====================
    final JFX_SWT_Wrapper wrapper = new JFX_SWT_Wrapper(parent, () -> {
        plot = new RTValuePlot(true);
        plot.getXAxis().setName(Messages.WaveformIndex);
        plot.getYAxes().get(0).setName(Messages.WaveformAmplitude);
        plot.getYAxes().get(0).setAutoscale(true);
        return new Scene(plot);
    });
    final Control plot_canvas = wrapper.getFXCanvas();
    plot_canvas.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, layout.numColumns, 1));
    // <<<<<< Slider >>>>>>
    sample_index = new Slider(parent, SWT.HORIZONTAL);
    sample_index.setToolTipText(Messages.WaveformTimeSelector);
    sample_index.setLayoutData(new GridData(SWT.FILL, 0, true, false, layout.numColumns, 1));
    sample_index.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            showSelectedSample();
        }
    });
    // Timestamp: __________ Sevr./Status: __________
    l = new Label(parent, 0);
    l.setText(Messages.WaveformTimestamp);
    l.setLayoutData(new GridData());
    timestamp = new Text(parent, SWT.BORDER | SWT.READ_ONLY);
    timestamp.setLayoutData(new GridData(SWT.FILL, 0, true, false));
    l = new Label(parent, 0);
    l.setText(Messages.WaveformStatus);
    l.setLayoutData(new GridData());
    status = new Text(parent, SWT.BORDER | SWT.READ_ONLY);
    status.setLayoutData(new GridData(SWT.FILL, 0, true, false));
    // Context Menu
    final MenuManager mm = new MenuManager();
    mm.setRemoveAllWhenShown(true);
    final Menu menu = mm.createContextMenu(plot_canvas);
    plot_canvas.setMenu(menu);
    getSite().registerContextMenu(mm, null);
    mm.addMenuListener(manager -> {
        mm.add(new ToggleToolbarAction(plot, true));
        mm.add(new ToggleLegendAction(plot, true));
        mm.add(new Separator());
        mm.add(new ToggleYAxisAction());
    });
}
Also used : Slider(org.eclipse.swt.widgets.Slider) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Scene(javafx.scene.Scene) ToggleToolbarAction(org.csstudio.trends.databrowser3.editor.ToggleToolbarAction) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) RTValuePlot(org.csstudio.javafx.rtplot.RTValuePlot) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuManager(org.eclipse.jface.action.MenuManager) JFX_SWT_Wrapper(org.csstudio.javafx.swt.JFX_SWT_Wrapper) Menu(org.eclipse.swt.widgets.Menu) Separator(org.eclipse.jface.action.Separator) SelectionListener(org.eclipse.swt.events.SelectionListener) ToggleLegendAction(org.csstudio.trends.databrowser3.editor.ToggleLegendAction)

Example 3 with JFX_SWT_Wrapper

use of org.csstudio.javafx.swt.JFX_SWT_Wrapper in project org.csstudio.display.builder by kasemir.

the class DisplayEditorPart method createPartControl.

@Override
public void createPartControl(final Composite parent) {
    parent.setLayout(new FillLayout());
    final JFX_SWT_Wrapper wrapper = new JFX_SWT_Wrapper(parent, () -> {
        editor = new DisplayEditor(toolkit, Preferences.getUndoSize());
        final Parent root = editor.create();
        editor.getToolBar().getItems().add(new ExecuteDisplayButton(this));
        return new Scene(root);
    });
    final Scene scene = wrapper.getScene();
    EditorUtil.setSceneStyle(scene);
    JFXCursorFix.apply(scene, parent.getDisplay());
    final AutocompleteMenu ac_menu = editor.getSelectedWidgetUITracker().getAutocompleteMenu();
    ac_menu.setUpdater(new AutoCompleteUpdater(ac_menu));
    editor.getUndoableActionManager().addListener(undo_redo_listener);
    final Control fx_canvas = wrapper.getFXCanvas();
    fx_canvas.setMenu(createContextMenu(fx_canvas));
    createRetargetableActionHandlers(fx_canvas);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, "org.csstudio.display.builder.editor.rcp.display_builder");
    loadModel();
}
Also used : Control(org.eclipse.swt.widgets.Control) DisplayEditor(org.csstudio.display.builder.editor.DisplayEditor) Parent(javafx.scene.Parent) ExecuteDisplayButton(org.csstudio.display.builder.editor.rcp.actions.ExecuteDisplayButton) FillLayout(org.eclipse.swt.layout.FillLayout) JFX_SWT_Wrapper(org.csstudio.javafx.swt.JFX_SWT_Wrapper) AutocompleteMenu(org.csstudio.display.builder.representation.javafx.AutocompleteMenu) Scene(javafx.scene.Scene)

Example 4 with JFX_SWT_Wrapper

use of org.csstudio.javafx.swt.JFX_SWT_Wrapper in project org.csstudio.display.builder by kasemir.

the class OutlinePage method createControl.

@Override
public void createControl(final Composite parent) {
    final JFX_SWT_Wrapper wrapper = new JFX_SWT_Wrapper(parent, () -> {
        // StackPane w/ tree as single child to 'fill' the available space.
        final StackPane root = new StackPane(tree.create());
        return new Scene(root, 200.0, 400.0);
    });
    canvas = wrapper.getFXCanvas();
    EditorUtil.setSceneStyle(wrapper.getScene());
    createContextMenu();
}
Also used : JFX_SWT_Wrapper(org.csstudio.javafx.swt.JFX_SWT_Wrapper) Scene(javafx.scene.Scene) StackPane(javafx.scene.layout.StackPane)

Example 5 with JFX_SWT_Wrapper

use of org.csstudio.javafx.swt.JFX_SWT_Wrapper in project org.csstudio.display.builder by kasemir.

the class RuntimeApplication method initializeUI.

private Stage initializeUI() {
    // TODO Load named color, font configs
    // Creating an FX Canvas results in a combined
    // SWT and JavaFX setup with common UI thread.
    // Shell that's created as a parent for the FX Canvas is never shown.
    display = Display.getDefault();
    final Shell temp_shell = new Shell(display);
    new JFX_SWT_Wrapper(temp_shell, () -> null);
    temp_shell.close();
    final Stage stage = new Stage();
    stage.setTitle("Display Runtime");
    stage.setWidth(600);
    stage.setHeight(400);
    stage.show();
    toolkit = new JFXStageRepresentation(stage);
    RuntimeUtil.hookRepresentationListener(toolkit);
    return stage;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) JFXStageRepresentation(org.csstudio.display.builder.representation.javafx.JFXStageRepresentation) Stage(javafx.stage.Stage) JFX_SWT_Wrapper(org.csstudio.javafx.swt.JFX_SWT_Wrapper)

Aggregations

JFX_SWT_Wrapper (org.csstudio.javafx.swt.JFX_SWT_Wrapper)11 Scene (javafx.scene.Scene)8 FillLayout (org.eclipse.swt.layout.FillLayout)5 Shell (org.eclipse.swt.widgets.Shell)4 Parent (javafx.scene.Parent)3 Control (org.eclipse.swt.widgets.Control)3 Display (org.eclipse.swt.widgets.Display)3 StackPane (javafx.scene.layout.StackPane)2 ModelBasedPlot (org.csstudio.trends.databrowser3.ui.ModelBasedPlot)2 Label (javafx.scene.control.Label)1 Stage (javafx.stage.Stage)1 DisplayEditor (org.csstudio.display.builder.editor.DisplayEditor)1 ExecuteDisplayButton (org.csstudio.display.builder.editor.rcp.actions.ExecuteDisplayButton)1 DisplayModel (org.csstudio.display.builder.model.DisplayModel)1 Macros (org.csstudio.display.builder.model.macros.Macros)1 AutocompleteMenu (org.csstudio.display.builder.representation.javafx.AutocompleteMenu)1 JFXRepresentation (org.csstudio.display.builder.representation.javafx.JFXRepresentation)1 JFXStageRepresentation (org.csstudio.display.builder.representation.javafx.JFXStageRepresentation)1 MacrosTable (org.csstudio.display.builder.representation.javafx.MacrosTable)1 RTValuePlot (org.csstudio.javafx.rtplot.RTValuePlot)1