Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2002, 2008 IBM Corporation and others. |
2 |
* Copyright (c) 2002, 2009 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 14-19
Link Here
|
14 |
* Contributors: |
14 |
* Contributors: |
15 |
* Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core |
15 |
* Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core |
16 |
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry |
16 |
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry |
|
|
17 |
* David McKnight (IBM) - [190805] [performance][dstore] Right-click > Disconnect on a dstore connection is slow and spawns many Jobs |
17 |
*******************************************************************************/ |
18 |
*******************************************************************************/ |
18 |
|
19 |
|
19 |
package org.eclipse.rse.internal.subsystems.files.dstore; |
20 |
package org.eclipse.rse.internal.subsystems.files.dstore; |
Lines 40-47
Link Here
|
40 |
import org.eclipse.rse.internal.subsystems.files.core.SystemFileResources; |
41 |
import org.eclipse.rse.internal.subsystems.files.core.SystemFileResources; |
41 |
import org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem; |
42 |
import org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem; |
42 |
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; |
43 |
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; |
43 |
import org.eclipse.rse.ui.SystemBasePlugin; |
|
|
44 |
import org.eclipse.swt.widgets.Display; |
45 |
import org.eclipse.swt.widgets.Shell; |
44 |
import org.eclipse.swt.widgets.Shell; |
46 |
import org.eclipse.ui.progress.UIJob; |
45 |
import org.eclipse.ui.progress.UIJob; |
47 |
|
46 |
|
Lines 64-105
Link Here
|
64 |
protected boolean _networkDown = false; |
63 |
protected boolean _networkDown = false; |
65 |
|
64 |
|
66 |
protected HashMap _decorateJobs; |
65 |
protected HashMap _decorateJobs; |
67 |
|
66 |
|
68 |
protected static class FindShell implements Runnable |
67 |
protected boolean _finished = false; |
69 |
{ |
|
|
70 |
|
71 |
private Shell shell; |
72 |
|
73 |
/** |
74 |
* @see Runnable#run() |
75 |
*/ |
76 |
public void run() |
77 |
{ |
78 |
try |
79 |
{ |
80 |
Shell[] shells = Display.getCurrent().getShells(); |
81 |
for (int loop = 0; loop < shells.length && shell == null; loop++) |
82 |
{ |
83 |
if (shells[loop].isEnabled()) |
84 |
{ |
85 |
shell = shells[loop]; |
86 |
} |
87 |
} |
88 |
} |
89 |
catch (Exception e) |
90 |
{ |
91 |
SystemBasePlugin.logError( |
92 |
"StatusChangeListener.FindShell exception: ", e); //$NON-NLS-1$ |
93 |
} |
94 |
} |
95 |
} |
96 |
|
68 |
|
97 |
public class DecorateJob extends UIJob |
69 |
public class DecorateJob extends UIJob |
98 |
{ |
70 |
{ |
99 |
private DStoreFile[] _files; |
71 |
private DataElement[] _files; |
100 |
private DStoreFile _parentFile; |
72 |
private DStoreFile _parentFile; |
101 |
private boolean _isDone = false; |
73 |
private boolean _isDone = false; |
102 |
public DecorateJob(DStoreFile[] files, DStoreFile parentFile) |
74 |
public DecorateJob(DataElement[] files, DStoreFile parentFile) |
103 |
{ |
75 |
{ |
104 |
super(SystemFileResources.RESID_JOB_DECORATEFILES_NAME); |
76 |
super(SystemFileResources.RESID_JOB_DECORATEFILES_NAME); |
105 |
_files= files; |
77 |
_files= files; |
Lines 114-136
Link Here
|
114 |
public IStatus runInUIThread(IProgressMonitor monitor) |
86 |
public IStatus runInUIThread(IProgressMonitor monitor) |
115 |
{ |
87 |
{ |
116 |
_isDone = false; |
88 |
_isDone = false; |
117 |
for (int i = 0; i < _files.length; i++) |
89 |
IRemoteFile[] children = new IRemoteFile[_files.length]; |
118 |
{ |
90 |
try { |
119 |
_registry.fireEvent(new |
91 |
for (int i = 0; i < _files.length; i++) |
120 |
org.eclipse.rse.core.events.SystemResourceChangeEvent(_files[i], |
92 |
{ |
121 |
ISystemResourceChangeEvents.EVENT_ICON_CHANGE, |
93 |
DataElement file = _files[i]; |
122 |
_parentFile)); |
94 |
StringBuffer path = new StringBuffer(file.getAttribute(DE.A_VALUE)); |
123 |
} |
95 |
path.append(_fileSubSystem.getSeparatorChar()); |
124 |
|
96 |
path.append(file.getName()); |
125 |
/* |
97 |
|
126 |
_registry.fireEvent(new |
98 |
children[i] = _fileSubSystem.getRemoteFileObject(path.toString(), monitor); |
127 |
org.eclipse.rse.ui.model.SystemResourceChangeEvent(_files, |
99 |
} |
128 |
ISystemResourceChangeEvent.EVENT_REPLACE_CHILDREN, |
100 |
|
129 |
_parentFile)); |
101 |
_registry.fireEvent(new |
130 |
*/ |
102 |
org.eclipse.rse.core.events.SystemResourceChangeEvent(children, |
|
|
103 |
ISystemResourceChangeEvents.EVENT_ICON_CHANGE, |
104 |
_parentFile)); |
105 |
} |
106 |
catch (Exception e){} |
107 |
|
131 |
_isDone = true; |
108 |
_isDone = true; |
132 |
_decorateJobs.remove(_parentFile); |
109 |
_decorateJobs.remove(_parentFile); |
133 |
return Status.OK_STATUS; |
110 |
return Status.OK_STATUS; |
134 |
} |
111 |
} |
135 |
|
112 |
|
136 |
} |
113 |
} |
Lines 140-145
Link Here
|
140 |
{ |
117 |
{ |
141 |
this.shell = shell; |
118 |
this.shell = shell; |
142 |
this._fileSubSystem = fileSS; |
119 |
this._fileSubSystem = fileSS; |
|
|
120 |
|
143 |
this.dataStore = dataStore; |
121 |
this.dataStore = dataStore; |
144 |
this.system = system; |
122 |
this.system = system; |
145 |
this._registry = RSECorePlugin.getTheSystemRegistry(); |
123 |
this._registry = RSECorePlugin.getTheSystemRegistry(); |
Lines 185-192
Link Here
|
185 |
public void finish() |
163 |
public void finish() |
186 |
{ |
164 |
{ |
187 |
dataStore.getDomainNotifier().removeDomainListener(this); |
165 |
dataStore.getDomainNotifier().removeDomainListener(this); |
|
|
166 |
_finished = true; |
188 |
} |
167 |
} |
189 |
|
168 |
|
|
|
169 |
public boolean isFinished() |
170 |
{ |
171 |
return _finished; |
172 |
} |
173 |
|
190 |
/** |
174 |
/** |
191 |
* @see IDomainListener#domainChanged(DomainEvent) |
175 |
* @see IDomainListener#domainChanged(DomainEvent) |
192 |
*/ |
176 |
*/ |
Lines 203-209
Link Here
|
203 |
parentPath.append(parent.getName()); |
187 |
parentPath.append(parent.getName()); |
204 |
DStoreFile parentFile = (DStoreFile) _fileSubSystem.getCachedRemoteFile(parentPath.toString()); |
188 |
DStoreFile parentFile = (DStoreFile) _fileSubSystem.getCachedRemoteFile(parentPath.toString()); |
205 |
|
189 |
|
206 |
boolean refreshParent = false; |
|
|
207 |
List toUpdate = new ArrayList(); |
190 |
List toUpdate = new ArrayList(); |
208 |
for (int i = 0; i < children.size(); i++) |
191 |
for (int i = 0; i < children.size(); i++) |
209 |
{ |
192 |
{ |
Lines 215-257
Link Here
|
215 |
type.equals(IUniversalDataStoreConstants.UNIVERSAL_FOLDER_DESCRIPTOR))) |
198 |
type.equals(IUniversalDataStoreConstants.UNIVERSAL_FOLDER_DESCRIPTOR))) |
216 |
|
199 |
|
217 |
{ |
200 |
{ |
218 |
StringBuffer path = new StringBuffer(subject.getAttribute(DE.A_VALUE)); |
201 |
toUpdate.add(subject); |
219 |
path.append(_fileSubSystem.getSeparatorChar()); |
|
|
220 |
path.append(subject.getName()); |
221 |
|
222 |
|
223 |
// find cached copy |
224 |
try |
225 |
{ |
226 |
DStoreFile updated = (DStoreFile) _fileSubSystem.getCachedRemoteFile(path.toString()); |
227 |
|
228 |
if (updated != null) |
229 |
{ |
230 |
String classification = updated.getClassification(); |
231 |
if (!classification.equals("file") && !classification.equals("directory")) //$NON-NLS-1$ //$NON-NLS-2$ |
232 |
{ |
233 |
refreshParent = true; |
234 |
toUpdate.add(updated); |
235 |
} |
236 |
|
237 |
} |
238 |
} |
239 |
catch (Exception e) |
240 |
{ |
241 |
e.printStackTrace(); |
242 |
} |
243 |
} |
202 |
} |
244 |
} |
203 |
} |
245 |
|
204 |
|
246 |
if (refreshParent) |
205 |
if (!toUpdate.isEmpty()) |
247 |
{ |
206 |
{ |
248 |
DecorateJob job = getDecorateJob(parentFile); |
207 |
DecorateJob job = getDecorateJob(parentFile); |
249 |
if (job == null) |
208 |
if (job == null) |
250 |
{ |
209 |
{ |
251 |
job = new DecorateJob((DStoreFile[])toUpdate.toArray(new DStoreFile[toUpdate.size()]), parentFile); |
210 |
job = new DecorateJob((DataElement[])toUpdate.toArray(new DataElement[toUpdate.size()]), parentFile); |
252 |
job.setRule(parentFile); |
211 |
job.setRule(parentFile); |
253 |
putDecorateJob(parentFile, job); |
212 |
putDecorateJob(parentFile, job); |
254 |
job.schedule(5000); |
213 |
job.schedule(1000); |
255 |
} |
214 |
} |
256 |
|
215 |
|
257 |
} |
216 |
} |
Lines 269-288
Link Here
|
269 |
_decorateJobs.put(file, job); |
228 |
_decorateJobs.put(file, job); |
270 |
} |
229 |
} |
271 |
|
230 |
|
272 |
|
231 |
|
273 |
public Shell getShell() |
|
|
274 |
{ |
275 |
// dy: DomainNotifier (which calls this method) requires the shell not |
276 |
// be disposed |
277 |
//if (shell == null) { |
278 |
if (shell == null || shell.isDisposed()) |
279 |
{ |
280 |
FindShell findShell = new FindShell(); |
281 |
Display.getDefault().syncExec(findShell); |
282 |
shell = findShell.shell; |
283 |
} |
284 |
return shell; |
285 |
} |
286 |
|
232 |
|
287 |
/** |
233 |
/** |
288 |
* @see ICommunicationsListener#communicationsStateChange(CommunicationsEvent) |
234 |
* @see ICommunicationsListener#communicationsStateChange(CommunicationsEvent) |