Ejemplo n.º 1
0
 @Action
 public void protocolSelectionChanged(final NSPopUpButton sender) {
   log.debug("protocolSelectionChanged:" + sender);
   final Protocol selected =
       ProtocolFactory.forName(protocolPopup.selectedItem().representedObject());
   host.setPort(selected.getDefaultPort());
   if (!host.getProtocol().isHostnameConfigurable()) {
     // Previously selected protocol had a default hostname. Change to default
     // of newly selected protocol.
     host.setHostname(selected.getDefaultHostname());
   }
   if (!selected.isHostnameConfigurable()) {
     // Hostname of newly selected protocol is not configurable. Change to default.
     host.setHostname(selected.getDefaultHostname());
   }
   if (StringUtils.isNotBlank(selected.getDefaultHostname())) {
     // Prefill with default hostname
     host.setHostname(selected.getDefaultHostname());
   }
   if (!selected.isWebUrlConfigurable()) {
     host.setWebURL(null);
   }
   host.setProtocol(selected);
   this.itemChanged();
   this.init();
   this.reachable();
 }
Ejemplo n.º 2
0
 public void setProtocolPopup(NSPopUpButton protocolPopup) {
   this.protocolPopup = protocolPopup;
   this.protocolPopup.setEnabled(true);
   this.protocolPopup.setTarget(this.id());
   this.protocolPopup.setAction(Foundation.selector("protocolSelectionChanged:"));
   this.protocolPopup.removeAllItems();
   for (Protocol protocol : ProtocolFactory.getKnownProtocols()) {
     final String title = protocol.getDescription();
     this.protocolPopup.addItemWithTitle(title);
     final NSMenuItem item = this.protocolPopup.itemWithTitle(title);
     item.setRepresentedObject(String.valueOf(protocol.hashCode()));
     item.setImage(IconCache.iconNamed(protocol.icon(), 16));
   }
 }