-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate logic of showing dialog on workspace stop
- Loading branch information
Mihail Kuznyetsov
committed
Apr 4, 2016
1 parent
4f2bf52
commit 582bc74
Showing
15 changed files
with
120 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
...-env-local/src/main/java/org/eclipse/che/env/local/client/CheWorkspaceStoppedHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012-2016 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.che.env.local.client; | ||
|
||
import com.google.gwt.core.client.Callback; | ||
import com.google.web.bindery.event.shared.EventBus; | ||
|
||
import org.eclipse.che.api.promises.client.Operation; | ||
import org.eclipse.che.api.promises.client.OperationException; | ||
import org.eclipse.che.api.workspace.gwt.client.WorkspaceServiceClient; | ||
import org.eclipse.che.api.workspace.gwt.client.event.WorkspaceStoppedEvent; | ||
import org.eclipse.che.api.workspace.gwt.client.event.WorkspaceStoppedHandler; | ||
import org.eclipse.che.api.workspace.shared.dto.WorkspaceDto; | ||
import org.eclipse.che.ide.api.component.Component; | ||
import org.eclipse.che.ide.workspace.start.StartWorkspacePresenter; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Singleton; | ||
import java.util.List; | ||
|
||
/** | ||
* Shows dialog after workspace stopped event. | ||
* | ||
* @author Mihail Kuznyetsov | ||
*/ | ||
@Singleton | ||
public class CheWorkspaceStoppedHandler implements WorkspaceStoppedHandler { | ||
|
||
private final static int SKIP_COUNT = 0; | ||
private final static int MAX_COUNT = 10; | ||
private final StartWorkspacePresenter startWorkspacePresenter; | ||
private final WorkspaceServiceClient workspaceServiceClient; | ||
private final Callback<Component, Exception> callback; | ||
|
||
@Inject | ||
public CheWorkspaceStoppedHandler(StartWorkspacePresenter startWorkspacePresenter, | ||
WorkspaceServiceClient workspaceServiceClient, | ||
EventBus eventBus) { | ||
this.startWorkspacePresenter = startWorkspacePresenter; | ||
this.workspaceServiceClient = workspaceServiceClient; | ||
|
||
this.callback = new Callback<Component, Exception>() { | ||
@Override | ||
public void onFailure(Exception reason) { | ||
} | ||
|
||
@Override | ||
public void onSuccess(Component result) { | ||
} | ||
}; | ||
eventBus.addHandler(WorkspaceStoppedEvent.TYPE, this); | ||
} | ||
|
||
@Override | ||
public void onWorkspaceStopped(WorkspaceStoppedEvent event) { | ||
workspaceServiceClient.getWorkspace(event.getWorkspace().getId()).then(new Operation<WorkspaceDto>() { | ||
@Override | ||
public void apply(WorkspaceDto workspace) throws OperationException { | ||
workspaceServiceClient.getWorkspaces(SKIP_COUNT, MAX_COUNT) | ||
.then(new Operation<List<WorkspaceDto>>() { | ||
@Override | ||
public void apply(List<WorkspaceDto> workspaces) | ||
throws OperationException { | ||
startWorkspacePresenter.show(workspaces, callback); | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters