|
19 | 19 |
|
20 | 20 | import org.eclipse.che.api.core.model.workspace.Workspace; |
21 | 21 | import org.eclipse.che.api.factory.shared.dto.FactoryDto; |
22 | | -import org.eclipse.che.api.promises.client.Operation; |
23 | | -import org.eclipse.che.api.promises.client.OperationException; |
24 | | -import org.eclipse.che.api.promises.client.PromiseError; |
25 | 22 | import org.eclipse.che.ide.api.app.AppContext; |
26 | 23 | import org.eclipse.che.ide.api.app.CurrentUser; |
27 | 24 | import org.eclipse.che.ide.api.app.StartUpAction; |
@@ -214,19 +211,13 @@ public void initResourceManager(final Callback<ResourceManager, Exception> callb |
214 | 211 | } |
215 | 212 |
|
216 | 213 | resourceManager = resourceManagerFactory.newResourceManager(runtime.getDevMachine()); |
217 | | - resourceManager.getWorkspaceProjects().then(new Operation<Project[]>() { |
218 | | - @Override |
219 | | - public void apply(Project[] projects) throws OperationException { |
220 | | - AppContextImpl.this.projects = projects; |
221 | | - java.util.Arrays.sort(AppContextImpl.this.projects, ResourcePathComparator.getInstance()); |
222 | | - callback.onSuccess(resourceManager); |
223 | | - eventBus.fireEvent(new WorkspaceReadyEvent(projects)); |
224 | | - } |
225 | | - }).catchError(new Operation<PromiseError>() { |
226 | | - @Override |
227 | | - public void apply(PromiseError error) throws OperationException { |
228 | | - callback.onFailure((Exception)error.getCause()); |
229 | | - } |
| 214 | + resourceManager.getWorkspaceProjects().then(projects -> { |
| 215 | + AppContextImpl.this.projects = projects; |
| 216 | + java.util.Arrays.sort(AppContextImpl.this.projects, ResourcePathComparator.getInstance()); |
| 217 | + callback.onSuccess(resourceManager); |
| 218 | + eventBus.fireEvent(new WorkspaceReadyEvent(projects)); |
| 219 | + }).catchError(error -> { |
| 220 | + callback.onFailure((Exception)error.getCause()); |
230 | 221 | }); |
231 | 222 | } |
232 | 223 |
|
@@ -304,6 +295,19 @@ public void onResourceChanged(ResourceChangedEvent event) { |
304 | 295 | projects[i] = (Project)resource; |
305 | 296 | } |
306 | 297 | } |
| 298 | + |
| 299 | + if (currentResources != null) { |
| 300 | + for (int i = 0; i < currentResources.length; i++) { |
| 301 | + if (currentResources[i].getLocation().equals(resource.getLocation())) { |
| 302 | + currentResources[i] = resource; |
| 303 | + break; |
| 304 | + } |
| 305 | + } |
| 306 | + } |
| 307 | + |
| 308 | + if (currentResource != null && currentResource.getLocation().equals(resource.getLocation())) { |
| 309 | + currentResource = resource; |
| 310 | + } |
307 | 311 | } |
308 | 312 | } |
309 | 313 |
|
@@ -457,16 +461,13 @@ public void onWorkspaceStarted(WorkspaceStartedEvent event) { |
457 | 461 |
|
458 | 462 | @Override |
459 | 463 | public void onWorkspaceStopped(WorkspaceStoppedEvent event) { |
460 | | - appStateManager.get().persistWorkspaceState(getWorkspaceId()).then(new Operation<Void>() { |
461 | | - @Override |
462 | | - public void apply(Void arg) throws OperationException { |
463 | | - for (Project project : projects) { |
464 | | - eventBus.fireEvent(new ResourceChangedEvent(new ResourceDeltaImpl(project, REMOVED))); |
465 | | - } |
466 | | - |
467 | | - projects = NO_PROJECTS; //avoid NPE |
468 | | - resourceManager = null; |
| 464 | + appStateManager.get().persistWorkspaceState(getWorkspaceId()).then(ignored -> { |
| 465 | + for (Project project : projects) { |
| 466 | + eventBus.fireEvent(new ResourceChangedEvent(new ResourceDeltaImpl(project, REMOVED))); |
469 | 467 | } |
| 468 | + |
| 469 | + projects = NO_PROJECTS; |
| 470 | + resourceManager = null; |
470 | 471 | }); |
471 | 472 |
|
472 | 473 | //goto close all editors |
|
0 commit comments