summaryrefslogtreecommitdiff
path: root/plugins/svn4idea/src/org/jetbrains/idea/svn/api/EventAction.java
blob: 3a1d3fc80ef1702a76fad28e6c5c0baea7ae5654 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
 * Copyright 2000-2014 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 org.jetbrains.idea.svn.api;

import com.intellij.util.ObjectUtils;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.tmatesoft.svn.core.wc.SVNEventAction;

import java.util.Map;

/**
 * @author Konstantin Kolosovsky.
 */
public enum EventAction {

  // currently used to represent some not used event action from SVNKit
  UNKNOWN("unknown"),

  ADD("add"),
  DELETE("delete"),
  RESTORE("restore"),
  REVERT("revert"),
  FAILED_REVERT("failed_revert"),
  SKIP("skip"),

  UPDATE_DELETE("update_delete"),
  UPDATE_ADD("update_add"),
  UPDATE_UPDATE("update_update"),
  UPDATE_NONE("update_none"),
  UPDATE_COMPLETED("update_completed"),
  UPDATE_EXTERNAL("update_external"),
  UPDATE_SKIP_OBSTRUCTION("update_skip_obstruction"),
  UPDATE_STARTED("update_started"),

  COMMIT_MODIFIED("commit_modified"),
  COMMIT_ADDED("commit_added"),
  COMMIT_DELETED("commit_deleted"),
  COMMIT_REPLACED("commit_replaced"),
  COMMIT_DELTA_SENT("commit_delta_sent"),
  FAILED_OUT_OF_DATE("failed_out_of_date"),

  LOCKED("locked"),
  UNLOCKED("unlocked"),
  LOCK_FAILED("lock_failed"),
  UNLOCK_FAILED("unlock_failed"),

  UPGRADED_PATH("upgraded_path"),

  TREE_CONFLICT("tree_conflict");

  @NotNull private static final Map<String, EventAction> ourAllActions = ContainerUtil.newHashMap();

  static {
    for (EventAction action : EventAction.values()) {
      register(action);
    }
  }

  private String myKey;

  EventAction(String key) {
    myKey = key;
  }

  public String toString() {
    return myKey;
  }

  private static void register(@NotNull EventAction action) {
    ourAllActions.put(action.myKey, action);
  }

  @NotNull
  public static EventAction from(@NotNull SVNEventAction action) {
    return ObjectUtils.notNull(ourAllActions.get(action.toString()), UNKNOWN);
  }
}