final String width = "700px";
// #194: Can't access all ontologies from VINE drop-down
// ListBox added as a fix to this issue.
final ListBox listBox = new ListBox();
// MultiWordSuggestOracle oracle = new MultiWordSuggestOracle("/ :");
// A map from a suggestion to its corresponding RegisteredOntologyInfo:
final Map<String,RegisteredOntologyInfo> suggestions = new HashMap<String,RegisteredOntologyInfo>();
List<BaseOntologyInfo> allUris = VineMain.getAllUris();
for ( int index = 0, count = allUris.size(); index < count; index++ ) {
BaseOntologyInfo ontologyInfo = allUris.get(index);
if ( VineMain.containsWorkingUri(ontologyInfo.getUri()) ) {
// do not add any suggestion for an entry that is already in the workingUris
continue;
}
if ( ! (ontologyInfo instanceof RegisteredOntologyInfo)) {
// only add suggestions for registered ontologies
continue;
}
RegisteredOntologyInfo registeredOntologyInfo = (RegisteredOntologyInfo) ontologyInfo;
String lab = ontologyInfo.getDisplayLabel();
String uri = ontologyInfo.getUri();
// // include a star as a convenience to see the whole list if the user types in a star:
// String suggestion = "* " +uri+ " : " +lab;
String suggestion = uri;
listBox.addItem(uri+ " : " +lab, suggestion);
suggestions.put(suggestion, registeredOntologyInfo);
// oracle.add(suggestion);
}
// final SuggestBox box = new SuggestBox(oracle);
// box.setWidth(width);
CellPanel hp = new VerticalPanel();
final MyDialog popup = new MyDialog(hp) {
public boolean onKeyUpPreview(char key, int modifiers) {
if ( key == KeyboardListener.KEY_ESCAPE ) {
hide();
return false;
}
return true;
}
};
hp.add(new TLabel("Ontology URI:",
"Select or enter the URL of the ontology you want to include in the list of working ontologies. " +
"<br/>" +
"As you type, URIs are displayed according to matching components in the " +
"URI or the associated title."
));
// hp.add(box);
// box.addEventHandler(new SuggestionHandler() {
// public void onSuggestionSelected(SuggestionEvent event) {
// String suggestion = event.getSelectedSuggestion().getReplacementString();
// RegisteredOntologyInfo ontologyInfo = suggestions.get(suggestion);
// mainPanel.notifyWorkingOntologyAdded(OntologySelection.this, ontologyInfo, popup);
// }
// });
final TextBox textBox = createTextBox(suggestions, listBox, popup);
textBox.setWidth(width);
hp.add(textBox);
// // we use the star (*) to show the whole list of vocabs. If the user enters something
// // different, then remove the star:
// box.addKeyboardListener(new KeyboardListener() {
// public void onKeyPress(Widget sender, char keyCode, int modifiers) {
// // FIXME: if the user wants to use the down arrow to pick a suggestion after
// // entering *, it cannot do it!
// if ( keyCode != '*' && box.getText().trim().equals("*") ) {
// box.setText("");
// }
// }
// public void onKeyDown(Widget sender, char keyCode, int modifiers) {}
//
// public void onKeyUp(Widget sender, char keyCode, int modifiers) {
// if ( keyCode == KeyboardListener.KEY_ENTER ) {
// String selectedUri = box.getText().trim();
// Orr.log("addVocabulary: ENTER: '" + selectedUri + "'");
// if (selectedUri.length() > 0) {
// if ( VineMain.containsWorkingUri(selectedUri) ) {
// // ignore the Enter
// return;
// }
// BaseOntologyInfo ontologyInfo = VineMain.getOntologyInfo(selectedUri);
// if (ontologyInfo instanceof RegisteredOntologyInfo) {
// // It is a registered ontology -- load it as a working one:
// RegisteredOntologyInfo roi = (RegisteredOntologyInfo) ontologyInfo;
// mainPanel.notifyWorkingOntologyAdded(OntologySelection.this, roi, popup);
// }
// else {
// // try as an external ontology:
// OntologySelection.this.mainPanel.addExternalOntology(selectedUri, popup);
// }
// }
// }
// }
// });
popup.setText("Select an ontology");
// hp.add(new HTML("Elements are displayed as you type. Enter * to see the full list."));
listBox.setWidth(width);
listBox.setVisibleItemCount(Math.min(listBox.getItemCount() + 2, 12));
hp.add(listBox);
// listBox.addChangeListener(new ChangeListener () {
// public void onChange(Widget sender) {
// String value = listBox.getValue(listBox.getSelectedIndex());