Commit 9cd91587 authored by Daniel Dreibrodt's avatar Daniel Dreibrodt

New XML parsing system: Basis finished but Items still need necessary constructors

parent 0a28a8e6
......@@ -2,8 +2,9 @@
Source: share/ICE_JNIRegistry.dll; DestDir: {app}
Source: LICENSE.TXT; DestDir: {app}
Source: README.TXT; DestDir: {app}; Flags: isreadme
Source: skin.dtd; DestDir: {app}
Source: share/VLCSkinEditor.exe; DestDir: {app}
Source: build/VLCSkinEditor.jar; DestDir: {app}
Source: VLCSkinEditor.jar; DestDir: {app}
Source: lang/English.txt; DestDir: {app}/lang
Source: lang/english/*.txt; DestDir: {app}/lang/english/
[Icons]
......@@ -12,7 +13,7 @@ Name: {group}\Uninstall VLC Skin Editor; Filename: {uninstallexe}
Name: {group}\Online Help; Filename: http://www.videolan.org/vlc/skinedhlp/
[Setup]
OutputBaseFilename=VLCSkinEditor_setup
VersionInfoVersion=0.7.5
VersionInfoVersion=0.8
VersionInfoCompany=VideoLAN
VersionInfoDescription=Setup for the VLC Skin Editor
VersionInfoCopyright=2008 VideoLAN
......@@ -30,7 +31,7 @@ AppPublisherURL=http://www.videolan.org
AppSupportURL=http://www.videolan.org/vlc/skineditor.html
AppUpdatesURL=http://www.videolan.org/vlc/skineditor.html
AppVersion=0.7
AppID={{977C5080-EA08-435D-8901-233A506E1651}
AppID={{977C5080-EA08-435D-8901-233A506E1651}}
AppReadmeFile={app}\README.TXT
UninstallDisplayIcon={app}\VLCSkinEditor.exe
UninstallDisplayName=VLC Skin Editor
......
......@@ -59,6 +59,7 @@
VLCSkinEditor.jar
README.TXT
LICENSE.TXT
skin.dtd
${lang}/*.txt
${lang}/*/*.txt" />
</zip>
......@@ -72,6 +73,7 @@
<fileset dir="." includes="README.TXT
LICENSE.TXT
VLCSkinEditor.jar
skin.dtd
${lang}/*.txt
${lang}/*/*.txt"/>
</zip>
......@@ -103,6 +105,7 @@
<fileset dir="." includes="README.TXT
LICENSE.TXT
VLCSkinEditor.jar
skin.dtd
${lang}/*.txt
${lang}/*/*.txt" />
</tar>
......
<!-- version 2.0
-->
<!ELEMENT Theme (ThemeInfo,(Include|IniFile|Bitmap|BitmapFont|Font|PopupMenu|Window)*)>
<!ATTLIST Theme
version CDATA #REQUIRED
tooltipfont CDATA "defaultfont"
magnet CDATA "15"
alpha CDATA "255"
movealpha CDATA "255"
>
<!-- main elements -->
<!ELEMENT IniFile EMPTY>
<!ATTLIST IniFile
id CDATA #REQUIRED
file CDATA #REQUIRED
>
<!ELEMENT Include EMPTY>
<!ATTLIST Include
file CDATA #REQUIRED
>
<!ELEMENT Bitmap (SubBitmap)*>
<!ATTLIST Bitmap
id CDATA #REQUIRED
file CDATA #REQUIRED
alphacolor CDATA #REQUIRED
nbframes CDATA "1"
fps CDATA "0"
>
<!ELEMENT SubBitmap EMPTY>
<!ATTLIST SubBitmap
id CDATA #REQUIRED
x CDATA #REQUIRED
y CDATA #REQUIRED
width CDATA #REQUIRED
height CDATA #REQUIRED
nbframes CDATA "1"
fps CDATA "0"
>
<!ELEMENT Font EMPTY>
<!ATTLIST Font
id CDATA #REQUIRED
file CDATA #REQUIRED
size CDATA "12"
>
<!ELEMENT BitmapFont EMPTY>
<!ATTLIST BitmapFont
id CDATA #REQUIRED
file CDATA #REQUIRED
type CDATA "digits"
>
<!ELEMENT PopupMenu (MenuItem|MenuSeparator)+>
<!ATTLIST PopupMenu
id CDATA #REQUIRED
>
<!ELEMENT MenuItem EMPTY>
<!ATTLIST MenuItem
label CDATA #REQUIRED
action CDATA "none"
>
<!ELEMENT MenuSeparator EMPTY>
<!ELEMENT ThemeInfo EMPTY>
<!ATTLIST ThemeInfo
name CDATA #IMPLIED
author CDATA #IMPLIED
email CDATA #IMPLIED
webpage CDATA #IMPLIED
>
<!ELEMENT Window (Layout)+>
<!ATTLIST Window
id CDATA "none"
visible CDATA "true"
x CDATA "0"
y CDATA "0"
dragdrop CDATA "true"
playondrop CDATA "true"
>
<!ELEMENT Layout (Group|Image|Button|Playlist|Slider|RadialSlider|Text|Checkbox|
Anchor|Video|Playtree|Panel)+>
<!ATTLIST Layout
id CDATA "none"
width CDATA #REQUIRED
height CDATA #REQUIRED
minwidth CDATA "-1"
maxwidth CDATA "-1"
minheight CDATA "-1"
maxheight CDATA "-1"
>
<!-- Grouping elements -->
<!ELEMENT Group (Group|Image|Button|Playlist|Slider|RadialSlider|Text|Checkbox|
Anchor|Video|Playtree|Panel)+>
<!ATTLIST Group
x CDATA "0"
y CDATA "0"
>
<!ELEMENT Panel (Group|Image|Button|Playlist|Slider|RadialSlider|Text|Checkbox|
Anchor|Video|Playtree|Panel)+>
<!ATTLIST Panel
x CDATA "0"
y CDATA "0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
xkeepratio CDATA "false"
ykeepratio CDATA "false"
width CDATA #REQUIRED
height CDATA #REQUIRED
>
<!-- Anchors -->
<!ELEMENT Anchor EMPTY>
<!ATTLIST Anchor
x CDATA "0"
y CDATA "0"
lefttop CDATA "lefttop"
priority CDATA #REQUIRED
points CDATA "(0,0)"
range CDATA "10"
>
<!-- Controls -->
<!ELEMENT Image EMPTY>
<!ATTLIST Image
id CDATA "none"
visible CDATA "true"
x CDATA "0"
y CDATA "0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
xkeepratio CDATA "false"
ykeepratio CDATA "false"
image CDATA #REQUIRED
action CDATA "none"
action2 CDATA "none"
resize CDATA "mosaic"
help CDATA ""
>
<!ELEMENT Button EMPTY>
<!ATTLIST Button
id CDATA "none"
visible CDATA "true"
x CDATA "0"
y CDATA "0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
xkeepratio CDATA "false"
ykeepratio CDATA "false"
up CDATA #REQUIRED
down CDATA "none"
over CDATA "none"
action CDATA "none"
tooltiptext CDATA ""
help CDATA ""
>
<!ELEMENT Checkbox EMPTY>
<!ATTLIST Checkbox
id CDATA "none"
visible CDATA "true"
x CDATA "0"
y CDATA "0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
xkeepratio CDATA "false"
ykeepratio CDATA "false"
up1 CDATA #REQUIRED
down1 CDATA "none"
over1 CDATA "none"
up2 CDATA #REQUIRED
down2 CDATA "none"
over2 CDATA "none"
state CDATA #REQUIRED
action1 CDATA "none"
action2 CDATA "none"
tooltiptext1 CDATA ""
tooltiptext2 CDATA ""
help CDATA ""
>
<!ELEMENT Slider (SliderBackground)?>
<!ATTLIST Slider
id CDATA "none"
visible CDATA "true"
x CDATA "0"
y CDATA "0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
xkeepratio CDATA "false"
ykeepratio CDATA "false"
up CDATA #REQUIRED
down CDATA "none"
over CDATA "none"
points CDATA #REQUIRED
thickness CDATA "10"
value CDATA "none"
background CDATA "none"
tooltiptext CDATA ""
help CDATA ""
>
<!ELEMENT SliderBackground EMPTY>
<!ATTLIST SliderBackground
id CDATA "none"
image CDATA #REQUIRED
nbhoriz CDATA "1"
nbvert CDATA "1"
padhoriz CDATA "0"
padvert CDATA "0"
>
<!ELEMENT RadialSlider EMPTY>
<!ATTLIST RadialSlider
id CDATA "none"
visible CDATA "true"
x CDATA "0"
y CDATA "0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
xkeepratio CDATA "false"
ykeepratio CDATA "false"
sequence CDATA #REQUIRED
nbimages CDATA #REQUIRED
minangle CDATA "0"
maxangle CDATA "360"
value CDATA "none"
tooltiptext CDATA ""
help CDATA ""
>
<!ELEMENT Text EMPTY>
<!ATTLIST Text
id CDATA "none"
visible CDATA "true"
x CDATA "0"
y CDATA "0"
width CDATA "0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
xkeepratio CDATA "false"
ykeepratio CDATA "false"
text CDATA ""
font CDATA #REQUIRED
color CDATA "#000000"
scrolling CDATA "auto"
alignment CDATA "left"
help CDATA ""
>
<!ELEMENT Playlist (Slider)?>
<!ATTLIST Playlist
id CDATA #REQUIRED
visible CDATA "true"
x CDATA "0"
y CDATA "0"
width CDATA "0"
height CDATA "0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
xkeepratio CDATA "false"
ykeepratio CDATA "false"
font CDATA #REQUIRED
bgimage CDATA "none"
fgcolor CDATA "#000000"
playcolor CDATA "#FF0000"
bgcolor1 CDATA "#FFFFFF"
bgcolor2 CDATA "#FFFFFF"
selcolor CDATA "#0000FF"
help CDATA ""
>
<!ELEMENT Playtree (Slider)?>
<!ATTLIST Playtree
id CDATA #REQUIRED
visible CDATA "true"
x CDATA "0"
y CDATA "0"
width CDATA "0"
height CDATA "0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
xkeepratio CDATA "false"
ykeepratio CDATA "false"
font CDATA #REQUIRED
bgimage CDATA "none"
itemimage CDATA "none"
openimage CDATA "none"
closedimage CDATA "none"
fgcolor CDATA "#000000"
playcolor CDATA "#FF0000"
bgcolor1 CDATA "#FFFFFF"
bgcolor2 CDATA "#FFFFFF"
selcolor CDATA "#0000FF"
help CDATA ""
flat CDATA "false"
>
<!ELEMENT Video EMPTY>
<!ATTLIST Video
id CDATA "none"
visible CDATA "true"
x CDATA "0"
y CDATA "0"
width CDATA "0"
height CDATA "0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
xkeepratio CDATA "false"
ykeepratio CDATA "false"
autoresize CDATA "true"
help CDATA ""
>
......@@ -24,6 +24,11 @@ package vlcskineditor;
import java.awt.Component;
import java.awt.Desktop;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
import javax.swing.JOptionPane;
/**
......@@ -70,4 +75,25 @@ public class Helper {
JOptionPane.showMessageDialog(null,Language.get("ERROR_BROWSE_MSG").replaceAll("%u", url),Language.get("ERROR_BROWSE_TITLE"),JOptionPane.WARNING_MESSAGE);
}
}
/**
* Taken from http://www.rgagnon.com/javadetails/java-0064.html
* @param in Source File
* @param out Destination File
* @throws java.io.IOException
*/
public static void copyFile(File in, File out) throws IOException {
FileChannel inChannel = new FileInputStream(in).getChannel();
FileChannel outChannel = new FileOutputStream(out).getChannel();
try {
inChannel.transferTo(0, inChannel.size(), outChannel);
}
catch (IOException e) {
throw e;
}
finally {
if (inChannel != null) inChannel.close();
if (outChannel != null) outChannel.close();
}
}
}
......@@ -30,6 +30,8 @@ import java.awt.event.*;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.border.*;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* Handles a windows' layout and it's content
......@@ -61,6 +63,28 @@ public class Layout implements ActionListener{
boolean created = false;
/**
* Parses a layout's structure from a given XML node
* @param n The XML node
* @param w_ The parent window
* @param s_ The parent skin manager
*/
public Layout(Node n, Window w_, Skin s_) {
s = s_;
parent = w_;
id = XML.getStringAttributeValue(n, "id", Language.get("UNNAMED").replaceAll("%t",type).replaceAll("%i",String.valueOf(s.getNewId())));
width = XML.getIntAttributeValue(n, "width", width);
height = XML.getIntAttributeValue(n, "height", height);
minwidth = XML.getIntAttributeValue(n, "minwidth", minwidth);
maxwidth = XML.getIntAttributeValue(n, "maxwidth", maxwidth);
minheight = XML.getIntAttributeValue(n, "minheight", minheight);
maxheight = XML.getIntAttributeValue(n, "maxheight", maxheight);
NodeList nodes = n.getChildNodes();
for(int i=0;i<nodes.getLength();i++) {
}
}
/**
* Creates a new Layout from XML.
* @param xmlcode The XML code from which the Layout should be created.
......
......@@ -47,12 +47,12 @@ import vlcskineditor.resources.SubBitmap;
*/
public class Main extends javax.swing.JFrame implements ActionListener, TreeSelectionListener, WindowListener, MouseListener{
private static final long serialVersionUID = 075;
private static final long serialVersionUID = 80;
private final String updateURL_s = "http://www.videolan.org/vlc/skineditor_update.php";
//The version identification of the current build.
public final static String VERSION = "0.7.5.dev";
public final static String VERSION = "0.8.0.dev";
//The directory in which the VLC executable is found
String vlc_dir = "";
//The directory from which VLC loads its skins
......@@ -608,7 +608,7 @@ public class Main extends javax.swing.JFrame implements ActionListener, TreeSele
RegistryKey vlc_key = Registry.openSubkey(Registry.HKEY_LOCAL_MACHINE,"Software\\VideoLAN\\VLC",RegistryKey.ACCESS_READ);
String installDir = vlc_key.getStringValue("InstallDir");
vlc_dir = installDir+File.separator;
vlc_skins_dir = vlc_dir+"skins";
vlc_skins_dir = vlc_dir+"skins\\";
}
catch (Exception e) {
System.err.println("Could not read VLC installation directory from Registry. VLC might not be properly installed.");
......@@ -638,7 +638,8 @@ public class Main extends javax.swing.JFrame implements ActionListener, TreeSele
openFile();
}
else {
System.exit(0);
saved = true;
exit();
}
}
/**
......
This diff is collapsed.
......@@ -29,6 +29,9 @@ import java.awt.event.*;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.border.*;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* Handles windows and their layouts
......@@ -61,6 +64,26 @@ public class Window implements ActionListener{
public String type = Language.get("WINDOW");
/**
* Parses a window's structure from a given XML node
* @param n The window node
* @param s_ The parent skin manager
*/
public Window(Node n, Skin s_) {
s = s_;
id = XML.getStringAttributeValue(n, "id", Language.get("UNNAMED").replaceAll("%t",type).replaceAll("%i",String.valueOf(s.getNewId())));
visible = XML.getStringAttributeValue(n, "visible", visible);
x = XML.getIntAttributeValue(n, "x", x);
y = XML.getIntAttributeValue(n, "y", y);
dragdrop = XML.getBoolAttributeValue(n, "dragdrop", dragdrop);
playondrop = XML.getBoolAttributeValue(n, "playondrop", playondrop);
NodeList nodes = n.getChildNodes();
for(int i=0;i<nodes.getLength();i++) {
if(nodes.item(i).getNodeName().equals("Layout"))
layouts.add(new Layout(n, this, s_));
}
}
/** Creates a new instance of Window */
public Window(String xmlcode, Skin s_) {
s = s_;
......
......@@ -22,17 +22,18 @@
package vlcskineditor;
import org.w3c.dom.Node;
/**
* XML Handler
* @author Daniel Dreibrodt
*/
public class XML {
/** Creates a new instance of XML */
public XML() {
}
/**
* Returns the value of a xml attribute from a given line of xml code
* @deprecated Now the DOM model is used
* @param line The XML Code
* @param field The name of the attribute whose value is to be retrieved
* @return The attribute's value
......@@ -42,6 +43,14 @@ public class XML {
int value_end = line.indexOf("\"",value_start);
return line.substring(value_start,value_end);
}
/**
* Returns the value of a xml attribute from a given line of xml code as an integer
* @deprecated Now the DOM model is used
* @param line
* @param field
* @return
*/
public static int getIntValue(String line, String field) {
int i = 0;
try {
......@@ -52,6 +61,14 @@ public class XML {
}
return i;
}
/**
* Returns the value of a xml attribute from a given line of xml code as a boolean value
* @deprecated Now the DOM model is used
* @param line
* @param field
* @return
*/
public static boolean getBoolValue(String line, String field) {
boolean b = false;
try {
......@@ -62,4 +79,44 @@ public class XML {
}
return b;
}
/**
* Gets the value of an XML node's attribute if it exists
* @param n The XML node
* @param name The name of the attribute
* @param oldvalue The value which is returned if the attribute is not set in the given node
* @return If the attribute is set, the attribute's value is returned. Otherwise the given old value.
*/
public static String getStringAttributeValue(Node n, String name, String oldvalue) {
if(n.getAttributes().getNamedItem(name)!=null) return n.getAttributes().getNamedItem(name).getNodeValue();
else return oldvalue;
}
/**
* Gets the value of an XML node's attribute as an integer if it exists
* @param n The XML node
* @param name The name of the attribute
* @param oldvalue The value which is returned if the attribute is not set in the given node
* @return If the attribute is set, the attribute's value is returned. Otherwise the given old value.
*/
public static int getIntAttributeValue(Node n, String name, int oldvalue) {
try {
if(n.getAttributes().getNamedItem(name)!=null) return Integer.parseInt(n.getAttributes().getNamedItem(name).getNodeValue());
} catch(NumberFormatException ex) {
System.err.println("Tried to get a node's attribute as an integer, although it is no integer. It's value is "+n.getAttributes().getNamedItem(name).getNodeValue());
}
return oldvalue;
}
/**
* Gets the value of an XML node's attribute as a boolean value if it exists
* @param n The XML node
* @param name The name of the attribute
* @param oldvalue The value which is returned if the attribute is not set in the given node
* @return If the attribute is set, the attribute's value is returned. Otherwise the given old value.
*/
public static boolean getBoolAttributeValue(Node n, String name, boolean oldvalue) {
if(n.getAttributes().getNamedItem(name)!=null) return Boolean.parseBoolean(n.getAttributes().getNamedItem(name).getNodeValue());
else return oldvalue;
}
}
......@@ -7,11 +7,6 @@
The VLC Skin Editor's main package
@author Daniel Dreibrodt <mailto:daniel_DOT_dreibrodt_AT_googlemail_DOT_com>
@version 0.7.0
</body>
</html>
......@@ -33,7 +33,8 @@ import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import java.io.*;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* Handles Bitmap resources
......@@ -61,18 +62,26 @@ public class Bitmap extends ImageResource implements ActionListener{
}
/**
* Creates a new Bitmap from a W3C DOM element
* @param e The W3C DOM element
* Creates a new Bitmap from a XML node
* @param n The XML node
* @param s_ The skin in which the Bitmap is used
*/
public Bitmap(Element e, Skin s_) {
public Bitmap(Node n, Skin s_) {
s = s_;
if(e.hasAttribute("id")) id = e.getAttribute("id");
if(e.hasAttribute("file")) file = e.getAttribute("file");
if(e.hasAttribute("alphacolor")) alphacolor = e.getAttribute("alphacolor");
if(e.hasAttribute("nbframes")) nbframes = Integer.valueOf(e.getAttribute("nbframes"));
if(e.hasAttribute("fps")) fps = Integer.valueOf(e.getAttribute("fps"));
updateImage();
id = XML.getStringAttributeValue(n, "id", id);
file = XML.getStringAttributeValue(n, "file", file);
alphacolor = XML.getStringAttributeValue(n, "alphacolor", alphacolor);
nbframes = XML.getIntAttributeValue(n, "nbframes", nbframes);
fps = XML.getIntAttributeValue(n, "fps", fps);
updateImage();
NodeList children = n.getChildNodes();
for(int i=0;i<children.getLength();i++) {
Node child = children.item(i);
if(child.getNodeType()==Node.ELEMENT_NODE) {
if(child.getNodeName().equals("SubBitmap"))
SubBitmaps.add(new SubBitmap(child, s, this));
}
}
}
/**
......
......@@ -30,7 +30,7 @@ import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
/**
* Handles font resources
* @author Daniel Dreibrodt
......@@ -54,11 +54,16 @@ public class Font extends Resource implements ActionListener{
type = Language.get("FONT");
}
public Font(Element e, Skin s_) {
/**
* Creates a Font from a XML node
* @param n The XML node
* @param s_ The parent skin manager
*/
public Font(Node n, Skin s_) {
s = s_;
if(e.hasAttribute("id")) id = e.getAttribute("id");
if(e.hasAttribute("file")) file = e.getAttribute("file");
if(e.hasAttribute("size")) size = Integer.parseInt(e.getAttribute("size"));
id = XML.getStringAttributeValue(n, "id", id);
file = XML.getStringAttributeValue(n, "file", file);
size = XML.getIntAttributeValue(n, "size", size);
}
/**
......
......@@ -28,7 +28,7 @@ import javax.swing.tree.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import vlcskineditor.history.SubBitmapAddEvent;
/**
......@@ -60,19 +60,19 @@ public class SubBitmap extends ImageResource implements ActionListener{
}
/**
* Creates a new SubBitmap from a DOM Element
* @param e The DOM Element
* Creates a new SubBitmap from a XML node
* @param n The XML node
* @param s_ The skin in which the SubBitmap is used
* @param parent_ The parent Bitmap. This is necessary to create the image represented by the SubBitmap.
*/
public SubBitmap(Element e, Skin s_, Bitmap parent_) {
public SubBitmap(Node n, Skin s_, Bitmap parent_) {
s = s_;
parent = parent_;
if(e.hasAttribute("id")) id = e.getAttribute("id");
if(e.hasAttribute("x")) x = Integer.parseInt(e.getAttribute("x"));
if(e.hasAttribute("y")) y = Integer.parseInt(e.getAttribute("y"));
if(e.hasAttribute("width")) width = Integer.parseInt(e.getAttribute("width"));
if(e.hasAttribute("height")) height = Integer.parseInt(e.getAttribute("height"));
id = XML.getStringAttributeValue(n, "id", id);
x = XML.getIntAttributeValue(n, "x", x);
y = XML.getIntAttributeValue(n, "y", y);
width = XML.getIntAttributeValue(n, "width", width);
height = XML.getIntAttributeValue(n, "height", height);
created = true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment