Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge remote-tracking branch 'origin/master'

Conflicts:
	.cache
	bin/gui/Control$$anon$1.class
	bin/gui/Control$$anon$10.class
	bin/gui/Control$$anon$11.class
	bin/gui/Control$$anon$12.class
	bin/gui/Control$$anon$13.class
	bin/gui/Control$$anon$14.class
	bin/gui/Control$$anon$15$$anonfun$actionPerformed$1$$anonfun$apply$1.class
	bin/gui/Control$$anon$15$$anonfun$actionPerformed$1.class
	bin/gui/Control$$anon$15$$anonfun$actionPerformed$2.class
	bin/gui/Control$$anon$15.class
	bin/gui/Control$$anon$16.class
	bin/gui/Control$$anon$17.class
	bin/gui/Control$$anon$18.class
	bin/gui/Control$$anon$19$$anonfun$mouseClicked$1.class
	bin/gui/Control$$anon$19$$anonfun$mouseClicked$2.class
	bin/gui/Control$$anon$19$$anonfun$mouseClicked$3.class
	bin/gui/Control$$anon$19$$anonfun$mouseClicked$4.class
	bin/gui/Control$$anon$19.class
	bin/gui/Control$$anon$2.class
	bin/gui/Control$$anon$20$$anonfun$mouseClicked$5.class
	bin/gui/Control$$anon$20.class
	bin/gui/Control$$anon$21$$anonfun$mouseClicked$6.class
	bin/gui/Control$$anon$21$$anonfun$mouseClicked$7.class
	bin/gui/Control$$anon$21.class
	bin/gui/Control$$anon$3.class
	bin/gui/Control$$anon$4.class
	bin/gui/Control$$anon$5.class
	bin/gui/Control$$anon$6.class
	bin/gui/Control$$anon$7.class
	bin/gui/Control$$anon$8.class
	bin/gui/Control$$anon$9.class
	bin/gui/Control$$anonfun$addLabels$1.class
	bin/gui/Control$$anonfun$addOverviewLabels$1.class
	bin/gui/Control$$anonfun$addRelationLabels$1.class
	bin/gui/Control$$anonfun$addRelationLabels$2.class
	bin/gui/Control$$anonfun$convertToFilelist$1.class
	bin/gui/Control$$anonfun$loadRelation$1.class
	bin/gui/Control$$anonfun$refreshOverview$1.class
	bin/gui/Control$$anonfun$refreshOverview$2.class
	bin/gui/Control.class
  • Loading branch information...
commit 705cdef98d1e1df019738d848e4a8340bd624846 2 parents da88dd2 + 291493b
@ThomasWedler authored
Showing with 168 additions and 98 deletions.
  1. +5 −5 .classpath
  2. BIN  bin/basic/Config.class
  3. BIN  bin/gui/Control$$anon$1.class
  4. BIN  bin/gui/Control$$anon$10.class
  5. BIN  bin/gui/Control$$anon$11.class
  6. BIN  bin/gui/Control$$anon$12.class
  7. BIN  bin/gui/Control$$anon$13.class
  8. BIN  bin/gui/Control$$anon$14.class
  9. BIN  bin/gui/Control$$anon$15$$anonfun$actionPerformed$1$$anonfun$apply$1.class
  10. BIN  bin/gui/Control$$anon$15$$anonfun$actionPerformed$1.class
  11. BIN  bin/gui/Control$$anon$15$$anonfun$actionPerformed$2.class
  12. BIN  bin/gui/Control$$anon$15.class
  13. BIN  bin/gui/Control$$anon$16.class
  14. BIN  bin/gui/Control$$anon$17.class
  15. BIN  bin/gui/Control$$anon$18.class
  16. BIN  bin/gui/Control$$anon$19$$anonfun$mouseClicked$1.class
  17. BIN  bin/gui/Control$$anon$19$$anonfun$mouseClicked$2.class
  18. BIN  bin/gui/Control$$anon$19$$anonfun$mouseClicked$3.class
  19. BIN  bin/gui/Control$$anon$19$$anonfun$mouseClicked$4.class
  20. BIN  bin/gui/Control$$anon$19.class
  21. BIN  bin/gui/Control$$anon$2.class
  22. BIN  bin/gui/Control$$anon$20$$anonfun$mouseClicked$5.class
  23. BIN  bin/gui/Control$$anon$20.class
  24. BIN  bin/gui/Control$$anon$21$$anonfun$mouseClicked$6.class
  25. BIN  bin/gui/Control$$anon$21$$anonfun$mouseClicked$7.class
  26. BIN  bin/gui/Control$$anon$21.class
  27. BIN  bin/gui/Control$$anon$3.class
  28. BIN  bin/gui/Control$$anon$4.class
  29. BIN  bin/gui/Control$$anon$5.class
  30. BIN  bin/gui/Control$$anon$6.class
  31. BIN  bin/gui/Control$$anon$7.class
  32. BIN  bin/gui/Control$$anon$8.class
  33. BIN  bin/gui/Control$$anon$9.class
  34. BIN  bin/gui/Control$$anonfun$addLabels$1.class
  35. BIN  bin/gui/Control$$anonfun$addOverviewLabels$1.class
  36. BIN  bin/gui/Control$$anonfun$addRelationLabels$1.class
  37. BIN  bin/gui/Control$$anonfun$addRelationLabels$2.class
  38. BIN  bin/gui/Control$$anonfun$convertToFilelist$1.class
  39. BIN  bin/gui/Control$$anonfun$loadRelation$1.class
  40. BIN  bin/gui/Control$$anonfun$refreshOverview$1.class
  41. BIN  bin/gui/Control$$anonfun$refreshOverview$2.class
  42. BIN  bin/optional/Thumbnails$$anon$1.class
  43. BIN  bin/optional/Thumbnails.class
  44. BIN  bin/resources/devTeam.png
  45. +119 −68 src/basic/Config.scala
  46. +7 −1 src/gui/Control.scala
  47. +37 −24 src/optional/Thumbnails.scala
  48. BIN  src/resources/devTeam.png
