Added
Link Here
|
1 |
/******************************************************************************** |
2 |
* Copyright (c) 2004, 2008 IBM Corporation and others. All rights reserved. |
3 |
* This program and the accompanying materials are made available under the terms |
4 |
* of the Eclipse Public License v1.0 which accompanies this distribution, and is |
5 |
* available at http://www.eclipse.org/legal/epl-v10.html |
6 |
* |
7 |
* Initial Contributors: |
8 |
* The following IBM employees contributed to the Remote System Explorer |
9 |
* component that contains this file: David McKnight, Kushal Munir, |
10 |
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, |
11 |
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. |
12 |
* |
13 |
* Contributors: |
14 |
* Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType |
15 |
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry |
16 |
* Martin Oberhuber (Wind River) - [202866] Fix exceptions in RSE browse dialog when SystemRegistry is not yet fully initialized |
17 |
* David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types |
18 |
********************************************************************************/ |
19 |
|
20 |
package org.eclipse.rse.internal.ui.view; |
21 |
import org.eclipse.rse.core.IRSESystemType; |
22 |
import org.eclipse.rse.core.RSECorePlugin; |
23 |
import org.eclipse.rse.core.model.IHost; |
24 |
import org.eclipse.rse.core.model.ISystemRegistry; |
25 |
import org.eclipse.rse.core.subsystems.ISubSystem; |
26 |
import org.eclipse.rse.ui.view.ISystemResourceSelectionInputProvider; |
27 |
import org.eclipse.rse.ui.view.SystemAbstractAPIProvider; |
28 |
|
29 |
|
30 |
public abstract class SystemResourceSelectionInputProvider extends SystemAbstractAPIProvider |
31 |
implements ISystemResourceSelectionInputProvider |
32 |
{ |
33 |
private IHost _connection = null; |
34 |
private boolean _onlyConnection = false; |
35 |
private boolean _allowNew = true; |
36 |
private IRSESystemType[] _systemTypes; |
37 |
private String _category = null; |
38 |
|
39 |
public SystemResourceSelectionInputProvider(IHost connection) |
40 |
{ |
41 |
_connection = connection; |
42 |
} |
43 |
|
44 |
public SystemResourceSelectionInputProvider() |
45 |
{ |
46 |
// choose random host |
47 |
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry(); |
48 |
IHost[] hosts = registry.getHosts(); |
49 |
if (hosts != null && hosts.length>0) { |
50 |
_connection = hosts[0]; |
51 |
} |
52 |
} |
53 |
|
54 |
public IHost getSystemConnection() |
55 |
{ |
56 |
return _connection; |
57 |
} |
58 |
|
59 |
public boolean allowMultipleConnections() |
60 |
{ |
61 |
return !_onlyConnection; |
62 |
} |
63 |
|
64 |
public void setAllowNewConnection(boolean flag) |
65 |
{ |
66 |
_allowNew = flag; |
67 |
} |
68 |
|
69 |
public boolean allowNewConnection() |
70 |
{ |
71 |
return _allowNew; |
72 |
} |
73 |
|
74 |
public void setSystemConnection(IHost connection, boolean onlyConnection) |
75 |
{ |
76 |
_connection = connection; |
77 |
_onlyConnection = onlyConnection; |
78 |
} |
79 |
|
80 |
public IRSESystemType[] getSystemTypes() |
81 |
{ |
82 |
return _systemTypes; |
83 |
} |
84 |
|
85 |
public void setSystemTypes(IRSESystemType[] types) |
86 |
{ |
87 |
_systemTypes = types; |
88 |
} |
89 |
|
90 |
public Object[] getSystemViewRoots() |
91 |
{ |
92 |
if (_connection == null) |
93 |
{ |
94 |
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry(); |
95 |
IHost[] hosts = registry.getHosts(); |
96 |
if (hosts!=null && hosts.length!=0) { |
97 |
_connection = registry.getHosts()[0]; |
98 |
} |
99 |
} |
100 |
return getConnectionChildren(_connection); |
101 |
} |
102 |
|
103 |
public boolean hasSystemViewRoots() |
104 |
{ |
105 |
return false; |
106 |
} |
107 |
|
108 |
public Object[] getConnectionChildren(IHost selectedConnection) |
109 |
{ |
110 |
if (selectedConnection != null) |
111 |
{ |
112 |
ISubSystem ss = getSubSystem(selectedConnection); |
113 |
if (ss!=null) { |
114 |
return ss.getChildren(); |
115 |
} |
116 |
} |
117 |
return new Object[0]; |
118 |
} |
119 |
|
120 |
public boolean hasConnectionChildren(IHost selectedConnection) |
121 |
{ |
122 |
if (selectedConnection != null) |
123 |
{ |
124 |
ISubSystem ss = getSubSystem(selectedConnection); |
125 |
if (ss!=null) { |
126 |
return ss.hasChildren(); |
127 |
} |
128 |
} |
129 |
return false; |
130 |
} |
131 |
|
132 |
protected abstract ISubSystem getSubSystem(IHost selectedConnection); |
133 |
|
134 |
|
135 |
public void setCategory(String category) |
136 |
{ |
137 |
_category = category; |
138 |
} |
139 |
|
140 |
public String getCategory() |
141 |
{ |
142 |
return _category; |
143 |
} |
144 |
|
145 |
|
146 |
} |