public RelationshipInstance(String name, RequiredPortInstance requiredEnd, ProvidedPortInstance providedEnd, Relationship type) { super(name); this.owner = new OptionalOwner<Deployment>(); setRequiredEnd(requiredEnd); setProvidedEnd(providedEnd); setType(type); }
public String selectClientPortInstance(RelationshipInstance bi) { JPanel panel = new JPanel(); panel.add(new JLabel("Please make a selection:")); DefaultComboBoxModel model = new DefaultComboBoxModel(); for (ComponentInstance ai : dm.getComponentInstances()) { if (ai instanceof InternalComponentInstance) { for (RequiredPortInstance ci : ((InternalComponentInstance) ai).getRequiredPorts()) { System.out.println(bi.getType().getRequiredEnd() + " #### " + ci.getType()); if (ci.getType().equals(bi.getType().getRequiredEnd())) { model.addElement(ci); } } } } JComboBox comboBox = new JComboBox(model); panel.add(comboBox); int result = JOptionPane.showConfirmDialog(null, panel, "RequiredPort", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); switch (result) { case JOptionPane.OK_OPTION: bi.setRequiredEnd((RequiredPortInstance) comboBox.getSelectedItem()); return ((RequiredPortInstance) comboBox.getSelectedItem()).getOwner().getName(); } return ""; }
private void addRelationships() { addedRelationships = new ArrayList<RelationshipInstance>(targetDM.getRelationshipInstances()); addedRelationships.removeAll(matchingRelationships.values()); for (RelationshipInstance ni : addedRelationships) { int i = currentDM.getComponentInstances().toList().indexOf(ni.getRequiredEnd().getOwner().get()); if (i >= 0) { ComponentInstance a = currentDM.getComponentInstances().toList().get(i); if (a.isInternal()) { int j = ((InternalComponentInstance) a).getRequiredPorts().toList().indexOf(ni.getRequiredEnd()); ni.setRequiredEnd(((InternalComponentInstance) a).getRequiredPorts().toList().get(j)); } } i = currentDM.getComponentInstances().toList().indexOf(ni.getProvidedEnd().getOwner().get()); if (i >= 0) { ComponentInstance a = currentDM.getComponentInstances().toList().get(i); int j = a.getProvidedPorts().toList().indexOf(ni.getProvidedEnd()); List<ProvidedPortInstance> l = a.getProvidedPorts().toList(); ni.setProvidedEnd(l.get(j)); } } }