Skip to content

Commit 5721638

Browse files
doble carpeta en mapeo.
se pueden poner 2 rutas en un mapeo (separadas por #), por defecto coge la primera, salvo que exista fichero en la 2, entonces coge la segunda (EJ: srv-war|src\\web\\web-prod\\srv#src\\web\\web-ap\\srv)
1 parent 141a157 commit 5721638

File tree

9 files changed

+107
-21
lines changed

9 files changed

+107
-21
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<groupId>org.bcjj.gitCompare</groupId>
77
<artifactId>compareToGit</artifactId>
88
<packaging>jar</packaging>
9-
<version>0.5</version>
9+
<version>0.6</version>
1010
<name>compareToGit</name>
1111
<url>http://maven.apache.org</url>
1212

src/main/java/images/carpeta.png

510 Bytes
Loading

src/main/java/images/tortoise.png

725 Bytes
Loading

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

+10-2
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,24 @@ public class FileVsGit extends FileInTreeInfo {
3333
private boolean borrar;
3434
private String tempFichBase;
3535
private String tempDirectoy;
36+
private int mapNumber;
3637

38+
public int getMapNumber() {
39+
return mapNumber;
40+
}
41+
42+
43+
3744
ComparacionInfo comparacionInfo=null;
3845

3946

40-
public FileVsGit(File fich, GitRepo gitRepo, String gitFile,boolean borrar,String tempDirectoy) {
47+
public FileVsGit(File fich, GitRepo gitRepo, String gitFile,int mapNumber, boolean borrar,String tempDirectoy) {
4148
super(fich.getName());
4249
this.tempDirectoy=tempDirectoy;
4350
this.fich = fich;
4451
this.gitRepo = gitRepo;
4552
this.gitFile = gitFile;
53+
this.mapNumber=mapNumber;
4654
this.borrar=borrar;
4755
this.tempFichBase=tempDirectoy+gitFile;
4856
initialize();
@@ -322,7 +330,7 @@ c56a6eb03deb Matthew Wilcox (Oracle) 20220501.004603 jbd2: Convert jbd2_journ
322330

323331
GitRepo gitRepo=new GitRepo("D:/linuxKernel-git/linux",commitIdControl);
324332

325-
FileVsGit fVsGit=new FileVsGit(new File("c:/isTheSame.txt"), gitRepo, "fs/ext4/inode.c",false,"c:/temp/");
333+
FileVsGit fVsGit=new FileVsGit(new File("c:/isTheSame.txt"), gitRepo,"fs/ext4/inode.c",1,false,"c:/temp/");
326334
fVsGit.getVersiones().forEach(gitFVInfo -> {
327335
System.out.println(gitFVInfo.getCommitId()+" f:"+gitFVInfo.getFechaYMDHMS()+" c:"+gitFVInfo.getShortMessage());
328336
});

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ public Component getTreeCellRendererComponent(JTree tree, Object value, boolean
8888
FileVsGit fileVsGit=(FileVsGit)userObject;
8989
ComparacionInfo comparacionInfo=fileVsGit.getComparacionInfo();
9090
nombreFicheroLabel.setForeground(Color.BLACK);
91-
91+
if (fileVsGit.getMapNumber()==2) {
92+
separa1Label.setText(" (map#2) ");
93+
separa1Label.setForeground(Color.BLUE);
94+
}
9295
String n=fileInTreeInfo.getPathName();
9396
if (n.indexOf(".")>-1) {
9497
String ext=n.substring(n.indexOf("."));

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

+81-14
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@ public class GitCompareMainWindow implements ContenedorHistorico {
291291
private JPanel panelOpcionFecha;
292292
private JButton listFiles;
293293
private JButton zipFiles;
294+
private JSplitPane splitPane;
295+
private JTextField txtFileGitSelected;
294296

295297
/**
296298
* Launch the application.
@@ -703,11 +705,11 @@ public int compare(File f1, File f2) {
703705
fileAbs=fileAbs.substring(0, fileAbs.length()-SUFIX_DEL.length());
704706
borrar=true;
705707
}
706-
String fileAbsMapeado=mapearReglas(fileAbs); // src/web/web-prod/srv/main.jsp
707-
if (fileAbsMapeado!="!") { //$NON-NLS-1$
708+
SalidaRegla fileAbsMapeadoRegla=mapearReglas(fileAbs,gitRepo); // src/web/web-prod/srv/main.jsp
709+
if (!fileAbsMapeadoRegla.candidato.equals("!")) { //$NON-NLS-1$
708710

709711

710-
FileVsGit fileVsGit=new FileVsGit(fich,gitRepo,fileAbsMapeado,borrar,tempDirectoy);
712+
FileVsGit fileVsGit=new FileVsGit(fich,gitRepo,fileAbsMapeadoRegla.candidato,fileAbsMapeadoRegla.parte,borrar,tempDirectoy);
711713
filesGit.add(fileVsGit);
712714
if (filesGit.size()==MAX_FILES_WARNING) {
713715
int input = JOptionPane.showConfirmDialog(frmGitcompare,
@@ -717,8 +719,8 @@ public int compare(File f1, File f2) {
717719
throw new Exception("cancelado por usuario");
718720
}
719721
}
720-
if (fileAbsMapeado.contains("codigo.java")) {
721-
System.out.println(fileAbsMapeado);
722+
if (fileAbsMapeadoRegla.candidato.contains("codigo.java")) {
723+
System.out.println(fileAbsMapeadoRegla.candidato);
722724
}
723725
//fileVsGit.initialize(); //.check()
724726
List<GitFileVersionInfo> versiones=fileVsGit.getVersiones();
@@ -791,25 +793,52 @@ private String trimPathSymbol(String exp) {
791793
return exp;
792794
}
793795

794-
private String mapearReglas(String fileAbs) { //como baseDirAbsolute termina forzosamente por /, fileAbs no comenzará por /
796+
797+
private static class SalidaRegla {
798+
String candidato;
799+
int parte=1;
800+
public SalidaRegla(String candidato, int parte) {
801+
super();
802+
this.candidato = candidato;
803+
this.parte = parte;
804+
}
805+
}
806+
807+
private SalidaRegla mapearReglas(String fileAbs,GitRepo gitRepo) { //como baseDirAbsolute termina forzosamente por /, fileAbs no comenzará por /
795808
fileAbs=StringUtils.replace(fileAbs, "\\", "/"); //$NON-NLS-1$ //$NON-NLS-2$
796809
if (confMapeoReglasMapeo==null) {
797-
return fileAbs;
810+
return new SalidaRegla(fileAbs,-1);
798811
}
799812
for (String s:confMapeoReglasMapeo) {
800813
StringTokenizer st=new StringTokenizer(s,"|"); //$NON-NLS-1$
801814
String buscar=trimPathSymbol(st.nextToken())+"/"; //$NON-NLS-1$
802-
String mapear=trimPathSymbol(st.nextToken())+"/"; //$NON-NLS-1$
815+
String mapearExp=trimPathSymbol(st.nextToken())+"/"; //$NON-NLS-1$
816+
817+
818+
//path.1=srv-war/WEB-INF/config|src/web/web-prod/properties:src/web/web-prim/properties
819+
//path.4=srv-war|src/web/web-prod/srv:src/web/web-prim/srv
820+
//Si existe en opcion 2 usa la 2, si no 1. (ponerlo como ayuda en MapeoDlg y en genSample y en directorio test)
821+
//Mostrar en gui la ruta elegida y un icono de aviso
822+
803823
if (fileAbs.startsWith(buscar)) {
804-
if (mapear.equals("!/")) { //$NON-NLS-1$
805-
return "!"; //$NON-NLS-1$
824+
if (mapearExp.equals("!/")) { //$NON-NLS-1$
825+
return new SalidaRegla("!",0); //$NON-NLS-1$
806826
}
807-
String mapeado=fileAbs.substring(buscar.length());
808-
mapeado=mapear+mapeado;
809-
return mapeado;
827+
String parteFinalFich=fileAbs.substring(buscar.length());
828+
//List<String> mapeos = new ArrayList<>(Arrays.asList(mapearExp.split("#")));
829+
String [] mapeos=mapearExp.split("#");
830+
if (mapeos.length>1) {
831+
String mapeado2=mapeos[1]+parteFinalFich;
832+
File f2=new File(gitRepo.getPath()+"/"+mapeado2);
833+
if (f2.exists()) {
834+
return new SalidaRegla(mapeado2,2);
835+
}
836+
}
837+
String mapeado=mapeos[0]+parteFinalFich;
838+
return new SalidaRegla(mapeado,1);
810839
}
811840
}
812-
return fileAbs;
841+
return new SalidaRegla(fileAbs,-1);
813842
}
814843

815844
private void actualizaConflictoEnNodosPadres(DefaultMutableTreeNode padreNode, NuevasVersionesInfo diferencia) {
@@ -858,6 +887,7 @@ public void valueChanged(TreeSelectionEvent e) {
858887
if (userObject!=null && userObject instanceof FileVsGit) {
859888
FileVsGit fileVsGit=(FileVsGit)userObject;
860889
getTxtFileSelected().setText(fileVsGit.getGitFile());
890+
//getTxtFileGitSelected().setText(fileVsGit.getFileInGit() );
861891

862892
if (fileVsGit.getEstadoProcesado()==EstadoProcesado.Revisado) {
863893
getChckbxDone().setSelected(true);
@@ -946,6 +976,23 @@ public void actionPerformed(ActionEvent event) {
946976
}
947977
});
948978

979+
JMenuItem itemExpF=new JMenuItem("expF (abrir en explorer Fichero (trabajo))", Iconos.iconoFolder );
980+
popup.add(itemExpF);
981+
itemExpF.setHorizontalTextPosition(JMenuItem.RIGHT);
982+
itemExpF.addActionListener(new ActionListener() {
983+
public void actionPerformed(ActionEvent event) {
984+
explorerFichero();
985+
}
986+
});
987+
988+
JMenuItem itemExpFGD=new JMenuItem("expFGD (abrir en explorer Fichero Directorio Git)", Iconos.iconoFolderGit );
989+
popup.add(itemExpFGD);
990+
itemExpFGD.setHorizontalTextPosition(JMenuItem.RIGHT);
991+
itemExpFGD.addActionListener(new ActionListener() {
992+
public void actionPerformed(ActionEvent event) {
993+
explorerFicheroGit();
994+
}
995+
});
949996
return popup;
950997
}
951998

@@ -1281,6 +1328,7 @@ private JPanel getPanelSelected() {
12811328
panelSelected.setMinimumSize(new Dimension(20, 20));
12821329
panelSelected.setLayout(new BorderLayout(0, 0));
12831330
panelSelected.add(getChckbxDone(), BorderLayout.WEST);
1331+
//panelSelected.add(getSplitPane(), BorderLayout.CENTER);
12841332
panelSelected.add(getTxtFileSelected(), BorderLayout.CENTER);
12851333
panelSelected.add(getPanel(), BorderLayout.EAST);
12861334
}
@@ -2636,4 +2684,23 @@ protected void generateZipFile() {
26362684
}
26372685

26382686
}
2687+
/*
2688+
private JSplitPane getSplitPane() {
2689+
if (splitPane == null) {
2690+
splitPane = new JSplitPane();
2691+
splitPane.setLeftComponent(getTxtFileSelected());
2692+
splitPane.setRightComponent(getTxtFileGitSelected());
2693+
splitPane.setDividerLocation(500);
2694+
}
2695+
return splitPane;
2696+
}
2697+
private JTextField getTxtFileGitSelected() {
2698+
if (txtFileGitSelected == null) {
2699+
txtFileGitSelected = new JTextField();
2700+
txtFileGitSelected.setEnabled(false);
2701+
txtFileGitSelected.setColumns(10);
2702+
}
2703+
return txtFileGitSelected;
2704+
}
2705+
*/
26392706
}

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

+8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ public class Iconos {
1818
static ImageIcon iconoCopy;
1919
static ImageIcon iconoCompare;
2020

21+
static ImageIcon iconoFolder;
22+
static ImageIcon iconoFolderGit;
23+
24+
2125
static ImageIcon iconoSinConflictosMini;
2226
static ImageIcon iconoConflictosMismoUsuarioMini;
2327
static ImageIcon iconoConflictosDistintoUsuarioMini;
@@ -34,6 +38,10 @@ public class Iconos {
3438
//static ImageIcon iconoIgual;
3539
//static ImageIcon iconoDistinto;
3640

41+
iconoFolder = createImageIcon("/images/carpeta.png"); //$NON-NLS-1$
42+
iconoFolderGit = createImageIcon("/images/tortoise.png"); //$NON-NLS-1$
43+
44+
3745
iconoPreCopy = createImageIcon("/images/page-white_go.png"); //$NON-NLS-1$
3846
iconoCopy = createImageIcon("/images/go-next.png"); //$NON-NLS-1$
3947
iconoCompare = createImageIcon("/images/project-development-new-template.png"); //$NON-NLS-1$

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ private JPanel getPanelAyuda() {
147147
private JTextPane getTxtPanelAyuda() {
148148
if (txtPanelAyuda==null) {
149149
txtPanelAyuda = new JTextPane();
150-
txtPanelAyuda.setText("- Una linea por cada mapeo, separando las rutas con | (pipe)\r\n- ruta file | ruta git\r\n- Las rutas ser\u00E1n relativas a los directorios de files o git.\r\n- El orden es importante, la primera ruta file que coincida, determina el mapeo.\r\n- Si no coinicide ninguna se supone que va de file directo a git\r\n- Si ruta git es ! entonces es que no se debe tener en cuenta (ejemplo: deployment/srv-war/WEB-INF/class|!)");
150+
txtPanelAyuda.setText("- Una linea por cada mapeo, separando las rutas con | (pipe)\r\n- ruta file | ruta git\r\n- Las rutas ser\u00E1n relativas a los directorios de files o git.\r\n- El orden es importante, la primera ruta file que coincida, determina el mapeo.\r\n- Si no coinicide ninguna se supone que va de file directo a git\r\n- Si ruta git es ! entonces es que no se debe tener en cuenta (ejemplo: deployment/srv-war/WEB-INF/class|!)\r\n-se pueden poner 2 rutas en un mapeo (separadas por #), por defecto coge la primera, salvo que exista fichero en la 2, entonces coge la segunda (EJ: srv-war|src\\\\web\\\\web-prod\\\\srv#src\\\\web\\\\web-ap\\\\srv) ");
151151
}
152152
return txtPanelAyuda;
153153
}
@@ -240,10 +240,10 @@ private JButton getBtnGensample() {
240240
btnGensample.addActionListener(new ActionListener() {
241241
public void actionPerformed(ActionEvent e) {
242242
getTextReglasMapeo().setText("srv-war\\WEB-INF\\java|src\\java"+NL
243-
+"srv-war\\WEB-INF\\config|src\\web\\web-prod\\properties"+NL
243+
+"srv-war\\WEB-INF\\config|src\\web\\web-prod\\properties#src\\web\\web-ap\\properties"+NL
244244
+"srv-war/WEB-INF/classes|!"+NL
245245
+"srv-war/WEB-INF/lib|!"+NL
246-
+"srv-war|src\\web\\web-prod\\srv"+NL);
246+
+"srv-war|src\\web\\web-prod\\srv#src\\web\\web-ap\\srv"+NL);
247247
}
248248
});
249249
}

testData/e_proyectos_comp2gitTest.7z

2.63 KB
Binary file not shown.

0 commit comments

Comments
 (0)