Skip to content

Commit

Permalink
Merge pull request #1 from svor/maven_project_api_4
Browse files Browse the repository at this point in the history
CHE-370: add loader widget for the process of resolving dependencies
  • Loading branch information
Evgen Vidolob committed Mar 23, 2016
2 parents 1beefa2 + 0553109 commit db5068f
Show file tree
Hide file tree
Showing 26 changed files with 923 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public static String getMainFontColor() {
return theme.getMainFontColor();
}

public static String getLoaderProgressStatusColor() {
return theme.loaderProgressStatusColor();
}

public static String getRadioButtonBackgroundColor() {
return theme.getRadioButtonBackgroundColor();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
/** Status Panel Group View */
public interface StatusPanelGroupView extends View<StatusPanelGroupView.ActionDelegate> {
/** Needs for delegate some function into BottomMenu view. */
public interface ActionDelegate {
interface ActionDelegate {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected WorkspaceViewImpl() {
getElement().setId("codenvyIdeWorkspaceViewImpl");
ideMainDockPanel.setWidgetHidden(noToolbarPanel, true);
ideMainDockPanel.setWidgetHidden(actionsPanel, true);
ideMainDockPanel.setWidgetHidden(statusPanel, true);
ideMainDockPanel.setWidgetHidden(statusPanel, false);
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
background-color: statusPanelColor;
border-top: #232323 1px solid;
overflow: hidden;
z-index: 1;
}

</ui:style>
Expand All @@ -53,23 +54,23 @@
</g:north>

<g:north size="34">
<g:SimplePanel width="100%" ui:field="toolbarPanel" addStyleNames="{style.toolbarPanel}"/>
<g:SimplePanel width="100%" ui:field="toolbarPanel" addStyleNames="{style.toolbarPanel}" debugId="toolbarPanel"/>
</g:north>

<g:north size="1">
<g:SimplePanel width="100%" height="1" ui:field="noToolbarPanel" addStyleNames="{style.noToolbarPanel}"/>
<g:SimplePanel width="100%" height="1" ui:field="noToolbarPanel" addStyleNames="{style.noToolbarPanel}" debugId="noToolbarPanel"/>
</g:north>

<g:south size="18">
<g:SimplePanel width="100%" ui:field="statusPanel" addStyleNames="{style.statusPanel}"/>
<g:SimplePanel width="100%" ui:field="statusPanel" addStyleNames="{style.statusPanel}" debugId="statusPanel"/>
</g:south>

<g:south size="41"> <!-- the valid size is 41, was 22 -->
<g:SimplePanel width="100%" ui:field="actionsPanel" addStyleNames="{style.actionsPanel}"/>
<g:SimplePanel width="100%" ui:field="actionsPanel" addStyleNames="{style.actionsPanel}" debugId="actionPanel"/>
</g:south>

<g:center>
<g:SimpleLayoutPanel debugId="perspectivePanel" ui:field="perspectivePanel" width="100%" height="100%"/>
<g:SimpleLayoutPanel ui:field="perspectivePanel" width="100%" height="100%" debugId="perspectivePanel"/>
</g:center>

</g:DockLayoutPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.eclipse.che.ide.extension.maven.client.actions.GetEffectivePomAction;
import org.eclipse.che.ide.extension.maven.client.actions.UpdateDependencyAction;
import org.eclipse.che.ide.extension.maven.client.comunnication.MavenMessagesHandler;
import org.eclipse.che.ide.extension.maven.client.comunnication.progressor.background.DependencyResolverAction;
import org.eclipse.che.ide.extension.maven.client.editor.ClassFileSourcesDownloader;
import org.eclipse.che.ide.extension.maven.client.editor.PomEditorProvider;
import org.eclipse.che.ide.extension.maven.shared.MavenAttributes;
Expand All @@ -53,6 +54,7 @@

import static org.eclipse.che.ide.api.action.IdeActions.GROUP_BUILD_CONTEXT_MENU;
import static org.eclipse.che.ide.api.action.IdeActions.GROUP_FILE_NEW;
import static org.eclipse.che.ide.api.action.IdeActions.GROUP_RIGHT_STATUS_PANEL;

/**
* Maven extension entry point.
Expand Down Expand Up @@ -153,6 +155,7 @@ private boolean isValid(Node node) {
private void prepareActions(ActionManager actionManager,
UpdateDependencyAction updateDependencyAction,
CreateMavenModuleAction createMavenModuleAction,
DependencyResolverAction dependencyResolverAction,
GetEffectivePomAction getEffectivePomAction) {
// register actions
actionManager.registerAction("updateDependency", updateDependencyAction);
Expand All @@ -171,6 +174,10 @@ private void prepareActions(ActionManager actionManager,
DefaultActionGroup buildContextMenuGroup = (DefaultActionGroup)actionManager.getAction(GROUP_BUILD_CONTEXT_MENU);
buildContextMenuGroup.addSeparator();
buildContextMenuGroup.addAction(updateDependencyAction);

// add resolver widget on right part of bottom panel
final DefaultActionGroup rightStatusPanelGroup = (DefaultActionGroup)actionManager.getAction(GROUP_RIGHT_STATUS_PANEL);
rightStatusPanelGroup.add(dependencyResolverAction);
}

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,13 @@ public interface MavenLocalizationConstant extends Messages {

@Key("maven.class.download.failed")
String mavenClassDownloadFailed(String fqn);

@Key("loader.action.name")
String loaderActionName();

@Key("loader.action.description")
String loaderActionDescription();

@Key("window.loader.title")
String windowLoaderTitle();
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto;
import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.api.event.project.ProjectUpdatedEvent;
import org.eclipse.che.ide.api.notification.Notification;
import org.eclipse.che.ide.api.notification.NotificationManager;
import org.eclipse.che.ide.api.notification.StatusNotification;
import org.eclipse.che.ide.collections.Jso;
import org.eclipse.che.ide.dto.DtoFactory;
import org.eclipse.che.ide.extension.maven.client.comunnication.progressor.background.BackgroundLoaderPresenter;
import org.eclipse.che.ide.extension.maven.shared.MavenAttributes;
import org.eclipse.che.ide.extension.maven.shared.MessageType;
import org.eclipse.che.ide.extension.maven.shared.dto.NotificationMessage;
import org.eclipse.che.ide.extension.maven.shared.dto.ProjectsUpdateMessage;
import org.eclipse.che.ide.extension.maven.shared.dto.StartStopNotification;
import org.eclipse.che.ide.part.explorer.project.ProjectExplorerPresenter;
import org.eclipse.che.ide.resource.Path;
import org.eclipse.che.ide.util.loging.Log;
import org.eclipse.che.ide.websocket.MessageBus;
Expand All @@ -46,35 +45,42 @@
import java.util.Set;

/**
* Handler which receives messages from the maven server.
*
* @author Evgen Vidolob
* @author Valeriy Svydenko
*/
@Singleton
public class MavenMessagesHandler {

private final EventBus eventBus;
private final NotificationManager notificationManager;
private final ProjectExplorerPresenter projectExplorer;
private final ProjectServiceClient projectServiceClient;
private final AppContext context;
private final PomEditorReconciler pomEditorReconciler;
private Notification notification;
private final EventBus eventBus;
private final NotificationManager notificationManager;
private final ProjectServiceClient projectServiceClient;
private final AppContext context;
private final BackgroundLoaderPresenter dependencyResolver;
private final PomEditorReconciler pomEditorReconciler;

@Inject
public MavenMessagesHandler(EventBus eventBus,
NotificationManager notificationManager,
final DtoFactory factory,
final ProjectExplorerPresenter projectExplorer,
DtoFactory factory,
ProjectServiceClient projectServiceClient,
AppContext context,
BackgroundLoaderPresenter dependencyResolver,
PomEditorReconciler pomEditorReconciler,
final WsAgentStateController agentStateController) {
WsAgentStateController agentStateController) {
this.eventBus = eventBus;

this.notificationManager = notificationManager;
this.projectExplorer = projectExplorer;
this.projectServiceClient = projectServiceClient;
this.context = context;
this.dependencyResolver = dependencyResolver;
this.pomEditorReconciler = pomEditorReconciler;

handleOperations(factory, agentStateController);
}

private void handleOperations(final DtoFactory factory, final WsAgentStateController agentStateController) {
eventBus.addHandler(WsAgentStateEvent.TYPE, new WsAgentStateHandler() {
@Override
public void onWsAgentStarted(WsAgentStateEvent event) {
Expand Down Expand Up @@ -108,6 +114,7 @@ public void onMessage(String message) {
}
});
} catch (WebSocketException e) {
dependencyResolver.hide();
Log.error(getClass(), e);
}
}
Expand All @@ -116,21 +123,17 @@ public void onMessage(String message) {

@Override
public void onWsAgentStopped(WsAgentStateEvent event) {

dependencyResolver.hide();
}
});


}


private void handleStartStop(StartStopNotification dto) {
if (dto.isStart()) {
notification = notificationManager.notify("Maven", "", StatusNotification.Status.PROGRESS, true);
dependencyResolver.show();
} else {
if (notification instanceof StatusNotification) {
((StatusNotification)notification).setStatus(StatusNotification.Status.SUCCESS);
}
notification = null;
dependencyResolver.hide();
}
}

Expand Down Expand Up @@ -170,12 +173,10 @@ private Set<String> computeUniqueHiLevelProjects(List<String> updatedProjects) {
}

private void handleNotification(NotificationMessage message) {
if (notification != null) {
notification.setContent(message.getText());
notification.notifyObservers();
if (message.getPercent() != 0) {
dependencyResolver.updateProgressBar((int)(message.getPercent() * 100));
} else {
Log.error(getClass(), "Notification is null.", message);
dependencyResolver.setProgressLabel(message.getText());
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*******************************************************************************
* 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.ide.extension.maven.client.comunnication.progressor;

import com.google.inject.Inject;
import com.google.inject.Singleton;

/**
* Presenter of the window which describes information about resolving dependencies more detailed.
*
* @author Valeriy Svydenko
*/
@Singleton
public class ResolveDependencyPresenter implements ResolveDependencyView.ActionDelegate {

private final ResolveDependencyView view;

@Inject
public ResolveDependencyPresenter(ResolveDependencyView view) {
this.view = view;
}

/** Shows the widget. */
public void show() {
view.show();
}

/**
* Set label into loader which describes current state of loader.
*
* @param text
* message of the status
*/
public void setProgressLabel(String text) {
view.setOperationLabel(text);
}

/**
* Change the value of resolved modules of the project.
*
* @param percentage
* value of resolved modules
*/
public void updateProgressBar(int percentage) {
view.updateProgressBar(percentage);
}

/** Hides the widget. */
public void hide() {
view.hide();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*******************************************************************************
* 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.ide.extension.maven.client.comunnication.progressor;

import com.google.inject.ImplementedBy;

import org.eclipse.che.ide.api.mvp.View;

/**
* View of {@link ResolveDependencyPresenter}.
*
* @author Valeriy Svydenko
*/
@ImplementedBy(ResolveDependencyViewImpl.class)
public interface ResolveDependencyView extends View<ResolveDependencyView.ActionDelegate> {

/** Shows the widget. */
void show();

/** Hides the widget. */
void hide();

/**
* Set label into loader which describes current state of loader.
*
* @param text
* message of the status
*/
void setOperationLabel(String text);

/**
* Change the value of resolved modules of the project.
*
* @param percentage
* value of resolved modules
*/
void updateProgressBar(int percentage);

interface ActionDelegate {

}
}
Loading

0 comments on commit db5068f

Please sign in to comment.