use of org.eclipse.draw2d.IFigure in project yamcs-studio by yamcs.
the class AbstractContainerEditpart method registerBasePropertyChangeHandlers.
@Override
protected void registerBasePropertyChangeHandlers() {
super.registerBasePropertyChangeHandlers();
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
MacrosInput macrosInput = (MacrosInput) newValue;
LinkedHashMap<String, String> macrosMap = new LinkedHashMap<String, String>();
if (macrosInput.isInclude_parent_macros()) {
macrosMap.putAll(getWidgetModel().getParentMacroMap());
}
macrosMap.putAll(macrosInput.getMacrosMap());
getWidgetModel().setMacroMap(macrosMap);
return false;
}
};
setPropertyChangeHandler(AbstractContainerModel.PROP_MACROS, handler);
layout();
childrenPropertyChangeListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getOldValue() instanceof Integer) {
addChild(createChild(evt.getNewValue()), ((Integer) evt.getOldValue()).intValue());
layout();
} else if (evt.getOldValue() instanceof AbstractWidgetModel) {
EditPart child = (EditPart) getViewer().getEditPartRegistry().get(evt.getOldValue());
if (child != null) {
removeChild(child);
layout();
}
} else
refreshChildren();
}
};
getWidgetModel().getChildrenProperty().addPropertyChangeListener(childrenPropertyChangeListener);
if (getExecutionMode() == ExecutionMode.EDIT_MODE) {
selectionPropertyChangeListener = new PropertyChangeListener() {
@SuppressWarnings("unchecked")
@Override
public void propertyChange(PropertyChangeEvent evt) {
List<AbstractWidgetModel> widgets = (List<AbstractWidgetModel>) evt.getNewValue();
List<EditPart> widgetEditparts = new ArrayList<EditPart>();
for (AbstractWidgetModel w : widgets) {
EditPart e = (EditPart) getViewer().getEditPartRegistry().get(w);
if (e != null)
widgetEditparts.add(e);
}
if (!(Boolean) evt.getOldValue()) {
// append
getViewer().deselectAll();
}
for (EditPart editpart : widgetEditparts) {
if (editpart.isSelectable())
getViewer().appendSelection(editpart);
}
}
};
getWidgetModel().getSelectionProperty().addPropertyChangeListener(selectionPropertyChangeListener);
}
}
use of org.eclipse.draw2d.IFigure in project yamcs-studio by yamcs.
the class DisplayEditpart method doCreateFigure.
@Override
protected IFigure doCreateFigure() {
Figure f = new FreeformLayer() {
@Override
protected void paintFigure(Graphics graphics) {
super.paintFigure(graphics);
if (getExecutionMode() == ExecutionMode.EDIT_MODE && ((DisplayModel) getModel()).isShowEditRange()) {
graphics.pushState();
graphics.setLineStyle(SWT.LINE_DASH);
graphics.setForegroundColor(ColorConstants.black);
graphics.drawRectangle(new Rectangle(new Point(0, 0), getWidgetModel().getSize()));
graphics.popState();
}
}
};
// f.setBorder(new MarginBorder(3));
f.setLayoutManager(new FreeformLayout());
return f;
}
use of org.eclipse.draw2d.IFigure in project yamcs-studio by yamcs.
the class PVWidgetEditpartDelegate method setControlEnabled.
/**
* Set whether the editpart is enabled for PV control. Disabled
* editparts have greyed-out figures, and the cursor is set to a cross.
*/
@Override
public void setControlEnabled(boolean enabled) {
if (enabled) {
IFigure figure = editpart.getFigure();
if (figure.getCursor() == Cursors.NO)
figure.setCursor(savedCursor);
figure.setEnabled(editpart.getWidgetModel().isEnabled());
figure.repaint();
} else {
IFigure figure = editpart.getFigure();
if (figure.getCursor() != Cursors.NO)
savedCursor = figure.getCursor();
figure.setEnabled(false);
figure.setCursor(Cursors.NO);
figure.repaint();
}
}
use of org.eclipse.draw2d.IFigure in project yamcs-studio by yamcs.
the class WidgetNodeEditPolicy method removeAnchorHandles.
/**
* removes the anchor handles
*/
protected void removeAnchorHandles() {
if (handles == null)
return;
IFigure layer = getLayer(LayerConstants.HANDLE_LAYER);
for (int i = 0; i < handles.size(); i++) layer.remove(handles.get(i));
handles = null;
}
use of org.eclipse.draw2d.IFigure in project yamcs-studio by yamcs.
the class WidgetXYLayoutEditPolicy method showSizeOnDropFeedback.
@Override
protected void showSizeOnDropFeedback(CreateRequest request) {
String typeId = determineTypeIdFromRequest(request);
IGraphicalFeedbackFactory feedbackFactory = WidgetsService.getInstance().getWidgetFeedbackFactory(typeId);
if (feedbackFactory != null) {
IFigure feedbackFigure = getSizeOnDropFeedback(request);
feedbackFactory.showSizeOnDropFeedback(request, feedbackFigure, getCreationFeedbackOffset(request));
// feedbackFigure.repaint();
} else {
super.showSizeOnDropFeedback(request);
}
}
Aggregations