2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.jetbrains
.idea
.svn
;
18 import com
.intellij
.openapi
.util
.IconLoader
;
19 import org
.jetbrains
.annotations
.Nullable
;
23 public enum ConflictState
{
24 none(false, false, false, null),
25 tree(true, false, false, "/icons/conflictc.png"),
26 text(false, true, false, "/icons/conflictt.png"),
27 prop(false, false, true, "/icons/conflictp.png"),
28 tree_text(true, true, false, "/icons/conflictct.png"), // ? -
29 tree_prop(true, false, true, "/icons/conflictcp.png"), // now falls but marked
30 text_prop(false, true, true, "/icons/conflicttp.png"),
31 all3(true, true, true, "/icons/conflictctp.png"); // ? -
33 private final boolean myTree
;
34 private final boolean myText
;
35 private final boolean myProperty
;
37 private final Icon myIcon
;
38 private final String myDescription
;
40 private ConflictState(final boolean tree
, final boolean text
, final boolean property
, final String iconPath
) {
43 myProperty
= property
;
45 if (iconPath
!= null) {
46 myIcon
= IconLoader
.getIcon(iconPath
);
51 myDescription
= createDescription();
55 private String
createDescription() {
57 final StringBuilder sb
= new StringBuilder();
58 cnt
= checkOne(myTree
, cnt
, sb
, "tree");
59 cnt
= checkOne(myText
, cnt
, sb
, "text");
60 cnt
= checkOne(myProperty
, cnt
, sb
, "property");
67 private int checkOne(final boolean value
, final int init
, final StringBuilder sb
, final String text
) {
69 if (sb
.length() > 0) {
78 public boolean isTree() {
82 public boolean isText() {
86 public boolean isProperty() {
90 public boolean isConflict() {
91 return myProperty
|| myText
|| myTree
;
95 public Icon
getIcon() {
99 public String
getDescription() {
100 return myDescription
;
103 public static ConflictState
mergeState(final ConflictState leftState
, final ConflictState rightState
) {
104 return getInstance(leftState
.myTree
| rightState
.myTree
, leftState
.myText
| rightState
.myText
,
105 leftState
.myProperty
| rightState
.myProperty
);
108 public static ConflictState
getInstance(final boolean tree
, final boolean text
, final boolean property
) {
109 final ConflictState
[] conflictStates
= values();
110 for (ConflictState state
: conflictStates
) {
111 if ((state
.isTree() == tree
) && (state
.isText() == text
) && (state
.isProperty() == property
)) {
115 // all combinations are defined