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 transferDataTypes() { List<Property> classAttributes = attributesTableModel.getEntries(); ArrayList<Element> createdList = new ArrayList<Element>(); for (Property property : classAttributes) { // Avoid the creation of duplicated types if (modelDataTypes.keySet().contains(property.getType().getName().trim()) == false) { UmlProject project = diagramManager.getCurrentProject(); AddCommand cmd = new AddCommand( project.getEditingDomain(), project.getModel().getPackagedElement(), property.getType()); project.getEditingDomain().getCommandStack().execute(cmd); modelDataTypes.put(property.getType().getName(), (DataType) property.getType()); createdList.add((Element) property.getType()); } } for (Element element : createdList) diagramManager.updateOLEDFromInclusion(element); }
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); } } } }
public void transferGenData() { boolean redesign = false; RefOntoUML.Type general = (RefOntoUML.Type) ((OntoUMLElement) generalCombo.getSelectedItem()).getElement(); if (general != null && !general.equals(element.getGeneral())) redesign = true; element.setGeneral((Classifier) general); RefOntoUML.Type specific = (RefOntoUML.Type) ((OntoUMLElement) specificCombo.getSelectedItem()).getElement(); if (specific != null && !specific.equals(element.getSpecific())) redesign = true; element.setSpecific((Classifier) specific); diagramManager.updateOLEDFromModification(element, redesign); }
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); } } }
public void transferAttributesData() { List<Property> classAttributes = attributesTableModel.getEntries(); if (cbxVisible.isSelected() == false) { if (classAttributes.size() > 0) { cbxVisible.setSelected(true); } } if (classElement != null) classElement.setShowAttributes(cbxVisible.isSelected()); diagramManager.updateOLEDFromInclusion(element); transferDataTypes(); deleteAttributes(classAttributes); transferAddedAttributes(classAttributes); classElement.reinitAttributesCompartment(); classElement.invalidate(); }
@SuppressWarnings({"unchecked", "rawtypes"}) public void setInitialData() { ArrayList<OntoUMLElement> generallist = new ArrayList<OntoUMLElement>(); ArrayList<OntoUMLElement> specificlist = new ArrayList<OntoUMLElement>(); OntoUMLElement generalValue = null; OntoUMLElement specificValue = null; OntoUMLParser refparser = diagramManager.getFrame().getBrowserManager().getProjectBrowser().getParser(); if (element.getGeneral() != null) generalValue = new OntoUMLElement(element.getGeneral(), ""); else generalValue = new OntoUMLElement(null, ""); if (element.getSpecific() != null) specificValue = new OntoUMLElement(element.getSpecific(), ""); else specificValue = new OntoUMLElement(null, ""); for (RefOntoUML.Type t : refparser.getAllInstances(RefOntoUML.Type.class)) { if (t instanceof RefOntoUML.Class || t instanceof RefOntoUML.DataType || t instanceof RefOntoUML.Association) { if (((OntoUMLElement) generalValue).getElement() != null && t.equals(((OntoUMLElement) generalValue).getElement())) generallist.add((OntoUMLElement) generalValue); else generallist.add(new OntoUMLElement(t, "")); if (((OntoUMLElement) specificValue).getElement() != null && t.equals(((OntoUMLElement) specificValue).getElement())) specificlist.add((OntoUMLElement) specificValue); else specificlist.add(new OntoUMLElement(t, "")); } } if (((OntoUMLElement) generalValue).getElement() == null) generallist.add((OntoUMLElement) generalValue); else if (!refparser.getAllInstances(RefOntoUML.Type.class).contains(element.getGeneral())) generallist.add((OntoUMLElement) generalValue); if (((OntoUMLElement) specificValue).getElement() == null) specificlist.add((OntoUMLElement) specificValue); else if (!refparser.getAllInstances(RefOntoUML.Type.class).contains(element.getSpecific())) specificlist.add((OntoUMLElement) specificValue); Collections.sort(generallist, new CustomComparator()); Collections.sort(specificlist, new CustomComparator()); generalCombo.setModel(new DefaultComboBoxModel(generallist.toArray())); generalCombo.setSelectedItem(generalValue); specificCombo.setModel(new DefaultComboBoxModel(specificlist.toArray())); specificCombo.setSelectedItem(specificValue); }