private void myPostInit() { modelDataTypes = new HashMap<String, DataType>(); List<DataType> dataTypes = ModelHelper.getModelDataTypes(diagramManager.getCurrentProject()); for (DataType item : dataTypes) { modelDataTypes.put(item.getName(), item); } TableColumn typeColumn = table.getColumnModel().getColumn(1); typeColumn.setCellEditor(createEditor(modelDataTypes.keySet().toArray())); TableColumn typeColumn2 = table.getColumnModel().getColumn(2); typeColumn2.setCellEditor(createEditor(new String[] {"1", "0..1", "0..*", "1..*"})); table.setSurrendersFocusOnKeystroke(true); if (element instanceof DataType) { DataType dataType = (DataType) element; for (Property attribute : dataType.getAttribute()) { attributesTableModel.addEntry(attribute); } } else { Class umlclass = (Class) element; for (Property attribute : umlclass.getAttribute()) { attributesTableModel.addEntry(attribute); } } }
private void transferAddedAttributes(List<Property> classAttributes) { for (Property property : classAttributes) { if (!property.getName().isEmpty() || !property.getType().getName().isEmpty()) { DataType existingType = modelDataTypes.get(property.getType().getName().trim()); if (existingType != null) { property.setType(existingType); } if (element instanceof DataType) { ((DataType) element).getOwnedAttribute().add(property); } else { ((Class) element).getOwnedAttribute().add(property); } diagramManager.updateOLEDFromInclusion(property); } } }
private void deleteAttributes(List<Property> classAttributes) { ArrayList<Property> attributes = new ArrayList<Property>(); if (element instanceof DataType) { attributes.addAll(((DataType) element).getOwnedAttribute()); for (Property p : attributes) { if (!classAttributes.contains(p)) { ((DataType) element).getOwnedAttribute().remove(p); diagramManager.updateOLEDFromDeletion(p); } } } if (element instanceof RefOntoUML.Class) { attributes.addAll(((RefOntoUML.Class) element).getOwnedAttribute()); for (Property p : attributes) { if (!classAttributes.contains(p)) { ((RefOntoUML.Class) element).getOwnedAttribute().remove(p); diagramManager.updateOLEDFromDeletion(p); } } } }