/
ConnectionControllerFactory.java
52 lines (45 loc) · 1.64 KB
/
ConnectionControllerFactory.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package ch.cyberduck.ui.cocoa;
/*
* Copyright (c) 2002-2013 David Kocher. All rights reserved.
* http://cyberduck.ch/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* Bug fixes, suggestions and comments should be sent to feedback@cyberduck.ch
*/
import ch.cyberduck.ui.cocoa.application.NSApplication;
import java.util.HashMap;
import java.util.Map;
/**
* @version $Id:$
*/
public final class ConnectionControllerFactory {
private static final Map<WindowController, ConnectionController> open
= new HashMap<WindowController, ConnectionController>();
private ConnectionControllerFactory() {
//
}
public static ConnectionController create(final WindowController parent) {
synchronized(NSApplication.sharedApplication()) {
if(!open.containsKey(parent)) {
final ConnectionController c = new ConnectionController(parent) {
@Override
protected void invalidate() {
open.remove(parent);
super.invalidate();
}
};
open.put(parent, c);
}
return open.get(parent);
}
}
}