git: don't show shelf/stash choice in the Update Project dialog: IDEA-220415

It is available in the settings, no need to force user make the choice.

GitOrigin-RevId: d81a18966eb034dcc102db061ca0106ce8ed7826
This commit is contained in:
Kirill Likhodedov
2019-10-13 15:02:11 +00:00
committed by intellij-monorepo-bot
parent adaacf3faf
commit 5b9a9177e3
3 changed files with 2 additions and 126 deletions
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="git4idea.update.GitUpdateOptionsPanel">
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="10" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="392" height="121"/>
@@ -49,37 +49,6 @@
</component>
</children>
</grid>
<grid id="fff58" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="100"/>
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<clientProperties>
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/>
</clientProperties>
<border type="none" title-resource-bundle="git4idea/i18n/GitBundle" title-key="update.options.save.before.update"/>
<children>
<component id="98593" class="javax.swing.JRadioButton" binding="myStashRadioButton" default-binding="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<selected value="true"/>
<text resource-bundle="git4idea/i18n/GitBundle" key="update.options.save.stash"/>
<toolTipText resource-bundle="git4idea/i18n/GitBundle" key="update.options.save.stash.tooltip"/>
</properties>
</component>
<component id="d7fb3" class="javax.swing.JRadioButton" binding="myShelveRadioButton" custom-create="true" default-binding="true">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<selected value="false"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
<buttonGroups>
@@ -15,10 +15,8 @@
*/
package git4idea.update;
import com.intellij.openapi.application.ApplicationNamesInfo;
import git4idea.config.GitVcsSettings;
import git4idea.config.UpdateMethod;
import git4idea.i18n.GitBundle;
import javax.swing.*;
@@ -30,8 +28,6 @@ public class GitUpdateOptionsPanel {
private JRadioButton myBranchDefaultRadioButton;
private JRadioButton myForceRebaseRadioButton;
private JRadioButton myForceMergeRadioButton;
private JRadioButton myStashRadioButton;
private JRadioButton myShelveRadioButton;
public JComponent getPanel() {
return myPanel;
@@ -39,14 +35,7 @@ public class GitUpdateOptionsPanel {
public boolean isModified(GitVcsSettings settings) {
UpdateMethod type = getUpdateType();
return type != settings.getUpdateMethod() || updateSaveFilesPolicy() != settings.updateChangesPolicy();
}
/**
* @return get policy value from selected radio buttons
*/
private GitVcsSettings.UpdateChangesPolicy updateSaveFilesPolicy() {
return UpdatePolicyUtils.getUpdatePolicy(myStashRadioButton, myShelveRadioButton);
return type != settings.getUpdateMethod();
}
/**
@@ -72,7 +61,6 @@ public class GitUpdateOptionsPanel {
*/
public void applyTo(GitVcsSettings settings) {
settings.setUpdateMethod(getUpdateType());
settings.setUpdateChangesPolicy(updateSaveFilesPolicy());
}
/**
@@ -92,12 +80,5 @@ public class GitUpdateOptionsPanel {
default:
assert false : "Unknown value of update type: " + settings.getUpdateMethod();
}
UpdatePolicyUtils.updatePolicyItem(settings.updateChangesPolicy(), myStashRadioButton, myShelveRadioButton);
}
private void createUIComponents() {
myShelveRadioButton = new JRadioButton(GitBundle.message("update.options.save.shelve"));
myShelveRadioButton.setToolTipText(GitBundle.message("update.options.save.shelve.tooltip",
ApplicationNamesInfo.getInstance().getFullProductName()));
}
}
@@ -1,74 +0,0 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package git4idea.update;
import git4idea.config.GitVcsSettings;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
/**
* The utilities for update policy
*/
public class UpdatePolicyUtils {
/**
* The private constructor
*/
private UpdatePolicyUtils() {
}
/**
* Set policy value to radio buttons
*
* @param updateChangesPolicy the policy value to set
* @param stashRadioButton the stash radio button
* @param shelveRadioButton the shelve radio button
*/
public static void updatePolicyItem(GitVcsSettings.UpdateChangesPolicy updateChangesPolicy,
JRadioButton stashRadioButton,
JRadioButton shelveRadioButton) {
switch (updateChangesPolicy == null ? GitVcsSettings.UpdateChangesPolicy.STASH : updateChangesPolicy) {
case STASH:
stashRadioButton.setSelected(true);
return;
case SHELVE:
shelveRadioButton.setSelected(true);
return;
default:
assert false : "Unknown policy value: " + updateChangesPolicy;
}
}
/**
* Get policy value from radio buttons
*
* @param stashRadioButton the stash radio button
* @param shelveRadioButton the shelve radio button
* @return the policy value
*/
public static GitVcsSettings.UpdateChangesPolicy getUpdatePolicy(@NotNull JRadioButton stashRadioButton,
@NotNull JRadioButton shelveRadioButton) {
if (stashRadioButton.isSelected()) {
return GitVcsSettings.UpdateChangesPolicy.STASH;
} else if (shelveRadioButton.isSelected()) {
return GitVcsSettings.UpdateChangesPolicy.SHELVE;
} else {
// the stash is a default policy, in case if the policy could not be determined
return GitVcsSettings.UpdateChangesPolicy.STASH;
}
}
}