Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHE-6608: Synchronize list of repositories and the list of local changes #7073

Merged
merged 21 commits into from
Oct 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
import java.util.Set;
import org.eclipse.che.api.core.jsonrpc.commons.RequestHandlerConfigurator;
import org.eclipse.che.api.git.shared.FileChangedEventDto;
import org.eclipse.che.api.git.shared.RepositoryDeletedEventDto;
import org.eclipse.che.api.git.shared.RepositoryInitializedEventDto;
import org.eclipse.che.api.git.shared.StatusChangedEventDto;
import org.eclipse.che.api.project.shared.dto.event.GitCheckoutEventDto;

/**
* Receives git events from server side. To avoid a risk of IDE slow down this handler bypasses
* event bus because of heavy load.
* Receives git events from server side.
*
* <p>To avoid a risk of IDE slow down this handler bypasses event bus because of heavy load.
*
* @author Igor Vinokur
* @author Mykola Morhun
Expand All @@ -30,8 +33,10 @@
public class GitEventsHandler implements GitEventSubscribable {

private static final String EVENT_GIT_FILE_CHANGED = "event/git-change";
private static final String EVENT_GIT_STATUS_CHANGED = "event/git/statusChanged";
private static final String EVENT_GIT_STATUS_CHANGED = "event/git/status-changed";
private static final String EVENT_GIT_CHECKOUT = "event/git-checkout";
private static final String EVENT_GIT_REPOSITORY_INITIALIZED = "event/git/initialized";
private static final String EVENT_GIT_REPOSITORY_DELETED = "event/git/deleted";

private final Set<GitEventsSubscriber> subscribers = new HashSet<>();

Expand Down Expand Up @@ -61,6 +66,20 @@ private void configureHandlers(RequestHandlerConfigurator configurator) {
.paramsAsDto(GitCheckoutEventDto.class)
.noResult()
.withBiConsumer(this::onCheckoutHandler);

configurator
.newConfiguration()
.methodName(EVENT_GIT_REPOSITORY_INITIALIZED)
.paramsAsDto(RepositoryInitializedEventDto.class)
.noResult()
.withBiConsumer(this::onRepositoryInitializedHandler);

configurator
.newConfiguration()
.methodName(EVENT_GIT_REPOSITORY_DELETED)
.paramsAsDto(RepositoryDeletedEventDto.class)
.noResult()
.withBiConsumer(this::onRepositoryDeletedHandler);
}

private void onFileChangedHandler(String endpointId, FileChangedEventDto fileChangedEventDto) {
Expand All @@ -82,6 +101,20 @@ private void onCheckoutHandler(String endpointId, GitCheckoutEventDto gitCheckou
}
}

private void onRepositoryInitializedHandler(
String endpointId, RepositoryInitializedEventDto repositoryInitializedEvent) {
for (GitEventsSubscriber subscriber : subscribers) {
subscriber.onGitRepositoryInitialized(endpointId, repositoryInitializedEvent);
}
}

private void onRepositoryDeletedHandler(
String endpointId, RepositoryDeletedEventDto repositoryDeletedEvent) {
for (GitEventsSubscriber subscriber : subscribers) {
subscriber.onGitRepositoryDeleted(endpointId, repositoryDeletedEvent);
}
}

@Override
public void addSubscriber(GitEventsSubscriber subscriber) {
subscribers.add(subscriber);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
package org.eclipse.che.ide.ext.git.client;

import org.eclipse.che.api.git.shared.FileChangedEventDto;
import org.eclipse.che.api.git.shared.RepositoryDeletedEventDto;
import org.eclipse.che.api.git.shared.RepositoryInitializedEventDto;
import org.eclipse.che.api.git.shared.StatusChangedEventDto;
import org.eclipse.che.api.project.shared.dto.event.GitCheckoutEventDto;

Expand All @@ -22,7 +24,7 @@
public interface GitEventsSubscriber {

/** Invoked when a project file was changed */
void onFileChanged(String endpointId, FileChangedEventDto dto);
default void onFileChanged(String endpointId, FileChangedEventDto dto) {}

