Search in sources :

Example 1 with ModelChangeAttributeAction

use of com.cburch.draw.actions.ModelChangeAttributeAction in project logisim-evolution by reds-heig.

the class AttrTableSelectionModel method setValueRequested.

@Override
public void setValueRequested(Attribute<Object> attr, Object value) throws AttrTableSetException {
    SelectionAttributes attrs = (SelectionAttributes) getAttributeSet();
    Map<AttributeMapKey, Object> oldVals;
    oldVals = new HashMap<AttributeMapKey, Object>();
    Map<AttributeMapKey, Object> newVals;
    newVals = new HashMap<AttributeMapKey, Object>();
    for (Map.Entry<AttributeSet, CanvasObject> ent : attrs.entries()) {
        AttributeMapKey key = new AttributeMapKey(attr, ent.getValue());
        oldVals.put(key, ent.getKey().getValue(attr));
        newVals.put(key, value);
    }
    CanvasModel model = canvas.getModel();
    canvas.doAction(new ModelChangeAttributeAction(model, oldVals, newVals));
    fireTitleChanged();
}
Also used : AttributeMapKey(com.cburch.draw.model.AttributeMapKey) CanvasObject(com.cburch.draw.model.CanvasObject) AttributeSet(com.cburch.logisim.data.AttributeSet) CanvasObject(com.cburch.draw.model.CanvasObject) CanvasModel(com.cburch.draw.model.CanvasModel) ModelChangeAttributeAction(com.cburch.draw.actions.ModelChangeAttributeAction) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ModelChangeAttributeAction (com.cburch.draw.actions.ModelChangeAttributeAction)1 AttributeMapKey (com.cburch.draw.model.AttributeMapKey)1 CanvasModel (com.cburch.draw.model.CanvasModel)1 CanvasObject (com.cburch.draw.model.CanvasObject)1 AttributeSet (com.cburch.logisim.data.AttributeSet)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1