Пример #1
0
 public void setFilesPopup(final NSPopUpButton p) {
   this.filesPopup = p;
   this.filesPopup.setTarget(this.id());
   this.filesPopup.removeAllItems();
   for (Path path : transfer.getRoots()) {
     NSMenuItem item =
         this.filesPopup
             .menu()
             .addItemWithTitle_action_keyEquivalent(
                 path.getName(), Foundation.selector("reveal:"), StringUtils.EMPTY);
     item.setRepresentedObject(path.getAbsolute());
     item.setImage(IconCache.instance().iconForPath(path, 16, false));
   }
   this.filesPopupMenuDelegate = new TransferMenuDelegate(transfer);
   this.filesPopup.menu().setDelegate(this.filesPopupMenuDelegate.id());
   NSNotificationCenter.defaultCenter()
       .addObserver(
           this.id(),
           Foundation.selector("filesPopupWillShow:"),
           NSPopUpButton.PopUpButtonWillPopUpNotification,
           this.filesPopup);
   NSNotificationCenter.defaultCenter()
       .addObserver(
           this.id(),
           Foundation.selector("filesPopupWillHide:"),
           "NSMenuDidEndTrackingNotification",
           this.filesPopup.menu());
 }
Пример #2
0
 /**
  * @param session
  * @return
  */
 public List<Path> copy(Session session) {
   List<Path> content = new ArrayList<Path>();
   for (Path path : this) {
     content.add(PathFactory.createPath(session, path.getAsDictionary()));
   }
   return content;
 }
 protected List<String> getContainers() {
   // List S3 containers
   final Session session =
       SessionFactory.createSession(
           new Host(Protocol.S3_SSL, Protocol.S3_SSL.getDefaultHostname(), host.getCredentials()));
   if (session.getHost().getCredentials().validate(session.getHost().getProtocol())) {
     List<String> buckets = new ArrayList<String>();
     for (Path bucket : session.mount().children()) {
       buckets.add(bucket.getName());
     }
     Collections.sort(buckets);
     return buckets;
   }
   return Collections.emptyList();
 }
 /**
  * @param files Files to purge
  * @param recursive Recursivly for folders
  * @return Key to files
  */
 protected List<String> getInvalidationKeys(List<Path> files, boolean recursive) {
   List<String> keys = new ArrayList<String>();
   for (Path file : files) {
     if (file.isContainer()) {
       keys.add(String.valueOf(Path.DELIMITER));
     } else {
       keys.add(file.getKey());
     }
     if (file.attributes().isDirectory()) {
       if (recursive) {
         keys.addAll(this.getInvalidationKeys(file.children(), recursive));
       }
     }
   }
   return keys;
 }
