public HierachicalConceptNameComboBox getToConceptComboBox() { if (toConceptComboBox == null) { toConceptComboBox = new HierachicalConceptNameComboBox(annotationPersistenceService); toConceptComboBox.setToolTipText("To Concept"); toConceptComboBox.addFocusListener( new FocusAdapter() { @Override public void focusGained(FocusEvent e) { toConceptComboBox.getEditor().selectAll(); } }); } return toConceptComboBox; }
/** * Set the selected link * * @param link */ public void setLink(final ILink link) { WaitIndicator waitIndicator = new LabeledSpinningDialWaitIndicator(this, "Loading " + link.getToConcept() + " ..."); getLinkNameTextField().setText(link.getLinkName()); getLinkValueTextField().setText(link.getLinkValue()); final HierachicalConceptNameComboBox comboBox = getToConceptComboBox(); comboBox.hidePopup(); getLinksComboBox().hidePopup(); String conceptName = link.getToConcept(); if (conceptName.equals(ILink.VALUE_NIL) || conceptName.equals(ILink.VALUE_SELF)) { SortedComboBoxModel<String> model = (SortedComboBoxModel<String>) comboBox.getModel(); model.clear(); model.addElement(conceptName); } else { // Retrieve the child concepts and add to gui try { final Concept c = (Concept) Worker.post( new Task() { @Override public Object run() throws Exception { return annotationPersistenceService.findConceptByName(link.getToConcept()); } }); comboBox.setConcept(c); conceptName = c.getPrimaryConceptName().getName(); } catch (final Exception e) { EventBus.publish(GlobalLookup.TOPIC_NONFATAL_ERROR, e); comboBox.addItem(conceptName); } } comboBox.setSelectedItem(conceptName); waitIndicator.dispose(); repaint(); }