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-5339: Mark with color Git changed files in project explorer #5722

Merged
merged 14 commits into from
Aug 14, 2017
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
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 @@ -70,6 +70,8 @@ public void onWsAgentStarted(WsAgentStateEvent event) {
initializeJsonRpc();
initializeTreeExplorerFileWatcher();
initializeGitCheckoutWatcher();
initializeGitChangeWatcher();
initializeGitIndexWatcher();
}

private void initializeJsonRpc() {
Expand Down Expand Up @@ -138,7 +140,7 @@ private void initializeTreeExplorerFileWatcher() {

requestTransmitter.newRequest()
.endpointId("ws-agent")
.methodName("track:project-tree")
.methodName("track/project-tree")
.paramsAsDto(params)
.sendAndSkipResult();

Expand All @@ -147,7 +149,23 @@ private void initializeTreeExplorerFileWatcher() {
private void initializeGitCheckoutWatcher() {
requestTransmitter.newRequest()
.endpointId("ws-agent")
.methodName("track:git-checkout")
.methodName("track/git-checkout")
.noParams()
.sendAndSkipResult();
}

private void initializeGitChangeWatcher() {
requestTransmitter.newRequest()
.endpointId("ws-agent")
.methodName("track/git-change")
.noParams()
.sendAndSkipResult();
}

private void initializeGitIndexWatcher() {
requestTransmitter.newRequest()
.endpointId("ws-agent")
.methodName("track/git-index")
.noParams()
.sendAndSkipResult();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public ProjectTreeStateNotificationOperation(AppContext appContext) {
@Inject
public void configureHandler(RequestHandlerConfigurator configurator) {
configurator.newConfiguration()
.methodName("event:project-tree-state-changed")
.methodName("event/project-tree-state-changed")
.paramsAsDto(ProjectTreeStateUpdateDto.class)
.noResult()
.withBiConsumer(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@ public interface EditorTab extends View<EditorTab.ActionDelegate>, TabItem {
*/
void setFile(VirtualFile file);

/**
* Set color to the label of editor's tab.
*
* @param color
* CSS color to set. Supported CSS color values:
* <ul>
* <li>Hexadecimal colors e.g. #ff0000</li>
* <li>RGB colors e.g. rgb(255, 0, 0)</li>
* <li>RGBA colors e.g. rgba(255, 0, 0, 0.3)</li>
* <li>HSL colors e.g. hsl(120, 60%, 70%)</li>
* <li>HSLA colors e.g. hsla(120, 100%, 25%, 0.3)</li>
* <li>Predefined/Cross-browser color names e.g. green</li>
* <ul/>
*/
void setTitleColor(String color);
Copy link
Contributor

@voievodin voievodin Jul 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it makes sense to specify the format of the color in the javadoc, like hash #000000 or color name like blue ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Any css valid color.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


/**
* Get editor part which associated with given tab
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.google.common.annotations.Beta;

import org.eclipse.che.api.promises.client.Promise;
import org.eclipse.che.ide.api.vcs.HasVcsStatus;
import org.eclipse.che.ide.resource.Path;

/**
Expand All @@ -30,7 +31,7 @@
* @since 4.4.0
*/
@Beta
public interface File extends Resource, VirtualFile, ModificationTracker {
public interface File extends Resource, VirtualFile, ModificationTracker, HasVcsStatus {

/** @see VirtualFile#getDisplayName() */
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -655,4 +655,16 @@ public static String getVcsConsoleModifiedFilesColor() {
public static String getVcsConsoleChangesLineNumbersColor() {
return theme.vcsConsoleChangesLineNumbersColor();
}

public static String getVcsStatusAddedColor() {
return theme.vcsStatusAddedColor();
}

public static String getVcsStatusModifiedColor() {
return theme.vcsStatusModifiedColor();
}

public static String getVcsStatusUntrackedColor() {
return theme.vcsStatusUntrackedColor();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1580,7 +1580,7 @@ public interface Theme {
String notificationPopupProgressBackground();

String notificationPopupWarningBackground();

String notificationPopupPanelShadow();

String notificationPopupIconSuccessFill();
Expand All @@ -1590,7 +1590,7 @@ public interface Theme {
String notificationPopupIconProgressFill();

String notificationPopupIconWarningFill();

String notificationPopupIconSvgFill();

String notificationPopupTextColor();
Expand Down Expand Up @@ -1655,6 +1655,12 @@ public interface Theme {

String vcsConsoleChangesLineNumbersColor();

String vcsStatusAddedColor();

String vcsStatusModifiedColor();

String vcsStatusUntrackedColor();

String editorPreferenceCategoryBackgroundColor();

/********************************************************************************************
Expand All @@ -1676,6 +1682,7 @@ public interface Theme {
String popupLoaderShadow();

String popupLoaderTitleColor();

String popupLoaderTextColor();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*******************************************************************************
* 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.api.vcs;

/**
* Indicates that specified resource has VCS status attribute.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please elaborate on what it means to have VCS status attribute?
Does it mean that each file has VCS status if the project is under VCS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It means that the resource can store and return VCS status

*
* @author Igor Vinokur
*/
public interface HasVcsStatus {

/**
* Returns VCS status attribute of the resource.
*/
VcsStatus getVcsStatus();

/**
* Set VCS status attribute to the resource.
*
* @param vcsStatus
* VCS status to set
*/
void setVcsStatus(VcsStatus vcsStatus);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*******************************************************************************
* 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.api.vcs;

import org.eclipse.che.ide.api.theme.Style;

import static java.util.Arrays.stream;

public enum VcsStatus {

UNTRACKED("untracked"),
ADDED("added"),
MODIFIED("modified"),
NOT_MODIFIED("not_modified");

private String value;

VcsStatus(String value) {
this.value = value;
}

public String getValue() {
return value;
}

public String getColor() {
switch (this) {
case UNTRACKED:
return Style.getVcsStatusUntrackedColor();
case MODIFIED:
return Style.getVcsStatusModifiedColor();
case ADDED:
return Style.getVcsStatusAddedColor();
case NOT_MODIFIED:
return Style.getMainFontColor();
default:
return null;
}
}

public static VcsStatus from(String value) {
return stream(VcsStatus.values()).filter(vcsStatus -> vcsStatus.getValue().equals(value.toLowerCase()))
.findAny()
.orElse(null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,9 @@ div[maximized="true"] svg[name="workBenchIconMaximize"] {
width: auto;
overflow: visible;

text-decoration: underline;
color: red;
text-decoration-line: underline;
text-decoration-style: wavy;
text-decoration-color: red;
}

/*@sprite .ide-PartStack-Tab-Line-Warning {*/
Expand All @@ -176,6 +177,7 @@ div[maximized="true"] svg[name="workBenchIconMaximize"] {
width: auto;
overflow: visible;

text-decoration: underline;
color: #FFD31E;
text-decoration-line: underline;
text-decoration-style: wavy;
text-decoration-color: #FFD31E;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.eclipse.che.ide.api.action.ActionEvent;
import org.eclipse.che.ide.api.action.ActionManager;
import org.eclipse.che.ide.api.action.Presentation;
import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.api.constraints.Constraints;
import org.eclipse.che.ide.api.editor.AbstractEditorPresenter;
import org.eclipse.che.ide.api.editor.EditorAgent;
Expand Down Expand Up @@ -86,6 +87,7 @@ public class EditorPartStackPresenter extends PartStackPresenter implements Edit
CloseNonPinnedEditorsHandler,
ResourceChangedHandler {
private final PresentationFactory presentationFactory;
private final AppContext appContext;
private final EditorPaneMenuItemFactory editorPaneMenuItemFactory;
private final EventBus eventBus;
private final EditorPaneMenu editorPaneMenu;
Expand All @@ -99,8 +101,8 @@ public class EditorPartStackPresenter extends PartStackPresenter implements Edit
private final LinkedList<EditorPartPresenter> partsOrder;
private final LinkedList<EditorPartPresenter> closedParts;

private HandlerRegistration closeNonPinnedEditorsHandler;
private HandlerRegistration resourceChangeHandler;
private HandlerRegistration closeNonPinnedEditorsHandler;
private HandlerRegistration resourceChangeHandler;

@VisibleForTesting
PaneMenuActionItemHandler paneMenuActionItemHandler;
Expand All @@ -109,6 +111,7 @@ public class EditorPartStackPresenter extends PartStackPresenter implements Edit

@Inject
public EditorPartStackPresenter(EditorPartStackView view,
AppContext appContext,
PartMenu partMenu,
PartsComparator partsComparator,
EditorPaneMenuItemFactory editorPaneMenuItemFactory,
Expand All @@ -122,6 +125,7 @@ public EditorPartStackPresenter(EditorPartStackView view,
CloseAllTabsPaneAction closeAllTabsPaneAction,
EditorAgent editorAgent) {
super(eventBus, partMenu, partStackEventHandler, tabItemFactory, partsComparator, view, null);
this.appContext = appContext;
this.editorPaneMenuItemFactory = editorPaneMenuItemFactory;
this.eventBus = eventBus;
this.presentationFactory = presentationFactory;
Expand Down Expand Up @@ -211,6 +215,14 @@ public void addPart(@NotNull PartPresenter part) {

final EditorTab editorTab = tabItemFactory.createEditorPartButton(editorPart, this);

appContext.getWorkspaceRoot()
.getFile(file.getLocation())
.then(optional -> {
if (optional.isPresent()) {
editorTab.setTitleColor(optional.get().getVcsStatus().getColor());
}
});

editorPart.addPropertyListener(new PropertyListener() {
@Override
public void propertyChanged(PartPresenter source, int propId) {
Expand Down Expand Up @@ -493,7 +505,8 @@ public void onItemClicked(@NotNull EditorPaneMenuItem<Action> item) {
}

@Override
public void onCloseButtonClicked(@NotNull EditorPaneMenuItem<Action> item) {}
public void onCloseButtonClicked(@NotNull EditorPaneMenuItem<Action> item) {
}
}

@VisibleForTesting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public ProjectExplorerPresenter(ProjectExplorerView view,
@Inject
public void initFileWatchers() {
final String endpointId = "ws-agent";
final String method = "track:project-tree";
final String method = "track/project-tree";

getTree().addExpandHandler(event -> {
Node node = event.getNode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ public void setFile(VirtualFile file) {
this.file = file;
}

@Override
public void setTitleColor(String color) {
this.title.getElement().getStyle().setColor(color);
}

@Override
public EditorPartPresenter getRelativeEditorPart() {
return relatedEditorPart;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.eclipse.che.ide.api.resources.File;
import org.eclipse.che.ide.api.resources.marker.Marker;
import org.eclipse.che.ide.api.resources.marker.PresentableTextMarker;
import org.eclipse.che.ide.api.vcs.VcsStatus;
import org.eclipse.che.ide.resource.Path;
import org.eclipse.che.ide.util.TextUtils;

Expand All @@ -34,17 +35,20 @@
@Beta
class FileImpl extends ResourceImpl implements File {

private final String contentUrl;
private final String contentUrl;
private VcsStatus vcsStatus;

private String modificationStamp;

@Inject
protected FileImpl(@Assisted Path path,
@Assisted String contentUrl,
@Assisted ResourceManager resourceManager) {
@Assisted ResourceManager resourceManager,
@Assisted VcsStatus vcsStatus) {
super(path, resourceManager);

this.contentUrl = contentUrl;
this.vcsStatus = vcsStatus;
}

/** {@inheritDoc} */
Expand Down Expand Up @@ -145,4 +149,14 @@ public String getModificationStamp() {
public void updateModificationStamp(String content) {
this.modificationStamp = TextUtils.md5(content);
}

@Override
public VcsStatus getVcsStatus() {
return vcsStatus;
}

@Override
public void setVcsStatus(VcsStatus vcsStatus) {
this.vcsStatus = vcsStatus;
}
}
Loading