-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from ShyamKunda/master
Change Diff view to use a HTMLView to display diff in colorful format (Issue #73)
- Loading branch information
Showing
7 changed files
with
219 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package io.github.gitfx.util; | ||
|
||
import java.io.*; | ||
|
||
public class GitCreateHtmlPage { | ||
|
||
public static void parseDiffData(String diffData) | ||
{ | ||
try { | ||
//define a HTML String Builder | ||
diffData = diffData.replaceAll("<", "<"); | ||
diffData = diffData.replaceAll(">", ">"); | ||
String textStr[] = diffData.split("\\r?\\n"); | ||
System.out.println("Number of lines: " + textStr.length); | ||
StringBuilder htmlStringBuilder=new StringBuilder(); | ||
//append html header and title | ||
htmlStringBuilder.append("<html><head><title>Selenium Test </title></head>"); | ||
//append body | ||
htmlStringBuilder.append("<body style=\"font-size:70%;font-family:courier;\">"); | ||
//append table | ||
for(String line : textStr) { | ||
if(line.length()>0) { | ||
char start = line.charAt(0) ; | ||
if(start=='-') { | ||
htmlStringBuilder.append("<div style=\"background-color:rgb(255, 163, 163);\"> " + line + "</div>"); | ||
} | ||
else if(start=='+') { | ||
htmlStringBuilder.append("<div style=\"background-color:rgb(66, 244, 158);\"> " + line + "</div>"); | ||
} | ||
else { | ||
htmlStringBuilder.append("<div> " + line + "</div>"); | ||
} | ||
} | ||
|
||
} | ||
htmlStringBuilder.append("</html>"); | ||
//write html string content to a file | ||
WriteToFile(htmlStringBuilder.toString(),"diffWebViewHtmlPage.html"); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
public static void WriteToFile(String fileContent, String fileName) throws IOException { | ||
String projectPath = System.getProperty("user.dir"); | ||
String tempFile = projectPath + File.separator+ "src\\main\\resources\\" + fileName; | ||
System.out.println(tempFile); | ||
File file = new File(tempFile); | ||
// if file does exists, then delete and create a new file | ||
if (file.exists()) { | ||
try { | ||
File newFileName = new File(projectPath + File.separator+ "src\\main\\resources\\" + "backup_"+fileName); | ||
file.renameTo(newFileName); | ||
file.createNewFile(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
//write to file with OutputStreamWriter | ||
OutputStream outputStream = new FileOutputStream(file.getAbsoluteFile()); | ||
Writer writer=new OutputStreamWriter(outputStream); | ||
writer.write(fileContent); | ||
writer.close(); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<html><head><title>Selenium Test </title></head><body style="font-size:70%;font-family:courier;"><div> diff --git a/build.gradle b/build.gradle</div><div> index 31f7c8a..a9c0501 100644</div><div style="background-color:rgb(255, 163, 163);"> --- a/build.gradle</div><div style="background-color:rgb(66, 244, 158);"> +++ b/build.gradle</div><div> @@ -22,4 +22,7 @@</div><div> compile 'org.eclipse.jgit:org.eclipse.jgit.http.server:3.7.0.201502260915-r'</div><div> compile 'org.eclipse.jgit:org.eclipse.jgit.ui:3.7.0.201502260915-r'</div><div> compile 'org.eclipse.jgit:org.eclipse.jgit.junit:3.7.0.201502260915-r'</div><div style="background-color:rgb(66, 244, 158);"> + compile 'com.jcabi:jcabi-aspects:0.22.5'</div><div style="background-color:rgb(66, 244, 158);"> + compile 'org.aspectj:aspectjtools:1.8.6'</div><div style="background-color:rgb(66, 244, 158);"> + compile 'org.aspectj:aspectjrt:1.6.12'</div><div> }</div><div> \ No newline at end of file</div></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<html><head><title>Selenium Test </title></head><body style="font-size:70%;font-family:courier;"></html> |
Oops, something went wrong.