Move commit-related settings to "Version Control" -> "Commit Dialog"

This commit is contained in:
Konstantin Kolosovsky
2017-09-13 08:55:46 +03:00
parent 8f792958b0
commit d8a5db2862
4 changed files with 98 additions and 99 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="com.intellij.openapi.vcs.configurable.CommitDialogSettingsPanel">
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="7" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
@@ -10,7 +10,7 @@
<children>
<component id="4d64c" class="com.intellij.ui.components.JBCheckBox" binding="myShowUnversionedFiles" default-binding="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Show unversioned files"/>
@@ -19,7 +19,7 @@
<grid id="e7891" 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="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<clientProperties>
@@ -35,6 +35,54 @@
</component>
</children>
</grid>
<component id="92b16" class="com.intellij.ui.components.JBCheckBox" binding="myClearInitialCommitMessage">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Clear &amp;initial commit message"/>
</properties>
</component>
<component id="34ec7" class="com.intellij.ui.components.JBCheckBox" binding="myForceNonEmptyCommitMessage">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/VcsBundle" key="checkbox.force.non.empty.messages"/>
</properties>
</component>
<component id="c98eb" class="com.intellij.ui.components.JBCheckBox" binding="myMoveUncommittedToAnotherChangeList">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/VcsBundle" key="checkbox.changelist.move.offer"/>
</properties>
</component>
<grid id="62c0" layout-manager="FlowLayout" hgap="5" vgap="2" flow-align="0">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="fd8ff" class="com.intellij.ui.components.JBLabel">
<constraints/>
<properties>
<text resource-bundle="messages/VcsBundle" key="create.changelist.on.failed.commit"/>
</properties>
</component>
<component id="7c462" class="com.intellij.openapi.ui.ComboBox" binding="myMoveToFailedCommitChangeList">
<constraints/>
<properties/>
</component>
</children>
</grid>
<vspacer id="20c64">
<constraints>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
</children>
</grid>
</form>
@@ -19,8 +19,12 @@ import com.intellij.openapi.Disposable;
import com.intellij.openapi.options.ConfigurableUi;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComboBox;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.vcs.VcsConfiguration;
import com.intellij.openapi.vcs.VcsShowConfirmationOption;
import com.intellij.ui.EnumComboBoxModel;
import com.intellij.ui.ListCellRendererWrapper;
import com.intellij.ui.components.JBCheckBox;
import com.intellij.vcs.commit.CommitMessageInspectionsPanel;
import org.jetbrains.annotations.NotNull;
@@ -32,25 +36,51 @@ public class CommitDialogSettingsPanel implements ConfigurableUi<VcsConfiguratio
private JBCheckBox myShowUnversionedFiles;
private JPanel myMainPanel;
private CommitMessageInspectionsPanel myInspectionsPanel;
private JBCheckBox myClearInitialCommitMessage;
private JBCheckBox myForceNonEmptyCommitMessage;
private JBCheckBox myMoveUncommittedToAnotherChangeList;
private ComboBox<VcsShowConfirmationOption.Value> myMoveToFailedCommitChangeList;
private EnumComboBoxModel<VcsShowConfirmationOption.Value> myMoveToFailedCommitChangeListModel;
public CommitDialogSettingsPanel(@NotNull Project project) {
myProject = project;
myMoveToFailedCommitChangeListModel = new EnumComboBoxModel<>(VcsShowConfirmationOption.Value.class);
myMoveToFailedCommitChangeList.setRenderer(new ListCellRendererWrapper<VcsShowConfirmationOption.Value>() {
@Override
public void customize(JList list, VcsShowConfirmationOption.Value value, int index, boolean selected, boolean hasFocus) {
setText(getConfirmationOptionText(value));
}
});
myMoveToFailedCommitChangeList.setModel(myMoveToFailedCommitChangeListModel);
}
@Override
public void reset(@NotNull VcsConfiguration settings) {
myShowUnversionedFiles.setSelected(settings.SHOW_UNVERSIONED_FILES_WHILE_COMMIT);
myClearInitialCommitMessage.setSelected(settings.CLEAR_INITIAL_COMMIT_MESSAGE);
myForceNonEmptyCommitMessage.setSelected(settings.FORCE_NON_EMPTY_COMMENT);
myMoveUncommittedToAnotherChangeList.setSelected(settings.OFFER_MOVE_TO_ANOTHER_CHANGELIST_ON_PARTIAL_COMMIT);
myMoveToFailedCommitChangeListModel.setSelectedItem(settings.MOVE_TO_FAILED_COMMIT_CHANGELIST);
myInspectionsPanel.reset();
}
@Override
public boolean isModified(@NotNull VcsConfiguration settings) {
return settings.SHOW_UNVERSIONED_FILES_WHILE_COMMIT != myShowUnversionedFiles.isSelected() || myInspectionsPanel.isModified();
return settings.SHOW_UNVERSIONED_FILES_WHILE_COMMIT != myShowUnversionedFiles.isSelected() ||
settings.CLEAR_INITIAL_COMMIT_MESSAGE != myClearInitialCommitMessage.isSelected() ||
settings.FORCE_NON_EMPTY_COMMENT != myForceNonEmptyCommitMessage.isSelected() ||
settings.OFFER_MOVE_TO_ANOTHER_CHANGELIST_ON_PARTIAL_COMMIT != myMoveUncommittedToAnotherChangeList.isSelected() ||
settings.MOVE_TO_FAILED_COMMIT_CHANGELIST != myMoveToFailedCommitChangeListModel.getSelectedItem() ||
myInspectionsPanel.isModified();
}
@Override
public void apply(@NotNull VcsConfiguration settings) throws ConfigurationException {
settings.SHOW_UNVERSIONED_FILES_WHILE_COMMIT = myShowUnversionedFiles.isSelected();
settings.CLEAR_INITIAL_COMMIT_MESSAGE = myClearInitialCommitMessage.isSelected();
settings.FORCE_NON_EMPTY_COMMENT = myForceNonEmptyCommitMessage.isSelected();
settings.OFFER_MOVE_TO_ANOTHER_CHANGELIST_ON_PARTIAL_COMMIT = myMoveUncommittedToAnotherChangeList.isSelected();
settings.MOVE_TO_FAILED_COMMIT_CHANGELIST = myMoveToFailedCommitChangeListModel.getSelectedItem();
myInspectionsPanel.apply();
}
@@ -68,4 +98,17 @@ public class CommitDialogSettingsPanel implements ConfigurableUi<VcsConfiguratio
public void dispose() {
Disposer.dispose(myInspectionsPanel);
}
@NotNull
private static String getConfirmationOptionText(@NotNull VcsShowConfirmationOption.Value value) {
switch (value) {
case SHOW_CONFIRMATION:
return "Ask";
case DO_NOTHING_SILENTLY:
return "No";
case DO_ACTION_SILENTLY:
return "Yes";
}
throw new IllegalArgumentException("Unknown confirmation option " + value);
}
}
@@ -152,7 +152,7 @@
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<grid id="aa6eb" layout-manager="GridLayoutManager" row-count="7" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="aa6eb" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -160,22 +160,6 @@
<properties/>
<border type="none"/>
<children>
<component id="2c789" class="javax.swing.JCheckBox" binding="myCbOfferToMoveChanges">
<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>
<text resource-bundle="messages/VcsBundle" key="checkbox.changelist.move.offer"/>
</properties>
</component>
<component id="5f121" class="javax.swing.JCheckBox" binding="myForceNonEmptyComment">
<constraints>
<grid row="2" 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>
<text resource-bundle="messages/VcsBundle" key="checkbox.force.non.empty.messages"/>
</properties>
</component>
<component id="9ee4d" class="javax.swing.JCheckBox" binding="myShowReadOnlyStatusDialog">
<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"/>
@@ -184,35 +168,9 @@
<text resource-bundle="messages/VcsBundle" key="checkbox.show.clear.read.only.status.dialog"/>
</properties>
</component>
<grid id="da366" layout-manager="FlowLayout" hgap="5" vgap="2" flow-align="0">
<constraints>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="d6cff" class="javax.swing.JLabel">
<constraints/>
<properties>
<labelFor value="c8cb8"/>
<text resource-bundle="messages/VcsBundle" key="create.changelist.on.failed.commit"/>
</properties>
</component>
<component id="c8cb8" class="javax.swing.JComboBox" binding="myFailedCommitChangelistCombo" default-binding="true">
<constraints/>
<properties>
<model>
<item value="Yes"/>
<item value="No"/>
<item value="Ask"/>
</model>
</properties>
</component>
</children>
</grid>
<grid id="6c335" layout-manager="FlowLayout" hgap="5" vgap="2" flow-align="0">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -236,17 +194,9 @@
</component>
</children>
</grid>
<component id="65b72" class="javax.swing.JCheckBox" binding="myClearInitialCommitMessage">
<constraints>
<grid row="3" 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>
<text value="Clear &amp;initial commit message"/>
</properties>
</component>
<component id="3e34c" class="javax.swing.JCheckBox" binding="myReloadContext">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<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>
<text value="Reload context on &amp;branch switching"/>
@@ -34,7 +34,6 @@ import java.util.List;
public class VcsGeneralConfigurationPanel {
private JCheckBox myForceNonEmptyComment;
private JCheckBox myShowReadOnlyStatusDialog;
private JRadioButton myShowDialogOnAddingFile;
@@ -57,10 +56,7 @@ public class VcsGeneralConfigurationPanel {
Map<VcsShowOptionsSettingImpl, JCheckBox> myPromptOptions = new LinkedHashMap<>();
private JPanel myRemoveConfirmationPanel;
private JPanel myAddConfirmationPanel;
private JCheckBox myCbOfferToMoveChanges;
private JComboBox myFailedCommitChangelistCombo;
private JComboBox myOnPatchCreation;
private JCheckBox myClearInitialCommitMessage;
private JCheckBox myReloadContext;
private ButtonGroup myEmptyChangelistRemovingGroup;
@@ -101,11 +97,7 @@ public class VcsGeneralConfigurationPanel {
VcsConfiguration settings = VcsConfiguration.getInstance(myProject);
settings.FORCE_NON_EMPTY_COMMENT = myForceNonEmptyComment.isSelected();
settings.CLEAR_INITIAL_COMMIT_MESSAGE = myClearInitialCommitMessage.isSelected();
settings.OFFER_MOVE_TO_ANOTHER_CHANGELIST_ON_PARTIAL_COMMIT = myCbOfferToMoveChanges.isSelected();
settings.REMOVE_EMPTY_INACTIVE_CHANGELISTS = getSelected(myEmptyChangelistRemovingGroup);
settings.MOVE_TO_FAILED_COMMIT_CHANGELIST = getFailedCommitConfirm();
settings.RELOAD_CONTEXT = myReloadContext.isSelected();
for (VcsShowOptionsSettingImpl setting : myPromptOptions.keySet()) {
@@ -135,14 +127,6 @@ public class VcsGeneralConfigurationPanel {
}
}
private VcsShowConfirmationOption.Value getFailedCommitConfirm() {
switch(myFailedCommitChangelistCombo.getSelectedIndex()) {
case 0: return VcsShowConfirmationOption.Value.DO_ACTION_SILENTLY;
case 1: return VcsShowConfirmationOption.Value.DO_NOTHING_SILENTLY;
default: return VcsShowConfirmationOption.Value.SHOW_CONFIRMATION;
}
}
private VcsShowConfirmationOption getAddConfirmation() {
return ProjectLevelVcsManagerEx.getInstanceEx(myProject)
.getConfirmation(VcsConfiguration.StandardConfirmation.ADD);
@@ -177,24 +161,11 @@ public class VcsGeneralConfigurationPanel {
public boolean isModified() {
VcsConfiguration settings = VcsConfiguration.getInstance(myProject);
if (settings.FORCE_NON_EMPTY_COMMENT != myForceNonEmptyComment.isSelected()){
return true;
}
if (settings.CLEAR_INITIAL_COMMIT_MESSAGE != myClearInitialCommitMessage.isSelected()){
return true;
}
if (settings.OFFER_MOVE_TO_ANOTHER_CHANGELIST_ON_PARTIAL_COMMIT != myCbOfferToMoveChanges.isSelected()){
return true;
}
if (settings.REMOVE_EMPTY_INACTIVE_CHANGELISTS != getSelected(myEmptyChangelistRemovingGroup)){
return true;
}
if (settings.RELOAD_CONTEXT != myReloadContext.isSelected()) return true;
if (!Comparing.equal(getFailedCommitConfirm(), settings.MOVE_TO_FAILED_COMMIT_CHANGELIST)) {
return true;
}
if (getReadOnlyStatusHandler().getState().SHOW_DIALOG != myShowReadOnlyStatusDialog.isSelected()) {
return true;
}
@@ -212,25 +183,12 @@ public class VcsGeneralConfigurationPanel {
public void reset() {
VcsConfiguration settings = VcsConfiguration.getInstance(myProject);
myForceNonEmptyComment.setSelected(settings.FORCE_NON_EMPTY_COMMENT);
myClearInitialCommitMessage.setSelected(settings.CLEAR_INITIAL_COMMIT_MESSAGE);
myCbOfferToMoveChanges.setSelected(settings.OFFER_MOVE_TO_ANOTHER_CHANGELIST_ON_PARTIAL_COMMIT);
myReloadContext.setSelected(settings.RELOAD_CONTEXT);
VcsShowConfirmationOption.Value value = settings.REMOVE_EMPTY_INACTIVE_CHANGELISTS;
UIUtil.setSelectedButton(myEmptyChangelistRemovingGroup, value == VcsShowConfirmationOption.Value.SHOW_CONFIRMATION
? 0
: value == VcsShowConfirmationOption.Value.DO_NOTHING_SILENTLY ? 2 : 1);
myShowReadOnlyStatusDialog.setSelected(getReadOnlyStatusHandler().getState().SHOW_DIALOG);
if (settings.MOVE_TO_FAILED_COMMIT_CHANGELIST == VcsShowConfirmationOption.Value.DO_ACTION_SILENTLY) {
myFailedCommitChangelistCombo.setSelectedIndex(0);
}
else if (settings.MOVE_TO_FAILED_COMMIT_CHANGELIST == VcsShowConfirmationOption.Value.DO_NOTHING_SILENTLY) {
myFailedCommitChangelistCombo.setSelectedIndex(1);
}
else {
myFailedCommitChangelistCombo.setSelectedIndex(2);
}
for (VcsShowOptionsSettingImpl setting : myPromptOptions.keySet()) {
myPromptOptions.get(setting).setSelected(setting.getValue());
}