forked from eclipse-che/che
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CHE-5718 Progress of the importing project is not displayed (eclipse-…
…che#5934) * CHE-5718 Progress of the importing project is not displayed * CHE-5718 Progress of the importing project is not displayed * CHE-5718 Progress of the importing project is not displayed * CHE-5718 Progress of the importing project is not displayed * Remove batch project creation from dashboard Signed-off-by: Anna Shumilova <ashumilo@redhat.com> * CHE-5718 Progress of the importing project is not displayed
- Loading branch information
Vitaliy Guliy
authored
Aug 8, 2017
1 parent
2e6d797
commit a258f2f
Showing
6 changed files
with
159 additions
and
23 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
107 changes: 107 additions & 0 deletions
107
...-core-ide-app/src/main/java/org/eclipse/che/ide/factory/utils/InitialProjectImporter.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,107 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012-2017 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.ide.factory.utils; | ||
|
||
import com.google.inject.Inject; | ||
import com.google.inject.Singleton; | ||
import org.eclipse.che.api.promises.client.*; | ||
import org.eclipse.che.api.promises.client.js.Promises; | ||
import org.eclipse.che.ide.CoreLocalizationConstant; | ||
import org.eclipse.che.ide.api.app.AppContext; | ||
import org.eclipse.che.ide.api.notification.NotificationManager; | ||
import org.eclipse.che.ide.api.notification.StatusNotification; | ||
import org.eclipse.che.ide.api.oauth.OAuth2AuthenticatorRegistry; | ||
import org.eclipse.che.ide.api.project.wizard.ImportProjectNotificationSubscriberFactory; | ||
import org.eclipse.che.ide.api.resources.Project; | ||
import org.eclipse.che.ide.api.user.AskCredentialsDialog; | ||
import org.eclipse.che.ide.part.explorer.project.ProjectExplorerPresenter; | ||
import org.eclipse.che.ide.projectimport.wizard.ProjectImportOutputJsonRpcNotifier; | ||
import org.eclipse.che.ide.projectimport.wizard.ProjectImporter; | ||
import org.eclipse.che.ide.projectimport.wizard.ProjectResolver; | ||
import java.util.*; | ||
|
||
import static org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode.FLOAT_MODE; | ||
import static org.eclipse.che.ide.api.notification.StatusNotification.Status.FAIL; | ||
import static org.eclipse.che.ide.api.notification.StatusNotification.Status.PROGRESS; | ||
|
||
/** | ||
* Imports projects on file system. | ||
*/ | ||
@Singleton | ||
public class InitialProjectImporter extends ProjectImporter { | ||
|
||
private final ProjectImportOutputJsonRpcNotifier subscriber; | ||
private final NotificationManager notificationManager; | ||
private final CoreLocalizationConstant locale; | ||
|
||
@Inject | ||
public InitialProjectImporter(CoreLocalizationConstant localizationConstant, | ||
ImportProjectNotificationSubscriberFactory subscriberFactory, | ||
AppContext appContext, | ||
ProjectResolver projectResolver, | ||
AskCredentialsDialog credentialsDialog, | ||
OAuth2AuthenticatorRegistry oAuth2AuthenticatorRegistry, | ||
ProjectImportOutputJsonRpcNotifier subscriber, | ||
NotificationManager notificationManager, | ||
CoreLocalizationConstant locale, | ||
ProjectExplorerPresenter projectExplorerPresenter) { | ||
|
||
super(localizationConstant, subscriberFactory, appContext, projectResolver, credentialsDialog, oAuth2AuthenticatorRegistry); | ||
|
||
this.subscriber = subscriber; | ||
this.notificationManager = notificationManager; | ||
this.locale = locale; | ||
} | ||
|
||
/** | ||
* Import source projects and if it's already exist in workspace | ||
* then show warning notification | ||
* | ||
* @param projects | ||
* list of projects that already exist in workspace and will be imported on file system | ||
*/ | ||
public void importProjects(final List<Project> projects) { | ||
if (projects.isEmpty()) { | ||
return; | ||
} | ||
|
||
final Project importProject = projects.remove(0); | ||
final StatusNotification notification = notificationManager.notify(locale.cloningSource(importProject.getName()), null, PROGRESS, FLOAT_MODE); | ||
subscriber.subscribe(importProject.getName(), notification); | ||
|
||
appContext.getWorkspaceRoot() | ||
.importProject() | ||
.withBody(importProject) | ||
.send() | ||
.then(new Operation<Project>() { | ||
@Override | ||
public void apply(Project project) throws OperationException { | ||
subscriber.onSuccess(); | ||
|
||
appContext.getWorkspaceRoot().synchronize(); | ||
|
||
importProjects(projects); | ||
} | ||
}).catchErrorPromise( | ||
new Function<PromiseError, Promise<Project>>() { | ||
@Override | ||
public Promise<Project> apply(PromiseError err) throws FunctionException { | ||
subscriber.onFailure(err.getMessage()); | ||
notification.setTitle(locale.cloningSourceFailedTitle(importProject.getName())); | ||
notification.setStatus(FAIL); | ||
|
||
return Promises.resolve(null); | ||
} | ||
} | ||
); | ||
} | ||
|
||
} |
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