Changeset 72

Show
Ignore:
Timestamp:
07/11/07 17:42:40 (1 year ago)
Author:
altglass
Message:

History for adds/edits of Windows and Layouts

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/vlcskineditor/Layout.java

    r71 r72  
    2424 
    2525import vlcskineditor.items.*; 
     26import vlcskineditor.history.*; 
    2627import java.util.*; 
    2728import java.awt.*; 
     
    4950  public int width, height; 
    5051  Skin s; 
     52  Window parent; 
    5153   
    5254  JFrame frame = null; 
     
    6567   * @param s_ The Skin in which the Layout is used. 
    6668   */ 
    67   public Layout(String xmlcode, Skin s_) { 
     69  public Layout(String xmlcode, Window w_, Skin s_) { 
    6870    s=s_; 
     71    parent=w_; 
    6972    String[] code = xmlcode.split("\n");    
    7073    width = XML.getIntValue(code[0],"width"); 
     
    152155   * @param s_ The Skin in which the Layout is used. 
    153156   */ 
    154   public Layout(Skin s_) { 
     157  public Layout(Window w_, Skin s_) { 
    155158    s=s_; 
     159    parent=w_; 
    156160    id = "Unnamed layout #"+s.getNewId(); 
    157161    width=0; 
     
    163167   */ 
    164168  public void update() { 
    165     id=id_tf.getText(); 
    166     width=Integer.parseInt(width_tf.getText()); 
    167     height=Integer.parseInt(height_tf.getText()); 
    168     minwidth=Integer.parseInt(minwidth_tf.getText()); 
    169     minheight=Integer.parseInt(minheight_tf.getText()); 
    170     maxwidth=Integer.parseInt(maxwidth_tf.getText()); 
    171     maxheight=Integer.parseInt(maxheight_tf.getText()); 
    172     s.updateWindows(); 
    173     s.expandLayout(id); 
    174     created = true; 
    175     frame.setDefaultCloseOperation(frame.HIDE_ON_CLOSE); 
     169    if(!created) { 
     170      LayoutAddEvent lae = new LayoutAddEvent(parent,this); 
     171      id=id_tf.getText(); 
     172      width=Integer.parseInt(width_tf.getText()); 
     173      height=Integer.parseInt(height_tf.getText()); 
     174      minwidth=Integer.parseInt(minwidth_tf.getText()); 
     175      minheight=Integer.parseInt(minheight_tf.getText()); 
     176      maxwidth=Integer.parseInt(maxwidth_tf.getText()); 
     177      maxheight=Integer.parseInt(maxheight_tf.getText()); 
     178      s.updateWindows(); 
     179      s.expandLayout(id); 
     180      created = true; 
     181      frame.setDefaultCloseOperation(frame.HIDE_ON_CLOSE); 
     182      s.m.hist.addEvent(lae); 
     183    } 
     184    else { 
     185      LayoutEditEvent lee = new LayoutEditEvent(this); 
     186      id=id_tf.getText(); 
     187      width=Integer.parseInt(width_tf.getText()); 
     188      height=Integer.parseInt(height_tf.getText()); 
     189      minwidth=Integer.parseInt(minwidth_tf.getText()); 
     190      minheight=Integer.parseInt(minheight_tf.getText()); 
     191      maxwidth=Integer.parseInt(maxwidth_tf.getText()); 
     192      maxheight=Integer.parseInt(maxheight_tf.getText()); 
     193      s.updateWindows(); 
     194      s.expandLayout(id);       
     195      lee.setNew(); 
     196      s.m.hist.addEvent(lee); 
     197    } 
    176198  } 
    177199  /** 
  • trunk/src/vlcskineditor/Skin.java

    r71 r72  
    4040public class Skin implements ActionListener{ 
    4141   
    42   java.util.List<Resource> resources = new LinkedList<Resource>(); 
    43   java.util.List<Window> windows = new LinkedList<Window>(); 
     42  public java.util.List<Resource> resources = new LinkedList<Resource>(); 
     43  public java.util.List<Window> windows = new LinkedList<Window>(); 
    4444  final String HEADER = "<!DOCTYPE Theme PUBLIC \"-//VideoLAN//DTD VLC Skins V2.0//EN\" \"skin.dtd\">"; 
    4545  final String THEME_VERSION_DEFAULT = "2.0"; 
  • trunk/src/vlcskineditor/Window.java

    r62 r72  
    2323package vlcskineditor; 
    2424 
     25import vlcskineditor.history.*; 
    2526import java.util.*; 
    2627import java.awt.*; 
     
    3637public class Window implements ActionListener{ 
    3738   
    38   /** Creates a new instance of Window */ 
    3939  final String ID_DEFAULT="none";   
    4040  final String VISIBLE_DEFAULT = "true"; 
     
    4444  final boolean PLAYONDROP_DEFAULT=true; 
    4545   
    46   String id=ID_DEFAULT; 
    47   String visible = VISIBLE_DEFAULT; 
    48   int x = X_DEFAULT; 
    49   int y = Y_DEFAULT; 
    50   boolean dragdrop = DRAGDROP_DEFAULT; 
    51   boolean playondrop = PLAYONDROP_DEFAULT; 
    52    
    53   java.util.List<Layout> layouts = new LinkedList<Layout>(); 
    54    
    55   Skin s; 
     46  public String id=ID_DEFAULT; 
     47  public String visible = VISIBLE_DEFAULT; 
     48  public int x = X_DEFAULT; 
     49  public int y = Y_DEFAULT; 
     50  public boolean dragdrop = DRAGDROP_DEFAULT; 
     51  public boolean playondrop = PLAYONDROP_DEFAULT; 
     52   
     53  public java.util.List<Layout> layouts = new LinkedList<Layout>(); 
     54   
     55  public Skin s; 
    5656   
    5757  JFrame frame = null; 
     
    6060  boolean created = false; 
    6161   
     62  /** Creates a new instance of Window */ 
    6263  public Window(String xmlcode, Skin s_) { 
    6364    s = s_; 
     
    8283      else if(code[i].startsWith("</Layout>")) { 
    8384        layoutcode+="\n"+code[i]; 
    84         layouts.add(new Layout(layoutcode,s)); 
     85        layouts.add(new Layout(layoutcode,this,s)); 
    8586        layoutcode = ""; 
    8687      } 
     
    9798    showOptions(); 
    9899  } 
    99   public void update(String id_, int x_, int y_, String v_, boolean dd_, boolean pod_) { 
    100     id=id_; 
    101     x=x_; 
    102     y=y_; 
    103     visible=v_; 
    104     dragdrop=dd_; 
    105     playondrop=pod_; 
    106     s.updateWindows();     
    107     created = true; 
    108     frame.setDefaultCloseOperation(frame.HIDE_ON_CLOSE); 
     100  public void update() { 
     101    if(!created) { 
     102      WindowAddEvent wae = new WindowAddEvent(s,this); 
     103      id=id_tf.getText(); 
     104      x=Integer.parseInt(x_tf.getText()); 
     105      y=Integer.parseInt(y_tf.getText()); 
     106      visible=visible_tf.getText(); 
     107      dragdrop=Boolean.parseBoolean(dragdrop_tf.getText()); 
     108      playondrop=Boolean.parseBoolean(playondrop_tf.getText()); 
     109      s.updateWindows();     
     110      created = true; 
     111      frame.setDefaultCloseOperation(frame.HIDE_ON_CLOSE);       
     112      s.m.hist.addEvent(wae); 
     113    } 
     114    else { 
     115      WindowEditEvent wee = new WindowEditEvent(this); 
     116      id=id_tf.getText(); 
     117      x=Integer.parseInt(x_tf.getText()); 
     118      y=Integer.parseInt(y_tf.getText()); 
     119      visible=visible_tf.getText(); 
     120      dragdrop=Boolean.parseBoolean(dragdrop_tf.getText()); 
     121      playondrop=Boolean.parseBoolean(playondrop_tf.getText()); 
     122      s.updateWindows();     
     123      wee.setNew(); 
     124      s.m.hist.addEvent(wee); 
     125    }     
    109126  } 
    110127  public void showOptions() { 
     
    215232      } 
    216233      frame.setVisible(false); 
    217       update(id_tf.getText(),Integer.parseInt(x_tf.getText()),Integer.parseInt(y_tf.getText()),visible_tf.getText(),Boolean.parseBoolean(dragdrop_tf.getText()),Boolean.parseBoolean(playondrop_tf.getText())); 
     234      update(); 
    218235    } 
    219236    else if(e.getSource().equals(help_btn)) { 
     
    238255  } 
    239256  public void addLayout() { 
    240     layouts.add(new Layout(s)); 
     257    layouts.add(new Layout(this,s)); 
    241258  } 
    242259  public String returnCode() { 
  • trunk/src/vlcskineditor/history/History.java

    r71 r72  
    4444    current = main; 
    4545  } 
    46   /** Adds an Event to the history */ 
     46  /** Adds an Event at the current point in the history list and removes any actions that could be redone*/ 
    4747  public void addEvent(HistoryEvent h) {     
    4848    current.setNext(h); 
     
    5151    m.setRedoEnabled(false); 
    5252    m.setUndoEnabled(true); 
     53    m.setUndoString(current.getDescription()); 
    5354  } 
    5455  /** Redoes the action that is next in the history list */