Skip to content

Commit 495bfba

Browse files
authored
CHE-3416: Add force push checkbox to Git Push dialog (eclipse-che#5444)
1 parent a2615cd commit 495bfba

6 files changed

Lines changed: 56 additions & 36 deletions

File tree

plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/GitLocalizationConstant.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,9 @@ public interface GitLocalizationConstant extends Messages {
385385
@Key("view.push.remote_branch.field")
386386
String pushViewRemoteBranchFieldTitle();
387387

388+
@Key("view.push.force.checkbox.title")
389+
String pushForceCheckboxTitle();
390+
388391
// Reset
389392
@Key("view.reset.files.title")
390393
String resetFilesViewTitle();

plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/push/PushToRemotePresenter.java

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ public void apply(List<Remote> remotes) throws OperationException {
113113
updateLocalBranches();
114114
view.setRepositories(remotes);
115115
view.setEnablePushButton(!remotes.isEmpty());
116+
view.setSelectedForcePushCheckBox(false);
116117
view.showDialog();
117118
}
118119
}).catchError(new Operation<PromiseError>() {
@@ -285,25 +286,21 @@ public void onPushClicked() {
285286

286287
final String repository = view.getRepository();
287288
final GitOutputConsole console = gitOutputConsoleFactory.create(PUSH_COMMAND_NAME);
288-
service.push(appContext.getDevMachine(), project.getLocation(), getRefs(), repository, false).then(new Operation<PushResponse>() {
289-
@Override
290-
public void apply(PushResponse response) throws OperationException {
291-
console.print(response.getCommandOutput());
292-
processesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
293-
notification.setStatus(SUCCESS);
294-
if (response.getCommandOutput().contains("Everything up-to-date")) {
295-
notification.setTitle(constant.pushUpToDate());
296-
} else {
297-
notification.setTitle(constant.pushSuccess(repository));
298-
}
299-
}
300-
}).catchError(new Operation<PromiseError>() {
301-
@Override
302-
public void apply(PromiseError error) throws OperationException {
303-
handleError(error.getCause(), notification, console);
304-
processesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
305-
}
306-
});
289+
service.push(appContext.getDevMachine(), project.getLocation(), getRefs(), repository, view.isForcePushSelected())
290+
.then(response -> {
291+
console.print(response.getCommandOutput());
292+
processesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
293+
notification.setStatus(SUCCESS);
294+
if (response.getCommandOutput().contains("Everything up-to-date")) {
295+
notification.setTitle(constant.pushUpToDate());
296+
} else {
297+
notification.setTitle(constant.pushSuccess(repository));
298+
}
299+
})
300+
.catchError(error -> {
301+
handleError(error.getCause(), notification, console);
302+
processesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
303+
});
307304
view.close();
308305
}
309306

plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/push/PushToRemoteView.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@ public interface ActionDelegate {
111111
*/
112112
void setEnablePushButton(boolean enabled);
113113

114+
/**
115+
* Set selected force push check-box.
116+
*/
117+
void setSelectedForcePushCheckBox(boolean isSelected);
118+
119+
/**
120+
* Returns {@code true} if force push check-box is selected, otherwise returns {@code false}.
121+
*/
122+
boolean isForcePushSelected();
123+
114124
/** Close dialog. */
115125
void close();
116126

plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/push/PushToRemoteViewImpl.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.google.gwt.uibinder.client.UiField;
2424
import com.google.gwt.uibinder.client.UiHandler;
2525
import com.google.gwt.user.client.ui.Button;
26+
import com.google.gwt.user.client.ui.CheckBox;
2627
import com.google.gwt.user.client.ui.ListBox;
2728
import com.google.gwt.user.client.ui.Widget;
2829
import com.google.inject.Inject;
@@ -50,6 +51,8 @@ interface PushToRemoteViewImplUiBinder extends UiBinder<Widget, PushToRemoteView
5051
ListBox localBranch;
5152
@UiField
5253
ListBox remoteBranch;
54+
@UiField
55+
CheckBox forcePush;
5356
Button btnPush;
5457
Button btnCancel;
5558
@UiField(provided = true)
@@ -177,6 +180,16 @@ public void execute() {
177180
});
178181
}
179182

183+
@Override
184+
public void setSelectedForcePushCheckBox(boolean isSelected) {
185+
forcePush.setValue(isSelected);
186+
}
187+
188+
@Override
189+
public boolean isForcePushSelected() {
190+
return forcePush.getValue();
191+
}
192+
180193
/** {@inheritDoc} */
181194
@Override
182195
public void close() {

plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/push/PushToRemoteViewImpl.ui.xml

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
-->
1313
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
1414
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
15-
xmlns:g='urn:import:com.google.gwt.user.client.ui'
16-
xmlns:svg='urn:import:org.vectomatic.dom.svg.ui'>
15+
xmlns:g='urn:import:com.google.gwt.user.client.ui'>
1716
<ui:with field='locale' type='org.eclipse.che.ide.ext.git.client.GitLocalizationConstant'/>
1817
<ui:with field='res' type='org.eclipse.che.ide.ext.git.client.GitResources'/>
1918
<ui:style>
@@ -24,25 +23,16 @@
2423
.emptyBorder {
2524
margin: 6px;
2625
}
27-
28-
.image {
29-
position: relative;
30-
float: left;
31-
top: 31px;
32-
left: 2px;
33-
width: 14px;
34-
height: 14px;
35-
}
3626
</ui:style>
37-
<g:DockLayoutPanel unit="PX" width="450px" height="90px" addStyleNames="{style.emptyBorder}" debugId="git-remotes-push-mainForm">
38-
<g:north size="26.0">
39-
<g:FlowPanel>
40-
<g:Label text="{locale.pushViewRemoteFieldTitle}" addStyleNames="{res.gitCSS.textFont} {style.alignLeft}"/>
41-
<g:ListBox width="290px" ui:field="repository" addStyleNames="{res.gitCSS.textFont} {style.alignLeft}"
27+
<g:DockLayoutPanel unit="PX" width="450px" height="110px" addStyleNames="{style.emptyBorder}" debugId="git-remotes-push-mainForm">
28+
<g:north size="28">
29+
<g:FlowPanel addStyleNames="{style.emptyBorder}">
30+
<g:Label text="{locale.pushViewRemoteFieldTitle}" width="145px" addStyleNames="{res.gitCSS.textFont} {style.alignLeft}"/>
31+
<g:ListBox width="292px" ui:field="repository" addStyleNames="{res.gitCSS.textFont} {style.alignLeft}"
4232
debugId="git-remotes-push-repository"/>
4333
</g:FlowPanel>
4434
</g:north>
45-
<g:center>
35+
<g:center size="20">
4636
<g:DockLayoutPanel unit="PCT" width="100%" height="100%">
4737
<g:east size="48">
4838
<g:FlowPanel addStyleNames="{style.emptyBorder}">
@@ -58,5 +48,11 @@
5848
</g:west>
5949
</g:DockLayoutPanel>
6050
</g:center>
51+
<g:south size="20">
52+
<g:FlowPanel addStyleNames="{style.emptyBorder}">
53+
<g:CheckBox ui:field="forcePush" text="{locale.pushForceCheckboxTitle}" width="145px"
54+
addStyleNames="{res.gitCSS.textFont} {style.alignLeft}" debugId="git-remotes-force-push-checkbox"/>
55+
</g:FlowPanel>
56+
</g:south>
6157
</g:DockLayoutPanel>
6258
</ui:UiBinder>

plugins/plugin-git/che-plugin-git-ext-git/src/main/resources/org/eclipse/che/ide/ext/git/client/GitLocalizationConstant.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ view.push.title=Push to remote repository
191191
view.push.remote.field=Choose remote repository:
192192
view.push.local_branch.field=Push from branch:
193193
view.push.remote_branch.field=To branch:
194+
view.push.force.checkbox.title=Force push
194195

195196
#Remote
196197
view.remote.name.field=Name:

0 commit comments

Comments
 (0)