Commit 4fd4b3f8 authored by Daniel Dreibrodt's avatar Daniel Dreibrodt

Fix: saving of checkbox does not needlessly export attributes set to their default value

parent 8f9b4d02
......@@ -19,7 +19,6 @@
* 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.Main;
......@@ -30,12 +29,14 @@ import vlcskineditor.Main;
* @author Daniel Dreibrodt
*/
public class History {
private HistoryEvent root, current;
private Main m;
/** Creates an empty history */
private Main m;
/**
* Creates an empty history
* @param m_ The main program instance
*/
public History(Main m_) {
m = m_;
m.setUndoEnabled(false);
......@@ -43,8 +44,12 @@ public class History {
root = new DummyEvent();
current = root;
}
/** Adds an Event at the current point in the history list and removes any actions that could be redone*/
public void addEvent(HistoryEvent h) {
/**
* Adds an Event at the current point in the history list and removes any actions that could be redone
* @param h The new history event
*/
public void addEvent(HistoryEvent h) {
current.setNext(h);
h.setPrevious(current);
current = current.getNext();
......@@ -52,34 +57,52 @@ public class History {
m.setRedoString("");
m.setUndoEnabled(true);
m.setUndoString(current.getDescription());
//Remove any link to an event that is more than 50 edits ago
HistoryEvent he = current.getPrevious();
for (int i=1;i<50;i++) {
if(he.getPrevious()==null) break;
for(int i = 1; i < 50; i++) {
if(he.getPrevious() == null) {
break;
}
he = he.getPrevious();
}
if(he!=root) he.setPrevious(root);
if(he != root) {
he.setPrevious(root);
}
}
/** Redoes the action that is next in the history list */
public void redo() {
if(current.getNext()==null) return;
/**
* Redoes the action that is next in the history list
*/
public void redo() {
if(current.getNext() == null) {
return;
}
current.getNext().redo();
current = current.getNext();
m.setRedoEnabled(current.getNext()!=null);
if(current.getNext()!=null) m.setRedoString(current.getNext().getDescription());
else m.setRedoString("");
current = current.getNext();
m.setRedoEnabled(current.getNext() != null);
if(current.getNext() != null) {
m.setRedoString(current.getNext().getDescription());
} else {
m.setRedoString("");
}
m.setUndoEnabled(true);
m.setUndoString(current.getDescription());
}
/** Undoes the current action */
/**
* Undoes the current action
*/
public void undo() {
if(current==root) return;
if(current == root) {
return;
}
current.undo();
current = current.getPrevious();
m.setRedoEnabled(true);
m.setRedoEnabled(true);
m.setRedoString(current.getNext().getDescription());
m.setUndoEnabled(current!=root);
m.setUndoEnabled(current != root);
m.setUndoString(current.getDescription());
}
}
......@@ -711,14 +711,14 @@ public class Checkbox extends Item implements ActionListener{
public String returnCode(String indent) {
String code = indent+"<Checkbox";
code+=" state=\""+state+"\" up1=\""+up1+"\" up2=\""+up2+"\"";
if (!down1.equals(ID_DEFAULT)) code+=" down1=\""+down1+"\"";
if (!down2.equals(ID_DEFAULT)) code+=" down2=\""+down2+"\"";
if (!over1.equals(ID_DEFAULT)) code+=" over1=\""+over1+"\"";
if (!over2.equals(ID_DEFAULT)) code+=" over2=\""+over2+"\"";
if (!action1.equals(ID_DEFAULT)) code+=" action1=\""+action1+"\"";
if (!action2.equals(ID_DEFAULT)) code+=" action2=\""+action2+"\"";
if (!tooltiptext1.equals(ID_DEFAULT)) code+=" tooltiptext1=\""+tooltiptext1+"\"";
if (!tooltiptext2.equals(ID_DEFAULT)) code+=" tooltiptext2=\""+tooltiptext2+"\"";
if (!down1.equals(DOWN1_DEFAULT)) code+=" down1=\""+down1+"\"";
if (!down2.equals(DOWN2_DEFAULT)) code+=" down2=\""+down2+"\"";
if (!over1.equals(OVER1_DEFAULT)) code+=" over1=\""+over1+"\"";
if (!over2.equals(OVER2_DEFAULT)) code+=" over2=\""+over2+"\"";
if (!action1.equals(ACTION1_DEFAULT)) code+=" action1=\""+action1+"\"";
if (!action2.equals(ACTION2_DEFAULT)) code+=" action2=\""+action2+"\"";
if (!tooltiptext1.equals(TOOLTIPTEXT1_DEFAULT)) code+=" tooltiptext1=\""+tooltiptext1+"\"";
if (!tooltiptext2.equals(TOOLTIPTEXT2_DEFAULT)) code+=" tooltiptext2=\""+tooltiptext2+"\"";
if (!id.equals(ID_DEFAULT)) code+=" id=\""+id+"\"";
if (x!=X_DEFAULT) code+=" x=\""+String.valueOf(x)+"\"";
if (y!=Y_DEFAULT) code+=" y=\""+String.valueOf(y)+"\"";
......
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