API  1.0.0
CPOpenPanel.j
Go to the documentation of this file.
1 /*
2  * CPOpenPanel.j
3  * AppKit
4  *
5  * Created by Ross Boucher.
6  * Copyright 2009, 280 North, Inc.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library 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 GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 
24 
25 @implementation CPOpenPanel : CPPanel
26 {
27  BOOL _canChooseFiles;
28  BOOL _canChooseDirectories;
29  BOOL _allowsMultipleSelection;
30  CPURL _directoryURL;
31  CPArray _URLs;
32 }
33 
34 + (id)openPanel
35 {
36  return [[CPOpenPanel alloc] init];
37 }
38 
39 - (CPInteger)runModal
40 {
41  if (typeof window["cpOpenPanel"] === "function")
42  {
43  // FIXME: Is this correct???
44  [[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
45 
46  var options = { directoryURL: [self directoryURL],
47  canChooseFiles: [self canChooseFiles],
48  canChooseDirectories: [self canChooseDirectories],
49  allowsMultipleSelection: [self allowsMultipleSelection] },
50 
51  result = window.cpOpenPanel(options);
52 
53  _URLs = result.URLs;
54 
55  return result.button;
56  }
57 
58  throw "-runModal is unimplemented.";
59 }
60 
61 - (CPArray)URLs
62 {
63  return _URLs;
64 }
65 
66 @end
67 
69 
73 - (BOOL)canChooseFiles
74 {
75  return _canChooseFiles;
76 }
77 
81 - (void)setCanChooseFiles:(BOOL)aValue
82 {
83  _canChooseFiles = aValue;
84 }
85 
89 - (BOOL)canChooseDirectories
90 {
91  return _canChooseDirectories;
92 }
93 
97 - (void)setCanChooseDirectories:(BOOL)aValue
98 {
99  _canChooseDirectories = aValue;
100 }
101 
105 - (BOOL)allowsMultipleSelection
106 {
107  return _allowsMultipleSelection;
108 }
109 
113 - (void)setAllowsMultipleSelection:(BOOL)aValue
114 {
115  _allowsMultipleSelection = aValue;
116 }
117 
121 - (CPURL)directoryURL
122 {
123  return _directoryURL;
124 }
125 
129 - (void)setDirectoryURL:(CPURL)aValue
130 {
131  _directoryURL = aValue;
132 }
133 
134 @end
BOOL allowsMultipleSelection()
Definition: CPOpenPanel.j:105
BOOL canChooseDirectories()
Definition: CPOpenPanel.j:89
The main run loop for the application.
Definition: CPRunLoop.h:2
CPRunLoop currentRunLoop()
Definition: CPRunLoop.j:232
CPDate limitDateForMode:(CPString aMode)
Definition: CPRunLoop.j:342
CPURL directoryURL()
Definition: CPOpenPanel.j:121
Definition: CPPanel.h:2
BOOL canChooseFiles()
Definition: CPOpenPanel.j:73
Definition: CPURL.h:2
id alloc()
Definition: CPObject.j:130