Author: rfelden
Date: Tue May 15 16:18:13 2007
New Revision: 37
URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D37&repname=3D=
jahia_upgrade
Log:
svnconnector cleanup
Added:
trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/svnconnector=
/version/
trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/svnconnector=
/version/FileVersion.java
trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/svnconnector=
/version/FileVersionAgglom.java
trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/svnconnector=
/version/RelatedFile.java
trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/svnconnector=
/version/RemoteSvnFile.java
trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/svnconnector=
/versiontree/
trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/svnconnector=
/versiontree/VersionTree.java
trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/svnconnector=
/versiontree/VersionTreeModel.java
trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/svnconnector=
/versiontree/VersionTreeView.java
Added: trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/svnconnec=
tor/version/FileVersion.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/trunk/create/f=
ixcreator/src/main/java/org/jahia/fixcreator/svnconnector/version/FileVersi=
on.java&rev=3D37&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/svnconnector=
/version/FileVersion.java (added)
+++ trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/svnconnector=
/version/FileVersion.java Tue May 15 16:18:13 2007
@@ -0,0 +1,80 @@
+package org.jahia.fixcreator.svnconnector.version;
+
+import static org.tmatesoft.svn.core.SVNRevisionProperty.AUTHOR;
+import static org.tmatesoft.svn.core.SVNRevisionProperty.DATE;
+import org.tmatesoft.svn.core.io.SVNFileRevision;
+
+import java.text.ParseException;
+import java.util.Map;
+
+
+/**
+ * Represent a version of a given file taken from a svn repository.
+ * Used in FileVersionAgglom to represent the main file along which
+ * other files where modified (represented by RelatedFile).
+ *
+ * @version 2007-03-14
+ * @author Romain Felden
+ */
+public class FileVersion {
+ SVNFileRevision raw ;
+ boolean primary ;
+ boolean included =3D false ;
+ private String author ;
+ private String date ;
+ private String fileName ;
+ private String filePath ;
+ private long revision ;
+
+ public FileVersion(SVNFileRevision fileRev, boolean isPrimary) throws =
ParseException {
+ raw =3D fileRev ;
+ primary =3D isPrimary ;
+ filePath =3D fileRev.getPath() ;
+ revision =3D fileRev.getRevision() ;
+ fileName =3D filePath.substring(filePath.lastIndexOf("/")+1);
+ Map properties =3D fileRev.getRevisionProperties() ;
+ author =3D (String)properties.get(AUTHOR) ;
+ date =3D (String)properties.get(DATE);
+ }
+ =
+
+
+ public String getAuthor() {
+ return author;
+ }
+
+ public String getDate() {
+ return date;
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public String getFilePath() {
+ return filePath;
+ }
+
+ public long getRevision() {
+ return revision;
+ }
+
+ public boolean isPrimary() {
+ return primary;
+ }
+
+ public boolean isIncluded() {
+ return included ;
+ }
+
+ public void setIncluded(boolean incl) {
+ included =3D incl ;
+ }
+
+
+ // this is used by the tree to display the node
+ public String toString() {
+ return fileName + FileVersionAgglom.SEPARATOR + revision + FileVer=
sionAgglom.SEPARATOR + date ;
+ }
+
+}
Added: trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/svnconnec=
tor/version/FileVersionAgglom.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/trunk/create/f=
ixcreator/src/main/java/org/jahia/fixcreator/svnconnector/version/FileVersi=
onAgglom.java&rev=3D37&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/svnconnector=
/version/FileVersionAgglom.java (added)
+++ trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/svnconnector=
/version/FileVersionAgglom.java Tue May 15 16:18:13 2007
@@ -0,0 +1,39 @@
+package org.jahia.fixcreator.svnconnector.version;
+
+import java.util.ArrayList;
+
+/**
+ * Represent a set of files that have been modified by a given author with=
in the same period.
+ * Files are to be taken from a svn repository.
+ *
+ * @version 2007-03-14
+ * @author Romain Felden
+ */
+public class FileVersionAgglom {
+ /**
+ * display purpose
+ */
+ public static final String SEPARATOR =3D " - " ;
+
+ private String author =3D "" ;
+ private FileVersion mainFile =3D null ;
+ private ArrayList<RelatedFile> linkedFiles ;
+
+ public FileVersionAgglom(FileVersion main, ArrayList<RelatedFile> file=
s) {
+ linkedFiles =3D files ;
+ mainFile =3D main ;
+ author =3D mainFile.getAuthor() ;
+ }
+
+ public ArrayList<RelatedFile> getLinkedFiles() {
+ return linkedFiles;
+ }
+
+ // this is used by the tree to display the node
+ public String toString() {
+ if (mainFile !=3D null)
+ return author + SEPARATOR + mainFile.getRevision() + SEPARATOR=
+ mainFile.getDate() ;
+ else
+ return SEPARATOR + "<not valid>" + SEPARATOR ;
+ }
+}
Added: trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/svnconnec=
tor/version/RelatedFile.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/trunk/create/f=
ixcreator/src/main/java/org/jahia/fixcreator/svnconnector/version/RelatedFi=
le.java&rev=3D37&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/svnconnector=
/version/RelatedFile.java (added)
+++ trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/svnconnector=
/version/RelatedFile.java Tue May 15 16:18:13 2007
@@ -0,0 +1,83 @@
+package org.jahia.fixcreator.svnconnector.version;
+
+import org.tmatesoft.svn.core.SVNLogEntry;
+import org.tmatesoft.svn.core.SVNLogEntryPath;
+import static org.jahia.fixcreator.svnconnector.version.FileVersionAgglom.=
* ;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * This is a file taht is related to a FileVersion taken from a svn reposi=
tory.
+ * It can be found in a list contained in a FileVersionAgglom.
+ * @see FileVersionAgglom
+ *
+ * @version 2007-03-20
+ * @author Romain Felden
+ */
+public class RelatedFile {
+
+ private String name ;
+ private String path ;
+ private String date ;
+ private String author ;
+ private long revision ;
+ private boolean included =3D false ;
+
+ public String getName() {
+ return name;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public String getDate() {
+ return date;
+ }
+
+ public String getAuthor() {
+ return author;
+ }
+
+ public long getRevision() {
+ return revision;
+ }
+
+ public boolean isIncluded() {
+ return included ;
+ }
+
+ public void toggleIncluded() {
+ included =3D !included ;
+ }
+
+ public String toString() {
+ return name + SEPARATOR + revision + SEPARATOR + author + SEPARATO=
R + date ;
+ }
+
+
+ public RelatedFile(String name, String path, String date, String autho=
r, long revision) {
+ this.name =3D name ;
+ this.path =3D path ;
+ this.date =3D date ;
+ this.author =3D author ;
+ this.revision =3D revision ;
+ }
+
+ public static ArrayList<RelatedFile> createRelatedFiles(SVNLogEntry en=
try, String branch) {
+ String date =3D entry.getDate().toString() ;
+ String author =3D entry.getAuthor() ;
+ long revision =3D entry.getRevision() ;
+ ArrayList<RelatedFile> related =3D new ArrayList<RelatedFile>() ;
+ Collection<SVNLogEntryPath> logs =3D entry.getChangedPaths().value=
s() ;
+ for (SVNLogEntryPath temp : logs) {
+ String path =3D temp.getPath() ;
+ if (path.indexOf(branch)!=3D-1) {
+ String name =3D path.substring(path.lastIndexOf("/")+1, pa=
th.length()) ;
+ related.add(new RelatedFile(name, path, date, author, revi=
sion));
+ }
+ }
+ return related ;
+ }
+}
Added: trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/svnconnec=
tor/version/RemoteSvnFile.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/trunk/create/f=
ixcreator/src/main/java/org/jahia/fixcreator/svnconnector/version/RemoteSvn=
File.java&rev=3D37&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/svnconnector=
/version/RemoteSvnFile.java (added)
+++ trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/svnconnector=
/version/RemoteSvnFile.java Tue May 15 16:18:13 2007
@@ -0,0 +1,41 @@
+package org.jahia.fixcreator.svnconnector.version;
+
+import org.tmatesoft.svn.core.SVNDirEntry;
+
+/**
+ * @version 2007-03-23
+ * @author Romain Felden
+ */
+public class RemoteSvnFile implements Comparable {
+
+ private String name ;
+ private String path ;
+
+ public RemoteSvnFile(SVNDirEntry entry) {
+ name =3D entry.getName() ;
+ path =3D entry.getRelativePath() ;
+ }
+
+ public RemoteSvnFile() {
+ name =3D "root" ;
+ path =3D "" ;
+ }
+
+
+ public String getName() {
+ return name;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public String toString() {
+ return name ;
+ }
+
+ public int compareTo(Object o) {
+ return toString().compareTo(o.toString()) ;
+ }
+}
+ =
Added: trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/svnconnec=
tor/versiontree/VersionTree.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/trunk/create/f=
ixcreator/src/main/java/org/jahia/fixcreator/svnconnector/versiontree/Versi=
onTree.java&rev=3D37&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/svnconnector=
/versiontree/VersionTree.java (added)
+++ trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/svnconnector=
/versiontree/VersionTree.java Tue May 15 16:18:13 2007
@@ -0,0 +1,30 @@
+package org.jahia.fixcreator.svnconnector.versiontree;
+
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreeSelectionModel;
+import javax.swing.JTree;
+
+
+/**
+ * @version 2007-03-14
+ * @author Romain Felden
+ */
+public class VersionTree extends JTree {
+
+ public VersionTree(TreeModel model) {
+ super(model);
+ setRootVisible(false);
+ getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TRE=
E_SELECTION);
+ }
+
+ /**
+ * Nice stub to retrieve selected object.
+ *
+ * @return the selected object
+ */
+ public Object getSelection() {
+ return getSelectionPath().getLastPathComponent() ;
+ }
+
+
+}
Added: trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/svnconnec=
tor/versiontree/VersionTreeModel.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/trunk/create/f=
ixcreator/src/main/java/org/jahia/fixcreator/svnconnector/versiontree/Versi=
onTreeModel.java&rev=3D37&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/svnconnector=
/versiontree/VersionTreeModel.java (added)
+++ trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/svnconnector=
/versiontree/VersionTreeModel.java Tue May 15 16:18:13 2007
@@ -0,0 +1,102 @@
+package org.jahia.fixcreator.svnconnector.versiontree;
+
+import org.jahia.fixcreator.svnconnector.version.FileVersionAgglom;
+import org.jahia.fixcreator.svnconnector.version.RelatedFile;
+
+import javax.swing.event.TreeModelEvent;
+import javax.swing.event.TreeModelListener;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreePath;
+import java.util.ArrayList;
+
+/**
+ * @version 2007-03-14
+ * @author Romain Felden
+ */
+public class VersionTreeModel implements TreeModel {
+
+ private ArrayList<FileVersionAgglom> m_files ;
+ private ArrayList<TreeModelListener> m_listeners ;
+
+ public VersionTreeModel(ArrayList<FileVersionAgglom> files) {
+ m_files =3D files ;
+ m_listeners =3D new ArrayList<TreeModelListener>() ;
+ }
+
+ public Object getRoot() {
+ return m_files ;
+ }
+
+ public void newRoot(ArrayList<FileVersionAgglom> files) {
+ m_files.clear() ;
+ m_files.addAll(files) ;
+ fireTreeStructureChanged();
+ }
+
+ public Object getChild(Object parent, int index) {
+ if (parent =3D=3D m_files) {
+ return m_files.get(index);
+ }
+ else if (parent instanceof FileVersionAgglom) {
+ return ((FileVersionAgglom)parent).getLinkedFiles().get(index)=
;
+ }
+ else return null ;
+ }
+
+ public int getChildCount(Object parent) {
+ if (parent =3D=3D m_files) {
+ return m_files.size();
+ }
+ else if (parent instanceof FileVersionAgglom) {
+ return ((FileVersionAgglom)parent).getLinkedFiles().size() ;
+ }
+ else return 0 ;
+ }
+
+ public boolean isLeaf(Object node) {
+ return node instanceof RelatedFile;
+ }
+
+ public void valueForPathChanged(TreePath path, Object newValue) {
+ if (path.getLastPathComponent() !=3D newValue) {
+ TreeModelEvent e =3D new TreeModelEvent(this, path) ;
+ for (TreeModelListener l : m_listeners) {
+ l.treeNodesChanged(e);
+ }
+ }
+ }
+
+ @SuppressWarnings({"SuspiciousMethodCalls"})
+ public int getIndexOfChild(Object parent, Object child) {
+ if (parent =3D=3D m_files && child instanceof FileVersionAgglom) {
+ return m_files.indexOf(child);
+ }
+ else if (parent instanceof FileVersionAgglom && child instanceof R=
elatedFile) {
+ return ((FileVersionAgglom)parent).getLinkedFiles().indexOf(ch=
ild) ;
+ }
+ else return 0 ;
+ }
+
+ public void addTreeModelListener(TreeModelListener l) {
+ m_listeners.add(l) ;
+ }
+
+ public void removeTreeModelListener(TreeModelListener l) {
+ m_listeners.remove(l) ;
+ }
+
+ public void fireTreeStructureChanged() {
+ TreeModelEvent e =3D new TreeModelEvent(this, new Object[] {m_file=
s});
+ for (TreeModelListener tml : m_listeners) {
+ tml.treeStructureChanged(e);
+ }
+ }
+
+ public void fireNodeChanged(TreePath path) {
+ TreeModelEvent e =3D new TreeModelEvent(this, new Object[] {path});
+ for (TreeModelListener tml : m_listeners) {
+ tml.treeNodesChanged(e);
+ }
+ }
+
+}
Added: trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/svnconnec=
tor/versiontree/VersionTreeView.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/trunk/create/f=
ixcreator/src/main/java/org/jahia/fixcreator/svnconnector/versiontree/Versi=
onTreeView.java&rev=3D37&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/svnconnector=
/versiontree/VersionTreeView.java (added)
+++ trunk/create/fixcreator/src/main/java/org/jahia/fixcreator/svnconnector=
/versiontree/VersionTreeView.java Tue May 15 16:18:13 2007
@@ -0,0 +1,83 @@
+package org.jahia.fixcreator.svnconnector.versiontree;
+
+import org.jahia.fixcreator.svnconnector.version.FileVersionAgglom;
+import org.jahia.fixcreator.svnconnector.version.FileVersion;
+import org.jahia.fixcreator.svnconnector.versiontree.VersionTreeModel;
+
+import javax.swing.JComponent;
+import javax.swing.JScrollPane;
+import javax.swing.JTree;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import javax.swing.tree.TreeSelectionModel;
+import java.util.ArrayList;
+import java.awt.Component;
+import java.io.File;
+
+/**
+ * @version 2007-03-14
+ * @author Romain Felden
+ */
+public class VersionTreeView {
+
+ private VersionTree tree ;
+
+ /**
+ * A view that displays bunches of files according to a FileVersionAgg=
lom ArrayList.
+ *
+ * @param files the files to be displayed
+ */
+ public VersionTreeView(ArrayList<FileVersionAgglom> files) {
+
+ TreeModel model =3D new VersionTreeModel(files) ;
+ tree =3D new VersionTree(model) ;
+ tree.setRootVisible(false);
+ tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGL=
E_TREE_SELECTION);
+ tree.setCellRenderer(new FileVersionTreeCellRenderer());
+ }
+
+ /**
+ * Retrieve the swing component for display purpose
+ *
+ * @return the tree into a JScrollPane
+ */
+ public JComponent swingComponent() {
+ return new JScrollPane(tree) ;
+ }
+
+
+ /**
+ * Changes the status of a given file in a FileVersionAgglom.
+ *
+ * @param file the modified file
+ */
+ public void onFileIncluded(File file) {
+
+ }
+
+
+ private class FileVersionTreeCellRenderer extends DefaultTreeCellRende=
rer {
+
+ public FileVersionTreeCellRenderer() {
+ super() ;
+ }
+
+ public Component getTreeCellRendererComponent(JTree tree, Object v=
alue, boolean selected, boolean expanded, boolean leaf, int row, boolean ha=
sFocus) {
+ // if leaf, change secondary files color (gray for now)
+ if (leaf) {
+ // this test should always be true, helps avoiding class c=
ast exception just in case
+ if (value instanceof FileVersion) {
+ if (((FileVersion)value).isPrimary()) {
+ setText("<html><FONT COLOR=3Dblue>"+value.toString=
()+"</FONT></html>");
+ }
+ else if (!((FileVersion)value).isIncluded()) {
+ setText("<html><FONT COLOR=3D#e0e0e0>"+value.toStr=
ing()+"</FONT></html>");
+ }
+ }
+ }
+
+ return this;
+ }
+ }
+
+}
_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list