}
/** Hide/show proxy panels for selected hosts. */
public void setProxyPanels(final boolean wizard) {
final Collection<Host> visible = new HashSet<Host>();
final Widget insidePortCB;
final Widget outsidePortCB;
final Widget portCB;
if (wizard) {
insidePortCB = insidePortComboBoxWizard;
outsidePortCB = insidePortComboBoxWizard;
portCB = portComboBoxWizard;
} else {
insidePortCB = insidePortComboBox;
outsidePortCB = insidePortComboBox;
portCB = portComboBox;
}
for (final Host host : getHosts()) {
final Host proxyHost = getProxyHost(host, wizard);
if (proxyHost != null) {
visible.add(proxyHost);
}
}
visible.addAll(selectedProxyHosts);
final boolean isProxy = !visible.isEmpty();
for (final Host pHost : getCluster().getProxyHosts()) {
final String section = Tools.getString("ResourceInfo.Proxy") + pHost.getName();
enableSection(section, visible.contains(pHost), wizard);
}
enableSection(SECTION_PROXY, isProxy, wizard);
enableSection(SECTION_PROXY_PORTS, isProxy, wizard);
final String portLabel;
if (isProxy) {
if (insidePortCB.isNew()
&& (savedInsidePort == null || savedInsidePort.isNothingSelected())) {
insidePortCB.setValue(new StringValue(Integer.toString(getDefaultInsidePort())));
}
if (outsidePortCB.isNew()
&& (savedOutsidePort == null || savedOutsidePort.isNothingSelected())) {
outsidePortCB.setValue(savedPort);
}
portLabel = Tools.getString("ResourceInfo.NetInterfacePortToProxy");
globalInfo.enableProxySection(wizard); /* never disable */
} else {
portLabel = Tools.getString("ResourceInfo.NetInterfacePort");
}
portCB.getLabel().setText(portLabel);
final Widget protocolWi = getWidget(DrbdXml.PROTOCOL_PARAM, Widget.WIZARD_PREFIX);
final Widget pingTimeoutWi = getWidget(DrbdXml.PING_TIMEOUT_PARAM, Widget.WIZARD_PREFIX);
final DrbdXml dxml = getBrowser().getDrbdXml();
if (protocolWi != null && getResource().isNew()) {
if (isProxy) {
protocolWi.setValue(PROXY_DEFAULT_PROTOCOL);
pingTimeoutWi.setValue(PROXY_DEFAULT_PING_TIMEOUT);
} else {
protocolWi.setValue(dxml.getParamPreferred(DrbdXml.PROTOCOL_PARAM));
pingTimeoutWi.setValue(dxml.getParamDefault(DrbdXml.PING_TIMEOUT_PARAM));
}
}
}