Fix transcript in transfer window.
[cyberduck.git] / source / ch / cyberduck / ui / cocoa / PreferencesController.java
blob5ce9f2c0f5f879d795166e3376f0e7d043a7d074
1 package ch.cyberduck.ui.cocoa;
3 /*
4 * Copyright (c) 2002-2010 David Kocher. All rights reserved.
6 * http://cyberduck.ch/
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * Bug fixes, suggestions and comments should be sent to:
19 * dkocher@cyberduck.ch
22 import ch.cyberduck.binding.ProxyController;
23 import ch.cyberduck.binding.application.*;
24 import ch.cyberduck.binding.foundation.NSAppleScript;
25 import ch.cyberduck.binding.foundation.NSArray;
26 import ch.cyberduck.binding.foundation.NSAttributedString;
27 import ch.cyberduck.binding.foundation.NSDictionary;
28 import ch.cyberduck.binding.foundation.NSMutableAttributedString;
29 import ch.cyberduck.binding.foundation.NSNotification;
30 import ch.cyberduck.binding.foundation.NSNotificationCenter;
31 import ch.cyberduck.binding.foundation.NSRange;
32 import ch.cyberduck.core.AbstractCollectionListener;
33 import ch.cyberduck.core.BookmarkCollection;
34 import ch.cyberduck.core.BookmarkNameProvider;
35 import ch.cyberduck.core.CollectionListener;
36 import ch.cyberduck.core.DefaultCharsetProvider;
37 import ch.cyberduck.core.Host;
38 import ch.cyberduck.core.Local;
39 import ch.cyberduck.core.LocalFactory;
40 import ch.cyberduck.core.LocaleFactory;
41 import ch.cyberduck.core.Permission;
42 import ch.cyberduck.core.Protocol;
43 import ch.cyberduck.core.ProtocolFactory;
44 import ch.cyberduck.core.Scheme;
45 import ch.cyberduck.core.editor.EditorFactory;
46 import ch.cyberduck.core.features.Location;
47 import ch.cyberduck.core.formatter.SizeFormatterFactory;
48 import ch.cyberduck.core.local.Application;
49 import ch.cyberduck.core.local.ApplicationFinder;
50 import ch.cyberduck.core.local.ApplicationFinderFactory;
51 import ch.cyberduck.core.local.FileDescriptorFactory;
52 import ch.cyberduck.core.preferences.Preferences;
53 import ch.cyberduck.core.preferences.PreferencesFactory;
54 import ch.cyberduck.core.resources.IconCacheFactory;
55 import ch.cyberduck.core.sparkle.Updater;
56 import ch.cyberduck.core.transfer.TransferAction;
57 import ch.cyberduck.core.urlhandler.SchemeHandlerFactory;
58 import ch.cyberduck.ui.cocoa.threading.WindowMainAction;
59 import ch.cyberduck.ui.cocoa.view.BookmarkCell;
61 import org.apache.commons.lang3.StringUtils;
62 import org.apache.log4j.Logger;
63 import org.jets3t.service.model.S3Object;
64 import org.rococoa.Foundation;
65 import org.rococoa.ID;
66 import org.rococoa.Selector;
67 import org.rococoa.cocoa.foundation.NSInteger;
68 import org.rococoa.cocoa.foundation.NSSize;
69 import org.rococoa.cocoa.foundation.NSUInteger;
71 import java.util.ArrayList;
72 import java.util.Arrays;
73 import java.util.List;
74 import java.util.StringTokenizer;
75 import java.util.regex.Pattern;
76 import java.util.regex.PatternSyntaxException;
78 /**
79 * @version $Id$
81 public class PreferencesController extends ToolbarWindowController {
82 private static Logger log = Logger.getLogger(PreferencesController.class);
84 private Preferences preferences
85 = PreferencesFactory.get();
87 public PreferencesController() {
88 this.loadBundle();
91 @Override
92 protected String getBundleName() {
93 return "Preferences";
96 @Outlet
97 private NSView panelGeneral;
98 @Outlet
99 private NSView panelEditor;
100 @Outlet
101 private NSView panelBrowser;
102 @Outlet
103 private NSView panelTransfer;
104 @Outlet
105 private NSView panelFTP;
106 @Outlet
107 private NSView panelSFTP;
108 @Outlet
109 private NSView panelS3;
110 @Outlet
111 private NSView panelGoogle;
112 @Outlet
113 private NSView panelBandwidth;
114 @Outlet
115 private NSView panelAdvanced;
116 @Outlet
117 private NSView panelUpdate;
118 @Outlet
119 private NSView panelLanguage;
121 public void setPanelUpdate(NSView v) {
122 this.panelUpdate = v;
125 public void setPanelAdvanced(NSView v) {
126 this.panelAdvanced = v;
129 public void setPanelBandwidth(NSView v) {
130 this.panelBandwidth = v;
133 public void setPanelSFTP(NSView v) {
134 this.panelSFTP = v;
137 public void setPanelFTP(NSView v) {
138 this.panelFTP = v;
141 public void setPanelS3(NSView v) {
142 this.panelS3 = v;
145 public void setPanelGoogle(NSView v) {
146 this.panelGoogle = v;
149 public void setPanelTransfer(NSView v) {
150 this.panelTransfer = v;
153 public void setPanelBrowser(NSView v) {
154 this.panelBrowser = v;
157 public void setPanelGeneral(NSView v) {
158 this.panelGeneral = v;
161 public void setPanelEditor(NSView v) {
162 this.panelEditor = v;
165 public void setPanelLanguage(NSView v) {
166 this.panelLanguage = v;
169 @Override
170 public NSToolbarItem toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar(final NSToolbar toolbar, final String itemIdentifier, final boolean flag) {
171 final NSToolbarItem item = super.toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar(toolbar, itemIdentifier, flag);
172 if(itemIdentifier.equals("sftp")) {
173 item.setImage(IconCacheFactory.<NSImage>get().iconNamed("ftp"));
175 return item;
178 @Override
179 protected List<NSView> getPanels() {
180 List<NSView> views = new ArrayList<NSView>();
181 views.add(panelGeneral);
182 views.add(panelBrowser);
183 views.add(panelTransfer);
184 views.add(panelEditor);
185 views.add(panelFTP);
186 views.add(panelSFTP);
187 views.add(panelS3);
188 views.add(panelBandwidth);
189 views.add(panelAdvanced);
190 if(null != Updater.getFeed()) {
191 views.add(panelUpdate);
193 views.add(panelLanguage);
194 return views;
197 @Override
198 protected List<String> getPanelIdentifiers() {
199 List<String> views = new ArrayList<String>();
200 views.add(PreferencesToolbarItem.general.name());
201 views.add(PreferencesToolbarItem.browser.name());
202 views.add(PreferencesToolbarItem.queue.name());
203 views.add(PreferencesToolbarItem.pencil.name());
204 views.add(PreferencesToolbarItem.ftp.name());
205 views.add(PreferencesToolbarItem.sftp.name());
206 views.add(PreferencesToolbarItem.s3.name());
207 views.add(PreferencesToolbarItem.bandwidth.name());
208 views.add(PreferencesToolbarItem.connection.name());
209 if(null != Updater.getFeed()) {
210 views.add(PreferencesToolbarItem.update.name());
212 views.add(PreferencesToolbarItem.language.name());
213 return views;
216 private enum PreferencesToolbarItem {
217 general,
218 browser,
219 queue,
220 pencil,
221 ftp,
222 sftp,
224 bandwidth,
225 connection,
226 update,
227 language
230 @Override
231 protected void initializePanel(final String identifier) {
232 PreferencesToolbarItem item;
233 try {
234 item = PreferencesToolbarItem.valueOf(identifier);
236 catch(IllegalArgumentException e) {
237 item = PreferencesToolbarItem.general;
239 switch(item) {
240 case general:
241 break;
242 case browser:
243 break;
244 case pencil:
245 this.updateEditorCombobox();
246 break;
247 case ftp:
248 this.configureDefaultProtocolHandlerCombobox(this.defaultFTPHandlerCombobox, Scheme.ftp);
249 break;
250 case sftp:
251 this.configureDefaultProtocolHandlerCombobox(this.defaultSFTPHandlerCombobox, Scheme.sftp);
252 break;
256 @Override
257 public void invalidate() {
258 BookmarkCollection.defaultCollection().removeListener(bookmarkCollectionListener);
259 super.invalidate();
262 @Override
263 public void setWindow(NSWindow window) {
264 window.setExcludedFromWindowsMenu(true);
265 window.setFrameAutosaveName("Preferences");
266 window.setContentMinSize(window.frame().size);
267 window.setContentMaxSize(new NSSize(800, window.frame().size.height.doubleValue()));
268 super.setWindow(window);
271 @Override
272 public void awakeFromNib() {
273 this.window.center();
275 this.chmodDownloadTypePopupChanged(this.chmodDownloadTypePopup);
276 this.chmodUploadTypePopupChanged(this.chmodUploadTypePopup);
278 boolean chmodDownloadDefaultEnabled = preferences.getBoolean("queue.download.permissions.change")
279 && preferences.getBoolean("queue.download.permissions.default");
280 this.downerr.setEnabled(chmodDownloadDefaultEnabled);
281 this.downerr.setTarget(this.id());
282 this.downerr.setAction(Foundation.selector("defaultPermissionsDownloadChanged:"));
283 this.downerw.setEnabled(chmodDownloadDefaultEnabled);
284 this.downerw.setTarget(this.id());
285 this.downerw.setAction(Foundation.selector("defaultPermissionsDownloadChanged:"));
286 this.downerx.setEnabled(chmodDownloadDefaultEnabled);
287 this.downerx.setTarget(this.id());
288 this.downerx.setAction(Foundation.selector("defaultPermissionsDownloadChanged:"));
290 this.dgroupr.setEnabled(chmodDownloadDefaultEnabled);
291 this.dgroupr.setTarget(this.id());
292 this.dgroupr.setAction(Foundation.selector("defaultPermissionsDownloadChanged:"));
293 this.dgroupw.setEnabled(chmodDownloadDefaultEnabled);
294 this.dgroupw.setTarget(this.id());
295 this.dgroupw.setAction(Foundation.selector("defaultPermissionsDownloadChanged:"));
296 this.dgroupx.setEnabled(chmodDownloadDefaultEnabled);
297 this.dgroupx.setTarget(this.id());
298 this.dgroupx.setAction(Foundation.selector("defaultPermissionsDownloadChanged:"));
300 this.dotherr.setEnabled(chmodDownloadDefaultEnabled);
301 this.dotherr.setTarget(this.id());
302 this.dotherr.setAction(Foundation.selector("defaultPermissionsDownloadChanged:"));
303 this.dotherw.setEnabled(chmodDownloadDefaultEnabled);
304 this.dotherw.setTarget(this.id());
305 this.dotherw.setAction(Foundation.selector("defaultPermissionsDownloadChanged:"));
306 this.dotherx.setEnabled(chmodDownloadDefaultEnabled);
307 this.dotherx.setTarget(this.id());
308 this.dotherx.setAction(Foundation.selector("defaultPermissionsDownloadChanged:"));
310 boolean chmodUploadDefaultEnabled = preferences.getBoolean("queue.upload.permissions.change")
311 && preferences.getBoolean("queue.upload.permissions.default");
312 this.uownerr.setEnabled(chmodUploadDefaultEnabled);
313 this.uownerr.setTarget(this.id());
314 this.uownerr.setAction(Foundation.selector("defaultPermissionsUploadChanged:"));
315 this.uownerw.setEnabled(chmodUploadDefaultEnabled);
316 this.uownerw.setTarget(this.id());
317 this.uownerw.setAction(Foundation.selector("defaultPermissionsUploadChanged:"));
318 this.uownerx.setEnabled(chmodUploadDefaultEnabled);
319 this.uownerx.setTarget(this.id());
320 this.uownerx.setAction(Foundation.selector("defaultPermissionsUploadChanged:"));
322 this.ugroupr.setEnabled(chmodUploadDefaultEnabled);
323 this.ugroupr.setTarget(this.id());
324 this.ugroupr.setAction(Foundation.selector("defaultPermissionsUploadChanged:"));
325 this.ugroupw.setEnabled(chmodUploadDefaultEnabled);
326 this.ugroupw.setTarget(this.id());
327 this.ugroupw.setAction(Foundation.selector("defaultPermissionsUploadChanged:"));
328 this.ugroupx.setEnabled(chmodUploadDefaultEnabled);
329 this.ugroupx.setTarget(this.id());
330 this.ugroupx.setAction(Foundation.selector("defaultPermissionsUploadChanged:"));
332 this.uotherr.setEnabled(chmodUploadDefaultEnabled);
333 this.uotherr.setTarget(this.id());
334 this.uotherr.setAction(Foundation.selector("defaultPermissionsUploadChanged:"));
335 this.uotherw.setEnabled(chmodUploadDefaultEnabled);
336 this.uotherw.setTarget(this.id());
337 this.uotherw.setAction(Foundation.selector("defaultPermissionsUploadChanged:"));
338 this.uotherx.setEnabled(chmodUploadDefaultEnabled);
339 this.uotherx.setTarget(this.id());
340 this.uotherx.setAction(Foundation.selector("defaultPermissionsUploadChanged:"));
342 super.awakeFromNib();
345 // ----------------------------------------------------------
346 // Outlets
347 // ----------------------------------------------------------
349 @Outlet
350 private NSPopUpButton editorCombobox;
352 public void setEditorCombobox(NSPopUpButton b) {
353 this.editorCombobox = b;
354 this.editorCombobox.setAutoenablesItems(false);
357 private void updateEditorCombobox() {
358 editorCombobox.removeAllItems();
359 for(Application editor : EditorFactory.instance().getEditors()) {
360 editorCombobox.addItemWithTitle(editor.getName());
361 editorCombobox.lastItem().setRepresentedObject(editor.getIdentifier());
362 final boolean enabled = ApplicationFinderFactory.get().isInstalled(editor);
363 editorCombobox.lastItem().setEnabled(enabled);
364 if(enabled) {
365 editorCombobox.lastItem().setImage(
366 IconCacheFactory.<NSImage>get().applicationIcon(editor, 16));
368 if(editor.equals(EditorFactory.instance().getDefaultEditor())) {
369 editorCombobox.selectItem(editorCombobox.lastItem());
372 editorCombobox.setTarget(this.id());
373 final Selector action = Foundation.selector("editorComboboxClicked:");
374 editorCombobox.setAction(action);
375 editorCombobox.menu().addItem(NSMenuItem.separatorItem());
376 editorCombobox.menu().addItemWithTitle_action_keyEquivalent(CHOOSE, action, StringUtils.EMPTY);
377 editorCombobox.lastItem().setTarget(this.id());
380 @Outlet
381 private NSOpenPanel editorPathPanel;
382 private ProxyController editorPathPanelDelegate = new EditorOpenPanelDelegate();
384 @Action
385 public void editorComboboxClicked(NSPopUpButton sender) {
386 if(sender.title().equals(CHOOSE)) {
387 editorPathPanel = NSOpenPanel.openPanel();
388 editorPathPanel.setDelegate(editorPathPanelDelegate.id());
389 editorPathPanel.setAllowsMultipleSelection(false);
390 editorPathPanel.setCanCreateDirectories(false);
391 editorPathPanel.beginSheetForDirectory("/Applications", null, this.window, this.id(),
392 Foundation.selector("editorPathPanelDidEnd:returnCode:contextInfo:"), null);
394 else {
395 preferences.setProperty("editor.bundleIdentifier", sender.selectedItem().representedObject());
396 for(BrowserController controller : MainController.getBrowsers()) {
397 controller.validateToolbar();
402 private static class EditorOpenPanelDelegate extends ProxyController {
403 public boolean panel_shouldShowFilename(ID panel, String path) {
404 final Local f = LocalFactory.get(path);
405 if(f.isDirectory()) {
406 return true;
408 final String extension = f.getExtension();
409 if(StringUtils.isEmpty(extension)) {
410 return false;
412 return extension.equals("app");
416 public void editorPathPanelDidEnd_returnCode_contextInfo(NSOpenPanel sheet, int returncode, ID contextInfo) {
417 if(returncode == SheetCallback.DEFAULT_OPTION) {
418 NSArray selected = sheet.filenames();
419 String filename;
420 if((filename = selected.lastObject().toString()) != null) {
421 final String path = LocalFactory.get(filename).getAbsolute();
422 final ApplicationFinder finder = ApplicationFinderFactory.get();
423 final Application application = finder.getDescription(path);
424 if(finder.isInstalled(application)) {
425 preferences.setProperty("editor.bundleIdentifier", application.getIdentifier());
426 for(BrowserController controller : MainController.getBrowsers()) {
427 controller.validateToolbar();
430 else {
431 log.error(String.format("Loading bundle %s failed", path));
435 this.updateEditorCombobox();
438 @Outlet
439 private NSButton defaultEditorCheckbox;
441 public void setDefaultEditorCheckbox(NSButton b) {
442 this.defaultEditorCheckbox = b;
443 this.defaultEditorCheckbox.setTarget(this.id());
444 this.defaultEditorCheckbox.setAction(Foundation.selector("defaultEditorCheckboxClicked:"));
445 this.defaultEditorCheckbox.setState(preferences.getBoolean("editor.alwaysUseDefault") ? NSCell.NSOnState : NSCell.NSOffState);
448 public void defaultEditorCheckboxClicked(final NSButton sender) {
449 boolean enabled = sender.state() == NSCell.NSOnState;
450 preferences.setProperty("editor.alwaysUseDefault", enabled);
453 @Outlet
454 private NSPopUpButton bookmarkSizePopup;
456 public void setBookmarkSizePopup(NSPopUpButton b) {
457 this.bookmarkSizePopup = b;
458 this.bookmarkSizePopup.setTarget(this.id());
459 this.bookmarkSizePopup.setAction(Foundation.selector("bookmarkSizePopupClicked:"));
460 final int size = preferences.getInteger("bookmark.icon.size");
461 // this.bookmarkSizePopup.itemAtIndex(0).setImage(IconCache.iconNamed("ftp", CDBookmarkCell.SMALL_BOOKMARK_SIZE));
462 // this.bookmarkSizePopup.itemAtIndex(1).setImage(IconCache.iconNamed("ftp", CDBookmarkCell.MEDIUM_BOOKMARK_SIZE));
463 // this.bookmarkSizePopup.itemAtIndex(2).setImage(IconCache.iconNamed("ftp", CDBookmarkCell.LARGE_BOOKMARK_SIZE));
464 for(int i = 0; i < this.bookmarkSizePopup.numberOfItems().intValue(); i++) {
465 this.bookmarkSizePopup.itemAtIndex(new NSInteger(i)).setState(NSCell.NSOffState);
467 if(BookmarkCell.SMALL_BOOKMARK_SIZE == size) {
468 this.bookmarkSizePopup.selectItemAtIndex(new NSInteger(0));
470 if(BookmarkCell.MEDIUM_BOOKMARK_SIZE == size) {
471 this.bookmarkSizePopup.selectItemAtIndex(new NSInteger(1));
473 if(BookmarkCell.LARGE_BOOKMARK_SIZE == size) {
474 this.bookmarkSizePopup.selectItemAtIndex(new NSInteger(2));
478 @Action
479 public void bookmarkSizePopupClicked(NSPopUpButton sender) {
480 if(sender.indexOfSelectedItem().intValue() == 0) {
481 preferences.setProperty("bookmark.icon.size", BookmarkCell.SMALL_BOOKMARK_SIZE);
483 if(sender.indexOfSelectedItem().intValue() == 1) {
484 preferences.setProperty("bookmark.icon.size", BookmarkCell.MEDIUM_BOOKMARK_SIZE);
486 if(sender.indexOfSelectedItem().intValue() == 2) {
487 preferences.setProperty("bookmark.icon.size", BookmarkCell.LARGE_BOOKMARK_SIZE);
489 BrowserController.updateBookmarkTableRowHeight();
492 @Outlet
493 private NSButton openUntitledBrowserCheckbox;
495 public void setOpenUntitledBrowserCheckbox(NSButton b) {
496 this.openUntitledBrowserCheckbox = b;
497 this.openUntitledBrowserCheckbox.setTarget(this.id());
498 this.openUntitledBrowserCheckbox.setAction(Foundation.selector("openUntitledBrowserCheckboxClicked:"));
499 this.openUntitledBrowserCheckbox.setState(preferences.getBoolean("browser.open.untitled") ? NSCell.NSOnState : NSCell.NSOffState);
502 @Action
503 public void openUntitledBrowserCheckboxClicked(final NSButton sender) {
504 boolean enabled = sender.state() == NSCell.NSOnState;
505 preferences.setProperty("browser.open.untitled", enabled);
508 @Outlet
509 private NSButton browserSerializeCheckbox;
511 public void setBrowserSerializeCheckbox(NSButton b) {
512 this.browserSerializeCheckbox = b;
513 this.browserSerializeCheckbox.setTarget(this.id());
514 this.browserSerializeCheckbox.setAction(Foundation.selector("browserSerializeCheckboxClicked:"));
515 this.browserSerializeCheckbox.setState(preferences.getBoolean("browser.serialize") ? NSCell.NSOnState : NSCell.NSOffState);
518 @Action
519 public void browserSerializeCheckboxClicked(final NSButton sender) {
520 boolean enabled = sender.state() == NSCell.NSOnState;
521 preferences.setProperty("browser.serialize", enabled);
524 @Outlet
525 private NSPopUpButton defaultBookmarkCombobox;
527 private final CollectionListener<Host> bookmarkCollectionListener = new AbstractCollectionListener<Host>() {
528 @Override
529 public void collectionItemAdded(final Host bookmark) {
530 invoke(new WindowMainAction(PreferencesController.this) {
531 @Override
532 public void run() {
533 defaultBookmarkCombobox.addItemWithTitle(BookmarkNameProvider.toString(bookmark));
534 defaultBookmarkCombobox.lastItem().setImage(IconCacheFactory.<NSImage>get().iconNamed("cyberduck-document.icns", 16));
535 defaultBookmarkCombobox.lastItem().setRepresentedObject(bookmark.getUuid());
540 @Override
541 public void collectionItemRemoved(final Host bookmark) {
542 invoke(new WindowMainAction(PreferencesController.this) {
543 @Override
544 public void run() {
545 String selected = defaultBookmarkCombobox.selectedItem().representedObject();
546 if(StringUtils.isNotEmpty(selected)) {
547 if(selected.equals(bookmark.getUuid())) {
548 preferences.deleteProperty("browser.open.bookmark.default");
551 NSInteger i = defaultBookmarkCombobox.menu().indexOfItemWithRepresentedObject(bookmark.getUuid());
552 if(i.intValue() == -1) {
553 return;
555 defaultBookmarkCombobox.removeItemAtIndex(i);
561 public void setDefaultBookmarkCombobox(NSPopUpButton b) {
562 this.defaultBookmarkCombobox = b;
563 this.defaultBookmarkCombobox.setToolTip(LocaleFactory.localizedString("Bookmarks"));
564 this.defaultBookmarkCombobox.removeAllItems();
565 this.defaultBookmarkCombobox.addItemWithTitle(LocaleFactory.localizedString("None"));
566 this.defaultBookmarkCombobox.selectItem(this.defaultBookmarkCombobox.lastItem());
567 this.defaultBookmarkCombobox.menu().addItem(NSMenuItem.separatorItem());
568 for(Host bookmark : BookmarkCollection.defaultCollection()) {
569 this.defaultBookmarkCombobox.addItemWithTitle(BookmarkNameProvider.toString(bookmark));
570 this.defaultBookmarkCombobox.lastItem().setImage(
571 IconCacheFactory.<NSImage>get().iconNamed(bookmark.getProtocol().icon(), 16));
572 this.defaultBookmarkCombobox.lastItem().setRepresentedObject(bookmark.getUuid());
573 if(bookmark.getUuid().equals(preferences.getProperty("browser.open.bookmark.default"))) {
574 this.defaultBookmarkCombobox.selectItem(this.defaultBookmarkCombobox.lastItem());
577 BookmarkCollection.defaultCollection().addListener(bookmarkCollectionListener);
578 this.defaultBookmarkCombobox.setTarget(this.id());
579 final Selector action = Foundation.selector("defaultBookmarkComboboxClicked:");
580 this.defaultBookmarkCombobox.setAction(action);
583 @Action
584 public void defaultBookmarkComboboxClicked(NSPopUpButton sender) {
585 final String selected = sender.selectedItem().representedObject();
586 if(null == selected) {
587 preferences.deleteProperty("browser.open.bookmark.default");
589 preferences.setProperty("browser.open.bookmark.default", selected);
592 @Outlet
593 private NSPopUpButton encodingCombobox;
595 public void setEncodingCombobox(NSPopUpButton b) {
596 this.encodingCombobox = b;
597 this.encodingCombobox.setTarget(this.id());
598 this.encodingCombobox.setAction(Foundation.selector("encodingComboboxClicked:"));
599 this.encodingCombobox.removeAllItems();
600 this.encodingCombobox.addItemsWithTitles(NSArray.arrayWithObjects(new DefaultCharsetProvider().availableCharsets()));
601 this.encodingCombobox.selectItemWithTitle(preferences.getProperty("browser.charset.encoding"));
604 @Action
605 public void encodingComboboxClicked(NSPopUpButton sender) {
606 preferences.setProperty("browser.charset.encoding", sender.titleOfSelectedItem());
609 @Outlet
610 private NSPopUpButton chmodUploadTypePopup;
612 public void setChmodUploadTypePopup(NSPopUpButton b) {
613 this.chmodUploadTypePopup = b;
614 this.chmodUploadTypePopup.selectItemAtIndex(new NSInteger(0));
615 this.chmodUploadTypePopup.setTarget(this.id());
616 this.chmodUploadTypePopup.setAction(Foundation.selector("chmodUploadTypePopupChanged:"));
619 @Action
620 public void chmodUploadTypePopupChanged(NSPopUpButton sender) {
621 Permission p = null;
622 if(sender.selectedItem().tag() == 0) {
623 p = new Permission(preferences.getInteger("queue.upload.permissions.file.default"));
625 if(sender.selectedItem().tag() == 1) {
626 p = new Permission(preferences.getInteger("queue.upload.permissions.folder.default"));
628 if(null == p) {
629 log.error("No selected item for:" + sender);
630 return;
632 Permission.Action ownerPerm = p.getUser();
633 Permission.Action groupPerm = p.getGroup();
634 Permission.Action otherPerm = p.getOther();
636 uownerr.setState(ownerPerm.implies(Permission.Action.read) ? NSCell.NSOnState : NSCell.NSOffState);
637 uownerw.setState(ownerPerm.implies(Permission.Action.write) ? NSCell.NSOnState : NSCell.NSOffState);
638 uownerx.setState(ownerPerm.implies(Permission.Action.execute) ? NSCell.NSOnState : NSCell.NSOffState);
640 ugroupr.setState(groupPerm.implies(Permission.Action.read) ? NSCell.NSOnState : NSCell.NSOffState);
641 ugroupw.setState(groupPerm.implies(Permission.Action.write) ? NSCell.NSOnState : NSCell.NSOffState);
642 ugroupx.setState(groupPerm.implies(Permission.Action.execute) ? NSCell.NSOnState : NSCell.NSOffState);
644 uotherr.setState(otherPerm.implies(Permission.Action.read) ? NSCell.NSOnState : NSCell.NSOffState);
645 uotherw.setState(otherPerm.implies(Permission.Action.write) ? NSCell.NSOnState : NSCell.NSOffState);
646 uotherx.setState(otherPerm.implies(Permission.Action.execute) ? NSCell.NSOnState : NSCell.NSOffState);
649 @Outlet
650 private NSPopUpButton chmodDownloadTypePopup;
652 public void setChmodDownloadTypePopup(NSPopUpButton b) {
653 this.chmodDownloadTypePopup = b;
654 this.chmodDownloadTypePopup.selectItemAtIndex(new NSInteger(0));
655 this.chmodDownloadTypePopup.setTarget(this.id());
656 this.chmodDownloadTypePopup.setAction(Foundation.selector("chmodDownloadTypePopupChanged:"));
659 @Action
660 public void chmodDownloadTypePopupChanged(NSPopUpButton sender) {
661 Permission p = null;
662 if(sender.selectedItem().tag() == 0) {
663 p = new Permission(preferences.getInteger("queue.download.permissions.file.default"));
665 if(sender.selectedItem().tag() == 1) {
666 p = new Permission(preferences.getInteger("queue.download.permissions.folder.default"));
668 if(null == p) {
669 log.error("No selected item for:" + sender);
670 return;
672 Permission.Action ownerPerm = p.getUser();
673 Permission.Action groupPerm = p.getGroup();
674 Permission.Action otherPerm = p.getOther();
676 downerr.setState(ownerPerm.implies(Permission.Action.read) ? NSCell.NSOnState : NSCell.NSOffState);
677 downerw.setState(ownerPerm.implies(Permission.Action.write) ? NSCell.NSOnState : NSCell.NSOffState);
678 downerx.setState(ownerPerm.implies(Permission.Action.execute) ? NSCell.NSOnState : NSCell.NSOffState);
680 dgroupr.setState(groupPerm.implies(Permission.Action.read) ? NSCell.NSOnState : NSCell.NSOffState);
681 dgroupw.setState(groupPerm.implies(Permission.Action.write) ? NSCell.NSOnState : NSCell.NSOffState);
682 dgroupx.setState(groupPerm.implies(Permission.Action.execute) ? NSCell.NSOnState : NSCell.NSOffState);
684 dotherr.setState(otherPerm.implies(Permission.Action.read) ? NSCell.NSOnState : NSCell.NSOffState);
685 dotherw.setState(otherPerm.implies(Permission.Action.write) ? NSCell.NSOnState : NSCell.NSOffState);
686 dotherx.setState(otherPerm.implies(Permission.Action.execute) ? NSCell.NSOnState : NSCell.NSOffState);
689 @Outlet
690 private NSButton chmodUploadCheckbox;
692 public void setChmodUploadCheckbox(NSButton b) {
693 this.chmodUploadCheckbox = b;
694 this.chmodUploadCheckbox.setTarget(this.id());
695 this.chmodUploadCheckbox.setAction(Foundation.selector("chmodUploadCheckboxClicked:"));
696 this.chmodUploadCheckbox.setState(preferences.getBoolean("queue.upload.permissions.change") ? NSCell.NSOnState : NSCell.NSOffState);
699 @Action
700 public void chmodUploadCheckboxClicked(final NSButton sender) {
701 boolean enabled = sender.state() == NSCell.NSOnState;
702 preferences.setProperty("queue.upload.permissions.change", enabled);
703 this.chmodUploadDefaultCheckbox.setEnabled(enabled);
704 this.chmodUploadCustomCheckbox.setEnabled(enabled);
705 boolean chmodUploadDefaultChecked = this.chmodUploadDefaultCheckbox.state() == NSCell.NSOnState;
706 this.uownerr.setEnabled(enabled && chmodUploadDefaultChecked);
707 this.uownerw.setEnabled(enabled && chmodUploadDefaultChecked);
708 this.uownerx.setEnabled(enabled && chmodUploadDefaultChecked);
709 this.ugroupr.setEnabled(enabled && chmodUploadDefaultChecked);
710 this.ugroupw.setEnabled(enabled && chmodUploadDefaultChecked);
711 this.ugroupx.setEnabled(enabled && chmodUploadDefaultChecked);
712 this.uotherr.setEnabled(enabled && chmodUploadDefaultChecked);
713 this.uotherw.setEnabled(enabled && chmodUploadDefaultChecked);
714 this.uotherx.setEnabled(enabled && chmodUploadDefaultChecked);
717 @Outlet
718 private NSButton chmodUploadDefaultCheckbox;
720 public void setChmodUploadDefaultCheckbox(NSButton b) {
721 this.chmodUploadDefaultCheckbox = b;
722 this.chmodUploadDefaultCheckbox.setTarget(this.id());
723 this.chmodUploadDefaultCheckbox.setAction(Foundation.selector("chmodUploadDefaultCheckboxClicked:"));
724 this.chmodUploadDefaultCheckbox.setState(preferences.getBoolean("queue.upload.permissions.default") ? NSCell.NSOnState : NSCell.NSOffState);
725 this.chmodUploadDefaultCheckbox.setEnabled(preferences.getBoolean("queue.upload.permissions.change"));
728 @Action
729 public void chmodUploadDefaultCheckboxClicked(final NSButton sender) {
730 boolean enabled = sender.state() == NSCell.NSOnState;
731 preferences.setProperty("queue.upload.permissions.default", enabled);
732 this.uownerr.setEnabled(enabled);
733 this.uownerw.setEnabled(enabled);
734 this.uownerx.setEnabled(enabled);
735 this.ugroupr.setEnabled(enabled);
736 this.ugroupw.setEnabled(enabled);
737 this.ugroupx.setEnabled(enabled);
738 this.uotherr.setEnabled(enabled);
739 this.uotherw.setEnabled(enabled);
740 this.uotherx.setEnabled(enabled);
741 this.chmodUploadCustomCheckbox.setState(!enabled ? NSCell.NSOnState : NSCell.NSOffState);
744 @Outlet
745 private NSButton chmodUploadCustomCheckbox;
747 public void setChmodUploadCustomCheckbox(NSButton b) {
748 this.chmodUploadCustomCheckbox = b;
749 this.chmodUploadCustomCheckbox.setTarget(this.id());
750 this.chmodUploadCustomCheckbox.setAction(Foundation.selector("chmodUploadCustomCheckboxClicked:"));
751 this.chmodUploadCustomCheckbox.setState(!preferences.getBoolean("queue.upload.permissions.default") ? NSCell.NSOnState : NSCell.NSOffState);
752 this.chmodUploadCustomCheckbox.setEnabled(preferences.getBoolean("queue.upload.permissions.change"));
755 @Action
756 public void chmodUploadCustomCheckboxClicked(final NSButton sender) {
757 boolean enabled = sender.state() == NSCell.NSOnState;
758 preferences.setProperty("queue.upload.permissions.default", !enabled);
759 this.uownerr.setEnabled(!enabled);
760 this.uownerw.setEnabled(!enabled);
761 this.uownerx.setEnabled(!enabled);
762 this.ugroupr.setEnabled(!enabled);
763 this.ugroupw.setEnabled(!enabled);
764 this.ugroupx.setEnabled(!enabled);
765 this.uotherr.setEnabled(!enabled);
766 this.uotherw.setEnabled(!enabled);
767 this.uotherx.setEnabled(!enabled);
768 this.chmodUploadDefaultCheckbox.setState(!enabled ? NSCell.NSOnState : NSCell.NSOffState);
771 @Outlet
772 private NSButton chmodDownloadCheckbox;
774 public void setChmodDownloadCheckbox(NSButton b) {
775 this.chmodDownloadCheckbox = b;
776 this.chmodDownloadCheckbox.setTarget(this.id());
777 this.chmodDownloadCheckbox.setAction(Foundation.selector("chmodDownloadCheckboxClicked:"));
778 this.chmodDownloadCheckbox.setState(preferences.getBoolean("queue.download.permissions.change") ? NSCell.NSOnState : NSCell.NSOffState);
781 @Action
782 public void chmodDownloadCheckboxClicked(final NSButton sender) {
783 boolean enabled = sender.state() == NSCell.NSOnState;
784 preferences.setProperty("queue.download.permissions.change", enabled);
785 this.chmodDownloadDefaultCheckbox.setEnabled(enabled);
786 this.chmodDownloadCustomCheckbox.setEnabled(enabled);
787 boolean chmodDownloadDefaultChecked = this.chmodDownloadDefaultCheckbox.state() == NSCell.NSOnState;
788 this.downerr.setEnabled(enabled && chmodDownloadDefaultChecked);
789 this.downerw.setEnabled(enabled && chmodDownloadDefaultChecked);
790 this.downerx.setEnabled(enabled && chmodDownloadDefaultChecked);
791 this.dgroupr.setEnabled(enabled && chmodDownloadDefaultChecked);
792 this.dgroupw.setEnabled(enabled && chmodDownloadDefaultChecked);
793 this.dgroupx.setEnabled(enabled && chmodDownloadDefaultChecked);
794 this.dotherr.setEnabled(enabled && chmodDownloadDefaultChecked);
795 this.dotherw.setEnabled(enabled && chmodDownloadDefaultChecked);
796 this.dotherx.setEnabled(enabled && chmodDownloadDefaultChecked);
799 @Outlet
800 private NSButton chmodDownloadDefaultCheckbox;
802 public void setChmodDownloadDefaultCheckbox(NSButton b) {
803 this.chmodDownloadDefaultCheckbox = b;
804 this.chmodDownloadDefaultCheckbox.setTarget(this.id());
805 this.chmodDownloadDefaultCheckbox.setAction(Foundation.selector("chmodDownloadDefaultCheckboxClicked:"));
806 this.chmodDownloadDefaultCheckbox.setState(preferences.getBoolean("queue.download.permissions.default") ? NSCell.NSOnState : NSCell.NSOffState);
807 this.chmodDownloadDefaultCheckbox.setEnabled(preferences.getBoolean("queue.download.permissions.change"));
810 @Action
811 public void chmodDownloadDefaultCheckboxClicked(final NSButton sender) {
812 boolean enabled = sender.state() == NSCell.NSOnState;
813 preferences.setProperty("queue.download.permissions.default", enabled);
814 this.downerr.setEnabled(enabled);
815 this.downerw.setEnabled(enabled);
816 this.downerx.setEnabled(enabled);
817 this.dgroupr.setEnabled(enabled);
818 this.dgroupw.setEnabled(enabled);
819 this.dgroupx.setEnabled(enabled);
820 this.dotherr.setEnabled(enabled);
821 this.dotherw.setEnabled(enabled);
822 this.dotherx.setEnabled(enabled);
823 this.chmodDownloadCustomCheckbox.setState(!enabled ? NSCell.NSOnState : NSCell.NSOffState);
826 @Outlet
827 private NSButton chmodDownloadCustomCheckbox;
829 public void setChmodDownloadCustomCheckbox(NSButton b) {
830 this.chmodDownloadCustomCheckbox = b;
831 this.chmodDownloadCustomCheckbox.setTarget(this.id());
832 this.chmodDownloadCustomCheckbox.setAction(Foundation.selector("chmodDownloadCustomCheckboxClicked:"));
833 this.chmodDownloadCustomCheckbox.setState(!preferences.getBoolean("queue.download.permissions.default") ? NSCell.NSOnState : NSCell.NSOffState);
834 this.chmodDownloadCustomCheckbox.setEnabled(preferences.getBoolean("queue.download.permissions.change"));
837 @Action
838 public void chmodDownloadCustomCheckboxClicked(final NSButton sender) {
839 boolean enabled = sender.state() == NSCell.NSOnState;
840 preferences.setProperty("queue.download.permissions.default", !enabled);
841 this.downerr.setEnabled(!enabled);
842 this.downerw.setEnabled(!enabled);
843 this.downerx.setEnabled(!enabled);
844 this.dgroupr.setEnabled(!enabled);
845 this.dgroupw.setEnabled(!enabled);
846 this.dgroupx.setEnabled(!enabled);
847 this.dotherr.setEnabled(!enabled);
848 this.dotherw.setEnabled(!enabled);
849 this.dotherx.setEnabled(!enabled);
850 this.chmodDownloadDefaultCheckbox.setState(!enabled ? NSCell.NSOnState : NSCell.NSOffState);
853 @Outlet
854 private NSButton downerr;
855 @Outlet
856 private NSButton downerw;
857 @Outlet
858 private NSButton downerx;
859 @Outlet
860 private NSButton dgroupr;
861 @Outlet
862 private NSButton dgroupw;
863 @Outlet
864 private NSButton dgroupx;
865 @Outlet
866 private NSButton dotherr;
867 @Outlet
868 private NSButton dotherw;
869 @Outlet
870 private NSButton dotherx;
872 public void setDownerr(NSButton downerr) {
873 this.downerr = downerr;
876 public void setDownerw(NSButton downerw) {
877 this.downerw = downerw;
880 public void setDownerx(NSButton downerx) {
881 this.downerx = downerx;
884 public void setDgroupr(NSButton dgroupr) {
885 this.dgroupr = dgroupr;
888 public void setDgroupw(NSButton dgroupw) {
889 this.dgroupw = dgroupw;
892 public void setDgroupx(NSButton dgroupx) {
893 this.dgroupx = dgroupx;
896 public void setDotherr(NSButton dotherr) {
897 this.dotherr = dotherr;
900 public void setDotherw(NSButton dotherw) {
901 this.dotherw = dotherw;
904 public void setDotherx(NSButton dotherx) {
905 this.dotherx = dotherx;
908 public void defaultPermissionsDownloadChanged(final ID sender) {
909 Permission.Action u = Permission.Action.none;
910 if(downerr.state() == NSCell.NSOnState) {
911 u = u.or(Permission.Action.read);
913 if(downerw.state() == NSCell.NSOnState) {
914 u = u.or(Permission.Action.write);
916 if(downerx.state() == NSCell.NSOnState) {
917 u = u.or(Permission.Action.execute);
919 Permission.Action g = Permission.Action.none;
920 if(dgroupr.state() == NSCell.NSOnState) {
921 g = g.or(Permission.Action.read);
923 if(dgroupw.state() == NSCell.NSOnState) {
924 g = g.or(Permission.Action.write);
926 if(dgroupx.state() == NSCell.NSOnState) {
927 g = g.or(Permission.Action.execute);
929 Permission.Action o = Permission.Action.none;
930 if(dotherr.state() == NSCell.NSOnState) {
931 o = o.or(Permission.Action.read);
933 if(dotherw.state() == NSCell.NSOnState) {
934 o = o.or(Permission.Action.write);
936 if(dotherx.state() == NSCell.NSOnState) {
937 o = o.or(Permission.Action.execute);
939 final Permission permission = new Permission(u, g, o);
940 if(chmodDownloadTypePopup.selectedItem().tag() == 0) {
941 preferences.setProperty("queue.download.permissions.file.default", permission.getMode());
943 if(chmodDownloadTypePopup.selectedItem().tag() == 1) {
944 preferences.setProperty("queue.download.permissions.folder.default", permission.getMode());
948 @Outlet
949 private NSButton uownerr;
950 @Outlet
951 private NSButton uownerw;
952 @Outlet
953 private NSButton uownerx;
954 @Outlet
955 private NSButton ugroupr;
956 @Outlet
957 private NSButton ugroupw;
958 @Outlet
959 private NSButton ugroupx;
960 @Outlet
961 private NSButton uotherr;
962 @Outlet
963 private NSButton uotherw;
964 @Outlet
965 private NSButton uotherx;
967 public void setUownerr(NSButton uownerr) {
968 this.uownerr = uownerr;
971 public void setUownerw(NSButton uownerw) {
972 this.uownerw = uownerw;
975 public void setUownerx(NSButton uownerx) {
976 this.uownerx = uownerx;
979 public void setUgroupr(NSButton ugroupr) {
980 this.ugroupr = ugroupr;
983 public void setUgroupw(NSButton ugroupw) {
984 this.ugroupw = ugroupw;
987 public void setUgroupx(NSButton ugroupx) {
988 this.ugroupx = ugroupx;
991 public void setUotherr(NSButton uotherr) {
992 this.uotherr = uotherr;
995 public void setUotherw(NSButton uotherw) {
996 this.uotherw = uotherw;
999 public void setUotherx(NSButton uotherx) {
1000 this.uotherx = uotherx;
1003 @Action
1004 public void defaultPermissionsUploadChanged(final NSButton sender) {
1005 Permission.Action u = Permission.Action.none;
1006 if(uownerr.state() == NSCell.NSOnState) {
1007 u = u.or(Permission.Action.read);
1009 if(uownerw.state() == NSCell.NSOnState) {
1010 u = u.or(Permission.Action.write);
1012 if(uownerx.state() == NSCell.NSOnState) {
1013 u = u.or(Permission.Action.execute);
1015 Permission.Action g = Permission.Action.none;
1016 if(ugroupr.state() == NSCell.NSOnState) {
1017 g = g.or(Permission.Action.read);
1019 if(ugroupw.state() == NSCell.NSOnState) {
1020 g = g.or(Permission.Action.write);
1022 if(ugroupx.state() == NSCell.NSOnState) {
1023 g = g.or(Permission.Action.execute);
1025 Permission.Action o = Permission.Action.none;
1026 if(uotherr.state() == NSCell.NSOnState) {
1027 o = o.or(Permission.Action.read);
1029 if(uotherw.state() == NSCell.NSOnState) {
1030 o = o.or(Permission.Action.write);
1032 if(uotherx.state() == NSCell.NSOnState) {
1033 o = o.or(Permission.Action.execute);
1035 final Permission permission = new Permission(u, g, o);
1036 if(chmodUploadTypePopup.selectedItem().tag() == 0) {
1037 preferences.setProperty("queue.upload.permissions.file.default", permission.getMode());
1039 if(chmodUploadTypePopup.selectedItem().tag() == 1) {
1040 preferences.setProperty("queue.upload.permissions.folder.default", permission.getMode());
1044 @Outlet
1045 private NSButton preserveModificationDownloadCheckbox;
1047 public void setPreserveModificationDownloadCheckbox(NSButton b) {
1048 this.preserveModificationDownloadCheckbox = b;
1049 this.preserveModificationDownloadCheckbox.setTarget(this.id());
1050 this.preserveModificationDownloadCheckbox.setAction(Foundation.selector("preserveModificationDownloadCheckboxClicked:"));
1051 this.preserveModificationDownloadCheckbox.setState(preferences.getBoolean("queue.download.timestamp.change") ? NSCell.NSOnState : NSCell.NSOffState);
1054 @Action
1055 public void preserveModificationDownloadCheckboxClicked(final NSButton sender) {
1056 boolean enabled = sender.state() == NSCell.NSOnState;
1057 preferences.setProperty("queue.download.timestamp.change", enabled);
1060 @Outlet
1061 private NSButton preserveModificationUploadCheckbox;
1063 public void setPreserveModificationUploadCheckbox(NSButton b) {
1064 this.preserveModificationUploadCheckbox = b;
1065 this.preserveModificationUploadCheckbox.setTarget(this.id());
1066 this.preserveModificationUploadCheckbox.setAction(Foundation.selector("preserveModificationUploadCheckboxClicked:"));
1067 this.preserveModificationUploadCheckbox.setState(preferences.getBoolean("queue.upload.timestamp.change") ? NSCell.NSOnState : NSCell.NSOffState);
1070 @Action
1071 public void preserveModificationUploadCheckboxClicked(final NSButton sender) {
1072 boolean enabled = sender.state() == NSCell.NSOnState;
1073 preferences.setProperty("queue.upload.timestamp.change", enabled);
1076 @Outlet
1077 private NSButton horizontalLinesCheckbox;
1079 public void setHorizontalLinesCheckbox(NSButton b) {
1080 this.horizontalLinesCheckbox = b;
1081 this.horizontalLinesCheckbox.setTarget(this.id());
1082 this.horizontalLinesCheckbox.setAction(Foundation.selector("horizontalLinesCheckboxClicked:"));
1083 this.horizontalLinesCheckbox.setState(preferences.getBoolean("browser.horizontalLines") ? NSCell.NSOnState : NSCell.NSOffState);
1086 @Action
1087 public void horizontalLinesCheckboxClicked(final NSButton sender) {
1088 boolean enabled = sender.state() == NSCell.NSOnState;
1089 preferences.setProperty("browser.horizontalLines", enabled);
1090 BrowserController.updateBrowserTableAttributes();
1093 @Outlet
1094 private NSButton verticalLinesCheckbox;
1096 public void setVerticalLinesCheckbox(NSButton b) {
1097 this.verticalLinesCheckbox = b;
1098 this.verticalLinesCheckbox.setTarget(this.id());
1099 this.verticalLinesCheckbox.setAction(Foundation.selector("verticalLinesCheckboxClicked:"));
1100 this.verticalLinesCheckbox.setState(preferences.getBoolean("browser.verticalLines") ? NSCell.NSOnState : NSCell.NSOffState);
1103 @Action
1104 public void verticalLinesCheckboxClicked(final NSButton sender) {
1105 boolean enabled = sender.state() == NSCell.NSOnState;
1106 preferences.setProperty("browser.verticalLines", enabled);
1107 BrowserController.updateBrowserTableAttributes();
1110 @Outlet
1111 private NSButton alternatingRowBackgroundCheckbox;
1113 public void setAlternatingRowBackgroundCheckbox(NSButton b) {
1114 this.alternatingRowBackgroundCheckbox = b;
1115 this.alternatingRowBackgroundCheckbox.setTarget(this.id());
1116 this.alternatingRowBackgroundCheckbox.setAction(Foundation.selector("alternatingRowBackgroundCheckboxClicked:"));
1117 this.alternatingRowBackgroundCheckbox.setState(preferences.getBoolean("browser.alternatingRows") ? NSCell.NSOnState : NSCell.NSOffState);
1120 @Action
1121 public void alternatingRowBackgroundCheckboxClicked(final NSButton sender) {
1122 boolean enabled = sender.state() == NSCell.NSOnState;
1123 preferences.setProperty("browser.alternatingRows", enabled);
1124 BrowserController.updateBrowserTableAttributes();
1127 @Outlet
1128 private NSButton infoWindowAsInspectorCheckbox;
1130 public void setInfoWindowAsInspectorCheckbox(NSButton b) {
1131 this.infoWindowAsInspectorCheckbox = b;
1132 this.infoWindowAsInspectorCheckbox.setTarget(this.id());
1133 this.infoWindowAsInspectorCheckbox.setAction(Foundation.selector("infoWindowAsInspectorCheckboxClicked:"));
1134 this.infoWindowAsInspectorCheckbox.setState(preferences.getBoolean("browser.info.inspector") ? NSCell.NSOnState : NSCell.NSOffState);
1137 @Action
1138 public void infoWindowAsInspectorCheckboxClicked(final NSButton sender) {
1139 boolean enabled = sender.state() == NSCell.NSOnState;
1140 preferences.setProperty("browser.info.inspector", enabled);
1143 @Outlet
1144 private NSPopUpButton downloadPathPopup;
1146 private static final String CHOOSE = LocaleFactory.localizedString("Choose") + "…";
1148 // The currently set download folder
1149 private final Local DEFAULT_DOWNLOAD_FOLDER = LocalFactory.get(preferences.getProperty("queue.download.folder"));
1151 public void setDownloadPathPopup(NSPopUpButton b) {
1152 this.downloadPathPopup = b;
1153 this.downloadPathPopup.setTarget(this.id());
1154 final Selector action = Foundation.selector("downloadPathPopupClicked:");
1155 this.downloadPathPopup.setAction(action);
1156 this.downloadPathPopup.removeAllItems();
1157 // Default download folder
1158 this.addDownloadPath(action, DEFAULT_DOWNLOAD_FOLDER);
1159 this.downloadPathPopup.menu().addItem(NSMenuItem.separatorItem());
1160 // Shortcut to the Desktop
1161 this.addDownloadPath(action, LocalFactory.get("~/Desktop"));
1162 // Shortcut to user home
1163 this.addDownloadPath(action, LocalFactory.get("~"));
1164 // Shortcut to user downloads for 10.5
1165 this.addDownloadPath(action, LocalFactory.get("~/Downloads"));
1166 // Choose another folder
1167 this.downloadPathPopup.menu().addItem(NSMenuItem.separatorItem());
1168 this.downloadPathPopup.menu().addItemWithTitle_action_keyEquivalent(CHOOSE, action, StringUtils.EMPTY);
1169 this.downloadPathPopup.lastItem().setTarget(this.id());
1172 private void addDownloadPath(Selector action, Local f) {
1173 this.downloadPathPopup.menu().addItemWithTitle_action_keyEquivalent(f.getDisplayName(), action, StringUtils.EMPTY);
1174 this.downloadPathPopup.lastItem().setTarget(this.id());
1175 this.downloadPathPopup.lastItem().setImage(
1176 IconCacheFactory.<NSImage>get().fileIcon(f, 16)
1178 this.downloadPathPopup.lastItem().setRepresentedObject(f.getAbbreviatedPath());
1179 if(DEFAULT_DOWNLOAD_FOLDER.equals(f)) {
1180 this.downloadPathPopup.selectItem(this.downloadPathPopup.lastItem());
1184 private NSOpenPanel downloadPathPanel;
1186 @Action
1187 public void downloadPathPopupClicked(final NSMenuItem sender) {
1188 if(sender.title().equals(CHOOSE)) {
1189 downloadPathPanel = NSOpenPanel.openPanel();
1190 downloadPathPanel.setCanChooseFiles(false);
1191 downloadPathPanel.setCanChooseDirectories(true);
1192 downloadPathPanel.setAllowsMultipleSelection(false);
1193 downloadPathPanel.setCanCreateDirectories(true);
1194 downloadPathPanel.beginSheetForDirectory(null, null, this.window, this.id(),
1195 Foundation.selector("downloadPathPanelDidEnd:returnCode:contextInfo:"), null);
1197 else {
1198 preferences.setProperty("queue.download.folder", sender.representedObject());
1202 public void downloadPathPanelDidEnd_returnCode_contextInfo(NSOpenPanel sheet, int returncode, ID contextInfo) {
1203 if(returncode == SheetCallback.DEFAULT_OPTION) {
1204 NSArray selected = sheet.filenames();
1205 String filename;
1206 if((filename = selected.lastObject().toString()) != null) {
1207 final Local folder = LocalFactory.get(filename);
1208 preferences.setProperty("queue.download.folder", folder.getAbbreviatedPath());
1209 preferences.setProperty("queue.download.folder.bookmark", folder.getBookmark());
1212 final Local custom = LocalFactory.get(preferences.getProperty("queue.download.folder"));
1213 final NSMenuItem item = downloadPathPopup.itemAtIndex(new NSInteger(0));
1214 item.setTitle(custom.getDisplayName());
1215 item.setRepresentedObject(custom.getAbsolute());
1216 item.setImage(IconCacheFactory.<NSImage>get().fileIcon(custom, 16));
1217 downloadPathPopup.selectItem(item);
1218 downloadPathPanel = null;
1221 @Outlet
1222 private NSPopUpButton transferPopup;
1224 public void setTransferPopup(NSPopUpButton b) {
1225 this.transferPopup = b;
1226 this.transferPopup.setTarget(this.id());
1227 this.transferPopup.setAction(Foundation.selector("transferPopupClicked:"));
1228 this.transferPopup.removeAllItems();
1229 for(String name : preferences.getList("queue.transfer.type.enabled")) {
1230 final Host.TransferType t = Host.TransferType.valueOf(name);
1231 this.transferPopup.addItemWithTitle(t.toString());
1232 this.transferPopup.lastItem().setRepresentedObject(t.name());
1234 this.transferPopup.selectItemAtIndex(this.transferPopup.indexOfItemWithRepresentedObject(
1235 preferences.getProperty("queue.transfer.type")
1239 @Action
1240 public void transferPopupClicked(final NSPopUpButton sender) {
1241 preferences.setProperty("queue.transfer.type", sender.selectedItem().representedObject());
1244 @Outlet
1245 private NSButton downloadSkipButton;
1247 public void setDownloadSkipButton(NSButton b) {
1248 this.downloadSkipButton = b;
1249 this.downloadSkipButton.setTarget(this.id());
1250 this.downloadSkipButton.setAction(Foundation.selector("downloadSkipButtonClicked:"));
1251 this.downloadSkipButton.setState(preferences.getBoolean("queue.download.skip.enable") ? NSCell.NSOnState : NSCell.NSOffState);
1254 @Action
1255 public void downloadSkipButtonClicked(final NSButton sender) {
1256 boolean enabled = sender.state() == NSCell.NSOnState;
1257 downloadSkipRegexField.setSelectable(enabled);
1258 downloadSkipRegexField.setEditable(enabled);
1259 downloadSkipRegexField.setTextColor(enabled ? NSColor.controlTextColor() : NSColor.disabledControlTextColor());
1260 preferences.setProperty("queue.download.skip.enable", enabled);
1263 @Outlet
1264 private NSButton downloadSkipRegexDefaultButton;
1266 public void setDownloadSkipRegexDefaultButton(NSButton b) {
1267 this.downloadSkipRegexDefaultButton = b;
1268 this.downloadSkipRegexDefaultButton.setTarget(this.id());
1269 this.downloadSkipRegexDefaultButton.setAction(Foundation.selector("downloadSkipRegexDefaultButtonClicked:"));
1272 @Action
1273 public void downloadSkipRegexDefaultButtonClicked(final NSButton sender) {
1274 final String regex = preferences.getProperty("queue.download.skip.regex.default");
1275 this.downloadSkipRegexField.setString(regex);
1276 preferences.setProperty("queue.download.skip.regex", regex);
1279 private NSTextView downloadSkipRegexField;
1281 public void setDownloadSkipRegexField(NSTextView t) {
1282 this.downloadSkipRegexField = t;
1283 this.downloadSkipRegexField.setFont(NSFont.userFixedPitchFontOfSize(9.0f));
1284 this.downloadSkipRegexField.setString(preferences.getProperty("queue.download.skip.regex"));
1285 NSNotificationCenter.defaultCenter().addObserver(this.id(),
1286 Foundation.selector("downloadSkipRegexFieldDidChange:"),
1287 NSText.TextDidChangeNotification,
1288 this.downloadSkipRegexField);
1291 public void downloadSkipRegexFieldDidChange(NSNotification sender) {
1292 String value = this.downloadSkipRegexField.string().trim();
1293 if(StringUtils.EMPTY.equals(value)) {
1294 preferences.setProperty("queue.download.skip.enable", false);
1295 preferences.setProperty("queue.download.skip.regex", value);
1296 this.downloadSkipButton.setState(NSCell.NSOffState);
1298 try {
1299 Pattern compiled = Pattern.compile(value);
1300 preferences.setProperty("queue.download.skip.regex",
1301 compiled.pattern());
1302 this.mark(this.downloadSkipRegexField.textStorage(), null);
1304 catch(PatternSyntaxException e) {
1305 this.mark(this.downloadSkipRegexField.textStorage(), e);
1309 @Outlet
1310 private NSButton uploadSkipButton;
1312 public void setUploadSkipButton(NSButton b) {
1313 this.uploadSkipButton = b;
1314 this.uploadSkipButton.setTarget(this.id());
1315 this.uploadSkipButton.setAction(Foundation.selector("uploadSkipButtonClicked:"));
1316 this.uploadSkipButton.setState(preferences.getBoolean("queue.upload.skip.enable") ? NSCell.NSOnState : NSCell.NSOffState);
1319 @Action
1320 public void uploadSkipButtonClicked(final NSButton sender) {
1321 boolean enabled = sender.state() == NSCell.NSOnState;
1322 uploadSkipRegexField.setSelectable(enabled);
1323 uploadSkipRegexField.setEditable(enabled);
1324 uploadSkipRegexField.setTextColor(enabled ? NSColor.controlTextColor() : NSColor.disabledControlTextColor());
1325 preferences.setProperty("queue.upload.skip.enable", enabled);
1328 @Outlet
1329 private NSButton uploadSkipRegexDefaultButton;
1331 public void setUploadSkipRegexDefaultButton(NSButton b) {
1332 this.uploadSkipRegexDefaultButton = b;
1333 this.uploadSkipRegexDefaultButton.setTarget(this.id());
1334 this.uploadSkipRegexDefaultButton.setAction(Foundation.selector("uploadSkipRegexDefaultButtonClicked:"));
1337 @Action
1338 public void uploadSkipRegexDefaultButtonClicked(final NSButton sender) {
1339 final String regex = preferences.getProperty("queue.upload.skip.regex.default");
1340 this.uploadSkipRegexField.setString(regex);
1341 preferences.setProperty("queue.upload.skip.regex", regex);
1344 private NSTextView uploadSkipRegexField;
1346 public void setUploadSkipRegexField(NSTextView b) {
1347 this.uploadSkipRegexField = b;
1348 this.uploadSkipRegexField.setFont(NSFont.userFixedPitchFontOfSize(9.0f));
1349 this.uploadSkipRegexField.setString(preferences.getProperty("queue.upload.skip.regex"));
1350 NSNotificationCenter.defaultCenter().addObserver(this.id(),
1351 Foundation.selector("uploadSkipRegexFieldDidChange:"),
1352 NSText.TextDidChangeNotification,
1353 this.uploadSkipRegexField);
1356 public void uploadSkipRegexFieldDidChange(NSNotification sender) {
1357 String value = this.uploadSkipRegexField.string().trim();
1358 if(StringUtils.EMPTY.equals(value)) {
1359 preferences.setProperty("queue.upload.skip.enable", false);
1360 preferences.setProperty("queue.upload.skip.regex", value);
1361 this.uploadSkipButton.setState(NSCell.NSOffState);
1363 try {
1364 Pattern compiled = Pattern.compile(value);
1365 preferences.setProperty("queue.upload.skip.regex",
1366 compiled.pattern());
1367 this.mark(this.uploadSkipRegexField.textStorage(), null);
1369 catch(PatternSyntaxException e) {
1370 this.mark(this.uploadSkipRegexField.textStorage(), e);
1374 protected static final NSDictionary RED_FONT = NSDictionary.dictionaryWithObjectsForKeys(
1375 NSArray.arrayWithObjects(NSColor.redColor()),
1376 NSArray.arrayWithObjects(NSAttributedString.ForegroundColorAttributeName)
1379 private void mark(NSMutableAttributedString text, PatternSyntaxException e) {
1380 if(null == e) {
1381 text.removeAttributeInRange(
1382 NSAttributedString.ForegroundColorAttributeName,
1383 NSRange.NSMakeRange(new NSUInteger(0), text.length()));
1384 return;
1386 int index = e.getIndex(); //The approximate index in the pattern of the error
1387 NSRange range = null;
1388 if(-1 == index) {
1389 range = NSRange.NSMakeRange(new NSUInteger(0), text.length());
1391 if(index < text.length().intValue()) {
1392 //Initializes the NSRange with the range elements of location and length;
1393 range = NSRange.NSMakeRange(new NSUInteger(index), new NSUInteger(1));
1395 text.addAttributesInRange(RED_FONT, range);
1398 @Outlet
1399 private NSButton keychainCheckbox;
1401 public void setKeychainCheckbox(NSButton b) {
1402 this.keychainCheckbox = b;
1403 this.keychainCheckbox.setTarget(this.id());
1404 this.keychainCheckbox.setAction(Foundation.selector("keychainCheckboxClicked:"));
1405 this.keychainCheckbox.setState(preferences.getBoolean("connection.login.useKeychain") ? NSCell.NSOnState : NSCell.NSOffState);
1408 @Action
1409 public void keychainCheckboxClicked(final NSButton sender) {
1410 boolean enabled = sender.state() == NSCell.NSOnState;
1411 preferences.setProperty("connection.login.useKeychain", enabled);
1414 @Outlet
1415 private NSButton doubleClickCheckbox;
1417 public void setDoubleClickCheckbox(NSButton b) {
1418 this.doubleClickCheckbox = b;
1419 this.doubleClickCheckbox.setTarget(this.id());
1420 this.doubleClickCheckbox.setAction(Foundation.selector("doubleClickCheckboxClicked:"));
1421 this.doubleClickCheckbox.setState(preferences.getBoolean("browser.doubleclick.edit") ? NSCell.NSOnState : NSCell.NSOffState);
1424 @Action
1425 public void doubleClickCheckboxClicked(final NSButton sender) {
1426 boolean enabled = sender.state() == NSCell.NSOnState;
1427 preferences.setProperty("browser.doubleclick.edit", enabled);
1430 @Outlet
1431 private NSButton returnKeyCheckbox;
1433 public void setReturnKeyCheckbox(NSButton b) {
1434 this.returnKeyCheckbox = b;
1435 this.returnKeyCheckbox.setTarget(this.id());
1436 this.returnKeyCheckbox.setAction(Foundation.selector("returnKeyCheckboxClicked:"));
1437 this.returnKeyCheckbox.setState(preferences.getBoolean("browser.enterkey.rename") ? NSCell.NSOnState : NSCell.NSOffState);
1440 @Action
1441 public void returnKeyCheckboxClicked(final NSButton sender) {
1442 boolean enabled = sender.state() == NSCell.NSOnState;
1443 preferences.setProperty("browser.enterkey.rename", enabled);
1446 @Outlet
1447 private NSButton showHiddenCheckbox;
1449 public void setShowHiddenCheckbox(NSButton b) {
1450 this.showHiddenCheckbox = b;
1451 this.showHiddenCheckbox.setTarget(this.id());
1452 this.showHiddenCheckbox.setAction(Foundation.selector("showHiddenCheckboxClicked:"));
1453 this.showHiddenCheckbox.setState(preferences.getBoolean("browser.showHidden") ? NSCell.NSOnState : NSCell.NSOffState);
1456 @Action
1457 public void showHiddenCheckboxClicked(final NSButton sender) {
1458 boolean enabled = sender.state() == NSCell.NSOnState;
1459 preferences.setProperty("browser.showHidden", enabled);
1462 @Outlet
1463 private NSButton bringQueueToFrontCheckbox;
1465 public void setBringQueueToFrontCheckbox(NSButton b) {
1466 this.bringQueueToFrontCheckbox = b;
1467 this.bringQueueToFrontCheckbox.setTarget(this.id());
1468 this.bringQueueToFrontCheckbox.setAction(Foundation.selector("bringQueueToFrontCheckboxClicked:"));
1469 this.bringQueueToFrontCheckbox.setState(preferences.getBoolean("queue.window.open.transfer.start") ? NSCell.NSOnState : NSCell.NSOffState);
1472 @Action
1473 public void bringQueueToFrontCheckboxClicked(final NSButton sender) {
1474 boolean enabled = sender.state() == NSCell.NSOnState;
1475 preferences.setProperty("queue.window.open.transfer.start", enabled);
1478 @Outlet
1479 private NSButton bringQueueToBackCheckbox;
1481 public void setBringQueueToBackCheckbox(NSButton b) {
1482 this.bringQueueToBackCheckbox = b;
1483 this.bringQueueToBackCheckbox.setTarget(this.id());
1484 this.bringQueueToBackCheckbox.setAction(Foundation.selector("bringQueueToBackCheckboxClicked:"));
1485 this.bringQueueToBackCheckbox.setState(preferences.getBoolean("queue.window.open.transfer.stop") ? NSCell.NSOnState : NSCell.NSOffState);
1488 @Action
1489 public void bringQueueToBackCheckboxClicked(final NSButton sender) {
1490 boolean enabled = sender.state() == NSCell.NSOnState;
1491 preferences.setProperty("queue.window.open.transfer.stop", enabled);
1494 @Outlet
1495 private NSButton removeFromQueueCheckbox;
1497 public void setRemoveFromQueueCheckbox(NSButton b) {
1498 this.removeFromQueueCheckbox = b;
1499 this.removeFromQueueCheckbox.setTarget(this.id());
1500 this.removeFromQueueCheckbox.setAction(Foundation.selector("removeFromQueueCheckboxClicked:"));
1501 this.removeFromQueueCheckbox.setState(preferences.getBoolean("queue.removeItemWhenComplete") ? NSCell.NSOnState : NSCell.NSOffState);
1504 @Action
1505 public void removeFromQueueCheckboxClicked(final NSButton sender) {
1506 boolean enabled = sender.state() == NSCell.NSOnState;
1507 preferences.setProperty("queue.removeItemWhenComplete", enabled);
1510 @Outlet
1511 private NSButton openAfterDownloadCheckbox;
1513 public void setOpenAfterDownloadCheckbox(NSButton b) {
1514 this.openAfterDownloadCheckbox = b;
1515 this.openAfterDownloadCheckbox.setTarget(this.id());
1516 this.openAfterDownloadCheckbox.setAction(Foundation.selector("openAfterDownloadCheckboxClicked:"));
1517 this.openAfterDownloadCheckbox.setState(preferences.getBoolean("queue.download.complete.open") ? NSCell.NSOnState : NSCell.NSOffState);
1520 @Action
1521 public void openAfterDownloadCheckboxClicked(final NSButton sender) {
1522 boolean enabled = sender.state() == NSCell.NSOnState;
1523 preferences.setProperty("queue.download.complete.open", enabled);
1526 @Outlet
1527 private NSPopUpButton duplicateDownloadCombobox;
1529 public void setDuplicateDownloadCombobox(NSPopUpButton b) {
1530 this.duplicateDownloadCombobox = b;
1531 this.duplicateDownloadCombobox.setAutoenablesItems(false);
1532 this.duplicateDownloadCombobox.setTarget(this.id());
1533 this.duplicateDownloadCombobox.setAction(Foundation.selector("duplicateDownloadComboboxClicked:"));
1534 this.duplicateDownloadCombobox.removeAllItems();
1535 for(TransferAction action : new TransferAction[]{
1536 TransferAction.callback,
1537 TransferAction.overwrite,
1538 TransferAction.resume,
1539 TransferAction.rename,
1540 TransferAction.renameexisting,
1541 TransferAction.comparison,
1542 TransferAction.skip}) {
1543 this.duplicateDownloadCombobox.addItemWithTitle(action.getTitle());
1544 this.duplicateDownloadCombobox.lastItem().setRepresentedObject(action.name());
1545 this.duplicateDownloadCombobox.addItemWithTitle(action.getDescription());
1546 this.duplicateDownloadCombobox.lastItem().setAttributedTitle(NSAttributedString.attributedStringWithAttributes(action.getDescription(),
1547 MENU_HELP_FONT_ATTRIBUTES));
1548 this.duplicateDownloadCombobox.lastItem().setEnabled(false);
1550 this.duplicateDownloadCombobox.selectItemWithTitle(
1551 TransferAction.forName(preferences.getProperty("queue.download.action")).getTitle());
1554 @Action
1555 public void duplicateDownloadComboboxClicked(NSPopUpButton sender) {
1556 preferences.setProperty("queue.download.action",
1557 TransferAction.forName(sender.selectedItem().representedObject()).name());
1558 this.duplicateDownloadOverwriteButtonClicked(duplicateDownloadOverwriteButton);
1561 @Outlet
1562 private NSButton duplicateDownloadOverwriteButton;
1564 public void setDuplicateDownloadOverwriteButton(NSButton b) {
1565 this.duplicateDownloadOverwriteButton = b;
1566 this.duplicateDownloadOverwriteButton.setTarget(this.id());
1567 this.duplicateDownloadOverwriteButton.setAction(Foundation.selector("duplicateDownloadOverwriteButtonClicked:"));
1568 this.duplicateDownloadOverwriteButton.setState(
1569 preferences.getProperty("queue.download.reload.action").equals(
1570 TransferAction.overwrite.name()) ? NSCell.NSOnState : NSCell.NSOffState);
1573 @Action
1574 public void duplicateDownloadOverwriteButtonClicked(final NSButton sender) {
1575 boolean enabled = sender.state() == NSCell.NSOnState;
1576 if(enabled) {
1577 preferences.setProperty("queue.download.reload.action", TransferAction.overwrite.name());
1579 else {
1580 preferences.setProperty("queue.download.reload.action",
1581 preferences.getProperty("queue.download.action"));
1585 @Outlet
1586 private NSPopUpButton duplicateUploadCombobox;
1588 public void setDuplicateUploadCombobox(NSPopUpButton b) {
1589 this.duplicateUploadCombobox = b;
1590 this.duplicateUploadCombobox.setAutoenablesItems(false);
1591 this.duplicateUploadCombobox.setTarget(this.id());
1592 this.duplicateUploadCombobox.setAction(Foundation.selector("duplicateUploadComboboxClicked:"));
1593 this.duplicateUploadCombobox.removeAllItems();
1594 for(TransferAction action : new TransferAction[]{
1595 TransferAction.callback,
1596 TransferAction.overwrite,
1597 TransferAction.resume,
1598 TransferAction.rename,
1599 TransferAction.renameexisting,
1600 TransferAction.comparison,
1601 TransferAction.skip}) {
1602 this.duplicateUploadCombobox.addItemWithTitle(action.getTitle());
1603 this.duplicateUploadCombobox.lastItem().setRepresentedObject(action.name());
1604 this.duplicateUploadCombobox.addItemWithTitle(action.getDescription());
1605 this.duplicateUploadCombobox.lastItem().setAttributedTitle(NSAttributedString.attributedStringWithAttributes(action.getDescription(),
1606 MENU_HELP_FONT_ATTRIBUTES));
1607 this.duplicateUploadCombobox.lastItem().setEnabled(false);
1609 this.duplicateUploadCombobox.selectItemWithTitle(
1610 TransferAction.forName(preferences.getProperty("queue.upload.action")).getTitle());
1613 @Action
1614 public void duplicateUploadComboboxClicked(NSPopUpButton sender) {
1615 preferences.setProperty("queue.upload.action",
1616 TransferAction.forName(sender.selectedItem().representedObject()).name());
1617 this.duplicateUploadOverwriteButtonClicked(duplicateUploadOverwriteButton);
1620 @Outlet
1621 private NSButton duplicateUploadOverwriteButton;
1623 public void setDuplicateUploadOverwriteButton(NSButton b) {
1624 this.duplicateUploadOverwriteButton = b;
1625 this.duplicateUploadOverwriteButton.setTarget(this.id());
1626 this.duplicateUploadOverwriteButton.setAction(Foundation.selector("duplicateUploadOverwriteButtonClicked:"));
1627 this.duplicateUploadOverwriteButton.setState(
1628 preferences.getProperty("queue.upload.reload.action").equals(
1629 TransferAction.overwrite.name()) ? NSCell.NSOnState : NSCell.NSOffState);
1632 @Action
1633 public void duplicateUploadOverwriteButtonClicked(final NSButton sender) {
1634 boolean enabled = sender.state() == NSCell.NSOnState;
1635 if(enabled) {
1636 preferences.setProperty("queue.upload.reload.action", TransferAction.overwrite.name());
1638 else {
1639 preferences.setProperty("queue.upload.reload.action",
1640 preferences.getProperty("queue.upload.action"));
1644 @Outlet
1645 private NSButton uploadTemporaryFilenameButton;
1647 public void setUploadTemporaryFilenameButton(NSButton b) {
1648 this.uploadTemporaryFilenameButton = b;
1649 this.uploadTemporaryFilenameButton.setTarget(this.id());
1650 this.uploadTemporaryFilenameButton.setAction(Foundation.selector("uploadTemporaryFilenameButtonClicked:"));
1651 this.uploadTemporaryFilenameButton.setState(
1652 preferences.getBoolean("queue.upload.file.temporary") ? NSCell.NSOnState : NSCell.NSOffState);
1655 @Action
1656 public void uploadTemporaryFilenameButtonClicked(final NSButton sender) {
1657 boolean enabled = sender.state() == NSCell.NSOnState;
1658 preferences.setProperty("queue.upload.file.temporary", enabled);
1661 @Outlet
1662 private NSPopUpButton protocolCombobox;
1664 public void setProtocolCombobox(NSPopUpButton b) {
1665 this.protocolCombobox = b;
1666 this.protocolCombobox.setTarget(this.id());
1667 this.protocolCombobox.setAction(Foundation.selector("protocolComboboxClicked:"));
1668 this.protocolCombobox.removeAllItems();
1669 for(Protocol protocol : ProtocolFactory.getEnabledProtocols()) {
1670 this.protocolCombobox.addItemWithTitle(protocol.getDescription());
1672 for(Protocol protocol : ProtocolFactory.getEnabledProtocols()) {
1673 final NSMenuItem item = this.protocolCombobox.itemWithTitle(protocol.getDescription());
1674 item.setRepresentedObject(protocol.getProvider());
1675 item.setImage(IconCacheFactory.<NSImage>get().iconNamed(protocol.icon(), 16));
1678 final Protocol defaultProtocol
1679 = ProtocolFactory.forName(preferences.getProperty("connection.protocol.default"));
1680 this.protocolCombobox.selectItemWithTitle(defaultProtocol.getDescription());
1683 @Action
1684 public void protocolComboboxClicked(NSPopUpButton sender) {
1685 final Protocol selected = ProtocolFactory.forName(sender.selectedItem().representedObject());
1686 preferences.setProperty("connection.protocol.default", selected.getProvider());
1687 preferences.setProperty("connection.port.default", selected.getDefaultPort());
1690 @Outlet
1691 private NSButton confirmDisconnectCheckbox;
1693 public void setConfirmDisconnectCheckbox(NSButton b) {
1694 this.confirmDisconnectCheckbox = b;
1695 this.confirmDisconnectCheckbox.setTarget(this.id());
1696 this.confirmDisconnectCheckbox.setAction(Foundation.selector("confirmDisconnectCheckboxClicked:"));
1697 this.confirmDisconnectCheckbox.setState(preferences.getBoolean("browser.disconnect.confirm") ? NSCell.NSOnState : NSCell.NSOffState);
1700 @Action
1701 public void confirmDisconnectCheckboxClicked(final NSButton sender) {
1702 boolean enabled = sender.state() == NSCell.NSOnState;
1703 preferences.setProperty("browser.disconnect.confirm", enabled);
1706 private void configureDefaultProtocolHandlerCombobox(final NSPopUpButton defaultProtocolHandlerCombobox, final Scheme protocol) {
1707 final Application defaultHandler = SchemeHandlerFactory.get().getDefaultHandler(protocol);
1708 if(Application.notfound.equals(defaultHandler)) {
1709 defaultProtocolHandlerCombobox.addItemWithTitle(LocaleFactory.localizedString("Unknown"));
1710 defaultProtocolHandlerCombobox.setEnabled(false);
1712 else {
1713 if(log.isDebugEnabled()) {
1714 log.debug(String.format("Default Protocol Handler for %s:%s", protocol, defaultHandler));
1716 for(Application handler : SchemeHandlerFactory.get().getAllHandlers(protocol)) {
1717 defaultProtocolHandlerCombobox.addItemWithTitle(handler.getName());
1718 final NSMenuItem item = defaultProtocolHandlerCombobox.lastItem();
1719 item.setImage(IconCacheFactory.<NSImage>get().applicationIcon(handler, 16));
1720 item.setRepresentedObject(handler.getIdentifier());
1721 if(handler.getIdentifier().equals(defaultHandler.getIdentifier())) {
1722 defaultProtocolHandlerCombobox.selectItem(item);
1728 @Outlet
1729 private NSPopUpButton defaultFTPHandlerCombobox;
1731 public void setDefaultFTPHandlerCombobox(NSPopUpButton b) {
1732 this.defaultFTPHandlerCombobox = b;
1733 this.defaultFTPHandlerCombobox.setTarget(this.id());
1734 this.defaultFTPHandlerCombobox.setAction(Foundation.selector("defaultFTPHandlerComboboxClicked:"));
1735 this.defaultFTPHandlerCombobox.removeAllItems();
1738 @Action
1739 public void defaultFTPHandlerComboboxClicked(NSPopUpButton sender) {
1740 String bundle = sender.selectedItem().representedObject();
1741 SchemeHandlerFactory.get().setDefaultHandler(
1742 Arrays.asList(Scheme.ftp, Scheme.ftps),
1743 new Application(bundle)
1747 @Outlet
1748 private NSPopUpButton defaultSFTPHandlerCombobox;
1750 public void setDefaultSFTPHandlerCombobox(NSPopUpButton b) {
1751 this.defaultSFTPHandlerCombobox = b;
1752 this.defaultSFTPHandlerCombobox.setTarget(this.id());
1753 this.defaultSFTPHandlerCombobox.setAction(Foundation.selector("defaultSFTPHandlerComboboxClicked:"));
1754 this.defaultSFTPHandlerCombobox.removeAllItems();
1757 @Action
1758 public void defaultSFTPHandlerComboboxClicked(NSPopUpButton sender) {
1759 String bundle = sender.selectedItem().representedObject();
1760 SchemeHandlerFactory.get().setDefaultHandler(
1761 Arrays.asList(Scheme.sftp), new Application(bundle)
1765 @Outlet
1766 private NSPopUpButton defaultDownloadThrottleCombobox;
1768 public void setDefaultDownloadThrottleCombobox(NSPopUpButton b) {
1769 this.defaultDownloadThrottleCombobox = b;
1770 this.defaultDownloadThrottleCombobox.setTarget(this.id());
1771 this.defaultDownloadThrottleCombobox.setAction(Foundation.selector("defaultDownloadThrottleComboboxClicked:"));
1772 int bandwidth = (int) preferences.getDouble("queue.download.bandwidth.bytes");
1773 final StringTokenizer options = new StringTokenizer(preferences.getProperty("queue.bandwidth.options"), ",");
1774 while(options.hasMoreTokens()) {
1775 final String bytes = options.nextToken();
1776 this.defaultDownloadThrottleCombobox.addItemWithTitle(SizeFormatterFactory.get().format(Integer.parseInt(bytes)) + "/s");
1777 this.defaultDownloadThrottleCombobox.lastItem().setRepresentedObject(bytes);
1779 if(-1 == bandwidth) {
1780 this.defaultDownloadThrottleCombobox.selectItemWithTag(new NSInteger(-1));
1782 else {
1783 this.defaultDownloadThrottleCombobox.selectItemAtIndex(
1784 this.defaultDownloadThrottleCombobox.menu().indexOfItemWithRepresentedObject(String.valueOf(bandwidth)));
1788 @Action
1789 public void defaultDownloadThrottleComboboxClicked(NSPopUpButton sender) {
1790 String bytes = sender.selectedItem().representedObject();
1791 if(null == bytes) {
1792 preferences.setProperty("queue.download.bandwidth.bytes", -1);
1794 else {
1795 preferences.setProperty("queue.download.bandwidth.bytes", Integer.parseInt(bytes));
1799 @Outlet
1800 private NSPopUpButton defaultUploadThrottleCombobox;
1802 public void setDefaultUploadThrottleCombobox(NSPopUpButton b) {
1803 this.defaultUploadThrottleCombobox = b;
1804 this.defaultUploadThrottleCombobox.setTarget(this.id());
1805 this.defaultUploadThrottleCombobox.setAction(Foundation.selector("defaultUploadThrottleComboboxClicked:"));
1806 int bandwidth = (int) preferences.getDouble("queue.upload.bandwidth.bytes");
1807 final StringTokenizer options = new StringTokenizer(preferences.getProperty("queue.bandwidth.options"), ",");
1808 while(options.hasMoreTokens()) {
1809 final String bytes = options.nextToken();
1810 this.defaultUploadThrottleCombobox.addItemWithTitle(SizeFormatterFactory.get().format(Integer.parseInt(bytes)) + "/s");
1811 this.defaultUploadThrottleCombobox.lastItem().setRepresentedObject(bytes);
1813 if(-1 == bandwidth) {
1814 this.defaultUploadThrottleCombobox.selectItemWithTag(new NSInteger(-1));
1816 else {
1817 this.defaultUploadThrottleCombobox.selectItemAtIndex(
1818 this.defaultUploadThrottleCombobox.menu().indexOfItemWithRepresentedObject(String.valueOf(bandwidth)));
1822 public void defaultUploadThrottleComboboxClicked(NSPopUpButton sender) {
1823 String bytes = sender.selectedItem().representedObject();
1824 if(null == bytes) {
1825 preferences.setProperty("queue.upload.bandwidth.bytes", -1);
1827 else {
1828 preferences.setProperty("queue.upload.bandwidth.bytes", Integer.parseInt(bytes));
1832 @Outlet
1833 private NSButton updateCheckbox;
1835 public void setUpdateCheckbox(NSButton b) {
1836 this.updateCheckbox = b;
1837 this.updateCheckbox.setTarget(this.id());
1838 this.updateCheckbox.setAction(Foundation.selector("updateCheckboxClicked:"));
1839 this.updateCheckbox.setState(preferences.getBoolean("update.check") ? NSCell.NSOnState : NSCell.NSOffState);
1842 @Action
1843 public void updateCheckboxClicked(final NSButton sender) {
1844 boolean enabled = sender.state() == NSCell.NSOnState;
1845 preferences.setProperty("update.check", enabled);
1846 // Update the Sparkle property. Default is in Info.plist
1847 if(enabled) {
1848 preferences.setProperty("SUScheduledCheckInterval", preferences.getProperty("update.check.interval"));
1850 else {
1851 preferences.deleteProperty("SUScheduledCheckInterval");
1855 @Outlet
1856 private NSButton updateCheckButton;
1858 public void setUpdateCheckButton(NSButton b) {
1859 this.updateCheckButton = b;
1860 this.updateCheckButton.setTarget(NSApplication.sharedApplication().delegate());
1861 this.updateCheckButton.setAction(Foundation.selector("updateMenuClicked:"));
1864 @Outlet
1865 private NSPopUpButton updateFeedPopup;
1867 public void setUpdateFeedPopup(NSPopUpButton b) {
1868 this.updateFeedPopup = b;
1869 this.updateFeedPopup.removeAllItems();
1870 this.updateFeedPopup.setAction(Foundation.selector("updateFeedPopupClicked:"));
1871 this.updateFeedPopup.addItemWithTitle(LocaleFactory.localizedString("Release"));
1872 this.updateFeedPopup.lastItem().setRepresentedObject(preferences.getProperty("update.feed.release"));
1873 this.updateFeedPopup.addItemWithTitle(LocaleFactory.localizedString("Beta"));
1874 this.updateFeedPopup.lastItem().setRepresentedObject(preferences.getProperty("update.feed.beta"));
1875 this.updateFeedPopup.addItemWithTitle(LocaleFactory.localizedString("Snapshot Builds"));
1876 this.updateFeedPopup.lastItem().setRepresentedObject(preferences.getProperty("update.feed.nightly"));
1877 String feed = preferences.getProperty("SUFeedURL");
1878 NSInteger selected = this.updateFeedPopup.menu().indexOfItemWithRepresentedObject(feed);
1879 if(-1 == selected.intValue()) {
1880 log.warn(String.format("Invalid feed setting:%s", feed));
1881 this.updateFeedPopup.selectItemAtIndex(this.updateFeedPopup.menu().indexOfItemWithRepresentedObject(
1882 preferences.getProperty("update.feed.release")));
1884 else {
1885 this.updateFeedPopup.selectItemAtIndex(selected);
1889 @Action
1890 public void updateFeedPopupClicked(NSPopUpButton sender) {
1891 // Update sparkle feed property. Default is in Info.plist
1892 String selected = sender.selectedItem().representedObject();
1893 if(null == selected || preferences.getDefault("SUFeedURL").equals(selected)) {
1894 // Remove custom value
1895 preferences.deleteProperty("SUFeedURL");
1897 else {
1898 preferences.setProperty("SUFeedURL", selected);
1902 @Outlet
1903 private NSPopUpButton defaultBucketLocation;
1905 public void setDefaultBucketLocation(NSPopUpButton b) {
1906 this.defaultBucketLocation = b;
1907 this.defaultBucketLocation.setAutoenablesItems(false);
1908 this.defaultBucketLocation.removeAllItems();
1909 for(Location.Name location : ProtocolFactory.S3_SSL.getRegions()) {
1910 this.defaultBucketLocation.addItemWithTitle(location.toString());
1911 this.defaultBucketLocation.lastItem().setRepresentedObject(location.getIdentifier());
1913 this.defaultBucketLocation.setTarget(this.id());
1914 this.defaultBucketLocation.setAction(Foundation.selector("defaultBucketLocationClicked:"));
1915 this.defaultBucketLocation.selectItemWithTitle(LocaleFactory.localizedString(preferences.getProperty("s3.location"), "S3"));
1918 @Action
1919 public void defaultBucketLocationClicked(NSPopUpButton sender) {
1920 preferences.setProperty("s3.location", sender.selectedItem().representedObject());
1923 @Outlet
1924 private NSPopUpButton defaultStorageClassPopup;
1926 public void setDefaultStorageClassPopup(NSPopUpButton b) {
1927 this.defaultStorageClassPopup = b;
1928 this.defaultStorageClassPopup.setAutoenablesItems(false);
1929 this.defaultStorageClassPopup.removeAllItems();
1930 this.defaultStorageClassPopup.addItemWithTitle(LocaleFactory.localizedString(S3Object.STORAGE_CLASS_STANDARD, "S3"));
1931 this.defaultStorageClassPopup.lastItem().setRepresentedObject(S3Object.STORAGE_CLASS_STANDARD);
1932 this.defaultStorageClassPopup.addItemWithTitle(LocaleFactory.localizedString(S3Object.STORAGE_CLASS_REDUCED_REDUNDANCY, "S3"));
1933 this.defaultStorageClassPopup.lastItem().setRepresentedObject(S3Object.STORAGE_CLASS_REDUCED_REDUNDANCY);
1934 this.defaultStorageClassPopup.setTarget(this.id());
1935 this.defaultStorageClassPopup.setAction(Foundation.selector("defaultStorageClassPopupClicked:"));
1936 this.defaultStorageClassPopup.selectItemWithTitle(LocaleFactory.localizedString(preferences.getProperty("s3.storage.class"), "S3"));
1939 @Action
1940 public void defaultStorageClassPopupClicked(NSPopUpButton sender) {
1941 preferences.setProperty("s3.storage.class", sender.selectedItem().representedObject());
1944 @Outlet
1945 private NSPopUpButton defaultEncryptionPopup;
1947 public void setDefaultEncryptionPopup(NSPopUpButton b) {
1948 this.defaultEncryptionPopup = b;
1949 this.defaultEncryptionPopup.setAutoenablesItems(false);
1950 this.defaultEncryptionPopup.removeAllItems();
1951 this.defaultEncryptionPopup.addItemWithTitle(LocaleFactory.localizedString("None"));
1952 this.defaultEncryptionPopup.addItemWithTitle(LocaleFactory.localizedString("AES256", "S3"));
1953 this.defaultEncryptionPopup.lastItem().setRepresentedObject("AES256");
1954 this.defaultEncryptionPopup.setTarget(this.id());
1955 this.defaultEncryptionPopup.setAction(Foundation.selector("defaultEncryptionPopupClicked:"));
1956 if(StringUtils.isNotBlank(preferences.getProperty("s3.encryption.algorithm"))) {
1957 this.defaultEncryptionPopup.selectItemWithTitle(LocaleFactory.localizedString(preferences.getProperty("s3.encryption.algorithm"), "S3"));
1959 else {
1960 this.defaultEncryptionPopup.selectItemWithTitle(LocaleFactory.localizedString("None"));
1964 @Action
1965 public void defaultEncryptionPopupClicked(NSPopUpButton sender) {
1966 preferences.setProperty("s3.encryption.algorithm", sender.selectedItem().representedObject());
1969 @Outlet
1970 private NSPopUpButton documentExportFormatPopup;
1972 public void setDocumentExportFormatPopup(NSPopUpButton b) {
1973 this.documentExportFormatPopup = b;
1974 this.documentExportFormatPopup.setAutoenablesItems(false);
1975 this.documentExportFormatPopup.removeAllItems();
1976 StringTokenizer formats = new StringTokenizer(
1977 preferences.getProperty("google.docs.export.document.formats"), ",");
1978 while(formats.hasMoreTokens()) {
1979 String format = formats.nextToken();
1980 final String description = FileDescriptorFactory.get().getKind(format);
1981 final String suffix = String.format(" (.%s)", format);
1982 final StringBuilder title = new StringBuilder(description);
1983 if(!description.endsWith(suffix)) {
1984 title.append(suffix);
1986 this.documentExportFormatPopup.addItemWithTitle(title.toString());
1987 this.documentExportFormatPopup.lastItem().setRepresentedObject(format);
1988 if(format.equals(preferences.getProperty("google.docs.export.document"))) {
1989 this.documentExportFormatPopup.selectItemWithTitle(title.toString());
1992 this.documentExportFormatPopup.setTarget(this.id());
1993 this.documentExportFormatPopup.setAction(Foundation.selector("documentExportFormatPopupClicked:"));
1996 @Action
1997 public void documentExportFormatPopupClicked(NSPopUpButton sender) {
1998 preferences.setProperty("google.docs.export.document", sender.selectedItem().representedObject());
2001 @Outlet
2002 private NSPopUpButton spreadsheetExportFormatPopup;
2004 public void setSpreadsheetExportFormatPopup(NSPopUpButton b) {
2005 this.spreadsheetExportFormatPopup = b;
2006 this.spreadsheetExportFormatPopup.setAutoenablesItems(false);
2007 this.spreadsheetExportFormatPopup.removeAllItems();
2008 StringTokenizer formats = new StringTokenizer(
2009 preferences.getProperty("google.docs.export.spreadsheet.formats"), ",");
2010 while(formats.hasMoreTokens()) {
2011 String format = formats.nextToken();
2012 final String title = String.format("%s (.%s)", FileDescriptorFactory.get().getKind(format), format);
2013 this.spreadsheetExportFormatPopup.addItemWithTitle(title);
2014 this.spreadsheetExportFormatPopup.lastItem().setRepresentedObject(format);
2015 if(format.equals(preferences.getProperty("google.docs.export.spreadsheet"))) {
2016 this.spreadsheetExportFormatPopup.selectItemWithTitle(title);
2019 this.spreadsheetExportFormatPopup.setTarget(this.id());
2020 this.spreadsheetExportFormatPopup.setAction(Foundation.selector("spreadsheetExportFormatPopupClicked:"));
2023 @Action
2024 public void spreadsheetExportFormatPopupClicked(NSPopUpButton sender) {
2025 preferences.setProperty("google.docs.export.spreadsheet", sender.selectedItem().representedObject());
2028 @Outlet
2029 private NSPopUpButton presentationExportFormatPopup;
2031 public void setPresentationExportFormatPopup(NSPopUpButton b) {
2032 this.presentationExportFormatPopup = b;
2033 this.presentationExportFormatPopup.setAutoenablesItems(false);
2034 this.presentationExportFormatPopup.removeAllItems();
2035 StringTokenizer formats = new StringTokenizer(
2036 preferences.getProperty("google.docs.export.presentation.formats"), ",");
2037 while(formats.hasMoreTokens()) {
2038 String format = formats.nextToken();
2039 final String title = String.format("%s (.%s)", FileDescriptorFactory.get().getKind(format), format);
2040 this.presentationExportFormatPopup.addItemWithTitle(title);
2041 this.presentationExportFormatPopup.lastItem().setRepresentedObject(format);
2042 if(format.equals(preferences.getProperty("google.docs.export.presentation"))) {
2043 this.presentationExportFormatPopup.selectItemWithTitle(title);
2046 this.presentationExportFormatPopup.setTarget(this.id());
2047 this.presentationExportFormatPopup.setAction(Foundation.selector("presentationExportFormatPopupClicked:"));
2050 @Action
2051 public void presentationExportFormatPopupClicked(NSPopUpButton sender) {
2052 preferences.setProperty("google.docs.export.presentation", sender.selectedItem().representedObject());
2055 @Outlet
2056 private NSButton convertUploadsCheckbox;
2058 public void setConvertUploadsCheckbox(NSButton b) {
2059 this.convertUploadsCheckbox = b;
2060 this.convertUploadsCheckbox.setTarget(this.id());
2061 this.convertUploadsCheckbox.setAction(Foundation.selector("convertUploadsCheckboxClicked:"));
2062 this.convertUploadsCheckbox.setState(preferences.getBoolean("google.docs.upload.convert") ? NSCell.NSOnState : NSCell.NSOffState);
2065 @Action
2066 public void convertUploadsCheckboxClicked(NSButton sender) {
2067 preferences.setProperty("google.docs.upload.convert", sender.state() == NSCell.NSOnState);
2070 @Outlet
2071 private NSButton ocrUploadsCheckbox;
2073 public void setOcrUploadsCheckbox(NSButton b) {
2074 this.ocrUploadsCheckbox = b;
2075 this.ocrUploadsCheckbox.setTarget(this.id());
2076 this.ocrUploadsCheckbox.setAction(Foundation.selector("ocrUploadsCheckboxClicked:"));
2077 this.ocrUploadsCheckbox.setState(preferences.getBoolean("google.docs.upload.ocr") ? NSCell.NSOnState : NSCell.NSOffState);
2080 @Action
2081 public void ocrUploadsCheckboxClicked(NSButton sender) {
2082 preferences.setProperty("google.docs.upload.ocr", sender.state() == NSCell.NSOnState);
2085 @Outlet
2086 private NSPopUpButton languagePopup;
2088 public void setLanguagePopup(NSPopUpButton b) {
2089 this.languagePopup = b;
2090 this.languagePopup.removeAllItems();
2091 this.languagePopup.setTarget(this.id());
2092 this.languagePopup.setAction(Foundation.selector("languagePopupClicked:"));
2093 this.languagePopup.addItemWithTitle(LocaleFactory.localizedString("Default"));
2094 this.languagePopup.menu().addItem(NSMenuItem.separatorItem());
2095 String custom = null;
2096 if(preferences.systemLocales().size() > 1) {
2097 // No user default application scope single value of AppleLanguages property is set but a list
2098 // of preferred languages from system preferences is returned.
2099 this.languagePopup.selectItemWithTitle(LocaleFactory.localizedString("Default"));
2101 else {
2102 // Custom language set for this application identifier
2103 custom = preferences.locale();
2105 for(String identifier : preferences.applicationLocales()) {
2106 this.languagePopup.addItemWithTitle(preferences.getDisplayName(identifier));
2107 this.languagePopup.lastItem().setRepresentedObject(identifier);
2108 if(identifier.equals(custom)) {
2109 this.languagePopup.selectItem(this.languagePopup.lastItem());
2114 @Action
2115 public void languagePopupClicked(NSPopUpButton sender) {
2116 LocaleFactory.get().setDefault(sender.selectedItem().representedObject());
2119 @Outlet
2120 private NSPopUpButton useProxiesButton;
2122 public void setUseProxiesButton(NSPopUpButton b) {
2123 this.useProxiesButton = b;
2124 this.useProxiesButton.setTarget(this.id());
2125 this.useProxiesButton.setAction(Foundation.selector("useProxiesButtonClicked:"));
2126 this.useProxiesButton.setState(preferences.getBoolean("connection.proxy.enable") ? NSCell.NSOnState : NSCell.NSOffState);
2129 @Action
2130 public void useProxiesButtonClicked(NSButton sender) {
2131 preferences.setProperty("connection.proxy.enable", sender.state() == NSCell.NSOnState);
2134 @Outlet
2135 private NSButton configureProxiesButton;
2137 public void setConfigureProxiesButton(NSButton b) {
2138 this.configureProxiesButton = b;
2139 this.configureProxiesButton.setTarget(this.id());
2140 this.configureProxiesButton.setAction(Foundation.selector("configureProxiesButtonClicked:"));
2143 @Action
2144 public void configureProxiesButtonClicked(NSButton sender) {
2145 final String script = "tell application \"System Preferences\"\n" +
2146 "activate\n" +
2147 "reveal anchor \"Proxies\" of pane \"com.apple.preference.network\"\n" +
2148 "end tell";
2149 NSAppleScript open = NSAppleScript.createWithSource(script);
2150 open.executeAndReturnError(null);