Commit a3da3723 authored by Daniel Dreibrodt's avatar Daniel Dreibrodt

Checkbox editing/adding can be undone/redone

parent 7a7cae0a
......@@ -11,6 +11,7 @@ Changelog:
the CONTROL button is pressed.
- Many bugfixes
- Many actions can be undone/redone
- SubBitmaps can be edited visually
0.5.0a - Boolean variables are interpreted in the preview
- Global variables can be edited (boolean only atm)
- Preview window perfomance improvements
......
/*****************************************************************************
* CheckboxAddEvent.java
*****************************************************************************
* Copyright (C) 2007 Daniel Dreibrodt
*
* This file is part of vlcskinAddor.history
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
package vlcskineditor.history;
import vlcskineditor.Item;
import vlcskineditor.items.Checkbox;
import java.util.List;
/**
* CheckboxAddEvent
* @author Daniel Dreibrodt
*/
public class CheckboxAddEvent extends HistoryEvent{
private List<Item> parent;
private Checkbox c;
/** Creates a new instance of CheckboxAddEvent */
public CheckboxAddEvent(List<Item> par, Checkbox che) {
parent = par;
c = che;
}
public void undo() {
parent.remove(c);
c.s.updateItems();
}
public void redo() {
parent.add(c);
c.s.updateItems();
c.s.expandItem(c.id);
}
public String getDescription() {
return "Add Checkbox";
}
}
/*****************************************************************************
* CheckboxEditEvent.java
*****************************************************************************
* Copyright (C) 2007 Daniel Dreibrodt
*
* This file is part of vlcskineditor.history
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
package vlcskineditor.history;
import vlcskineditor.items.Checkbox;
/**
* CheckboxEditEvent
* @author Daniel Dreibrodt
*/
public class CheckboxEditEvent extends HistoryEvent{
private Checkbox c;
private String id_old, id_new, visible_old, visible_new, lefttop_old, lefttop_new;
private String rightbottom_old, rightbottom_new, help_old, help_new;
private boolean xkeepratio_old, xkeepratio_new, ykeepratio_old, ykeepratio_new;
private int x_old, x_new, y_old, y_new;
private String down1_old, down1_new, down2_old, down2_new;
private String up1_old, up1_new, up2_old, up2_new;
private String over1_old, over1_new, over2_old, over2_new;
private String action1_old, action1_new, action2_old, action2_new;
private String tooltiptext1_old, tooltiptext1_new, tooltiptext2_old, tooltiptext2_new;
private String state_old, state_new;
/** Creates a new instance of CheckboxEditEvent */
public CheckboxEditEvent(Checkbox che) {
c = che;
id_old = c.id;
visible_old = c.visible;
lefttop_old = c.lefttop;
rightbottom_old = c.rightbottom;
xkeepratio_old = c.xkeepratio;
ykeepratio_old = c.ykeepratio;
x_old = c.x;
y_old = c.y;
down1_old = c.down1;
down2_old = c.down2;
up1_old = c.up1;
up2_old = c.up2;
over1_old = c.over1;
over2_old = c.over2;
action1_old = c.action1;
action2_old = c.action2;
tooltiptext1_old = c.tooltiptext1;
tooltiptext2_old = c.tooltiptext2;
state_old = c.state;
}
public void setNew() {
id_new = c.id;
visible_new = c.visible;
lefttop_new = c.lefttop;
rightbottom_new = c.rightbottom;
xkeepratio_new = c.xkeepratio;
ykeepratio_new = c.ykeepratio;
x_new = c.x;
y_new = c.y;
down1_new = c.down1;
down2_new = c.down2;
up1_new = c.up1;
up2_new = c.up2;
over1_new = c.over1;
over2_new = c.over2;
action1_new = c.action1;
action2_new = c.action2;
tooltiptext1_new = c.tooltiptext1;
tooltiptext2_new = c.tooltiptext2;
state_new = c.state;
}
public void undo() {
c.id = id_old;
c.visible = visible_old;
c.lefttop = lefttop_old;
c.rightbottom = rightbottom_old;
c.xkeepratio = xkeepratio_old;
c.ykeepratio = ykeepratio_old;
c.x = x_old;
c.y = y_old;
c.down1 = down1_old;
c.down2 = down2_old;
c.up1 = up1_old;
c.up2 = up2_old;
c.over1 = over1_old;
c.over2 = over2_old;
c.action1 = action1_old;
c.action2 = action2_old;
c.tooltiptext1 = tooltiptext1_old;
c.tooltiptext2 = tooltiptext2_old;
c.state = state_old;
}
public void redo() {
c.id = id_new;
c.visible = visible_new;
c.lefttop = lefttop_new;
c.rightbottom = rightbottom_new;
c.xkeepratio = xkeepratio_new;
c.ykeepratio = ykeepratio_new;
c.x = x_new;
c.y = y_new;
c.down1 = down1_new;
c.down2 = down2_new;
c.up1 = up1_new;
c.up2 = up2_new;
c.over1 = over1_new;
c.over2 = over2_new;
c.action1 = action1_new;
c.action2 = action2_new;
c.tooltiptext1 = tooltiptext1_new;
c.tooltiptext2 = tooltiptext2_new;
c.state = state_new;
}
public String getDescription() {
return "Edit Checkbox";
}
}
......@@ -23,6 +23,7 @@
package vlcskineditor.items;
import vlcskineditor.*;
import vlcskineditor.history.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
......@@ -99,32 +100,68 @@ public class Checkbox extends Item implements ActionListener{
showOptions();
}
public void update() {
id = id_tf.getText();
x = Integer.parseInt(x_tf.getText());
y = Integer.parseInt(y_tf.getText());
lefttop = lefttop_cb.getSelectedItem().toString();
rightbottom = rightbottom_cb.getSelectedItem().toString();
xkeepratio = Boolean.parseBoolean(xkeepratio_cb.getSelectedItem().toString());
ykeepratio = Boolean.parseBoolean(ykeepratio_cb.getSelectedItem().toString());
visible = visible_tf.getText();
help = help_tf.getText();
up1 = up1_tf.getText();
over1 = over1_tf.getText();
down1 = down1_tf.getText();
action1 = action1_tf.getText();
tooltiptext1 = tooltiptext1_tf.getText();
up2 = up2_tf.getText();
over2 = over2_tf.getText();
down2 = down2_tf.getText();
action2 = action2_tf.getText();
tooltiptext2 = tooltiptext2_tf.getText();
state = state_tf.getText();
s.updateItems();
s.expandItem(id);
frame.setDefaultCloseOperation(frame.HIDE_ON_CLOSE);
created = true;
if(!created) {
id = id_tf.getText();
x = Integer.parseInt(x_tf.getText());
y = Integer.parseInt(y_tf.getText());
lefttop = lefttop_cb.getSelectedItem().toString();
rightbottom = rightbottom_cb.getSelectedItem().toString();
xkeepratio = Boolean.parseBoolean(xkeepratio_cb.getSelectedItem().toString());
ykeepratio = Boolean.parseBoolean(ykeepratio_cb.getSelectedItem().toString());
visible = visible_tf.getText();
help = help_tf.getText();
up1 = up1_tf.getText();
over1 = over1_tf.getText();
down1 = down1_tf.getText();
action1 = action1_tf.getText();
tooltiptext1 = tooltiptext1_tf.getText();
up2 = up2_tf.getText();
over2 = over2_tf.getText();
down2 = down2_tf.getText();
action2 = action2_tf.getText();
tooltiptext2 = tooltiptext2_tf.getText();
state = state_tf.getText();
CheckboxAddEvent cae = new CheckboxAddEvent(s.getParentListOf(id),this);
s.m.hist.addEvent(cae);
s.updateItems();
s.expandItem(id);
frame.setDefaultCloseOperation(frame.HIDE_ON_CLOSE);
created = true;
}
else {
CheckboxEditEvent cee = new CheckboxEditEvent(this);
id = id_tf.getText();
x = Integer.parseInt(x_tf.getText());
y = Integer.parseInt(y_tf.getText());
lefttop = lefttop_cb.getSelectedItem().toString();
rightbottom = rightbottom_cb.getSelectedItem().toString();
xkeepratio = Boolean.parseBoolean(xkeepratio_cb.getSelectedItem().toString());
ykeepratio = Boolean.parseBoolean(ykeepratio_cb.getSelectedItem().toString());
visible = visible_tf.getText();
help = help_tf.getText();
up1 = up1_tf.getText();
over1 = over1_tf.getText();
down1 = down1_tf.getText();
action1 = action1_tf.getText();
tooltiptext1 = tooltiptext1_tf.getText();
up2 = up2_tf.getText();
over2 = over2_tf.getText();
down2 = down2_tf.getText();
action2 = action2_tf.getText();
tooltiptext2 = tooltiptext2_tf.getText();
state = state_tf.getText();
cee.setNew();
s.m.hist.addEvent(cee);
s.updateItems();
s.expandItem(id);
}
}
public void showOptions() {
if(frame==null) {
......
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