// TODO change method name or behaviour. It is not git status actually.
// For example, this even won't be fired when:
Expand All @@ -31,8 +33,16 @@ public interface GitEventsSubscriber {
// - delete a committed file
// And maybe some others
/** Invoked when git status of project was changed */
void onGitStatusChanged(String endpointId, StatusChangedEventDto dto);
default void onGitStatusChanged(String endpointId, StatusChangedEventDto dto) {}

/** Invoked when git checkout was performed */
void onGitCheckout(String endpointId, GitCheckoutEventDto dto);
default void onGitCheckout(String endpointId, GitCheckoutEventDto dto) {}

/** Invoked when git repository was initialized inside an existing project. */
default void onGitRepositoryInitialized(
String endpointId, RepositoryInitializedEventDto gitRepositoryInitializedEventDto) {}

/** Invoked when git repository was deleted inside an existing project. */
default void onGitRepositoryDeleted(
String endpointId, RepositoryDeletedEventDto repositoryDeletedEventDto) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public GitExtension(
KeyBindingAgent keyBinding) {

resources.gitCSS().ensureInjected();
resources.gitPanelCss().ensureInjected();

DefaultActionGroup mainMenu = (DefaultActionGroup) actionManager.getAction(GROUP_MAIN_MENU);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -652,13 +652,16 @@ public interface GitLocalizationConstant extends Messages {
@Key("checkout.reference.message")
String checkoutReferenceMessage();

// Panel
/* Panel */
@Key("panel.title")
String panelTitle();

@Key("panel.title.tooltip")
String panelTitleToolTip();

@Key("panel.repositories")
String repositories();

/* Controls */
@Key("control.branches.title")
String branchesControlTitle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,23 @@ interface GitCSS extends CssResource {
String spacing();
}

interface GitPanelCss extends CssResource {
@ClassName("git-panel-full-height")
String fullHeight();

@ClassName("git-panel-panel-top-indent")
String topIndent();

@ClassName("git-panel-panel-bottom-indent")
String bottomIndent();

@ClassName("git-panel-vertical-items")
String verticalItems();

@ClassName("git-panel-repository-changes-label")
String repositoryChangesLabel();
}

interface Css extends CssResource {
String insertion();

Expand All @@ -50,12 +67,21 @@ interface Css extends CssResource {
@Source({"git.css", "org/eclipse/che/ide/api/ui/style.css"})
GitCSS gitCSS();

@Source("panel/gitPanel.css")
GitPanelCss gitPanelCss();

@Source({"changeMarkers.css", "org/eclipse/che/ide/api/ui/style.css"})
Css changeMarkersCSS();

@Source("panel/git.svg")
SVGResource git();

@Source("panel/git-logo.svg")
SVGResource gitLogo();

@Source("panel/repository.svg")
SVGResource repository();

@Source("push/arrow.svg")
SVGResource arrow();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ public MutableAlteredFiles(Project project, String diff) {
super(project, diff);
}

/**
* Created mutable altered files list based on changes from another project.
*
* @param project the project under diff operation
* @param alteredFiles changes from another project
*/
public MutableAlteredFiles(Project project, AlteredFiles alteredFiles) {
super(project, "");
this.alteredFilesStatuses.putAll(alteredFiles.alteredFilesStatuses);
this.alteredFilesList.addAll(alteredFiles.alteredFilesList);
}

/**
* Creates an empty list of altered files.
*
Expand All @@ -40,7 +52,7 @@ public MutableAlteredFiles(Project project) {
}

/**
* Adds a file to altered file list. If given file is already exists
* Adds a file to altered file list. If given file is already exists does nothing.
*
* @param file full path to file and its name relatively to project root
* @param status git status of the file
Expand All @@ -57,10 +69,10 @@ public boolean addFile(String file, Status status) {
}

/**
* Removes given file from the altered files list.
* Removes given file from the altered files list. If given file isn't present does nothing.
*
* @param file full path to file and its name relatively to project root
* @return true if the file as deleted and false otherwise
* @return true if the file was deleted and false otherwise
*/
public boolean removeFile(String file) {
alteredFilesStatuses.remove(file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public ChangesPanelPresenter(
* Show panel with changed files. If empty map with changed files is received, all buttons would
* be disabled.
*
* @param changedFiles Map with files and their status
* @param changedFiles altered files to show
*/
public void show(AlteredFiles changedFiles) {
this.changedFiles = changedFiles;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputPartViewImpl;
import org.eclipse.che.ide.ext.git.client.panel.GitPanelView;
import org.eclipse.che.ide.ext.git.client.panel.GitPanelViewImpl;
import org.eclipse.che.ide.ext.git.client.panel.RepositoryNodeFactory;
import org.eclipse.che.ide.ext.git.client.plugins.EditorTabsColorizer;
import org.eclipse.che.ide.ext.git.client.plugins.GitChangeMarkerManager;
import org.eclipse.che.ide.ext.git.client.plugins.ProjectExplorerTreeColorizer;
Expand Down Expand Up @@ -116,6 +117,7 @@ protected void configure() {
new GinFactoryModuleBuilder()
.implement(GitOutputConsole.class, GitOutputConsolePresenter.class)
.build(GitOutputConsoleFactory.class));
install(new GinFactoryModuleBuilder().build(RepositoryNodeFactory.class));

bind(GitEventsHandler.class).asEagerSingleton();

Expand Down
Loading