Skip to content

Commit 82cdb58

Browse files
0.5 - siempre *-del ; *-orig en gris ; iconos = o <> pequeños para no principales ; menu contextual copia y compara ; datos para pruebas
1 parent f55a9ab commit 82cdb58

24 files changed

+343
-127
lines changed

compileCompareToGit.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
rem # create project:
22
rem # mvn archetype:generate -DgroupId=org.bcjj.gitCompare -DartifactId=compareToGit -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
33

4-
set JAVA_HOME=C:\jdk1.8.0_144
4+
set JAVA_HOME=C:\java\jdk1.8.0_144
55

66
mvn clean install dependency:copy-dependencies dependency:sources
77

pom.xml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
33
<modelVersion>4.0.0</modelVersion>
4+
5+
46
<groupId>org.bcjj.gitCompare</groupId>
57
<artifactId>compareToGit</artifactId>
68
<packaging>jar</packaging>
7-
<version>0.4</version>
9+
<version>0.5</version>
810
<name>compareToGit</name>
911
<url>http://maven.apache.org</url>
1012

Loading
Loading
951 Bytes
Loading
832 Bytes
Loading
1.06 KB
Loading

src/main/java/images/compress.png

1.21 KB
Loading

src/main/java/images/go-next.png

1.12 KB
Loading

src/main/java/images/page-add.png

1.2 KB
Loading

src/main/java/images/page-go.png

1.23 KB
Loading
1.04 KB
Loading
1.08 KB
Loading
Loading
677 Bytes
Loading
3.36 KB
Loading

