/**
* Updates the various links and buttons according to the interface type and
* whether there is a users logged in.
*/
void updateLinks(InterfaceType type) {
LoginResult loginResult = PortalControl.getInstance().getLoginResult();
List<Widget> widgets = new ArrayList<Widget>();
List<Widget> widgets2 = new ArrayList<Widget>();
if ( loginResult != null ) {
accountLink.setText(loginResult.getUserName());
}
else if ( type != InterfaceType.USER_ACCOUNT ) {
accountLink.setText("Create account");
}
boolean editing = false;
switch ( type ) {
case BROWSE:
widgets2.add(searchLink);
break;
case ONTOLOGY_VIEW:
case USER_ACCOUNT:
case ENTITY_VIEW:
case ENTITY_NOT_FOUND:
case ADMIN:
widgets2.add(browseLink);
widgets2.add(searchLink);
break;
case SEARCH:
widgets2.add(browseLink);
break;
case ONTOLOGY_EDIT_NEW_VERSION:
case ONTOLOGY_EDIT_NEW:
editing = true;
break;
}
widgets.add(helpButton);
widgets.add(touButton);
if ( loginResult == null ) {
if ( type != InterfaceType.USER_ACCOUNT ) {
accountLink.setText("Create account");
widgets.add(accountLink);
widgets.add(signInLink);
}
}
else {
if ( editing ) {
// note, just a label, not a clickable thing
widgets.add(new Label(loginResult.getUserName()));
}
else {
widgets.add(accountLink);
widgets.add(signOutLink);
}