14
14
* @author Daniel Espendiller <daniel@espendiller.net>
15
15
*/
16
16
public class DoctrineEntityLookupElement extends LookupElement {
17
-
18
17
private final String entityName ;
19
- private final PhpClass className ;
18
+ private final String className ;
20
19
private boolean useClassNameAsLookupString = false ;
21
20
private DoctrineTypes .Manager manager ;
22
21
private boolean isWeak = false ;
@@ -26,14 +25,14 @@ public DoctrineEntityLookupElement(String entityName, PhpClass className, boolea
26
25
this .useClassNameAsLookupString = useClassNameAsLookupString ;
27
26
}
28
27
29
- public DoctrineEntityLookupElement (String entityName , PhpClass className , boolean useClassNameAsLookupString , boolean isWeak ) {
30
- this (entityName , className , useClassNameAsLookupString );
28
+ public DoctrineEntityLookupElement (String entityName , PhpClass phpClass , boolean useClassNameAsLookupString , boolean isWeak ) {
29
+ this (entityName , phpClass , useClassNameAsLookupString );
31
30
this .isWeak = isWeak ;
32
31
}
33
32
34
- public DoctrineEntityLookupElement (String entityName , PhpClass className ) {
33
+ public DoctrineEntityLookupElement (String entityName , PhpClass phpClass ) {
35
34
this .entityName = entityName ;
36
- this .className = className ;
35
+ this .className = StringUtils . stripStart ( phpClass . getFQN (), " \\ " ) ;
37
36
}
38
37
39
38
public DoctrineEntityLookupElement withManager (DoctrineTypes .Manager manager ) {
@@ -44,46 +43,42 @@ public DoctrineEntityLookupElement withManager(DoctrineTypes.Manager manager) {
44
43
@ NotNull
45
44
@ Override
46
45
public String getLookupString () {
47
-
48
- if (this .useClassNameAsLookupString ) {
49
- return StringUtils .stripStart (this .className .getPresentableFQN (), "\\ " );
46
+ if (this .useClassNameAsLookupString ) {
47
+ return this .className ;
50
48
}
51
49
52
50
return entityName ;
53
51
}
54
52
55
- public void renderElement (LookupElementPresentation presentation ) {
56
-
57
- if (this .useClassNameAsLookupString ) {
58
- presentation .setItemText (className .getPresentableFQN ());
53
+ public void renderElement (@ NotNull LookupElementPresentation presentation ) {
54
+ if (this .useClassNameAsLookupString ) {
55
+ presentation .setItemText (className );
59
56
presentation .setTypeText (getLookupString ());
60
57
} else {
61
58
presentation .setItemText (getLookupString ());
62
- presentation .setTypeText (className . getPresentableFQN () );
59
+ presentation .setTypeText (className );
63
60
}
64
61
65
62
presentation .setTypeGrayed (true );
66
- if (isWeak ) {
63
+ if (isWeak ) {
67
64
// @TODO: remove weak
68
65
presentation .setIcon (getWeakIcon ());
69
66
} else {
70
67
presentation .setIcon (getIcon ());
71
68
}
72
-
73
-
74
69
}
75
70
76
71
@ Nullable
77
72
private Icon getWeakIcon () {
78
- if (manager == null ) {
73
+ if (manager == null ) {
79
74
return null ;
80
75
}
81
76
82
- if (manager == DoctrineTypes .Manager .ORM ) {
77
+ if (manager == DoctrineTypes .Manager .ORM ) {
83
78
return Symfony2Icons .DOCTRINE_WEAK ;
84
79
}
85
80
86
- if (manager == DoctrineTypes .Manager .MONGO_DB || manager == DoctrineTypes .Manager .COUCH_DB ) {
81
+ if (manager == DoctrineTypes .Manager .MONGO_DB || manager == DoctrineTypes .Manager .COUCH_DB ) {
87
82
return Symfony2Icons .NO_SQL ;
88
83
}
89
84
@@ -92,20 +87,19 @@ private Icon getWeakIcon() {
92
87
93
88
@ Nullable
94
89
private Icon getIcon () {
95
- if (manager == null ) {
90
+ if (manager == null ) {
96
91
return null ;
97
92
}
98
93
99
- if (manager == DoctrineTypes .Manager .ORM ) {
94
+ if (manager == DoctrineTypes .Manager .ORM ) {
100
95
return Symfony2Icons .DOCTRINE ;
101
96
}
102
97
103
- if (manager == DoctrineTypes .Manager .MONGO_DB || manager == DoctrineTypes .Manager .COUCH_DB ) {
98
+ if (manager == DoctrineTypes .Manager .MONGO_DB || manager == DoctrineTypes .Manager .COUCH_DB ) {
104
99
return Symfony2Icons .NO_SQL ;
105
100
}
106
101
107
102
return null ;
108
103
}
109
-
110
104
}
111
105
0 commit comments