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());
 }
 public void setAlertIcon(NSButton alertIcon) {
   this.alertIcon = alertIcon;
   this.alertIcon.setEnabled(false);
   this.alertIcon.setImage(null);
   this.alertIcon.setTarget(this.id());
   this.alertIcon.setAction(Foundation.selector("launchNetworkAssistant:"));
 }
  public void setDownloadPathPopup(NSPopUpButton downloadPathPopup) {
    this.downloadPathPopup = downloadPathPopup;
    this.downloadPathPopup.setTarget(this.id());
    final Selector action = Foundation.selector("downloadPathPopupClicked:");
    this.downloadPathPopup.setAction(action);
    this.downloadPathPopup.removeAllItems();

    // Default download folder
    this.addDownloadPath(action, host.getDownloadFolder());
    this.downloadPathPopup.menu().addItem(NSMenuItem.separatorItem());
    this.addDownloadPath(
        action,
        LocalFactory.createLocal(Preferences.instance().getProperty("queue.download.folder")));
    // Shortcut to the Desktop
    this.addDownloadPath(action, LocalFactory.createLocal("~/Desktop"));
    // Shortcut to user home
    this.addDownloadPath(action, LocalFactory.createLocal("~"));
    // Shortcut to user downloads for 10.5
    this.addDownloadPath(action, LocalFactory.createLocal("~/Downloads"));
    // Choose another folder

    // Choose another folder
    this.downloadPathPopup.menu().addItem(NSMenuItem.separatorItem());
    this.downloadPathPopup
        .menu()
        .addItemWithTitle_action_keyEquivalent(CHOOSE, action, StringUtils.EMPTY);
    this.downloadPathPopup.lastItem().setTarget(this.id());
  }
 public void setUsernameField(NSTextField usernameField) {
   this.usernameField = usernameField;
   NSNotificationCenter.defaultCenter()
       .addObserver(
           this.id(),
           Foundation.selector("usernameInputDidChange:"),
           NSControl.NSControlTextDidChangeNotification,
           this.usernameField);
 }
 public void setPathField(NSTextField pathField) {
   this.pathField = pathField;
   NSNotificationCenter.defaultCenter()
       .addObserver(
           this.id(),
           Foundation.selector("pathInputDidChange:"),
           NSControl.NSControlTextDidChangeNotification,
           this.pathField);
 }
 public void setPortField(NSTextField portField) {
   this.portField = portField;
   NSNotificationCenter.defaultCenter()
       .addObserver(
           this.id(),
           Foundation.selector("portInputDidEndEditing:"),
           NSControl.NSControlTextDidChangeNotification,
           this.portField);
 }
 public void setHostField(NSTextField hostField) {
   this.hostField = hostField;
   NSNotificationCenter.defaultCenter()
       .addObserver(
           this.id(),
           Foundation.selector("hostFieldDidChange:"),
           NSControl.NSControlTextDidChangeNotification,
           hostField);
 }
 public void setConnectmodePopup(NSPopUpButton connectmodePopup) {
   this.connectmodePopup = connectmodePopup;
   this.connectmodePopup.setTarget(this.id());
   this.connectmodePopup.setAction(Foundation.selector("connectmodePopupClicked:"));
   this.connectmodePopup.removeAllItems();
   this.connectmodePopup.addItemWithTitle(DEFAULT);
   this.connectmodePopup.menu().addItem(NSMenuItem.separatorItem());
   this.connectmodePopup.addItemWithTitle(CONNECTMODE_ACTIVE);
   this.connectmodePopup.addItemWithTitle(CONNECTMODE_PASSIVE);
 }
 public void setTransferPopup(NSPopUpButton transferPopup) {
   this.transferPopup = transferPopup;
   this.transferPopup.setTarget(this.id());
   this.transferPopup.setAction(Foundation.selector("transferPopupClicked:"));
   this.transferPopup.removeAllItems();
   this.transferPopup.addItemWithTitle(DEFAULT);
   this.transferPopup.menu().addItem(NSMenuItem.separatorItem());
   this.transferPopup.addItemWithTitle(TRANSFER_NEWCONNECTION);
   this.transferPopup.addItemWithTitle(TRANSFER_BROWSERCONNECTION);
 }
示例#10
0
 public void setCommentField(NSTextView commentField) {
   this.commentField = commentField;
   this.commentField.setFont(NSFont.userFixedPitchFontOfSize(11f));
   NSNotificationCenter.defaultCenter()
       .addObserver(
           this.id(),
           Foundation.selector("commentInputDidChange:"),
           NSText.TextDidChangeNotification,
           this.commentField);
 }
