Simplify VcsShowConfirmationOption.Value: remove id param from enum

This commit is contained in:
Kirill Likhodedov
2013-08-06 17:41:13 +04:00
parent 13e6436cf7
commit dd3dda81a8
2 changed files with 13 additions and 18 deletions
@@ -16,34 +16,27 @@
package com.intellij.openapi.vcs;
public interface VcsShowConfirmationOption {
enum Value {
SHOW_CONFIRMATION(0),
DO_NOTHING_SILENTLY(1),
DO_ACTION_SILENTLY(2);
// NB: don't reorder enum values, otherwise you may break user settings based on the obsolete implementation
SHOW_CONFIRMATION,
DO_NOTHING_SILENTLY,
DO_ACTION_SILENTLY;
private final int myId;
Value(final int id) {
myId = id;
}
public int getId() {
return myId;
}
public String toString() {
return String.valueOf(myId);
// compatibility with the old implementation
return String.valueOf(ordinal());
}
@Deprecated
public static Value fromString(String s){
if (s == null) return SHOW_CONFIRMATION;
if (s.equals("1")) return DO_NOTHING_SILENTLY;
if (s.equals("2")) return DO_ACTION_SILENTLY;
return SHOW_CONFIRMATION;
}
}
public static final VcsShowConfirmationOption STATIC_SHOW_CONFIRMATION = new VcsShowConfirmationOption() {
VcsShowConfirmationOption STATIC_SHOW_CONFIRMATION = new VcsShowConfirmationOption() {
@Override
public Value getValue() {
return Value.SHOW_CONFIRMATION;
@@ -216,8 +216,10 @@ public class VcsGeneralConfigurationPanel implements SearchableConfigurable {
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);
int id = settings.REMOVE_EMPTY_INACTIVE_CHANGELISTS.getId();
UIUtil.setSelectedButton(myEmptyChangelistRemovingGroup, id == 0 ? 0 : id == 1 ? 2 : 1);
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);