Search in sources :

Example 1 with WidgetIgnorableUITask

use of org.csstudio.opibuilder.datadefinition.WidgetIgnorableUITask in project yamcs-studio by yamcs.

the class WidgetConnectionEditPart method activate.

@Override
public void activate() {
    if (!isActive()) {
        super.activate();
        getWidgetModel().getProperty(ConnectionModel.PROP_LINE_COLOR).addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                getConnectionFigure().setForegroundColor(((OPIColor) evt.getNewValue()).getSWTColor());
            }
        });
        getWidgetModel().getProperty(ConnectionModel.PROP_LINE_STYLE).addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                getConnectionFigure().setLineStyle(getWidgetModel().getLineStyle());
            }
        });
        getWidgetModel().getProperty(ConnectionModel.PROP_LINE_WIDTH).addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                getConnectionFigure().setLineWidth(getWidgetModel().getLineWidth());
            }
        });
        getWidgetModel().getProperty(ConnectionModel.PROP_ROUTER).addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                updateRouter(getConnectionFigure());
            }
        });
        getWidgetModel().getProperty(ConnectionModel.PROP_POINTS).addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(final PropertyChangeEvent evt) {
                if (getViewer() == null || getViewer().getControl() == null) {
                    return;
                }
                Runnable runnable = new Runnable() {

                    @Override
                    public void run() {
                        if (((PointList) evt.getOldValue()).size() != ((PointList) evt.getNewValue()).size())
                            updateRouter(getConnectionFigure());
                        else
                            refreshBendpoints(getConnectionFigure());
                    }
                };
                // It should update at the same rate as other widget at run time
                if (getExecutionMode() == ExecutionMode.RUN_MODE) {
                    Display display = getViewer().getControl().getDisplay();
                    WidgetIgnorableUITask task = new WidgetIgnorableUITask(getWidgetModel().getProperty(ConnectionModel.PROP_POINTS), runnable, display);
                    GUIRefreshThread.getInstance(getExecutionMode() == ExecutionMode.RUN_MODE).addIgnorableTask(task);
                } else
                    runnable.run();
            }
        });
        getWidgetModel().getProperty(ConnectionModel.PROP_ARROW_LENGTH).addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                updateArrowLength(getConnectionFigure());
            }
        });
        getWidgetModel().getProperty(ConnectionModel.PROP_ARROW_TYPE).addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                updateDecoration(getConnectionFigure());
                updateArrowLength(getConnectionFigure());
            }
        });
        getWidgetModel().getProperty(ConnectionModel.PROP_FILL_ARROW).addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                updateDecoration(getConnectionFigure());
                updateArrowLength(getConnectionFigure());
            }
        });
        getWidgetModel().getProperty(ConnectionModel.PROP_ANTIALIAS).addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                getConnectionFigure().setAntialias(getWidgetModel().isAntiAlias() ? SWT.ON : SWT.OFF);
                for (Object obj : getConnectionFigure().getChildren()) {
                    if (obj instanceof Shape)
                        ((Shape) obj).setAntialias(getWidgetModel().isAntiAlias() ? SWT.ON : SWT.OFF);
                }
            }
        });
        getWidgetModel().getProperty(ConnectionModel.PROP_LINE_JUMP_ADD).addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                getConnectionFigure().setLineJumpAdd(getWidgetModel().getLineJumpAdd());
                Runnable runnable = new Runnable() {

                    @Override
                    public void run() {
                        getConnectionFigure().repaint();
                    }
                };
                WidgetIgnorableUITask task = new WidgetIgnorableUITask(getWidgetModel().getProperty(ConnectionModel.PROP_LINE_JUMP_ADD), runnable, getViewer().getControl().getDisplay());
                GUIRefreshThread.getInstance(getExecutionMode() == ExecutionMode.EDIT_MODE).addIgnorableTask(task);
            }
        });
        getWidgetModel().getProperty(ConnectionModel.PROP_LINE_JUMP_SIZE).addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                getConnectionFigure().setLineJumpSize(getWidgetModel().getLineJumpSize());
                Runnable runnable = new Runnable() {

                    @Override
                    public void run() {
                        getConnectionFigure().repaint();
                    }
                };
                WidgetIgnorableUITask task = new WidgetIgnorableUITask(getWidgetModel().getProperty(ConnectionModel.PROP_LINE_JUMP_SIZE), runnable, getViewer().getControl().getDisplay());
                GUIRefreshThread.getInstance(getExecutionMode() == ExecutionMode.EDIT_MODE).addIgnorableTask(task);
            }
        });
        getWidgetModel().getProperty(ConnectionModel.PROP_LINE_JUMP_STYLE).addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                getConnectionFigure().setLineJumpStyle(getWidgetModel().getLineJumpStyle());
                Runnable runnable = new Runnable() {

                    @Override
                    public void run() {
                        getConnectionFigure().repaint();
                    }
                };
                WidgetIgnorableUITask task = new WidgetIgnorableUITask(getWidgetModel().getProperty(ConnectionModel.PROP_LINE_JUMP_SIZE), runnable, getViewer().getControl().getDisplay());
                GUIRefreshThread.getInstance(getExecutionMode() == ExecutionMode.EDIT_MODE).addIgnorableTask(task);
            }
        });
        getWidgetModel().getProperty(ConnectionModel.PROP_IS_LOADED_FROM_LINKING_CONTAINER).addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                updateRouter(getConnectionFigure());
            }
        });
    }
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) PropertyChangeEvent(java.beans.PropertyChangeEvent) Shape(org.eclipse.draw2d.Shape) PropertyChangeListener(java.beans.PropertyChangeListener) WidgetIgnorableUITask(org.csstudio.opibuilder.datadefinition.WidgetIgnorableUITask) OPIColor(org.csstudio.opibuilder.util.OPIColor) Display(org.eclipse.swt.widgets.Display)

