use of org.eclipse.draw2d.IFigure in project yamcs-studio by yamcs.
the class AbstractShapeEditPart method registerPropertyChangeHandlers.
/**
* {@inheritDoc}
*/
@Override
protected void registerPropertyChangeHandlers() {
// line width
IWidgetPropertyChangeHandler lineWidthHandler = new IWidgetPropertyChangeHandler() {
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
Shape shape = (Shape) refreshableFigure;
if (((Integer) newValue).equals(0))
shape.setOutline(false);
else {
shape.setOutline(true);
shape.setLineWidth((Integer) newValue);
}
return true;
}
};
setPropertyChangeHandler(AbstractShapeModel.PROP_LINE_WIDTH, lineWidthHandler);
// line style
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
Shape shape = (Shape) refreshableFigure;
shape.setLineStyle(LineStyle.values()[(Integer) newValue].getStyle());
return true;
}
};
setPropertyChangeHandler(AbstractShapeModel.PROP_LINE_STYLE, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
if (GraphicsUtil.useAdvancedGraphics())
((Shape) figure).setAntialias(((Boolean) newValue) ? SWT.ON : null);
return false;
}
};
setPropertyChangeHandler(AbstractShapeModel.PROP_ANTIALIAS, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
if (GraphicsUtil.useAdvancedGraphics()) {
if ((Integer) newValue < 255)
((Shape) figure).setAlpha((Integer) newValue);
else
((Shape) figure).setAlpha(null);
}
return false;
}
};
setPropertyChangeHandler(AbstractShapeModel.PROP_ALPHA, handler);
}
use of org.eclipse.draw2d.IFigure in project yamcs-studio by yamcs.
the class ArcEditpart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
super.registerPropertyChangeHandlers();
// fill
IWidgetPropertyChangeHandler fillHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ArcFigure figure = (ArcFigure) refreshableFigure;
figure.setFill((Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(ArcModel.PROP_FILL, fillHandler);
// start angle
IWidgetPropertyChangeHandler startAngleHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ArcFigure figure = (ArcFigure) refreshableFigure;
figure.setStartAngle((Integer) newValue);
return true;
}
};
setPropertyChangeHandler(ArcModel.PROP_START_ANGLE, startAngleHandler);
// total angle
IWidgetPropertyChangeHandler totalAngleHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ArcFigure figure = (ArcFigure) refreshableFigure;
figure.setTotalAngle((Integer) newValue);
return true;
}
};
setPropertyChangeHandler(ArcModel.PROP_TOTAL_ANGLE, totalAngleHandler);
}
use of org.eclipse.draw2d.IFigure in project yamcs-studio by yamcs.
the class ArrayEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
for (AbstractWidgetModel child : getWidgetModel().getAllChildren()) {
child.setEnabled((Boolean) newValue);
}
return true;
}
};
setPropertyChangeHandler(AbstractWidgetModel.PROP_ENABLED, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
VType value = (VType) newValue;
if (value instanceof VNumberArray) {
Object wrappedArray = VTypeHelper.getWrappedArray(((VNumberArray) value));
if (wrappedArray != null)
setValue(wrappedArray);
else
setValue(VTypeHelper.getDoubleArray(value));
} else {
if (value instanceof VEnum)
setValue(new String[] { ((VEnum) value).getValue() });
else if (value instanceof VString)
setValue(new String[] { ((VString) value).getValue() });
else if (value instanceof VStringArray)
setValue(((VStringArray) value).getData().toArray());
else
setValue(VTypeHelper.getDoubleArray(value));
}
return false;
}
};
setPropertyChangeHandler(ArrayModel.PROP_PVVALUE, handler);
getWidgetModel().getProperty(ArrayModel.PROP_PVNAME).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
updatePropSheet();
}
});
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
registerLoadPVDataTypeListener();
return false;
}
};
setPropertyChangeHandler(ArrayModel.PROP_PVNAME, handler);
getWidgetModel().getProperty(ArrayModel.PROP_DATA_TYPE).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
initValueArray();
}
});
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
updateWidgetSize();
return false;
}
};
setPropertyChangeHandler(ArrayModel.PROP_BORDER_STYLE, handler);
setPropertyChangeHandler(ArrayModel.PROP_BORDER_WIDTH, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
getArrayFigure().setArrayLength((Integer) newValue);
return false;
}
};
setPropertyChangeHandler(ArrayModel.PROP_ARRAY_LENGTH, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((ArrayFigure) figure).setSpinnerWidth((Integer) newValue);
keepElementSize = true;
getWidgetModel().setSize(((ArrayFigure) figure).getPreferredSize());
keepElementSize = false;
return false;
}
};
setPropertyChangeHandler(ArrayModel.PROP_SPINNER_WIDTH, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((ArrayFigure) figure).setHorizontal((Boolean) newValue);
keepElementSize = true;
getWidgetModel().setSize(((ArrayFigure) figure).getPreferredSize());
keepElementSize = false;
return false;
}
};
setPropertyChangeHandler(ArrayModel.PROP_HORIZONTAL, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((ArrayFigure) figure).setShowScrollbar((Boolean) newValue);
keepElementSize = true;
getWidgetModel().setSize(((ArrayFigure) figure).getPreferredSize());
keepElementSize = false;
return false;
}
};
setPropertyChangeHandler(ArrayModel.PROP_SHOW_SCROLLBAR, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((ArrayFigure) figure).setShowSpinner((Boolean) newValue);
keepElementSize = true;
getWidgetModel().setSize(((ArrayFigure) figure).getPreferredSize());
keepElementSize = false;
return false;
}
};
setPropertyChangeHandler(ArrayModel.PROP_SHOW_SPINNER, handler);
PropertyChangeListener sizePropertyChangeListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (getWidgetModel().getChildren().size() == 0 || inSync || keepElementSize)
return;
Dimension elementSize = getArrayFigure().getElementSize();
int delta = (Integer) evt.getNewValue() - (Integer) evt.getOldValue();
int elementWH = elementSize.height;
String propID = evt.getPropertyName();
boolean elementCountDirection = false;
if (getWidgetModel().isHorizontal() && propID.equals(AbstractWidgetModel.PROP_WIDTH)) {
elementWH = elementSize.width;
elementCountDirection = true;
} else if (!getWidgetModel().isHorizontal() && propID.equals(AbstractWidgetModel.PROP_HEIGHT)) {
elementWH = elementSize.height;
elementCountDirection = true;
}
if (elementCountDirection) {
int deltaElementsCount = Math.round((float) delta / elementWH);
int idelta = (Math.round((float) delta / elementWH) * elementWH);
setPropertyValue(propID, (Integer) evt.getOldValue() + idelta, false);
int visibleElementsCount = getArrayFigure().getVisibleElementsCount() + deltaElementsCount;
setPropertyValue(ArrayModel.PROP_VISIBLE_ELEMENTS_COUNT, visibleElementsCount);
setValue(getValue());
} else {
int wh;
if (propID.equals(AbstractWidgetModel.PROP_WIDTH))
wh = getArrayFigure().getElementSize().width;
else
wh = getArrayFigure().getElementSize().height;
syncAllChildrenProperties(propID, wh + delta);
}
}
};
getWidgetModel().getProperty(AbstractWidgetModel.PROP_WIDTH).addPropertyChangeListener(sizePropertyChangeListener);
getWidgetModel().getProperty(AbstractWidgetModel.PROP_HEIGHT).addPropertyChangeListener(sizePropertyChangeListener);
}
use of org.eclipse.draw2d.IFigure in project yamcs-studio by yamcs.
the class CheckBoxEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
// value
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
if (newValue == null)
return false;
CheckBoxFigure figure = (CheckBoxFigure) refreshableFigure;
switch(VTypeHelper.getBasicDataType((VType) newValue)) {
case SHORT:
figure.setTotalBits(TotalBits.BITS_16);
break;
case INT:
case ENUM:
figure.setTotalBits(TotalBits.BITS_32);
break;
default:
break;
}
figure.setValue(VTypeHelper.getDouble((VType) newValue));
return true;
}
};
setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVVALUE, handler);
// bit
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
CheckBoxFigure figure = (CheckBoxFigure) refreshableFigure;
figure.setBit((Integer) newValue);
return true;
}
};
setPropertyChangeHandler(CheckBoxModel.PROP_BIT, handler);
// label
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
CheckBoxFigure figure = (CheckBoxFigure) refreshableFigure;
figure.setText((String) newValue);
Display.getCurrent().timerExec(10, new Runnable() {
@Override
public void run() {
if (getWidgetModel().isAutoSize())
performAutoSize(refreshableFigure);
}
});
return true;
}
};
setPropertyChangeHandler(CheckBoxModel.PROP_LABEL, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
if ((Boolean) newValue) {
performAutoSize(figure);
figure.revalidate();
}
return true;
}
};
setPropertyChangeHandler(CheckBoxModel.PROP_AUTOSIZE, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((CheckBoxFigure) figure).setSelectedColor(getWidgetModel().getSelectedColor().getSWTColor());
return true;
}
};
setPropertyChangeHandler(CheckBoxModel.PROP_SELECTED_COLOR, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
Display.getCurrent().timerExec(10, new Runnable() {
@Override
public void run() {
if (getWidgetModel().isAutoSize()) {
performAutoSize(figure);
figure.revalidate();
}
}
});
return true;
}
};
setPropertyChangeHandler(CheckBoxModel.PROP_FONT, handler);
setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_STYLE, handler);
setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_WIDTH, handler);
}
use of org.eclipse.draw2d.IFigure in project yamcs-studio by yamcs.
the class GroupingContainerEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
figure.setOpaque(!(Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(GroupingContainerModel.PROP_TRANSPARENT, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
for (AbstractWidgetModel child : getWidgetModel().getChildren()) {
child.setEnabled((Boolean) newValue);
}
return true;
}
};
setPropertyChangeHandler(AbstractWidgetModel.PROP_ENABLED, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
lockChildren((Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(GroupingContainerModel.PROP_LOCK_CHILDREN, handler);
lockChildren(getWidgetModel().isLocked());
if (getWidgetModel().getParent() instanceof TabModel) {
removeAllPropertyChangeHandlers(AbstractWidgetModel.PROP_VISIBLE);
IWidgetPropertyChangeHandler visibilityHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
boolean visible = (Boolean) newValue;
final IFigure figure = getFigure();
figure.setVisible(visible);
return true;
}
};
setPropertyChangeHandler(AbstractWidgetModel.PROP_VISIBLE, visibilityHandler);
}
IWidgetPropertyChangeHandler showBarHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
((GroupingContainerFigure) refreshableFigure).setShowScrollBar((Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(GroupingContainerModel.PROP_SHOW_SCROLLBAR, showBarHandler);
IWidgetPropertyChangeHandler fowardColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
if (getWidgetModel().isForwardColors())
forwardColors();
return true;
}
};
setPropertyChangeHandler(GroupingContainerModel.PROP_FORWARD_COLORS, fowardColorHandler);
setPropertyChangeHandler(GroupingContainerModel.PROP_COLOR_BACKGROUND, fowardColorHandler);
setPropertyChangeHandler(GroupingContainerModel.PROP_COLOR_FOREGROUND, fowardColorHandler);
// use property listener because it doesn't need to be queued in GUIRefreshThread.
getWidgetModel().getProperty(AbstractWidgetModel.PROP_WIDTH).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
resizeChildren((Integer) (evt.getNewValue()), (Integer) (evt.getOldValue()), true);
}
});
getWidgetModel().getProperty(AbstractWidgetModel.PROP_HEIGHT).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
resizeChildren((Integer) (evt.getNewValue()), (Integer) (evt.getOldValue()), false);
}
});
}
Aggregations