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());
}
});
}
}
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()));
}
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);
}
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;
}
Aggregations