Example 2 with WidgetIgnorableUITask

use of org.csstudio.opibuilder.datadefinition.WidgetIgnorableUITask in project yamcs-studio by yamcs.

the class AbstractSWTWidgetFigure method relocateWidget.

/**
 * relocate the widget so it follows the figure position.
 */
protected void relocateWidget() {
    if (wrapComposite != null && getParent().getParent() instanceof Viewport) {
        var viewPortArea = getParent().getParent().getClientArea();
        var clientArea = getClientArea();
        getParent().translateToAbsolute(viewPortArea);
        translateToAbsolute(clientArea);
        isIntersectViewPort = viewPortArea.intersects(clientArea);
    // isIntersectViewPort = getParent().getParent().getClientArea()
    // .intersects(getClientArea());
    }
    GUIRefreshThread.getInstance(runmode).addIgnorableTask(new WidgetIgnorableUITask(this, () -> {
        if (!getSWTWidget().isDisposed() && getParent() != null) {
            doRelocateWidget();
        }
    }, composite.getDisplay()));
}
Also used : WidgetIgnorableUITask(org.csstudio.opibuilder.datadefinition.WidgetIgnorableUITask) Viewport(org.eclipse.draw2d.Viewport)

Example 3 with WidgetIgnorableUITask

use of org.csstudio.opibuilder.datadefinition.WidgetIgnorableUITask in project yamcs-studio by yamcs.

the class WidgetPropertyChangeListener method propertyChange.

@Override
public void propertyChange(final PropertyChangeEvent evt) {
    Runnable runnable = new Runnable() {

        @Override
        public synchronized void run() {
            if (editpart == null || !editpart.isActive()) {
                return;
            }
            for (IWidgetPropertyChangeHandler h : handlers) {
                IFigure figure = editpart.getFigure();
                h.handleChange(evt.getOldValue(), evt.getNewValue(), figure);
            }
        }
    };
    Display display = editpart.getViewer().getControl().getDisplay();
    WidgetIgnorableUITask task = new WidgetIgnorableUITask(widgetProperty, runnable, display);
    GUIRefreshThread.getInstance(editpart.getExecutionMode() == ExecutionMode.RUN_MODE).addIgnorableTask(task);
}
Also used : WidgetIgnorableUITask(org.csstudio.opibuilder.datadefinition.WidgetIgnorableUITask) IFigure(org.eclipse.draw2d.IFigure) Display(org.eclipse.swt.widgets.Display)

Example 4 with WidgetIgnorableUITask

use of org.csstudio.opibuilder.datadefinition.WidgetIgnorableUITask in project yamcs-studio by yamcs.

the class LockUnlockChildrenAction method createLockUnlockCommand.

public static Command createLockUnlockCommand(GroupingContainerModel containerModel) {
    Command cmd = new SetWidgetPropertyCommand(containerModel, GroupingContainerModel.PROP_LOCK_CHILDREN, !containerModel.isLocked()) {

        @Override
        public void execute() {
            super.execute();
            selectWidgets();
        }

        @Override
        public void undo() {
            super.undo();
            selectWidgets();
        }

        private void selectWidgets() {
            // must be queued so it is executed after property has been changed.
            GUIRefreshThread.getInstance(false).addIgnorableTask(new WidgetIgnorableUITask(this, () -> containerModel.getParent().selectWidget(containerModel, false), Display.getCurrent()));
        }
    };
    cmd.setLabel(containerModel.isLocked() ? "Unlock Children" : "Lock Children");
    return cmd;
}
Also used : SetWidgetPropertyCommand(org.csstudio.opibuilder.commands.SetWidgetPropertyCommand) Command(org.eclipse.gef.commands.Command) SetWidgetPropertyCommand(org.csstudio.opibuilder.commands.SetWidgetPropertyCommand) WidgetIgnorableUITask(org.csstudio.opibuilder.datadefinition.WidgetIgnorableUITask)

Aggregations

WidgetIgnorableUITask (org.csstudio.opibuilder.datadefinition.WidgetIgnorableUITask)4 Display (org.eclipse.swt.widgets.Display)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 SetWidgetPropertyCommand (org.csstudio.opibuilder.commands.SetWidgetPropertyCommand)1 OPIColor (org.csstudio.opibuilder.util.OPIColor)1 IFigure (org.eclipse.draw2d.IFigure)1 Shape (org.eclipse.draw2d.Shape)1 Viewport (org.eclipse.draw2d.Viewport)1 PointList (org.eclipse.draw2d.geometry.PointList)1 Command (org.eclipse.gef.commands.Command)1