View
10 .classpath
@@ -3,10 +3,10 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER"/>
- <classpathentry kind="lib" path="/Users/Thomas/Documents/workspace/SQ-Project/commons-io-2.1.jar"/>
- <classpathentry kind="lib" path="/Users/Thomas/Documents/workspace/SQ-Project/jna-3.4.0.jar"/>
- <classpathentry kind="lib" path="/Users/Thomas/Documents/workspace/SQ-Project/PDFRenderer-0.9.1.jar"/>
- <classpathentry kind="lib" path="/Users/Thomas/Documents/workspace/SQ-Project/platform-3.4.0.jar"/>
- <classpathentry kind="lib" path="/Users/Thomas/Documents/workspace/SQ-Project/vlcj-2.0.0.jar"/>
+ <classpathentry kind="lib" path="C:/Users/Kristof/workspace/SQ-Project/commons-io-2.1.jar"/>
+ <classpathentry kind="lib" path="C:/Users/Kristof/workspace/SQ-Project/jna-3.4.0.jar"/>
+ <classpathentry kind="lib" path="C:/Users/Kristof/workspace/SQ-Project/PDFRenderer-0.9.1.jar"/>
+ <classpathentry kind="lib" path="C:/Users/Kristof/workspace/SQ-Project/platform-3.4.0.jar"/>
+ <classpathentry kind="lib" path="C:/Users/Kristof/workspace/SQ-Project/vlcj-2.0.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
View
BIN  bin/basic/Config.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$1.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$10.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$11.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$12.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$13.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$14.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$15$$anonfun$actionPerformed$1$$anonfun$apply$1.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$15$$anonfun$actionPerformed$1.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$15$$anonfun$actionPerformed$2.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$15.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$16.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$17.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$18.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$19$$anonfun$mouseClicked$1.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$19$$anonfun$mouseClicked$2.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$19$$anonfun$mouseClicked$3.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$19$$anonfun$mouseClicked$4.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$19.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$2.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$20$$anonfun$mouseClicked$5.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$20.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$21$$anonfun$mouseClicked$6.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$21$$anonfun$mouseClicked$7.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$21.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$3.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$4.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$5.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$6.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$7.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$8.class
Binary file not shown
View
BIN  bin/gui/Control$$anon$9.class
Binary file not shown
View
BIN  bin/gui/Control$$anonfun$addLabels$1.class
Binary file not shown
View
BIN  bin/gui/Control$$anonfun$addOverviewLabels$1.class
Binary file not shown
View
BIN  bin/gui/Control$$anonfun$addRelationLabels$1.class
Binary file not shown
View
BIN  bin/gui/Control$$anonfun$addRelationLabels$2.class
Binary file not shown
View
BIN  bin/gui/Control$$anonfun$convertToFilelist$1.class
Binary file not shown
View
BIN  bin/gui/Control$$anonfun$loadRelation$1.class
Binary file not shown
View
BIN  bin/gui/Control$$anonfun$refreshOverview$1.class
Binary file not shown
View
BIN  bin/gui/Control$$anonfun$refreshOverview$2.class
Binary file not shown
View
BIN  bin/optional/Thumbnails$$anon$1.class
Binary file not shown
View
BIN  bin/optional/Thumbnails.class
Binary file not shown
View
BIN  bin/resources/devTeam.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
187 src/basic/Config.scala
@@ -2,17 +2,70 @@ package basic
import scala.xml._
import org.apache.commons.io.FileUtils
-import java.io.File
+import java.io.{ File, IOException }
/** Provides methods for reading and editing the configuration file */
class Config {
+ // Set path and filename of configuration file
+ val configFile = "config.xml"
+
+ /** Checks if configuration file exits and contains valid values.
+ * In case file doesn't exists it is created and filled with standard values.
+ */
+ def tryConfig() {
+ if (!(new File(configFile).exists())) {
+ val file: File = new File(configFile)
+ try {
+ new File(configFile).createNewFile()
+ } catch {
+ case io: IOException => println("No configuration file found. Failed to create a new one.")
+ }
+ var config = scala.xml.XML.loadFile(configFile)
+
+ // Create XML-Elements with empty values.
+ val newJpgRead = Elem(null, "read", Null, TopScope, Text(""))
+ val newJpgEdit = Elem(null, "edit", Null, TopScope, Text(""))
+ val newPdfRead = Elem(null, "read", Null, TopScope, Text(""))
+ val newPdfEdit = Elem(null, "edit", Null, TopScope, Text(""))
+ val newMp4Read = Elem(null, "read", Null, TopScope, Text(""))
+ val newMp4Edit = Elem(null, "edit", Null, TopScope, Text(""))
+ val newJpg = Elem(null, "jpg", Null, TopScope, newJpgRead, newJpgEdit)
+ val newPdf = Elem(null, "jpg", Null, TopScope, newPdfRead, newPdfEdit)
+ val newMp4 = Elem(null, "jpg", Null, TopScope, newMp4Read, newMp4Edit)
+ val newConfig = Elem(null, "config", Null, TopScope, newJpg, newPdf, newMp4)
+
+ var prettyfier = new scala.xml.PrettyPrinter(80, 2)
+ val header = """<?xml version="1.0" encoding="UTF-8" ?>""" + "\n"
+ val prettyConfig = header + prettyfier.format(config)
+ val xmlFile: File = new File(configFile)
+ try {
+ FileUtils.write(xmlFile, prettyConfig, "UTF-8")
+ } catch {
+ case io: IOException => println("No configuration file found. Created a new one but failed to fill it.")
+ }
+ } else {
+ try {
+ var config = scala.xml.XML.loadFile(configFile)
+ val jpgRead = (config \\ "config" \\ "jpg" \ "read").text
+ val jpgEdit = (config \\ "config" \\ "jpg" \ "edit").text
+ val pdfRead = (config \\ "config" \\ "pdf" \ "read").text
+ val pdfEdit = (config \\ "config" \\ "pdf" \ "edit").text
+ val mp4Read = (config \\ "config" \\ "mp4" \ "read").text
+ val mp4Edit = (config \\ "config" \\ "mp4" \ "edit").text
+ } catch {
+ case wrongXML: Exception => println("Configuration file is broken. Remove it and retry again.")
+ }
+ }
+ }
+
/** Returns reader for given filetype.
*
* @param filetype (String).
* @return reader for given filetype (String).
*/
def getReader(filetype: String): String = {
- val config = scala.xml.XML.loadFile("config.xml")
+ tryConfig()
+ val config = scala.xml.XML.loadFile(configFile)
if (filetype == "jpg") {
return (config \\ "config" \\ "jpg" \ "read").text
} else if (filetype == "pdf") {
@@ -30,7 +83,8 @@ class Config {
* @return editor for given filetype (String).
*/
def getEditor(filetype: String): String = {
- val config = scala.xml.XML.loadFile("config.xml")
+ tryConfig()
+ val config = scala.xml.XML.loadFile(configFile)
if (filetype == "jpg") {
return (config \\ "config" \\ "jpg" \ "edit").text
} else if (filetype == "pdf") {
@@ -48,43 +102,44 @@ class Config {
* @param reader (String).
*/
def setReader(filetype: String, reader: String) {
- var config = scala.xml.XML.loadFile("config.xml")
- val jpgread = (config \\ "config" \\ "jpg" \ "read").text
- val jpgedit = (config \\ "config" \\ "jpg" \ "edit").text
- val pdfread = (config \\ "config" \\ "pdf" \ "read").text
- val pdfedit = (config \\ "config" \\ "pdf" \ "edit").text
- val mp4read = (config \\ "config" \\ "mp4" \ "read").text
- val mp4edit = (config \\ "config" \\ "mp4" \ "edit").text
- val newjpgread, newjpgedit, newpdfread, newpdfedit, newmp4read, newmp4edit = null
+ tryConfig()
+ var config = scala.xml.XML.loadFile(configFile)
+
+ // Read in specific values out of the configuration file.
+ val jpgRead = (config \\ "config" \\ "jpg" \ "read").text
+ val jpgEdit = (config \\ "config" \\ "jpg" \ "edit").text
+ val pdfRead = (config \\ "config" \\ "pdf" \ "read").text
+ val pdfEdit = (config \\ "config" \\ "pdf" \ "edit").text
+ val mp4Read = (config \\ "config" \\ "mp4" \ "read").text
+ val mp4Edit = (config \\ "config" \\ "mp4" \ "edit").text
+
+ // Create new XML-elements by filling them with read values.
+ var newJpgRead = Elem(null, "read", Null, TopScope, Text(jpgRead))
+ val newJpgEdit = Elem(null, "edit", Null, TopScope, Text(jpgEdit))
+ var newPdfRead = Elem(null, "read", Null, TopScope, Text(pdfRead))
+ val newPdfEdit = Elem(null, "edit", Null, TopScope, Text(pdfEdit))
+ var newMp4Read = Elem(null, "read", Null, TopScope, Text(mp4Read))
+ val newMp4Edit = Elem(null, "edit", Null, TopScope, Text(mp4Edit))
+
+ // Change values according to the given filetype.
if (filetype == "jpg") {
- val newjpgread = Elem(null, "read", Null, TopScope, Text(reader))
- val newjpgedit = Elem(null, "edit", Null, TopScope, Text(jpgedit))
- val newpdfread = Elem(null, "read", Null, TopScope, Text(pdfread))
- val newpdfedit = Elem(null, "edit", Null, TopScope, Text(pdfedit))
- val newmp4read = Elem(null, "read", Null, TopScope, Text(mp4read))
- val newmp4edit = Elem(null, "edit", Null, TopScope, Text(mp4edit))
+ newJpgRead = Elem(null, "read", Null, TopScope, Text(reader))
} else if (filetype == "pdf") {
- val newjpgread = Elem(null, "read", Null, TopScope, Text(jpgread))
- val newjpgedit = Elem(null, "edit", Null, TopScope, Text(jpgedit))
- val newpdfread = Elem(null, "read", Null, TopScope, Text(reader))
- val newpdfedit = Elem(null, "edit", Null, TopScope, Text(pdfedit))
- val newmp4read = Elem(null, "read", Null, TopScope, Text(mp4read))
- val newmp4edit = Elem(null, "edit", Null, TopScope, Text(mp4edit))
+ newPdfRead = Elem(null, "read", Null, TopScope, Text(reader))
} else if (filetype == "mp4") {
- val newjpgread = Elem(null, "read", Null, TopScope, Text(jpgread))
- val newjpgedit = Elem(null, "edit", Null, TopScope, Text(jpgedit))
- val newpdfread = Elem(null, "read", Null, TopScope, Text(pdfread))
- val newpdfedit = Elem(null, "edit", Null, TopScope, Text(pdfedit))
- val newmp4read = Elem(null, "read", Null, TopScope, Text(reader))
- val newmp4edit = Elem(null, "edit", Null, TopScope, Text(mp4edit))
+ newMp4Read = Elem(null, "read", Null, TopScope, Text(reader))
}
- val newjpg = Elem(null, "jpg", Null, TopScope, newjpgread, newjpgedit)
- val newpdf = Elem(null, "jpg", Null, TopScope, newpdfread, newpdfedit)
- val newmp4 = Elem(null, "jpg", Null, TopScope, newmp4read, newmp4edit)
+ val newJpg = Elem(null, "jpg", Null, TopScope, newJpgRead, newJpgEdit)
+ val newPdf = Elem(null, "jpg", Null, TopScope, newPdfRead, newPdfEdit)
+ val newMp4 = Elem(null, "jpg", Null, TopScope, newMp4Read, newMp4Edit)
- val newconfig = Elem(null, "config", Null, TopScope, newjpg, newpdf, newmp4)
+ val newConfig = Elem(null, "config", Null, TopScope, newJpg, newPdf, newMp4)
- scala.xml.XML.save("config.xml", newconfig)
+ var prettyfier = new scala.xml.PrettyPrinter(80, 2)
+ val header = """<?xml version="1.0" encoding="UTF-8" ?>""" + "\n"
+ val prettyConfig = header + prettyfier.format(newConfig)
+ val xmlFile: File = new File(configFile)
+ FileUtils.write(xmlFile, prettyConfig, "UTF-8")
}
/** Sets given editor for given filetype.
@@ -93,47 +148,43 @@ class Config {
* @param editor (String).
*/
def setEditor(filetype: String, editor: String) {
- var config = scala.xml.XML.loadFile("config.xml")
- val jpgread = (config \\ "config" \\ "jpg" \ "read").text
- val jpgedit = (config \\ "config" \\ "jpg" \ "edit").text
- val pdfread = (config \\ "config" \\ "pdf" \ "read").text
- val pdfedit = (config \\ "config" \\ "pdf" \ "edit").text
- val mp4read = (config \\ "config" \\ "mp4" \ "read").text
- val mp4edit = (config \\ "config" \\ "mp4" \ "edit").text
- val newjpgread, newjpgedit, newpdfread, newpdfedit, newmp4read, newmp4edit = null
+ tryConfig()
+ var config = scala.xml.XML.loadFile(configFile)
+
+ // Read in specific values out of the configuration file.
+ val jpgRead = (config \\ "config" \\ "jpg" \ "read").text
+ val jpgEdit = (config \\ "config" \\ "jpg" \ "edit").text
+ val pdfRead = (config \\ "config" \\ "pdf" \ "read").text
+ val pdfEdit = (config \\ "config" \\ "pdf" \ "edit").text
+ val mp4Read = (config \\ "config" \\ "mp4" \ "read").text
+ val mp4Edit = (config \\ "config" \\ "mp4" \ "edit").text
+
+ // Create new XML-elements by filling them with read values.
+ val newJpgRead = Elem(null, "read", Null, TopScope, Text(jpgRead))
+ var newJpgEdit = Elem(null, "edit", Null, TopScope, Text(jpgEdit))
+ val newPdfRead = Elem(null, "read", Null, TopScope, Text(pdfRead))
+ var newPdfEdit = Elem(null, "edit", Null, TopScope, Text(pdfEdit))
+ val newMp4Read = Elem(null, "read", Null, TopScope, Text(mp4Read))
+ var newMp4Edit = Elem(null, "edit", Null, TopScope, Text(mp4Edit))
+
+ // Change values according to the given filetype.
if (filetype == "jpg") {
- val newjpgread = Elem(null, "read", Null, TopScope, Text(jpgread))
- val newjpgedit = Elem(null, "edit", Null, TopScope, Text(editor))
- val newpdfread = Elem(null, "read", Null, TopScope, Text(pdfread))
- val newpdfedit = Elem(null, "edit", Null, TopScope, Text(pdfedit))
- val newmp4read = Elem(null, "read", Null, TopScope, Text(mp4read))
- val newmp4edit = Elem(null, "edit", Null, TopScope, Text(mp4edit))
+ val newJpgEdit = Elem(null, "edit", Null, TopScope, Text(editor))
} else if (filetype == "pdf") {
- val newjpgread = Elem(null, "read", Null, TopScope, Text(jpgread))
- val newjpgedit = Elem(null, "edit", Null, TopScope, Text(jpgedit))
- val newpdfread = Elem(null, "read", Null, TopScope, Text(pdfread))
- val newpdfedit = Elem(null, "edit", Null, TopScope, Text(editor))
- val newmp4read = Elem(null, "read", Null, TopScope, Text(mp4read))
- val newmp4edit = Elem(null, "edit", Null, TopScope, Text(mp4edit))
+ val newPdfEdit = Elem(null, "edit", Null, TopScope, Text(editor))
} else if (filetype == "mp4") {
- val newjpgread = Elem(null, "read", Null, TopScope, Text(jpgread))
- val newjpgedit = Elem(null, "edit", Null, TopScope, Text(jpgedit))
- val newpdfread = Elem(null, "read", Null, TopScope, Text(pdfread))
- val newpdfedit = Elem(null, "edit", Null, TopScope, Text(pdfedit))
- val newmp4read = Elem(null, "read", Null, TopScope, Text(mp4read))
- val newmp4edit = Elem(null, "edit", Null, TopScope, Text(editor))
+ val newMp4Edit = Elem(null, "edit", Null, TopScope, Text(editor))
}
- val newjpg = Elem(null, "jpg", Null, TopScope, newjpgread, newjpgedit)
- val newpdf = Elem(null, "jpg", Null, TopScope, newpdfread, newpdfedit)
- val newmp4 = Elem(null, "jpg", Null, TopScope, newmp4read, newmp4edit)
+ val newJpg = Elem(null, "jpg", Null, TopScope, newJpgRead, newJpgEdit)
+ val newPdf = Elem(null, "jpg", Null, TopScope, newPdfRead, newPdfEdit)
+ val newMp4 = Elem(null, "jpg", Null, TopScope, newMp4Read, newMp4Edit)
- val newconfig = Elem(null, "config", Null, TopScope, newjpg, newpdf, newmp4)
+ val newConfig = Elem(null, "config", Null, TopScope, newJpg, newPdf, newMp4)
var prettyfier = new scala.xml.PrettyPrinter(80, 2)
val header = """<?xml version="1.0" encoding="UTF-8" ?>""" + "\n"
- val prettyConfig = header + prettyfier.format(config)
- val xmlFile: File = new File("config.xml")
- FileUtils.write(xmlFile, prettyConfig, "UTF-8")
+ val prettyConfig = header + prettyfier.format(newConfig)
+ val xmlFile: File = new File(configFile)
+ FileUtils.write(xmlFile, prettyConfig, "UTF-8")
}
-
}
View
8 src/gui/Control.scala
@@ -18,6 +18,8 @@ import java.io.FileReader
import javax.swing.JFileChooser
import javax.swing.filechooser.FileNameExtensionFilter
import javax.swing.BorderFactory
+import javax.swing.ImageIcon
+import javax.swing.SwingConstants
// Verwaltung der darzustellenden Daten
@@ -144,7 +146,11 @@ class Control {
// about
view.mntmAbout.addActionListener( new ActionListener {
def actionPerformed(e:ActionEvent) {
- JOptionPane.showMessageDialog(null, "Version 1.0.0\n\nVery special thanks to:\n David Cyborra\n Kristof Korwisi\n Thomas Wedler\n Chris Zimmerer", "About", JOptionPane.INFORMATION_MESSAGE);
+ val devImage: ImageIcon = new ImageIcon(getClass().getResource("/resources/devTeam.png"), "");
+ val devLabel: JLabel = new JLabel("<html><br />Version 1.0.0<br /><br />The Team (FLTR): David Cyborra, Thomas Wedler, Kristof Korwisi, Chris Zimmerer</html>", devImage, javax.swing.SwingConstants.CENTER)
+ devLabel.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+ devLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER)
+ JOptionPane.showMessageDialog(null, devLabel, "About", JOptionPane.PLAIN_MESSAGE);
}
})
View
61 src/optional/Thumbnails.scala
@@ -1,25 +1,24 @@
/** This package provides optional features to SQ-Project */
package optional
-import java.io.File
+import java.io.{ File, IOException, RandomAccessFile }
import java.awt.image.BufferedImage
-import java.awt.{Image, Graphics2D, Color, RenderingHints}
+import java.awt.{ Image, Graphics2D, Color, RenderingHints, Rectangle }
/*
* "PDFRenderer only deals with up to version 1.4 of the PDF spec.
* The current version is 1.6, and there have been quite a few additions
* and changes between 1.4 and 1.6 which seem to break PDFRenderer."
*/
-import com.sun.pdfview.{PDFFile, PDFPage}
+import com.sun.pdfview.{ PDFFile, PDFPage }
-import java.io.RandomAccessFile
import java.nio.channels.FileChannel
import java.nio.ByteBuffer
-import java.awt.Rectangle
// See http://www.capricasoftware.co.uk/vlcj/index.php for requirements and dependencies
+import uk.co.caprica.vlcj.player.{ MediaPlayer, MediaPlayerEventAdapter, MediaPlayerFactory }
+
import java.util.concurrent.CountDownLatch
-import uk.co.caprica.vlcj.player.{MediaPlayer, MediaPlayerEventAdapter, MediaPlayerFactory}
/** Provides methods for creating and managing thumbnails */
class Thumbnails {
@@ -42,8 +41,7 @@ class Thumbnails {
path = path + "mp4/"
thumbnailFile = new File(path + file)
} else if (extension == "txt") {
- /*
- * txt-files are for relations only and therefor will not have a thumbnail.
+ /* txt-files are for relations only and therefor will not have a thumbnail.
* To avoid thumbnail-generation true is returned even it's not :-)
*/
return true
@@ -91,7 +89,11 @@ class Thumbnails {
var filename = path + file
thumbnailFile = "filesystem/thumbnails/jpg/" + file
- image = javax.imageio.ImageIO.read(new File(filename))
+ try {
+ image = javax.imageio.ImageIO.read(new File(filename))
+ } catch {
+ case io: IOException => println("Failed to read JPG file.")
+ }
// Generate thumbnail of a PDF-file
} else if (extension == "pdf") {
@@ -99,15 +101,19 @@ class Thumbnails {
var filename = path + file
thumbnailFile = "filesystem/thumbnails/pdf/" + file.split('.').init :+ "jpg" mkString "."
- var pdffilename: File = new File(filename)
- var raf: RandomAccessFile = new RandomAccessFile(pdffilename, "r")
+ var pdfFilename: File = new File(filename)
+ var raf: RandomAccessFile = new RandomAccessFile(pdfFilename, "r")
var channel: FileChannel = raf.getChannel()
var buf: ByteBuffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size())
- var pdffile: PDFFile = new PDFFile(buf)
-
- // Draw first page to an image
- var page: PDFPage = pdffile.getPage(0)
-
+ var pdfFile: PDFFile = new PDFFile(buf)
+
+ var page: PDFPage = null
+ try {
+ // Draw first page to an image
+ page = pdfFile.getPage(0)
+ } catch {
+ case io: IOException => println("Failed to read PDF file.")
+ }
// Get width and height for the doc at the default zoom
var rect: Rectangle = new Rectangle(0, 0, page.getBBox().getWidth().toInt, page.getBBox().getHeight().toInt)
@@ -159,12 +165,16 @@ class Thumbnails {
}
})
- if (mediaPlayer.startMedia(mrl)) {
- mediaPlayer.setPosition(VLC_THUMBNAIL_POSITION)
- inPositionLatch.await() // Might wait forever if error
- image = mediaPlayer.getSnapshot()
- snapshotTakenLatch.await() // Might wait forever if error
- mediaPlayer.stop()
+ try {
+ if (mediaPlayer.startMedia(mrl)) {
+ mediaPlayer.setPosition(VLC_THUMBNAIL_POSITION)
+ inPositionLatch.await() // Might wait forever if error
+ image = mediaPlayer.getSnapshot()
+ snapshotTakenLatch.await() // Might wait forever if error
+ mediaPlayer.stop()
+ }
+ } catch {
+ case io: IOException => println("Failed to read MP4 file.")
}
mediaPlayer.release()
@@ -199,7 +209,10 @@ class Thumbnails {
graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR)
graphics2D.drawImage(image, 0, 0, thumbWidth, thumbHeight, null)
- javax.imageio.ImageIO.write(thumbImage, "jpg", new File(thumbnailFile));
-
+ try {
+ javax.imageio.ImageIO.write(thumbImage, "jpg", new File(thumbnailFile));
+ } catch {
+ case io: IOException => println("Failed to write thumbnail.")
+ }
}
}
View
BIN  src/resources/devTeam.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Please sign in to comment.
Something went wrong with that request. Please try again.