src/main/java/org/bcjj/gitCompare/ComparacionInfo.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
public class ComparacionInfo {
44
//comp3-F-V(B)G-FGD->FGD
5-
EstadoComparacion F_FGD; // Fichero vs Fichero Directorio Git
6-
EstadoComparacion VG_FGD; // (ultima) Version Git vs Fichero Directorio Git
7-
EstadoComparacion F_VG; // Fichero vs (ultima) Version Git -- hace falta?
5+
EstadoComparacion F_FGD; // F_FGD : Fichero vs Fichero Directorio Git
6+
EstadoComparacion VG_FGD; // VG_FGD : (ultima) Version Git (tmp) vs Fichero Directorio Git
7+
EstadoComparacion F_VG; // F_VG : Fichero vs (ultima) Version Git (tmp) -- hace falta?
8+
9+
// F_FGD : Fichero vs Fichero Directorio Git -- VG_FGD : (ultima) Version Git (tmp) vs Fichero Directorio Git -- F_VG : Fichero vs (ultima) Version Git (tmp)
10+
811

912
public EstadoComparacion getF_FGD() {
1013
return F_FGD;

src/main/java/org/bcjj/gitCompare/FileVsGit.java

+5
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ public String getPathName() {
6565
return fich.getName()+" ("+getVersionesConCambios()+") ";
6666
}
6767

68+
public String getPathNameSinVersionesConCambios() {
69+
return fich.getName();
70+
}
71+
72+
6873
public int getVersionesConCambios() {
6974
int v=versiones.size();
7075
if (tieneBase) {

src/main/java/org/bcjj/gitCompare/GitRepo.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public void outputGitFile(String commitId, String filePath, OutputStream outputS
157157
RevCommit commit = revWalk.parseCommit(commitIdObjId);
158158
// and using commit's tree find the path
159159
RevTree tree = commit.getTree();
160-
System.out.println("Having tree: " + tree);
160+
//System.out.println("Having tree: " + tree);
161161

162162
// now try to find a specific file
163163
try (TreeWalk treeWalk = new TreeWalk(repository)) {

src/main/java/org/bcjj/gitCompare/gui/FileTreeCellRenderer.java

+82-82
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,21 @@
44
import java.awt.Component;
55
import java.awt.FlowLayout;
66
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;
713

814
import javax.swing.BoxLayout;
915
import javax.swing.ImageIcon;
1016
import javax.swing.JLabel;
1117
import javax.swing.JPanel;
1218
import javax.swing.JTree;
19+
import javax.swing.event.CellEditorListener;
1320
import javax.swing.tree.DefaultMutableTreeNode;
21+
import javax.swing.tree.TreeCellEditor;
1422
import javax.swing.tree.TreeCellRenderer;
1523

1624
import org.bcjj.gitCompare.NuevasVersionesInfo;
@@ -20,136 +28,138 @@
2028
import org.bcjj.gitCompare.FileInTreeInfo;
2129
import org.bcjj.gitCompare.FileVsGit;
2230

23-
public class FileTreeCellRenderer implements TreeCellRenderer {
31+
public class FileTreeCellRenderer implements TreeCellRenderer /*, TreeCellEditor*/ {
2432

2533
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+
3736

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;
5039
}
5140

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+
5842

5943

6044
public void setActiva(boolean activa) {
6145
this.activa=activa;
6246
}
6347

6448

49+
50+
51+
6552
@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) {
6954
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
7055

7156
DefaultMutableTreeNode nodo=(DefaultMutableTreeNode)value;
7257
Object userObject=nodo.getUserObject();
7358
JPanel panel = new JPanel();
7459
//panel.setLayout(new FlowLayout(FlowLayout.LEADING, 2, 0));
7560
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("");
7864
if (userObject instanceof FileInTreeInfo) {
7965
FileInTreeInfo fileInTreeInfo=(FileInTreeInfo)userObject;
8066
//JPanel renderer = new JPanel(new GridLayout(0, 1));
81-
label1=new JLabel(fileInTreeInfo.getPathName());
67+
nombreFicheroLabel=new JLabel(fileInTreeInfo.getPathName());
8268
if (fileInTreeInfo.getNuevasVersionesInfo()==NuevasVersionesInfo.SinNuevasVersiones) {
8369
if (fileInTreeInfo instanceof FileVsGit) {
84-
label1.setIcon(iconoSinConflictos);
70+
nombreFicheroLabel.setIcon(Iconos.iconoSinConflictos);
8571
} else {
86-
label1.setIcon(iconoSinConflictosMini);
72+
nombreFicheroLabel.setIcon(Iconos.iconoSinConflictosMini);
8773
}
8874
} else if (fileInTreeInfo.getNuevasVersionesInfo()==NuevasVersionesInfo.NuevasVersionesMismoAutor) {
8975
if (fileInTreeInfo instanceof FileVsGit) {
90-
label1.setIcon(iconoConflictosMismoUsuario);
76+
nombreFicheroLabel.setIcon(Iconos.iconoConflictosMismoUsuario);
9177
} else {
92-
label1.setIcon(iconoConflictosMismoUsuarioMini);
78+
nombreFicheroLabel.setIcon(Iconos.iconoConflictosMismoUsuarioMini);
9379
}
9480
} else if (fileInTreeInfo.getNuevasVersionesInfo()==NuevasVersionesInfo.NuevasVersionesDistintosAutores) {
9581
if (fileInTreeInfo instanceof FileVsGit) {
96-
label1.setIcon(iconoConflictosDistintoUsuario);
82+
nombreFicheroLabel.setIcon(Iconos.iconoConflictosDistintoUsuario);
9783
} else {
98-
label1.setIcon(iconoConflictosDistintoUsuarioMini);
84+
nombreFicheroLabel.setIcon(Iconos.iconoConflictosDistintoUsuarioMini);
9985
}
10086
}
10187
if (userObject instanceof FileVsGit) {
10288
FileVsGit fileVsGit=(FileVsGit)userObject;
10389
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+
}
10599

106100
String htmlInfo="";
107101
if (comparacionInfo!=null) {
108102
String spc="&nbsp;";
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 = &lt;&gt</font> "
108+
+" <font size='2'>2 = &lt;&gt</font> "
109+
+" <font size='3'>3 = &lt;&gt</font> "
110+
+" <font size='4'>4 = &lt;&gt</font> "
111+
+" <font size='5'>5 = &lt;&gt</font> "
112+
+" <font size='6'>6 = &lt;&gt</font> "
113+
+" <font size='7'>7 = &lt;&gt</font> "
114+
*/
112115
+nbsps(20) //<font color='white'> - - - - - - </font>"
113116
+"</html>";
114117
}
115-
label2.setText(htmlInfo);
118+
//System.out.println(fileInTreeInfo.getPathName()+" ------ "+htmlInfo);
119+
infoFicheroLabel.setText(htmlInfo);
116120
//label2.setToolTipText("F: Fich -- FGD: Fich Directorio Git -- VG: Version en Git ultima");
117121

118122
} else {
119-
label1.setForeground(Color.GRAY);
123+
nombreFicheroLabel.setForeground(Color.GRAY);
120124
}
121125
if (fileInTreeInfo.getEstadoProcesado()==EstadoProcesado.Revisado) {
126+
infoFicheroLabel.setToolTipText("revisado");
122127
if (fileInTreeInfo instanceof FileVsGit) {
123-
label2.setIcon(iconoHecho);
128+
infoFicheroLabel.setIcon(Iconos.iconoHecho);
124129
} else {
125-
label2.setIcon(iconoHechoMini);
130+
infoFicheroLabel.setIcon(Iconos.iconoHechoMini);
126131
}
127132
} else {
133+
infoFicheroLabel.setToolTipText("pendiente");
128134
if (fileInTreeInfo instanceof FileVsGit) {
129-
label2.setIcon(iconoPendiente);
135+
infoFicheroLabel.setIcon(Iconos.iconoPendiente);
130136
} else {
131-
label2.setIcon(iconoPendienteMini);
137+
infoFicheroLabel.setIcon(Iconos.iconoPendienteMini);
132138
}
133139
}
134140
} else {
135-
label1=new JLabel(userObject.toString());
141+
nombreFicheroLabel=new JLabel(userObject.toString());
136142
}
137143
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);
142148
Color LightYellow=new Color(255, 255, 224); //LightYellow FF FF E0 255 255 224
143-
label2.setBackground(LightYellow);
149+
infoFicheroLabel.setBackground(LightYellow);
144150
} 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);
149155
}
150-
panel.add(label1);
151-
panel.add(label2);
156+
panel.add(nombreFicheroLabel);
157+
158+
panel.add(separa1Label);
159+
160+
panel.add(infoFicheroLabel);
152161
panel.setOpaque(false);
162+
153163
return panel;
154164

155165
}
@@ -162,35 +172,25 @@ private String nbsps(int cuantos) {
162172
return h;
163173
}
164174

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>";
176177
}
177178

