use of org.csstudio.opibuilder.model.AbstractWidgetModel in project yamcs-studio by yamcs.
the class ContainerTreeEditpart method activate.
@Override
public void activate() {
super.activate();
childrenPropertyChangeListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getOldValue() instanceof Integer) {
addChild(createChild(evt.getNewValue()), ((Integer) evt.getOldValue()).intValue());
} else if (evt.getOldValue() instanceof AbstractWidgetModel) {
EditPart child = (EditPart) getViewer().getEditPartRegistry().get(evt.getOldValue());
if (child != null)
removeChild(child);
} else
refreshChildren();
refreshVisuals();
}
};
getWidgetModel().getChildrenProperty().addPropertyChangeListener(childrenPropertyChangeListener);
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel in project yamcs-studio by yamcs.
the class WidgetNodeEditPolicy method getReconnectSourceCommand.
@Override
protected Command getReconnectSourceCommand(ReconnectRequest request) {
ConnectionModel connection = (ConnectionModel) request.getConnectionEditPart().getModel();
AbstractWidgetModel newSource = getWidgetEditPart().getWidgetModel();
ConnectionAnchor anchor = getWidgetEditPart().getTargetConnectionAnchor(request);
String newTerminal = getWidgetEditPart().getTerminalNameFromAnchor(anchor);
ConnectionReconnectCommand cmd = new ConnectionReconnectCommand(connection);
cmd.setNewSource(newSource);
cmd.setNewSourceTerminal(newTerminal);
// clear point list
return cmd.chain(new SetWidgetPropertyCommand(connection, ConnectionModel.PROP_POINTS, new PointList()));
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel in project yamcs-studio by yamcs.
the class WidgetXYLayoutEditPolicy method createAddCommand.
@SuppressWarnings("deprecation")
@Override
protected Command createAddCommand(EditPart child, Object constraint) {
if (!(child instanceof AbstractBaseEditPart) || !(constraint instanceof Rectangle))
return super.createAddCommand(child, constraint);
AbstractContainerModel container = (AbstractContainerModel) getHost().getModel();
AbstractWidgetModel widget = (AbstractWidgetModel) child.getModel();
CompoundCommand result = new CompoundCommand("Adding widgets to container");
result.add(new AddWidgetCommand(container, widget, (Rectangle) constraint));
return result;
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel in project yamcs-studio by yamcs.
the class WidgetXYLayoutEditPolicy method determineTypeIdFromRequest.
/**
* Creates a prototype object to determine the type identification of the
* widget model, that is about to be created.
*
* @param request
* the create request
* @return the type identification
*/
@SuppressWarnings("rawtypes")
private String determineTypeIdFromRequest(final CreateRequest request) {
Class newObject = (Class) request.getNewObjectType();
AbstractWidgetModel instance;
// $NON-NLS-1$
String typeId = "";
try {
instance = (AbstractWidgetModel) newObject.newInstance();
typeId = instance.getTypeID();
} catch (Exception e) {
// $NON-NLS-1$
OPIBuilderPlugin.getLogger().log(Level.WARNING, "Unknown type", e);
}
return typeId;
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel in project yamcs-studio by yamcs.
the class XMLUtil method XMLElementToWidgetSub.
private static AbstractWidgetModel XMLElementToWidgetSub(Element element, DisplayModel displayModel, List<IPath> trace, final MacrosInput macrosInput_) throws Exception {
if (element == null)
return null;
AbstractWidgetModel result = null;
if (WIDGET_TAGS.contains(element.getName())) {
result = fillWidgets(element, displayModel);
if (result instanceof AbstractContainerModel)
fillLinkingContainersSub((AbstractContainerModel) result, trace, macrosInput_);
fillConnections(element, displayModel);
return result;
} else {
String errorMessage = "Unknown Tag: " + element.getName();
ConsoleService.getInstance().writeError(errorMessage);
return null;
}
}
Aggregations