示例#11
0
 public void setWebURLField(NSTextField webURLField) {
   this.webURLField = webURLField;
   final NSTextFieldCell cell = this.webURLField.cell();
   cell.setPlaceholderString(host.getDefaultWebURL());
   NSNotificationCenter.defaultCenter()
       .addObserver(
           this.id(),
           Foundation.selector("webURLInputDidChange:"),
           NSControl.NSControlTextDidChangeNotification,
           this.webURLField);
 }
示例#12
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));
   }
 }
示例#13
0
 public void setEncodingPopup(NSPopUpButton encodingPopup) {
   this.encodingPopup = encodingPopup;
   this.encodingPopup.setEnabled(true);
   this.encodingPopup.removeAllItems();
   this.encodingPopup.addItemWithTitle(DEFAULT);
   this.encodingPopup.menu().addItem(NSMenuItem.separatorItem());
   this.encodingPopup.addItemsWithTitles(
       NSArray.arrayWithObjects(MainController.availableCharsets()));
   if (null == host.getEncoding()) {
     this.encodingPopup.selectItemWithTitle(DEFAULT);
   } else {
     this.encodingPopup.selectItemWithTitle(host.getEncoding());
   }
   this.encodingPopup.setTarget(this.id());
   final Selector action = Foundation.selector("encodingSelectionChanged:");
   this.encodingPopup.setAction(action);
 }
示例#14
0
 @Action
 public void downloadPathPopupClicked(final NSMenuItem sender) {
   if (sender.title().equals(CHOOSE)) {
     downloadPathPanel = NSOpenPanel.openPanel();
     downloadPathPanel.setCanChooseFiles(false);
     downloadPathPanel.setCanChooseDirectories(true);
     downloadPathPanel.setAllowsMultipleSelection(false);
     downloadPathPanel.setCanCreateDirectories(true);
     downloadPathPanel.beginSheetForDirectory(
         null,
         null,
         this.window,
         this.id(),
         Foundation.selector("downloadPathPanelDidEnd:returnCode:contextInfo:"),
         null);
   } else {
     host.setDownloadFolder(LocalFactory.createLocal(sender.representedObject()));
     this.itemChanged();
   }
 }
示例#15
0
 @Action
 public void pkCheckboxSelectionChanged(final NSButton sender) {
   log.debug("pkCheckboxSelectionChanged");
   if (sender.state() == NSCell.NSOnState) {
     publicKeyPanel = NSOpenPanel.openPanel();
     publicKeyPanel.setCanChooseDirectories(false);
     publicKeyPanel.setCanChooseFiles(true);
     publicKeyPanel.setAllowsMultipleSelection(false);
     publicKeyPanel.setMessage(
         Locale.localizedString("Select the private key in PEM or PuTTY format", "Credentials"));
     publicKeyPanel.setPrompt(Locale.localizedString("Choose"));
     publicKeyPanel.beginSheetForDirectory(
         LocalFactory.createLocal("~/.ssh").getAbsolute(),
         null,
         this.window(),
         this.id(),
         Foundation.selector("pkSelectionPanelDidEnd:returnCode:contextInfo:"),
         null);
   } else {
     this.pkSelectionPanelDidEnd_returnCode_contextInfo(
         publicKeyPanel, NSPanel.NSCancelButton, null);
   }
 }
示例#16
0
 public void setTimezonePopup(NSPopUpButton timezonePopup) {
   this.timezonePopup = timezonePopup;
   this.timezonePopup.setTarget(this.id());
   this.timezonePopup.setAction(Foundation.selector("timezonePopupClicked:"));
   this.timezonePopup.removeAllItems();
   final List<String> timezones = Arrays.asList(TimeZone.getAvailableIDs());
   this.timezonePopup.addItemWithTitle(UTC.getID());
   this.timezonePopup.lastItem().setRepresentedObject(UTC.getID());
   this.timezonePopup.menu().addItem(NSMenuItem.separatorItem());
   Collections.sort(
       timezones,
       new Comparator<String>() {
         @Override
         public int compare(String o1, String o2) {
           return TimeZone.getTimeZone(o1).getID().compareTo(TimeZone.getTimeZone(o2).getID());
         }
       });
   for (String tz : timezones) {
     if (tz.matches(TIMEZONE_CONTINENT_PREFIXES)) {
       this.timezonePopup.addItemWithTitle(String.format("%s", tz));
       this.timezonePopup.lastItem().setRepresentedObject(tz);
     }
   }
 }