Пример #5
0
 private void init() {
   window.setTitle(host.getNickname());
   this.updateField(hostField, host.getHostname());
   hostField.setEnabled(host.getProtocol().isHostnameConfigurable());
   hostField.cell().setPlaceholderString(host.getProtocol().getDefaultHostname());
   this.updateField(nicknameField, host.getNickname());
   final String url;
   if (StringUtils.isNotBlank(host.getDefaultPath())) {
     url = host.toURL() + Path.normalize(host.getDefaultPath());
   } else {
     url = host.toURL();
   }
   urlField.setAttributedStringValue(HyperlinkAttributedStringFactory.create(url));
   this.updateField(portField, String.valueOf(host.getPort()));
   portField.setEnabled(host.getProtocol().isPortConfigurable());
   this.updateField(pathField, host.getDefaultPath());
   this.updateField(usernameField, host.getCredentials().getUsername());
   usernameField.cell().setPlaceholderString(host.getProtocol().getUsernamePlaceholder());
   usernameField.setEnabled(!host.getCredentials().isAnonymousLogin());
   anonymousCheckbox.setEnabled(host.getProtocol().isAnonymousConfigurable());
   anonymousCheckbox.setState(
       host.getCredentials().isAnonymousLogin() ? NSCell.NSOnState : NSCell.NSOffState);
   protocolPopup.selectItemAtIndex(
       protocolPopup.indexOfItemWithRepresentedObject(
           String.valueOf(host.getProtocol().hashCode())));
   if (null == host.getMaxConnections()) {
     transferPopup.selectItemWithTitle(DEFAULT);
   } else {
     transferPopup.selectItemWithTitle(
         host.getMaxConnections() == 1 ? TRANSFER_BROWSERCONNECTION : TRANSFER_NEWCONNECTION);
   }
   encodingPopup.setEnabled(host.getProtocol().isEncodingConfigurable());
   connectmodePopup.setEnabled(host.getProtocol().isConnectModeConfigurable());
   if (host.getProtocol().isConnectModeConfigurable()) {
     if (null == host.getFTPConnectMode()) {
       connectmodePopup.selectItemWithTitle(DEFAULT);
     } else if (host.getFTPConnectMode().equals(FTPConnectMode.PASV)) {
       connectmodePopup.selectItemWithTitle(CONNECTMODE_PASSIVE);
     } else if (host.getFTPConnectMode().equals(FTPConnectMode.PORT)) {
       connectmodePopup.selectItemWithTitle(CONNECTMODE_ACTIVE);
     }
   }
   pkCheckbox.setEnabled(host.getProtocol().equals(Protocol.SFTP));
   if (host.getCredentials().isPublicKeyAuthentication()) {
     pkCheckbox.setState(NSCell.NSOnState);
     this.updateField(pkLabel, host.getCredentials().getIdentity().getAbbreviatedPath());
     pkLabel.setTextColor(NSColor.textColor());
   } else {
     pkCheckbox.setState(NSCell.NSOffState);
     pkLabel.setStringValue(Locale.localizedString("No private key selected"));
     pkLabel.setTextColor(NSColor.disabledControlTextColor());
   }
   webURLField.setEnabled(host.getProtocol().isWebUrlConfigurable());
   final String webURL = host.getWebURL();
   webUrlImage.setToolTip(webURL);
   this.updateField(webURLField, host.getDefaultWebURL().equals(webURL) ? null : webURL);
   this.updateField(commentField, host.getComment());
   this.timezonePopup.setEnabled(!host.getProtocol().isUTCTimezone());
   if (null == host.getTimezone()) {
     if (host.getProtocol().isUTCTimezone()) {
       this.timezonePopup.setTitle(UTC.getID());
     } else {
       if (Preferences.instance().getBoolean("ftp.timezone.auto")) {
         this.timezonePopup.setTitle(AUTO);
       } else {
         this.timezonePopup.setTitle(
             TimeZone.getTimeZone(Preferences.instance().getProperty("ftp.timezone.default"))
                 .getID());
       }
     }
   } else {
     this.timezonePopup.setTitle(host.getTimezone().getID());
   }
 }
Пример #6
0
 public NSImage iconForPath(final Path item, final Integer size, final boolean overlay) {
   if (item.attributes().isSymbolicLink()) {
     final NSImage badge = this.iconForName("aliasbadge.tiff", size);
     badge.setName("aliasbadge");
     if (item.attributes().isDirectory()) {
       return this.iconForFolder(badge, size);
     }
     return this.iconForExtension(badge, item.getExtension(), size);
   }
   if (item.attributes().isFile()) {
     if (StringUtils.isEmpty(item.getExtension())) {
       if (item.attributes().getPermission().isExecutable()) {
         return this.iconForName("executable.tiff", size);
       }
     }
     return this.iconForExtension(item.getExtension(), size);
   }
   if (item.attributes().isVolume()) {
     return this.iconForName(item.getHost().getProtocol().disk(), size);
   }
   if (item.attributes().isDirectory()) {
     if (overlay) {
       if (!item.attributes().getPermission().isExecutable()) {
         final NSImage badge = this.iconForName("privatefolderbadge.tiff", size);
         badge.setName("privatefolderbadge");
         return this.iconForFolder(badge, size);
       }
       if (!item.attributes().getPermission().isReadable()) {
         if (item.attributes().getPermission().isWritable()) {
           final NSImage badge = this.iconForName("dropfolderbadge.tiff", size);
           badge.setName("dropfolderbadge");
           return this.iconForFolder(badge, size);
         }
       }
       if (!item.attributes().getPermission().isWritable()) {
         final NSImage badge = this.iconForName("readonlyfolderbadge.tiff", size);
         badge.setName("readonlyfolderbadge");
         return this.iconForFolder(badge, size);
       }
     }
     return this.iconForFolder(size);
   }
   return this.iconForName("notfound.tiff", size);
 }