4
4
import java .awt .Component ;
5
5
import java .awt .FlowLayout ;
6
6
import java .awt .Image ;
7
+ import java .awt .Point ;
8
+ import java .awt .event .ActionEvent ;
9
+ import java .awt .event .ActionListener ;
10
+ import java .awt .event .MouseAdapter ;
11
+ import java .awt .event .MouseEvent ;
12
+ import java .util .EventObject ;
7
13
8
14
import javax .swing .BoxLayout ;
9
15
import javax .swing .ImageIcon ;
10
16
import javax .swing .JLabel ;
11
17
import javax .swing .JPanel ;
12
18
import javax .swing .JTree ;
19
+ import javax .swing .event .CellEditorListener ;
13
20
import javax .swing .tree .DefaultMutableTreeNode ;
21
+ import javax .swing .tree .TreeCellEditor ;
14
22
import javax .swing .tree .TreeCellRenderer ;
15
23
16
24
import org .bcjj .gitCompare .NuevasVersionesInfo ;
20
28
import org .bcjj .gitCompare .FileInTreeInfo ;
21
29
import org .bcjj .gitCompare .FileVsGit ;
22
30
23
- public class FileTreeCellRenderer implements TreeCellRenderer {
31
+ public class FileTreeCellRenderer implements TreeCellRenderer /*, TreeCellEditor*/ {
24
32
25
33
public boolean activa =false ;
26
- ImageIcon iconoSinConflictos ;
27
- ImageIcon iconoConflictosMismoUsuario ;
28
- ImageIcon iconoConflictosDistintoUsuario ;
29
- ImageIcon iconoPendiente ;
30
- ImageIcon iconoHecho ;
31
-
32
- ImageIcon iconoSinConflictosMini ;
33
- ImageIcon iconoConflictosMismoUsuarioMini ;
34
- ImageIcon iconoConflictosDistintoUsuarioMini ;
35
- ImageIcon iconoPendienteMini ;
36
- ImageIcon iconoHechoMini ;
34
+ GitCompareMainWindow gitCompareMainWindow =null ;
35
+
37
36
38
- public FileTreeCellRenderer (ImageIcon iconoSinConflictos , ImageIcon iconoConflictosMismoUsuario , ImageIcon iconoConflictosDistintoUsuario ,ImageIcon iconoPendiente ,ImageIcon iconoHecho ) {
39
- this .iconoSinConflictos =iconoSinConflictos ;
40
- this .iconoConflictosMismoUsuario =iconoConflictosMismoUsuario ;
41
- this .iconoConflictosDistintoUsuario =iconoConflictosDistintoUsuario ;
42
- this .iconoPendiente =iconoPendiente ;
43
- this .iconoHecho =iconoHecho ;
44
-
45
- this .iconoSinConflictosMini =halfSize (iconoSinConflictos );
46
- this .iconoConflictosMismoUsuarioMini =halfSize (iconoConflictosMismoUsuario );
47
- this .iconoConflictosDistintoUsuarioMini =halfSize (iconoConflictosDistintoUsuario );
48
- this .iconoPendienteMini =halfSize (iconoPendiente );
49
- this .iconoHechoMini =halfSize (iconoHecho );
37
+ public FileTreeCellRenderer (GitCompareMainWindow gitCompareMainWindow ) {
38
+ this .gitCompareMainWindow =gitCompareMainWindow ;
50
39
}
51
40
52
- private ImageIcon halfSize (ImageIcon imageIcon ) {
53
- Image image = imageIcon .getImage (); // transform it
54
- Image newimg = image .getScaledInstance (image .getWidth (null )/2 , image .getHeight (null )/2 , java .awt .Image .SCALE_SMOOTH ); // scale it the smooth way
55
- imageIcon = new ImageIcon (newimg ); // transform it back
56
- return imageIcon ;
57
- }
41
+
58
42
59
43
60
44
public void setActiva (boolean activa ) {
61
45
this .activa =activa ;
62
46
}
63
47
64
48
49
+
50
+
51
+
65
52
@ Override
66
- public Component getTreeCellRendererComponent (JTree tree , Object value , boolean selected , boolean expanded ,
67
- boolean leaf , int row , boolean hasFocus ) {
68
-
53
+ public Component getTreeCellRendererComponent (JTree tree , Object value , boolean selected , boolean expanded , boolean leaf , int row , boolean hasFocus ) {
69
54
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode ) tree .getLastSelectedPathComponent ();
70
55
71
56
DefaultMutableTreeNode nodo =(DefaultMutableTreeNode )value ;
72
57
Object userObject =nodo .getUserObject ();
73
58
JPanel panel = new JPanel ();
74
59
//panel.setLayout(new FlowLayout(FlowLayout.LEADING, 2, 0));
75
60
panel .setLayout (new BoxLayout (panel , BoxLayout .X_AXIS ));
76
- JLabel label1 =null ;
77
- JLabel label2 =new JLabel ("" );
61
+ JLabel nombreFicheroLabel =null ;
62
+ JLabel separa1Label =new JLabel (" " );
63
+ JLabel infoFicheroLabel =new JLabel ("" );
78
64
if (userObject instanceof FileInTreeInfo ) {
79
65
FileInTreeInfo fileInTreeInfo =(FileInTreeInfo )userObject ;
80
66
//JPanel renderer = new JPanel(new GridLayout(0, 1));
81
- label1 =new JLabel (fileInTreeInfo .getPathName ());
67
+ nombreFicheroLabel =new JLabel (fileInTreeInfo .getPathName ());
82
68
if (fileInTreeInfo .getNuevasVersionesInfo ()==NuevasVersionesInfo .SinNuevasVersiones ) {
83
69
if (fileInTreeInfo instanceof FileVsGit ) {
84
- label1 .setIcon (iconoSinConflictos );
70
+ nombreFicheroLabel .setIcon (Iconos . iconoSinConflictos );
85
71
} else {
86
- label1 .setIcon (iconoSinConflictosMini );
72
+ nombreFicheroLabel .setIcon (Iconos . iconoSinConflictosMini );
87
73
}
88
74
} else if (fileInTreeInfo .getNuevasVersionesInfo ()==NuevasVersionesInfo .NuevasVersionesMismoAutor ) {
89
75
if (fileInTreeInfo instanceof FileVsGit ) {
90
- label1 .setIcon (iconoConflictosMismoUsuario );
76
+ nombreFicheroLabel .setIcon (Iconos . iconoConflictosMismoUsuario );
91
77
} else {
92
- label1 .setIcon (iconoConflictosMismoUsuarioMini );
78
+ nombreFicheroLabel .setIcon (Iconos . iconoConflictosMismoUsuarioMini );
93
79
}
94
80
} else if (fileInTreeInfo .getNuevasVersionesInfo ()==NuevasVersionesInfo .NuevasVersionesDistintosAutores ) {
95
81
if (fileInTreeInfo instanceof FileVsGit ) {
96
- label1 .setIcon (iconoConflictosDistintoUsuario );
82
+ nombreFicheroLabel .setIcon (Iconos . iconoConflictosDistintoUsuario );
97
83
} else {
98
- label1 .setIcon (iconoConflictosDistintoUsuarioMini );
84
+ nombreFicheroLabel .setIcon (Iconos . iconoConflictosDistintoUsuarioMini );
99
85
}
100
86
}
101
87
if (userObject instanceof FileVsGit ) {
102
88
FileVsGit fileVsGit =(FileVsGit )userObject ;
103
89
ComparacionInfo comparacionInfo =fileVsGit .getComparacionInfo ();
104
- label1 .setForeground (Color .BLACK );
90
+ nombreFicheroLabel .setForeground (Color .BLACK );
91
+
92
+ String n =fileInTreeInfo .getPathName ();
93
+ if (n .indexOf ("." )>-1 ) {
94
+ String ext =n .substring (n .indexOf ("." ));
95
+ if (ext .toLowerCase ().indexOf ("-orig" )>-1 ) {
96
+ nombreFicheroLabel .setForeground (Color .GRAY );
97
+ }
98
+ }
105
99
106
100
String htmlInfo ="" ;
107
101
if (comparacionInfo !=null ) {
108
102
String spc =" " ;
109
- htmlInfo ="<html><b>" +ampliaFuenteTexto (spc +spc +spc +" F-FGD:" ,-2 )+getEstadoHtml (comparacionInfo .getF_FGD ())+"</b> " +
110
- ampliaFuenteTexto (spc +" / " +spc +" VG-FGD:" ,-2 )+getEstadoHtml (comparacionInfo .getVG_FGD ())+" " +
111
- ampliaFuenteTexto (spc +" / " +spc +" F-VG:" +getEstadoHtml (comparacionInfo .getF_VG ()),-3 )
103
+ htmlInfo ="<html><b>" +ampliaFuenteTexto (spc +spc +spc +" F-FGD:" ,3 )+getEstadoHtml (comparacionInfo .getF_FGD (),4 )+"</b> " +
104
+ ampliaFuenteTexto (spc +" / " +spc +" VG-FGD:" ,2 )+getEstadoHtml (comparacionInfo .getVG_FGD (),2 )+" " +
105
+ ampliaFuenteTexto (spc +" / " +spc +" F-VG:" ,2 )+getEstadoHtml (comparacionInfo .getF_VG (),2 )
106
+ /*
107
+ +" <font size='1'>1 = <></font> "
108
+ +" <font size='2'>2 = <></font> "
109
+ +" <font size='3'>3 = <></font> "
110
+ +" <font size='4'>4 = <></font> "
111
+ +" <font size='5'>5 = <></font> "
112
+ +" <font size='6'>6 = <></font> "
113
+ +" <font size='7'>7 = <></font> "
114
+ */
112
115
+nbsps (20 ) //<font color='white'> - - - - - - </font>"
113
116
+"</html>" ;
114
117
}
115
- label2 .setText (htmlInfo );
118
+ //System.out.println(fileInTreeInfo.getPathName()+" ------ "+htmlInfo);
119
+ infoFicheroLabel .setText (htmlInfo );
116
120
//label2.setToolTipText("F: Fich -- FGD: Fich Directorio Git -- VG: Version en Git ultima");
117
121
118
122
} else {
119
- label1 .setForeground (Color .GRAY );
123
+ nombreFicheroLabel .setForeground (Color .GRAY );
120
124
}
121
125
if (fileInTreeInfo .getEstadoProcesado ()==EstadoProcesado .Revisado ) {
126
+ infoFicheroLabel .setToolTipText ("revisado" );
122
127
if (fileInTreeInfo instanceof FileVsGit ) {
123
- label2 .setIcon (iconoHecho );
128
+ infoFicheroLabel .setIcon (Iconos . iconoHecho );
124
129
} else {
125
- label2 .setIcon (iconoHechoMini );
130
+ infoFicheroLabel .setIcon (Iconos . iconoHechoMini );
126
131
}
127
132
} else {
133
+ infoFicheroLabel .setToolTipText ("pendiente" );
128
134
if (fileInTreeInfo instanceof FileVsGit ) {
129
- label2 .setIcon (iconoPendiente );
135
+ infoFicheroLabel .setIcon (Iconos . iconoPendiente );
130
136
} else {
131
- label2 .setIcon (iconoPendienteMini );
137
+ infoFicheroLabel .setIcon (Iconos . iconoPendienteMini );
132
138
}
133
139
}
134
140
} else {
135
- label1 =new JLabel (userObject .toString ());
141
+ nombreFicheroLabel =new JLabel (userObject .toString ());
136
142
}
137
143
if (selectedNode ==nodo ) {
138
- label1 .setOpaque (true );
139
- label1 .setBackground (Color .YELLOW );
140
- label1 .setText (label1 .getText ());
141
- label2 .setOpaque (true );
144
+ nombreFicheroLabel .setOpaque (true );
145
+ nombreFicheroLabel .setBackground (Color .YELLOW );
146
+ nombreFicheroLabel .setText (nombreFicheroLabel .getText ());
147
+ infoFicheroLabel .setOpaque (true );
142
148
Color LightYellow =new Color (255 , 255 , 224 ); //LightYellow FF FF E0 255 255 224
143
- label2 .setBackground (LightYellow );
149
+ infoFicheroLabel .setBackground (LightYellow );
144
150
} else {
145
- label1 .setOpaque (false );
146
- label1 .setBackground (Color .WHITE );
147
- label2 .setOpaque (false );
148
- label2 .setBackground (Color .WHITE );
151
+ nombreFicheroLabel .setOpaque (false );
152
+ nombreFicheroLabel .setBackground (Color .WHITE );
153
+ infoFicheroLabel .setOpaque (false );
154
+ infoFicheroLabel .setBackground (Color .WHITE );
149
155
}
150
- panel .add (label1 );
151
- panel .add (label2 );
156
+ panel .add (nombreFicheroLabel );
157
+
158
+ panel .add (separa1Label );
159
+
160
+ panel .add (infoFicheroLabel );
152
161
panel .setOpaque (false );
162
+
153
163
return panel ;
154
164
155
165
}
@@ -162,35 +172,25 @@ private String nbsps(int cuantos) {
162
172
return h ;
163
173
}
164
174
165
- private String ampliaFuenteTexto (String txt , int amp ) {
166
- if (amp !=0 ) {
167
- if (amp >0 ) {
168
- return txt ; //problemas de repintado
169
- //return "<font size='+"+amp+"'>"+txt+"</font>";
170
- } else {
171
- return "<font size='-" +(-amp )+"'>" +txt +"</font>" ;
172
- }
173
- } else {
174
- return txt ;
175
- }
175
+ private String ampliaFuenteTexto (String txt , int size ) { // 1 a 6, 7 es muy grando
176
+ return "<font size='" +size +"'>" +txt +"</font>" ;
176
177
}
177
178
178
- private String getEstadoHtml (EstadoComparacion estadoComparacion ) {
179
+ private String getEstadoHtml (EstadoComparacion estadoComparacion , int size ) {
179
180
if (estadoComparacion ==EstadoComparacion .Distintos ) {
180
- return "<font color='red'><></font>" ; // <>
181
+ return "<font color='red' size='" + size + "' ><></font>" ; // <>
181
182
}
182
183
if (estadoComparacion ==EstadoComparacion .Iguales ) {
183
- return "<font color='lime ' size='+1 '>=</font>" ;
184
+ return "<font color='#00EA00 ' size='" +( size + 1 )+ " '>=</font>" ; // #00FF00 #00CC00
184
185
}
185
186
if (estadoComparacion ==EstadoComparacion .OrigenExisteDestinoNo ) {
186
- return "<font color='purple'>!2</font>" ;
187
+ return "<font color='purple' size='" + size + "' >!2</font>" ;
187
188
}
188
189
if (estadoComparacion ==EstadoComparacion .OrigenNoExisteDestinoSi ) {
189
- return "<font color='purple'>!1</font>" ;
190
+ return "<font color='purple' size='" + size + "' >!1</font>" ;
190
191
}
191
192
return "<font color='orange'>Error</font>" ;
192
- }
193
+ }
193
194
194
195
195
-
196
196
}
0 commit comments