示例#17
0
 public void setPkCheckbox(NSButton pkCheckbox) {
   this.pkCheckbox = pkCheckbox;
   this.pkCheckbox.setTarget(this.id());
   this.pkCheckbox.setAction(Foundation.selector("pkCheckboxSelectionChanged:"));
 }
示例#18
0
 public void setAnonymousCheckbox(NSButton anonymousCheckbox) {
   this.anonymousCheckbox = anonymousCheckbox;
   this.anonymousCheckbox.setTarget(this.id());
   this.anonymousCheckbox.setAction(Foundation.selector("anonymousCheckboxClicked:"));
   this.anonymousCheckbox.setState(NSCell.NSOffState);
 }
示例#19
0
 public void setWebUrlImage(NSButton b) {
   this.webUrlImage = b;
   this.webUrlImage.setTarget(this.id());
   this.webUrlImage.setAction(Foundation.selector("openWebUrl:"));
   this.webUrlImage.setImage(IconCache.iconNamed("site.tiff", 16));
 }
示例#20
0
  @Override
  public void mount(Session s) {
    if (!this.isAvailable()) {
      this.invoke(
          new DefaultMainAction() {
            @Override
            public void run() {}
          });
      return;
    }
    session = s;
    filesystem = GMUserFileSystem.create((fileystemCallback = new FSCallback()).id(), true);

    NSNotificationCenter center = NSNotificationCenter.defaultCenter();
    center.addObserver(
        fileystemCallback.id(),
        Foundation.selector("mountFailed:"),
        GMUserFileSystem.kGMUserFileSystemMountFailed,
        null);
    center.addObserver(
        fileystemCallback.id(),
        Foundation.selector("didMount:"),
        GMUserFileSystem.kGMUserFileSystemDidMount,
        null);
    center.addObserver(
        fileystemCallback.id(),
        Foundation.selector("didUnmount:"),
        GMUserFileSystem.kGMUserFileSystemDidUnmount,
        null);

    final NSMutableArray options = NSMutableArray.array();
    options.addObject(
        "volicon="
            + NSBundle.mainBundle()
                .pathForResource_ofType(session.getHost().getProtocol().disk(), "icns"));
    // You can use the volname option to specify a name for the MacFUSE volume being mounted. This
    // is the name that would show up on the Desktop. In the absence of this option, MacFUSE will
    // automatically generate a name that would incorporate the MacFUSE device index and the
    // user-space file system being used. For example, an SSHFS mount might have an automatically
    // assigned name "MacFUSE Volume 0 (sshfs)".
    final String volume = session.getHost().getHostname();
    options.addObject("volname=" + volume);
    // By default, if MacFUSE detects a change in a file's size during getattr(), it will purge
    // that file's buffer cache. When auto_cache is enabled, MacFUSE will additionally
    // detect modification time changes during getattr() and open() and will automatically
    // purge the buffer cache and/or attributes of the file if necessary. It will also
    // generate the relevant kqueue messages. All this is subject to the attribute timeout.
    // That is, up to one purge can occur per attribute timeout window. As long as the
    // user-space file system's getattr() callback returns up-to-date size and modification
    // time information, this should work as intended. For user-space file systems that wish
    // the kernel to keep up with "remote" changes, this should obviate the need for explicit
    // purging. auto_cache is not enabled by default: it's opt-in.
    options.addObject("auto_cache");
    // This option makes MacFUSE deny all types of access to extended attributes that begin with the
    // "com.apple." prefix. On Mac OS X 10.5.x, this is the preferred option if you wish to disallow
    // entities such as resource forks and Finder information.
    options.addObject("noapplexattr");
    // This option makes MacFUSE deny all types of access to Apple Double (._) files and .DS_Store
    // files. Any existing files will become apparently non-existent. New files that match the
    // criteria will be disallowed from being created.
    options.addObject("noappledouble");
    mountpoint = LocalFactory.createLocal("/Volumes/" + volume);
    if (mountpoint.exists()) {
      // Make sure we do not mount to a already existing path
      final String parent = mountpoint.getParent().getAbsolute();
      int no = 0;
      while (mountpoint.exists()) {
        no++;
        String proposal = volume + "-" + no;
        mountpoint = LocalFactory.createLocal(parent, proposal);
      }
    }
    filesystem.mountAtPath_withOptions_shouldForeground_detachNewThread(
        mountpoint.getAbsolute(), options, true, true);
  }