}
private void addVncViewersToTheMenu(final Collection<UpdatableItem> items, final Host host) {
if (application.isUseTightvnc()) {
/* tight vnc test menu */
final UpdatableItem tightvncViewerMenu = menuFactory.createMenuItem(
getVNCMenuString("TIGHT", host),
DomainInfo.VNC_ICON,
getVNCMenuString("TIGHT", host),
new AccessMode(AccessMode.RO, AccessMode.NORMAL),
new AccessMode(AccessMode.RO, AccessMode.NORMAL))
.enablePredicate(new EnablePredicate() {
@Override
public String check() {
if (getResource().isNew()) {
return DomainInfo.NOT_APPLIED;
}
final VmsXml vmsXml = getBrowser().getVmsXml(host);
if (vmsXml == null) {
return DomainInfo.NO_VM_STATUS_STRING;
}
if (!vmsXml.isRunning(domainInfo.getDomainName())) {
return "not running";
}
return null;
}
})
.addAction(new MenuAction() {
@Override
public void run(final String text) {
domainInfo.hidePopup();
final VmsXml vxml = getBrowser().getVmsXml(host);
if (vxml != null) {
final int remotePort = vxml.getRemotePort(domainInfo.getDomainName());
final Host host = vxml.getDefinedOnHost();
if (host != null && remotePort > 0) {
application.startTightVncViewer(host, remotePort);
}
}
}
});
items.add(tightvncViewerMenu);
}
if (application.isUseUltravnc()) {
final UpdatableItem ultravncViewerMenu = menuFactory.createMenuItem(
getVNCMenuString("ULTRA", host),
DomainInfo.VNC_ICON,
getVNCMenuString("ULTRA", host),
new AccessMode(AccessMode.RO, AccessMode.NORMAL),
new AccessMode(AccessMode.RO, AccessMode.NORMAL))
.enablePredicate(new EnablePredicate() {
@Override
public String check() {
if (getResource().isNew()) {
return DomainInfo.NOT_APPLIED;
}
final VmsXml vmsXml = getBrowser().getVmsXml(host);
if (vmsXml == null) {
return DomainInfo.NO_VM_STATUS_STRING;
}
if (!vmsXml.isRunning(domainInfo.getDomainName())) {
return "not running";
}
return null;
}
})
.addAction(new MenuAction() {
@Override
public void run(final String text) {
domainInfo.hidePopup();
final VmsXml vxml = getBrowser().getVmsXml(host);
if (vxml != null) {
final int remotePort = vxml.getRemotePort(domainInfo.getDomainName());
final Host host = vxml.getDefinedOnHost();
if (host != null && remotePort > 0) {
application.startUltraVncViewer(host, remotePort);
}
}
}
});
items.add(ultravncViewerMenu);
}
if (application.isUseRealvnc()) {
final UpdatableItem realvncViewerMenu = menuFactory.createMenuItem(
getVNCMenuString("REAL", host),
DomainInfo.VNC_ICON,
getVNCMenuString("REAL", host),
new AccessMode(AccessMode.RO, AccessMode.NORMAL),
new AccessMode(AccessMode.RO, AccessMode.NORMAL))