public void dbAttributeAdded(AttributeEvent e) { rebuildTable((DbEntity) e.getEntity()); table.select(e.getAttribute()); }
/** Creates a Attribute name change event.*/ public AttributeEvent(Object src, Attribute attr, Entity entity, String oldName) { this(src, attr, entity); setOldName(oldName); }
/** Creates a Attribute change event. */ public AttributeEvent(Object src, Attribute attr, Entity entity) { super(src, entity); setAttribute(attr); }
private void handleAttributeUpdate(AttributeEvent e) { if ((e == null) || (e.getEntity() != this)) { Attribute attr = e.getAttribute(); if ((attr == null) && (this.attributes.isEmpty())) { this.primaryKey.clear(); if (e.getId() == AttributeEvent.CHANGE && e.isNameChange()) { String oldName = e.getOldName(); String newName = e.getNewName(); switch (e.getId()) { case MapEvent.ADD: this.primaryKey.add(attr); switch (e.getId()) { case MapEvent.ADD: this.generatedAttributes.add(attr);
/** * Adds a new attribute to this entity. * * @throws IllegalArgumentException if Attribute has no name or there is an existing attribute * with the same name * @throws IllegalArgumentException if a relationship has the same name as this attribute * @since 3.0 */ public void addAttribute(DbAttribute attr) { super.addAttribute(attr); this.dbAttributeAdded(new AttributeEvent(this, attr, this, MapEvent.ADD)); }
public void removeObjAttributes(ObjEntity entity, ObjAttribute[] attribs) { ProjectController mediator = getProjectController(); for (ObjAttribute attrib : attribs) { entity.removeAttribute(attrib.getName()); AttributeEvent e = new AttributeEvent( Application.getFrame(), attrib, entity, MapEvent.REMOVE); mediator.fireObjAttributeEvent(e); Collection<ObjEntity> objEntities = ProjectUtil.getCollectionOfChildren((ObjEntity) e.getEntity()); for (ObjEntity objEntity: objEntities) { objEntity.removeAttributeOverride(e.getAttribute().getName()); } } }
AttributeEvent e = new AttributeEvent(eventSource, attr, entity); e.setOldName(attr.getName()); attr.setName((String) newVal); ((DbEntity) attr.getEntity()).dbAttributeChanged(e);
public void objAttributeChanged(AttributeEvent e) { ObjAttributeTableModel model = (ObjAttributeTableModel) table.getModel(); if (!model.isValid()) { model.resetModel(); } model.fireTableDataChanged(); int ind = -1; List<ObjAttributeWrapper> list = model.getObjectList(); for (int i = 0; i < list.size(); i++) { if (list.get(i).getValue() == e.getAttribute()) { ind = i; } } table.select(ind); if (e.getOldName() != null) { removeDuplicateAttribute(e); } }
/** Attribute property changed. */ public void dbAttributeChanged(AttributeEvent e) { Entity entity = e.getEntity(); if (entity instanceof DbEntity) { ((DbEntity) entity).dbAttributeChanged(e); } }
public void dbAttributeChanged(AttributeEvent e) { table.select(e.getAttribute()); }
/** Notifies all listeners of the change(add, remove) and does the change. */ public void fireDbAttributeEvent(AttributeEvent e) { setDirty(true); for (EventListener listener : listenerList.getListeners(DbAttributeListener.class)) { DbAttributeListener temp = (DbAttributeListener) listener; switch (e.getId()) { case MapEvent.ADD: temp.dbAttributeAdded(e); break; case MapEvent.CHANGE: temp.dbAttributeChanged(e); break; case MapEvent.REMOVE: temp.dbAttributeRemoved(e); break; default: throw new IllegalArgumentException("Invalid AttributeEvent type: " + e.getId()); } } }
/** Creates a Attribute event of a specified type. */ public AttributeEvent(Object src, Attribute attr, Entity entity, int id) { this(src, attr, entity); setId(id); }
private void handleAttributeUpdate(AttributeEvent e) { if (e == null || e.getEntity() != this) { Attribute attribute = e.getAttribute(); if (attribute == null && this.attributes.isEmpty()) { this.primaryKey.clear(); if (e.getId() == AttributeEvent.CHANGE && e.isNameChange()) { String oldName = e.getOldName(); String newName = e.getNewName(); switch (e.getId()) { case MapEvent.ADD: this.primaryKey.add(dbAttribute); switch (e.getId()) { case MapEvent.ADD: this.generatedAttributes.add(dbAttribute);
@Override public void clearAttributes() { super.clearAttributes(); // post dummy event for no specific attribute this.dbAttributeRemoved(new AttributeEvent(this, null, this, MapEvent.REMOVE)); }
@Override public void setUpdatedValueAt(Object value, int row, int column) { ObjAttributeWrapper attribute = getAttribute(row); attribute.resetEdits(); AttributeEvent event = new AttributeEvent(eventSource, attribute.getValue(), entity); if (column == OBJ_ATTRIBUTE) { event.setOldName(attribute.getName()); setObjAttribute(attribute, value); fireTableCellUpdated(row, column); } else if (column == OBJ_ATTRIBUTE_TYPE) { setObjAttributeType(attribute, value); fireTableCellUpdated(row, column); } else if (column == LOCKING) { setColumnLocking(attribute, value); fireTableCellUpdated(row, column); } else { if (column == DB_ATTRIBUTE) { setDbAttribute(attribute, value); } fireTableRowsUpdated(row, row); } mediator.fireObjAttributeEvent(event); }
public void objAttributeChanged(AttributeEvent e) { updateEntityCell(e.getEntity()); }
public void dbAttributeRemoved(AttributeEvent e) { DbAttributeTableModel model = (DbAttributeTableModel) table.getModel(); int ind = model.getObjectList().indexOf(e.getAttribute()); model.removeRow(e.getAttribute()); table.select(ind); }
/** Notifies all listeners of the change (add, remove) and does the change. */ public void fireObjAttributeEvent(AttributeEvent e) { setDirty(true); for (EventListener listener : listenerList.getListeners(ObjAttributeListener.class)) { ObjAttributeListener temp = (ObjAttributeListener) listener; switch (e.getId()) { case MapEvent.ADD: temp.objAttributeAdded(e); break; case MapEvent.CHANGE: temp.objAttributeChanged(e); break; case MapEvent.REMOVE: temp.objAttributeRemoved(e); break; default: throw new IllegalArgumentException("Invalid AttributeEvent type: " + e.getId()); } } }
/** Creates a Attribute event of a specified type. */ public AttributeEvent(Object src, Attribute attr, Entity entity, int id) { this(src, attr, entity); setId(id); }
/** * Updates attribute "primaryKey" property. */ public void setPrimaryKey(boolean primaryKey) { if (this.primaryKey != primaryKey) { this.primaryKey = primaryKey; Entity e = this.getEntity(); if (e instanceof DbAttributeListener) { ((DbAttributeListener) e).dbAttributeChanged(new AttributeEvent(this, this, e)); } } }