Skip to content

Commit

Permalink
CHE-3416: Add force push checkbox to Git Push dialog (eclipse-che#5444)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinokurig authored Jun 23, 2017
1 parent a2615cd commit 495bfba
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ public interface GitLocalizationConstant extends Messages {
@Key("view.push.remote_branch.field")
String pushViewRemoteBranchFieldTitle();

@Key("view.push.force.checkbox.title")
String pushForceCheckboxTitle();

// Reset
@Key("view.reset.files.title")
String resetFilesViewTitle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public void apply(List<Remote> remotes) throws OperationException {
updateLocalBranches();
view.setRepositories(remotes);
view.setEnablePushButton(!remotes.isEmpty());
view.setSelectedForcePushCheckBox(false);
view.showDialog();
}
}).catchError(new Operation<PromiseError>() {
Expand Down Expand Up @@ -285,25 +286,21 @@ public void onPushClicked() {

final String repository = view.getRepository();
final GitOutputConsole console = gitOutputConsoleFactory.create(PUSH_COMMAND_NAME);
service.push(appContext.getDevMachine(), project.getLocation(), getRefs(), repository, false).then(new Operation<PushResponse>() {
@Override
public void apply(PushResponse response) throws OperationException {
console.print(response.getCommandOutput());
processesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
notification.setStatus(SUCCESS);
if (response.getCommandOutput().contains("Everything up-to-date")) {
notification.setTitle(constant.pushUpToDate());
} else {
notification.setTitle(constant.pushSuccess(repository));
}
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
handleError(error.getCause(), notification, console);
processesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
}
});
service.push(appContext.getDevMachine(), project.getLocation(), getRefs(), repository, view.isForcePushSelected())
.then(response -> {
console.print(response.getCommandOutput());
processesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
notification.setStatus(SUCCESS);
if (response.getCommandOutput().contains("Everything up-to-date")) {
notification.setTitle(constant.pushUpToDate());
} else {
notification.setTitle(constant.pushSuccess(repository));
}
})
.catchError(error -> {
handleError(error.getCause(), notification, console);
processesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
});
view.close();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ public interface ActionDelegate {
*/
void setEnablePushButton(boolean enabled);

/**
* Set selected force push check-box.
*/
void setSelectedForcePushCheckBox(boolean isSelected);

/**
* Returns {@code true} if force push check-box is selected, otherwise returns {@code false}.
*/
boolean isForcePushSelected();

/** Close dialog. */
void close();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
Expand Down Expand Up @@ -50,6 +51,8 @@ interface PushToRemoteViewImplUiBinder extends UiBinder<Widget, PushToRemoteView
ListBox localBranch;
@UiField
ListBox remoteBranch;
@UiField
CheckBox forcePush;
Button btnPush;
Button btnCancel;
@UiField(provided = true)
Expand Down Expand Up @@ -177,6 +180,16 @@ public void execute() {
});
}

@Override
public void setSelectedForcePushCheckBox(boolean isSelected) {
forcePush.setValue(isSelected);
}

@Override
public boolean isForcePushSelected() {
return forcePush.getValue();
}

/** {@inheritDoc} */
@Override
public void close() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
-->
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'
xmlns:svg='urn:import:org.vectomatic.dom.svg.ui'>
xmlns:g='urn:import:com.google.gwt.user.client.ui'>
<ui:with field='locale' type='org.eclipse.che.ide.ext.git.client.GitLocalizationConstant'/>
<ui:with field='res' type='org.eclipse.che.ide.ext.git.client.GitResources'/>
<ui:style>
Expand All @@ -24,25 +23,16 @@
.emptyBorder {
margin: 6px;
}

.image {
position: relative;
float: left;
top: 31px;
left: 2px;
width: 14px;
height: 14px;
}
</ui:style>
<g:DockLayoutPanel unit="PX" width="450px" height="90px" addStyleNames="{style.emptyBorder}" debugId="git-remotes-push-mainForm">
<g:north size="26.0">
<g:FlowPanel>
<g:Label text="{locale.pushViewRemoteFieldTitle}" addStyleNames="{res.gitCSS.textFont} {style.alignLeft}"/>
<g:ListBox width="290px" ui:field="repository" addStyleNames="{res.gitCSS.textFont} {style.alignLeft}"
<g:DockLayoutPanel unit="PX" width="450px" height="110px" addStyleNames="{style.emptyBorder}" debugId="git-remotes-push-mainForm">
<g:north size="28">
<g:FlowPanel addStyleNames="{style.emptyBorder}">
<g:Label text="{locale.pushViewRemoteFieldTitle}" width="145px" addStyleNames="{res.gitCSS.textFont} {style.alignLeft}"/>
<g:ListBox width="292px" ui:field="repository" addStyleNames="{res.gitCSS.textFont} {style.alignLeft}"
debugId="git-remotes-push-repository"/>
</g:FlowPanel>
</g:north>
<g:center>
<g:center size="20">
<g:DockLayoutPanel unit="PCT" width="100%" height="100%">
<g:east size="48">
<g:FlowPanel addStyleNames="{style.emptyBorder}">
Expand All @@ -58,5 +48,11 @@
</g:west>
</g:DockLayoutPanel>
</g:center>
<g:south size="20">
<g:FlowPanel addStyleNames="{style.emptyBorder}">
<g:CheckBox ui:field="forcePush" text="{locale.pushForceCheckboxTitle}" width="145px"
addStyleNames="{res.gitCSS.textFont} {style.alignLeft}" debugId="git-remotes-force-push-checkbox"/>
</g:FlowPanel>
</g:south>
</g:DockLayoutPanel>
</ui:UiBinder>
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ view.push.title=Push to remote repository
view.push.remote.field=Choose remote repository:
view.push.local_branch.field=Push from branch:
view.push.remote_branch.field=To branch:
view.push.force.checkbox.title=Force push

#Remote
view.remote.name.field=Name:
Expand Down

0 comments on commit 495bfba

Please sign in to comment.