178-
private String getEstadoHtml(EstadoComparacion estadoComparacion) {
179+
private String getEstadoHtml(EstadoComparacion estadoComparacion, int size) {
179180
if (estadoComparacion==EstadoComparacion.Distintos) {
180-
return "<font color='red'>&lt;&gt;</font>"; // <>
181+
return "<font color='red' size='"+size+"'>&lt;&gt;</font>"; // <>
181182
}
182183
if (estadoComparacion==EstadoComparacion.Iguales) {
183-
return "<font color='lime' size='+1'>=</font>";
184+
return "<font color='#00EA00' size='"+(size+1)+"'>=</font>"; // #00FF00 #00CC00
184185
}
185186
if (estadoComparacion==EstadoComparacion.OrigenExisteDestinoNo) {
186-
return "<font color='purple'>!2</font>";
187+
return "<font color='purple' size='"+size+"'>!2</font>";
187188
}
188189
if (estadoComparacion==EstadoComparacion.OrigenNoExisteDestinoSi) {
189-
return "<font color='purple'>!1</font>";
190+
return "<font color='purple' size='"+size+"'>!1</font>";
190191
}
191192
return "<font color='orange'>Error</font>";
192-
}
193+
}
193194

194195

195-
196196
}

0 commit comments

Comments
 (0)