Search in sources :

Example 76 with AbstractWidgetModel

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);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) PropertyChangeListener(java.beans.PropertyChangeListener) RootEditPart(org.eclipse.gef.RootEditPart) EditPart(org.eclipse.gef.EditPart)

Example 77 with AbstractWidgetModel

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()));
}
Also used : SetWidgetPropertyCommand(org.csstudio.opibuilder.commands.SetWidgetPropertyCommand) PointList(org.eclipse.draw2d.geometry.PointList) ConnectionAnchor(org.eclipse.draw2d.ConnectionAnchor) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) ConnectionModel(org.csstudio.opibuilder.model.ConnectionModel) ConnectionReconnectCommand(org.csstudio.opibuilder.commands.ConnectionReconnectCommand)

Example 78 with AbstractWidgetModel

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;
}
Also used : AbstractContainerModel(org.csstudio.opibuilder.model.AbstractContainerModel) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) AbstractBaseEditPart(org.csstudio.opibuilder.editparts.AbstractBaseEditPart) PrecisionRectangle(org.eclipse.draw2d.geometry.PrecisionRectangle) Rectangle(org.eclipse.draw2d.geometry.Rectangle) AddWidgetCommand(org.csstudio.opibuilder.commands.AddWidgetCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 79 with AbstractWidgetModel

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;
}
Also used : AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel)

Example 80 with AbstractWidgetModel

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;
    }
}
Also used : AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) AbstractContainerModel(org.csstudio.opibuilder.model.AbstractContainerModel)

Aggregations

AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)82 AbstractContainerModel (org.csstudio.opibuilder.model.AbstractContainerModel)27 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)22 Rectangle (org.eclipse.draw2d.geometry.Rectangle)18 AbstractBaseEditPart (org.csstudio.opibuilder.editparts.AbstractBaseEditPart)17 ArrayList (java.util.ArrayList)15 Point (org.eclipse.draw2d.geometry.Point)14 SetWidgetPropertyCommand (org.csstudio.opibuilder.commands.SetWidgetPropertyCommand)12 ConnectionModel (org.csstudio.opibuilder.model.ConnectionModel)10 DisplayModel (org.csstudio.opibuilder.model.DisplayModel)9 IFigure (org.eclipse.draw2d.IFigure)9 PropertyChangeEvent (java.beans.PropertyChangeEvent)8 PropertyChangeListener (java.beans.PropertyChangeListener)8 Dimension (org.eclipse.draw2d.geometry.Dimension)8 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)7 EditPart (org.eclipse.gef.EditPart)7 PointList (org.eclipse.draw2d.geometry.PointList)6 List (java.util.List)5 AddWidgetCommand (org.csstudio.opibuilder.commands.AddWidgetCommand)5 WidgetCreateCommand (org.csstudio.opibuilder.commands.WidgetCreateCommand)5