Commit f1a40811 authored by Daniel Dreibrodt's avatar Daniel Dreibrodt

new parsing system fix in layout and window

new parsing sytem support for anchor and button
bugfix in button edit gui, mistakenly used the up attribute as id
parent 9cd91587
......@@ -22,16 +22,28 @@
package vlcskineditor;
import vlcskineditor.items.*;
import vlcskineditor.history.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.border.*;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.LinkedList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SpringLayout;
import javax.swing.border.EtchedBorder;
import javax.swing.tree.DefaultMutableTreeNode;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import vlcskineditor.history.LayoutAddEvent;
import vlcskineditor.history.LayoutEditEvent;
import vlcskineditor.items.*;
/**
* Handles a windows' layout and it's content
......@@ -80,8 +92,11 @@ public class Layout implements ActionListener{
minheight = XML.getIntAttributeValue(n, "minheight", minheight);
maxheight = XML.getIntAttributeValue(n, "maxheight", maxheight);
NodeList nodes = n.getChildNodes();
for(int i=0;i<nodes.getLength();i++) {
for(int i=0;i<nodes.getLength();i++) {
if(nodes.item(i).getNodeName().equals("Anchor"))
items.add(new Anchor(nodes.item(i), s));
else if(nodes.item(i).getNodeName().equals("Button"))
items.add(new Button(nodes.item(i), s));
}
}
......
......@@ -80,7 +80,7 @@ public class Window implements ActionListener{
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_));
layouts.add(new Layout(nodes.item(i), this, s));
}
}
......
......@@ -30,6 +30,7 @@ import java.awt.geom.*;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.border.*;
import org.w3c.dom.Node;
/**
* Anchor item
......@@ -56,6 +57,24 @@ public class Anchor extends Item implements ActionListener{
type = Language.get("ANCHOR");
}
/**
* Creates an anchor item from a given XML node
* @param n The XML node
* @param s_ The parent skin manager
*/
public Anchor(Node n, Skin s_) {
s = s_;
id = type+" #"+s.getNewId();
points = XML.getStringAttributeValue(n, "points", points);
priority = XML.getIntAttributeValue(n, "priority", priority);
range = XML.getIntAttributeValue(n, "range", range);
x = XML.getIntAttributeValue(n, "x", x);
y = XML.getIntAttributeValue(n, "y", y);
lefttop = XML.getStringAttributeValue(n, "lefttop", lefttop);
updateBezier();
created = true;
}
/**
* Creates a new Anchor from XML.
* @param xmlcode The XML code from which the Anchor should be created. One line per tag.
......
......@@ -29,6 +29,7 @@ import java.awt.event.*;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.border.*;
import org.w3c.dom.Node;
import vlcskineditor.resources.ImageResource;
/**
......@@ -60,6 +61,35 @@ public class Button extends Item implements ActionListener{
type = Language.get("BUTTON");
}
/**
* Creates a new button item from a XML node
* @param n The XML node
* @param s_ The parent skin manager
*/
public Button(Node n, Skin s_) {
s = s_;
id = XML.getStringAttributeValue(n, "id", Language.get("UNNAMED").replaceAll("%t",type).replaceAll("%i",String.valueOf(s.getNewId())));
up = XML.getStringAttributeValue(n, "up", up);
down = XML.getStringAttributeValue(n, "down", down);
over = XML.getStringAttributeValue(n, "over", over);
action = XML.getStringAttributeValue(n, "action", action);
x = XML.getIntAttributeValue(n, "x", x);
y = XML.getIntAttributeValue(n, "y", y);
lefttop = XML.getStringAttributeValue(n, "lefttop", lefttop);
rightbottom = XML.getStringAttributeValue(n, "rightbottom", rightbottom);
xkeepratio = XML.getBoolAttributeValue(n, "xkeepratio", xkeepratio);
ykeepratio = XML.getBoolAttributeValue(n, "ykeepratio", ykeepratio);
tooltiptext = XML.getStringAttributeValue(n, "tooltiptext", tooltiptext);
visible = XML.getStringAttributeValue(n, "visible", visible);
created = true;
up_res = s.getImageResource(up);
over_res = s.getImageResource(over);
down_res = s.getImageResource(down);
}
/** Creates a new instance of Button
* @param xmlcode The XML code
* @param s_ The parent skin
......@@ -403,7 +433,7 @@ public class Button extends Item implements ActionListener{
frame.getRootPane().setDefaultButton(ok_btn);
}
up_tf.setText(id);
id_tf.setText(id);
x_tf.setText(String.valueOf(x));
y_tf.setText(String.valueOf(y));
lefttop_cb.setSelectedItem(lefttop);
......@@ -424,13 +454,13 @@ public class Button extends Item implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource().equals(ok_btn)) {
if(up_tf.getText().equals("")) {
if(id_tf.getText().equals("")) {
JOptionPane.showMessageDialog(frame,Language.get("ERROR_ID_INVALID_MSG"),Language.get("ERROR_ID_INVALID_TITLE"),JOptionPane.INFORMATION_MESSAGE);
return;
}
else if(!up_tf.getText().equals(id)) {
if(s.idExists(up_tf.getText())) {
JOptionPane.showMessageDialog(frame,Language.get("ERROR_ID_EXISTS_MSG").replaceAll("%i", up_tf.getText()),Language.get("ERROR_ID_INVALID_TITLE"),JOptionPane.INFORMATION_MESSAGE);
else if(!id_tf.getText().equals(id)) {
if(s.idExists(id_tf.getText())) {
JOptionPane.showMessageDialog(frame,Language.get("ERROR_ID_EXISTS_MSG").replaceAll("%i", id_tf.getText()),Language.get("ERROR_ID_INVALID_TITLE"),JOptionPane.INFORMATION_MESSAGE);
return;
}
}
......
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