Author: rfelden
Date: Mon Jun 11 16:58:13 2007
New Revision: 56
URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D56&repname=3D=
jahia_upgrade
Log:
added properties file merge support (.old for old files) (to be continued i=
n fixapplier)
TODO : html manual update
Added:
trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/views/screen=
/PropertyMergeScreen.java
Modified:
trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/controller/M=
yController.java
trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/model/MyData=
Model.java
trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/views/MainWi=
ndow.java
trunk/create/fixcreator/src/main/resources/org/jahia/fixcreator/resourc=
es/ui.properties
Modified: trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/contro=
ller/MyController.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/create/fixcreat=
or/src/main/java/org/jahia/fixcreator/controller/MyController.java&rev=3D56=
&repname=3Djahia_upgrade
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/controller/M=
yController.java (original)
+++ trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/controller/M=
yController.java Mon Jun 11 16:58:13 2007
@@ -1087,6 +1087,29 @@
}
}
=
+
+//////////////////////////////////////////////////////////////////////////=
////////////
+// REMOVED PATHS /////////////////////////////////////////////////////////=
////////////
+//////////////////////////////////////////////////////////////////////////=
////////////
+
+ /**
+ * Retrieve included properties files (.properties/.xml/.plist)
+ *
+ * @return the properties files list as file paths
+ */
+ public String[] getIncludedProperties() {
+ return dataModel.getIncludedProperties() ;
+ }
+
+ /**
+ * Add specified properties to the 'to merge' list.
+ *
+ * @param indices the indices to add
+ */
+ public void addPropertiesToMerge(int[] indices) {
+ dataModel.setPropertiesToMerge(indices);
+ }
+
//////////////////////////////////////////////////////////////////////////=
////////////
// REMOVED PATHS /////////////////////////////////////////////////////////=
////////////
//////////////////////////////////////////////////////////////////////////=
////////////
@@ -1287,6 +1310,10 @@
}
=
for (String path : dataModel.getCoreFileNames()) {
+ File oldVersion =3D null ;
+ if (dataModel.getPropertiesToMerge().contains(path)) {
+ oldVersion =3D new File(dataModel.getOriginalProjectLo=
cation(), StringUtils.replaceAllTokens(path, "/", File.separator)) ;
+ }
boolean isIncludedInBindings =3D false ;
for (Binding binding : getBindings()) {
=
@@ -1355,7 +1382,7 @@
// in this case it is not a .java file=
, might be a .properties or something, so let's give it a generic treatment
} else if (source.getName().equals(fil=
eNameWithoutDotJava)) {
File dest =3D new File(destination=
Dir, source.getName()) ;
- result =3D (Tools.copy(source, de=
st) && result);
+ result &=3D Tools.copy(source, de=
st) ;
}
=
}
@@ -1387,6 +1414,12 @@
// copy the file to the binded output loca=
tion
File dest =3D new File(destinationDir, sou=
rce.getName()) ;
result =3D (Tools.copy(source, dest) && r=
esult);
+
+ // copy original properties file along the=
updated copy if needed
+ if (oldVersion !=3D null && oldVersion.exi=
sts()) {
+ File oldDest =3D new File(destinationD=
ir, source.getName()+".old") ;
+ result &=3D Tools.copy(oldVersion, ol=
dDest) ;
+ }
}
}
}
@@ -1415,10 +1448,17 @@
=
// copy the file to the binded output location
File dest =3D new File(destinationDir, source.getN=
ame()) ;
- result =3D (Tools.copy(source, dest) && result);
+ result &=3D Tools.copy(source, dest) ;
+
+ // copy original properties file along the updated=
copy if needed
+ if (oldVersion !=3D null && oldVersion.exists()) {
+ File oldDest =3D new File(destinationDir, sour=
ce.getName()+".old") ;
+ result &=3D Tools.copy(oldVersion, oldDest) ;
+ }
}
=
}
+
}
// if anything failed, notify the user
assert(MyHTMLTrace.channel(Application.TRACE_CHANNEL).leaveMet=
hod()) ;
Modified: trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/model/=
MyDataModel.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/create/fixcreat=
or/src/main/java/org/jahia/fixcreator/model/MyDataModel.java&rev=3D56&repna=
me=3Djahia_upgrade
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/model/MyData=
Model.java (original)
+++ trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/model/MyData=
Model.java Mon Jun 11 16:58:13 2007
@@ -49,6 +49,7 @@
=
private ProjectConfiguration config ;
private ArrayList<File> coreFiles;
+ private ArrayList<String> propertiesToMerge ;
private ArrayList<File> otherFiles ;
private String fixName ;
=
@@ -58,6 +59,7 @@
public MyDataModel() {
m_fix =3D new Fix() ;
coreFiles =3D new ArrayList<File>() ;
+ propertiesToMerge =3D new ArrayList<String>() ;
otherFiles =3D new ArrayList<File>() ;
config =3D new ProjectConfiguration("default") ;
}
@@ -304,8 +306,6 @@
return m_fix.getCoreFiles() ;
}
=
- =
-
/**
* Add a compiled java core class to the fix.
*
@@ -329,6 +329,41 @@
}
=
/**
+ * Retrieve included properties files (.properties/.xml/.plist)
+ *
+ * @return the properties files list as file paths
+ */
+ public String[] getIncludedProperties() {
+ ArrayList<String> properties =3D new ArrayList<String>() ;
+
+ for (String file: getCoreFileNames()) {
+ if (file.endsWith(".properties") ||
+ file.endsWith(".xml") ||
+ file.endsWith(".plist")) {
+ properties.add(file) ;
+ }
+ }
+
+ return properties.toArray(new String[0]) ;
+ }
+
+ /**
+ * Add properties files that correspond to the indices array.
+ * @param indices the indices to add
+ */
+ public void setPropertiesToMerge(int[] indices) {
+ String[] properties =3D getIncludedProperties() ;
+ propertiesToMerge.clear();
+ for (int index: indices) {
+ propertiesToMerge.add(properties[index]);
+ }
+ }
+
+ public ArrayList<String> getPropertiesToMerge() {
+ return propertiesToMerge ;
+ }
+
+ /**
* Add an other kind of file to the fix (generic treatment).
*
* @param file the file to add
Modified: trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/views/=
MainWindow.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/create/fixcreat=
or/src/main/java/org/jahia/fixcreator/views/MainWindow.java&rev=3D56&repnam=
e=3Djahia_upgrade
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/views/MainWi=
ndow.java (original)
+++ trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/views/MainWi=
ndow.java Mon Jun 11 16:58:13 2007
@@ -313,6 +313,7 @@
screens.add(new InfoScreen(m_controller, this));
screens.add(new DiffMethodScreen(m_controller, this)) ;
screens.add(new CoreFilesScreen(m_controller, this));
+ screens.add(new PropertyMergeScreen(m_controller, this)) ;
screens.add(new RemovedScreen(m_controller, this)) ;
screens.add(new CopyingScreen(m_controller, this));
screens.add(new OtherFilesScreen(m_controller, this)) ;
Added: trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/views/scr=
een/PropertyMergeScreen.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/trunk/create/f=
ixcreator/src/main/java/org/jahia/fixcreator/views/screen/PropertyMergeScre=
en.java&rev=3D56&repname=3Djahia_upgrade
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/views/screen=
/PropertyMergeScreen.java (added)
+++ trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/views/screen=
/PropertyMergeScreen.java Mon Jun 11 16:58:13 2007
@@ -0,0 +1,122 @@
+package org.jahia.fixcreator.views.screen;
+
+import org.jahia.fixcreator.views.ScreenAdapter;
+import org.jahia.fixcreator.views.MainWindow;
+import org.jahia.fixcreator.controller.MyController;
+
+import javax.swing.JCheckBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.border.EmptyBorder;
+import java.awt.BorderLayout;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+
+/**
+ * Here files are copied into a clean merged directory so you can compile =
this hybrid project
+ * and build classes needed for the fix.
+ * @version 2007-03-15
+ * @author Romain Felden
+ */
+public class PropertyMergeScreen extends ScreenAdapter {
+
+ private JLabel message;
+ private JLabel merge ;
+ private JLabel file ;
+ private JCheckBox[] selection ;
+
+ public PropertyMergeScreen(MyController controller, MainWindow gui) {
+ // functional resources
+ m_controller =3D controller ;
+ m_gui =3D gui ;
+
+ // border size
+ border =3D 20 ;
+
+ }
+
+ public void build() {
+
+ // property message
+ message =3D new JLabel(resources.getString("display.propertyMessag=
e"));
+
+ merge =3D new JLabel(resources.getString("display.propertyCheck"))=
;
+ file =3D new JLabel(resources.getString("display.propertyFile")) ;
+
+ built =3D true ;
+
+ done =3D true ;
+ }
+
+ public void display() {
+
+ // ui resources
+ main =3D new JPanel(new BorderLayout()) ;
+ main.setBorder(new EmptyBorder(border,border,border,border));
+
+ String[] properties =3D m_controller.getIncludedProperties() ;
+ selection =3D new JCheckBox[properties.length] ;
+ for (int i =3D 0; i < selection.length; i++) {
+ selection[i] =3D new JCheckBox() ;
+ }
+
+ GridBagLayout gbl =3D new GridBagLayout() ;
+ JPanel tablePane =3D new JPanel(gbl) ;
+
+ GridBagConstraints c =3D new GridBagConstraints() ;
+ c.insets =3D new Insets(5, 20, 5, 20) ;
+ c.gridy =3D 0 ;
+ c.gridx =3D 0 ;
+ c.anchor =3D GridBagConstraints.CENTER ;
+ gbl.setConstraints(merge, c);
+ tablePane.add(merge) ;
+ c.gridx =3D 1 ;
+ c.anchor =3D GridBagConstraints.CENTER ;
+ gbl.setConstraints(file, c);
+ tablePane.add(file) ;
+ for (int i =3D 0; i < selection.length; i++) {
+ c.gridy =3D i+1 ;
+ c.gridx =3D 0 ;
+ c.anchor =3D GridBagConstraints.CENTER ;
+ gbl.setConstraints(selection[i], c);
+ tablePane.add(selection[i]) ;
+ c.gridx =3D 1 ;
+ c.anchor =3D GridBagConstraints.WEST ;
+ JLabel label =3D new JLabel(properties[i]) ;
+ gbl.setConstraints(label, c);
+ tablePane.add(label) ;
+ }
+
+ JPanel table =3D new JPanel(new BorderLayout()) ;
+ table.add(new JScrollPane(tablePane), BorderLayout.CENTER) ;
+ table.setBorder(new EmptyBorder(30, 40, 30, 40)) ;
+
+ main.add(table, BorderLayout.CENTER) ;
+
+ // add components to the displayed pane
+ main.add(message, BorderLayout.NORTH);
+ }
+
+ public void loadRemoteData() {}
+
+ public void movingNext() {
+ int[] indicesTemp =3D new int[selection.length] ;
+ int counter =3D 0 ;
+ for (int i =3D 0; i < selection.length; i++) {
+ if (selection[i].isSelected()) {
+ indicesTemp[counter++] =3D i ;
+ }
+ }
+ int[] indices =3D new int[counter] ;
+ System.arraycopy(indicesTemp, 0, indices, 0, counter) ;
+ m_controller.addPropertiesToMerge(indices);
+ }
+
+ public JPanel swingComponent() {
+ return main ;
+ }
+
+
+}
Modified: trunk/create/fixcreator/src/main/resources/org/jahia/fixcreator/r=
esources/ui.properties
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/create/fixcreat=
or/src/main/resources/org/jahia/fixcreator/resources/ui.properties&rev=3D56=
&repname=3Djahia_upgrade
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/create/fixcreator/src/main/resources/org/jahia/fixcreator/resourc=
es/ui.properties (original)
+++ trunk/create/fixcreator/src/main/resources/org/jahia/fixcreator/resourc=
es/ui.properties Mon Jun 11 16:58:13 2007
@@ -200,6 +200,11 @@
# CORE FILES SCREEN
display.coreFilesSelection =3D <html>Choose the files to be part of the fi=
x...<P></html>
=
+# PROPERTY MERGE SCREEN
+display.propertyMessage =3D <html>Select the properties files to be merged=
when patching.<P>Unselected will simply replace the old ones.</html>
+display.propertyCheck =3D <html><b>Merge</b></html>
+display.propertyFile =3D <html><b>File path</b></html>
+
# REMOVED PATHS SCREEN
display.removedPaths =3D <html>Please check out the paths that are marked =
for deletion.<P><P></html>
display.removedPaths.buttons.add =3D Add
@@ -211,12 +216,6 @@
display.copyingFiles =3D <html><B>Copying project files...</B></html>
display.copyingFilesMessage =3D <html>The application is copying the origi=
nal project files<P>into a new directory and replacing modified files.<P><P=
><P><P><P>You will then have to manually compile the copy directory.<P><P>O=
nce it is done you may proceed to the next step.</html>
=
-# DEPENDANCY SCREEN
-display.selectMainClass =3D Main class
-display.setHistoryDepth =3D History depth
-display.startRevision =3D Start at revision
-display.stopRevision =3D Stop at revision
-
# OTHER FILES SCREEN
display.otherFileSelection =3D <html>Choose the other files to be part of =
the fix... (change current root below on the left)<P></html>
=
_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list