Changeset 32

Show
Ignore:
Timestamp:
10/09/07 11:37:25 (1 year ago)
Author:
altglass
Message:

Release 0.4.0a finished
Trees automatically expand themselves to the changed element after being updated

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/README.TXT

    r27 r32  
    1 VLC Skin Editor release 0.3.5b 
     1VLC Skin Editor release 0.4.0a 
    22----------------------------------------------------------- 
    33Changelog: 
    44----------------------------------------------------------- 
     50.4.0a - Items can be positioned with the mouse 
     6       - Trees don't collapse anymore completely when an 
     7         element in it is updated, they automatically 
     8         expand the path to the updated item and select it 
    590.3.5b - NullPointerException fix for Playtree rendering 
    610       - VLT files can be imported 
  • trunk/src/vlcskineditor/Item.java

    r28 r32  
    8585  } 
    8686  /** If an item contains a subitem of the given id the list containing the subitem is returned **/ 
    87   public java.util.List<Item> getParentOf(String id_) { 
     87  public java.util.List<Item> getParentListOf(String id_) { 
     88    return null; 
     89  } 
     90  /** If an item contains a subitem of the given id the itemis returned **/ 
     91  public Item getParentOf(String id_) { 
    8892    return null; 
    8993  } 
  • trunk/src/vlcskineditor/Items/Anchor.java

    r28 r32  
    7575    range=r_; 
    7676    s.updateItems(); 
     77    s.expandItem(id); 
    7778  } 
    7879  public void showOptions() { 
  • trunk/src/vlcskineditor/Items/Button.java

    r28 r32  
    9292     
    9393    s.updateItems();     
     94    s.expandItem(id); 
    9495  } 
    9596  public void showOptions() { 
  • trunk/src/vlcskineditor/Items/Checkbox.java

    r28 r32  
    117117    state = state_tf.getText(); 
    118118     
    119     s.updateItems();     
     119    s.updateItems();    
     120    s.expandItem(id); 
    120121  } 
    121122  public void showOptions() { 
  • trunk/src/vlcskineditor/Items/Group.java

    r28 r32  
    103103    s=s_; 
    104104    id = "Unnamed group #"+s.getNewId(); 
    105     showOptions(); 
    106     for(Item i:items) { 
    107       i.setOffset(x,y); 
    108     } 
     105    showOptions();     
     106    s.updateItems();     
     107    s.expandItem(id); 
    109108  } 
    110109  public void update(String id_, int x_, int y_) { 
     
    116115    } 
    117116    s.updateItems();     
     117    s.expandItem(id); 
    118118  } 
    119119  public void showOptions() { 
     
    242242    return null; 
    243243  } 
    244   public java.util.List<Item> getParentOf(String id_) { 
     244  public java.util.List<Item> getParentListOf(String id_) { 
    245245    for(int x=0;x<items.size();x++) { 
    246246      Item i = items.get(x); 
    247       if(i.id.equals(id_)) { 
    248         System.out.println(id+": I is parent of "+id_); 
     247      if(i.id.equals(id_)) {         
    249248        return items;         
    250249      } 
    251250      if (i.type.equals("Group")||i.type.equals("Panel")) { 
    252         java.util.List<Item> p = i.getParentOf(id_); 
     251        java.util.List<Item> p = i.getParentListOf(id_); 
    253252        if (p!=null) return p; 
    254253      } 
     
    256255    return null; 
    257256  } 
     257  public Item getParentOf(String id_) { 
     258    for(int x=0;x<items.size();x++) { 
     259      Item i = items.get(x); 
     260      if(i.id.equals(id_)) {         
     261        return this;         
     262      } 
     263      Item it = i.getParentOf(id_); 
     264      if (it!=null) return it;       
     265    } 
     266    return null; 
     267  } 
    258268} 
  • trunk/src/vlcskineditor/Items/Image.java

    r28 r32  
    8888    action2 = action2_tf.getText();    
    8989     
    90     s.updateItems();     
     90    s.updateItems();       
     91    s.expandItem(id); 
    9192  } 
    9293  public void showOptions() { 
  • trunk/src/vlcskineditor/Items/Panel.java

    r28 r32  
    117117    id = "Unnamed panel #"+s.getNewId(); 
    118118    showOptions(); 
    119     for(Item i:items) { 
    120       i.setOffset(x,y); 
    121     } 
     119    s.updateItems(); 
     120    s.expandItem(id); 
    122121  } 
    123122  public void update() { 
     
    136135     
    137136    s.updateItems();     
     137    s.expandItem(id); 
    138138    for(Item i:items) { 
    139139      i.setOffset(x,y); 
     
    347347    return null; 
    348348  } 
    349   public java.util.List<Item> getParentOf(String id_) { 
     349  public java.util.List<Item> getParentListOf(String id_) { 
    350350    for(int x=0;x<items.size();x++) { 
    351351      Item i = items.get(x); 
    352       if(i.id.equals(id_)) { 
    353         System.out.println(id+": I is parent of "+id_); 
     352      if(i.id.equals(id_)) {         
    354353        return items;         
    355354      } 
    356355      if (i.type.equals("Group")||i.type.equals("Panel")) { 
    357         java.util.List<Item> p = i.getParentOf(id_); 
     356        java.util.List<Item> p = i.getParentListOf(id_); 
    358357        if (p!=null) return p; 
    359358      } 
     
    361360    return null; 
    362361  } 
     362  public Item getParentOf(String id_) { 
     363    for(int x=0;x<items.size();x++) { 
     364      Item i = items.get(x); 
     365      if(i.id.equals(id_)) {         
     366        return this;         
     367      } 
     368      Item it = i.getParentOf(id_); 
     369      if (it!=null) return it;       
     370    } 
     371    return null; 
     372  } 
    363373} 
  • trunk/src/vlcskineditor/Items/Playlist.java

    r19 r32  
    3131 * Playlist item 
    3232 * @author Daniel Dreibrodt 
     33 * @Deprecated All Playlists are automatically converted to flat playtrees 
    3334 */ 
    34 public class Playlist extends Item{ 
     35@Deprecated public class Playlist extends Item{ 
    3536   
    3637  /** Creates a new instance of Playlist */ 
  • trunk/src/vlcskineditor/Items/Playtree.java

    r28 r32  
    130130    showOptions(); 
    131131    s.updateItems(); 
     132    s.expandItem(id); 
    132133  } 
    133134  public void update()  { 
     
    155156    bgcolor2 = bgcolor2_tf.getText(); 
    156157    flat = (Boolean)flat_cb.getSelectedItem(); 
     158     
     159    s.updateItems(); 
     160    s.expandItem(id); 
    157161  } 
    158162  public void showOptions() { 
     
    655659    else return slider.getItem(id_); 
    656660  } 
     661  public Item getParentOf(String id_) { 
     662   if(slider!=null) { 
     663     if(slider.id.equals(id_)) return this; 
     664     else return slider.getParentOf(id_); 
     665   } 
     666   else return null; 
     667  } 
    657668} 
  • trunk/src/vlcskineditor/Items/Slider.java

    r28 r32  
    126126    id = "Unnamed slider #"+s.getNewId(); 
    127127    showOptions(); 
     128    s.updateItems(); 
     129    s.expandItem(id); 
    128130  } 
    129131  public Slider(Skin s_, boolean ipt) { 
     
    153155    tooltiptext = tooltiptext_tf.getText(); 
    154156     
    155     s.updateItems();     
     157    s.updateItems();    
     158    s.expandItem(id); 
    156159  } 
    157160  public void showOptions() { 
     
    481484    else return null; 
    482485  } 
     486  public Item getParentOf(String id_) { 
     487   if(sbg!=null) { 
     488     if(sbg.id.equals(id_)) return this; 
     489     else return null; 
     490   } 
     491   else return null; 
     492  } 
    483493} 
  • trunk/src/vlcskineditor/Layout.java

    r19 r32  
    151151    maxheight=maxh_; 
    152152    s.updateWindows(); 
     153    s.expandLayout(id); 
    153154  } 
    154155  public void showOptions() { 
     
    319320    return null; 
    320321  } 
    321   public java.util.List<Item> getParentOf(String id_) { 
     322  public java.util.List<Item> getParentListOf(String id_) { 
    322323    for(int x=0;x<items.size();x++) { 
    323324      Item i = items.get(x); 
    324       if(i.id.equals(id_)) { 
    325         System.out.println(id+": I is parent of "+id_); 
     325      if(i.id.equals(id_)) {         
    326326        return items;         
    327327      } 
    328328      if (i.type.equals("Group")||i.type.equals("Panel")) { 
    329         java.util.List<Item> p = i.getParentOf(id_); 
     329        java.util.List<Item> p = i.getParentListOf(id_); 
    330330        if (p!=null) return p; 
    331331      } 
     
    333333    return null; 
    334334  } 
     335  public Item getParentOf(String id_) { 
     336    for(int x=0;x<items.size();x++) { 
     337      Item i = items.get(x); 
     338      if(i.id.equals(id_)) {         
     339        return null;         
     340      } 
     341      Item it = i.getParentOf(id_); 
     342      if (it!=null) return it;       
     343    } 
     344    return null; 
     345  } 
    335346} 
  • trunk/src/vlcskineditor/Main.java

    r29 r32  
    922922      w.layouts.set(index,w.layouts.set(index-1,l)); 
    923923      s.updateWindows(); 
     924      s.expandLayout(l.id); 
    924925    } 
    925926    else if(e.getSource().equals(win_layout_down)) { 
     
    931932      w.layouts.set(index,w.layouts.set(index+1,l)); 
    932933      s.updateWindows(); 
     934      s.expandLayout(l.id); 
    933935    } 
    934936    //</editor-fold> 
     
    993995      Item i = s.getItem(selected_item); 
    994996      if(i==null) return; 
    995       java.util.List<Item> l = s.getParentOf(selected_item); 
     997      java.util.List<Item> l = s.getParentListOf(selected_item); 
     998      if(l==null) return; 
    996999      int index = l.indexOf(i); 
    9971000      if(index<=0) return;       
    9981001      l.set(index,l.set(index-1,i)); 
    999       s.updateItems(); 
     1002      s.updateItems();       
     1003      s.expandItem(selected_item); 
    10001004    } 
    10011005    else if(e.getSource().equals(items_down)) { 
    10021006      Item i = s.getItem(selected_item); 
    10031007      if(i==null) return; 
    1004       java.util.List<Item> l = s.getParentOf(selected_item); 
     1008      java.util.List<Item> l = s.getParentListOf(selected_item); 
    10051009      int index = l.indexOf(i); 
    10061010      if(index>=l.size()-1) return;       
    10071011      l.set(index,l.set(index+1,i)); 
    1008       s.updateItems(); 
     1012      s.updateItems();       
     1013      s.expandItem(selected_item); 
    10091014    } 
    10101015    //</editor-fold> 
     
    10201025    else if(e.getSource().equals(items_add_pu_anchor)) {       
    10211026      java.util.List<Item> i; 
    1022       if (selected_item!=null ) i = s.getParentOf(selected_item); 
     1027      if (selected_item!=null ) i = s.getParentListOf(selected_item); 
    10231028      else i = s.getWindow(selected_window).getLayout(selected_layout).items;        
    10241029      i.add(new Anchor(s));            
     
    10261031    else if(e.getSource().equals(items_add_pu_button)) {       
    10271032      java.util.List<Item> i; 
    1028       if (selected_item!=null ) i = s.getParentOf(selected_item); 
     1033      if (selected_item!=null ) i = s.getParentListOf(selected_item); 
    10291034      else i = s.getWindow(selected_window).getLayout(selected_layout).items;        
    10301035      i.add(new vlcskineditor.Items.Button(s));            
     
    10321037    else if(e.getSource().equals(items_add_pu_checkbox)) {       
    10331038      java.util.List<Item> i; 
    1034       if (selected_item!=null ) i = s.getParentOf(selected_item); 
     1039      if (selected_item!=null ) i = s.getParentListOf(selected_item); 
    10351040      else i = s.getWindow(selected_window).getLayout(selected_layout).items;        
    10361041      i.add(new vlcskineditor.Items.Checkbox(s));            
     
    10381043    else if(e.getSource().equals(items_add_pu_panel)) {       
    10391044      java.util.List<Item> i; 
    1040       if (selected_item!=null ) i = s.getParentOf(selected_item); 
     1045      if (selected_item!=null ) i = s.getParentListOf(selected_item); 
    10411046      else i = s.getWindow(selected_window).getLayout(selected_layout).items;        
    10421047      i.add(new vlcskineditor.Items.Panel(s));            
     
    10441049    else if(e.getSource().equals(items_add_pu_image)) {       
    10451050      java.util.List<Item> i; 
    1046       if (selected_item!=null ) i = s.getParentOf(selected_item); 
     1051      if (selected_item!=null ) i = s.getParentListOf(selected_item); 
    10471052      else i = s.getWindow(selected_window).getLayout(selected_layout).items;        
    10481053      i.add(new vlcskineditor.Items.Image(s));            
     
    10501055    else if(e.getSource().equals(items_add_pu_playtree)) {       
    10511056      java.util.List<Item> i; 
    1052       if (selected_item!=null ) i = s.getParentOf(selected_item); 
     1057      if (selected_item!=null ) i = s.getParentListOf(selected_item); 
    10531058      else i = s.getWindow(selected_window).getLayout(selected_layout).items;        
    10541059      i.add(new Playtree(s));            
     
    10561061    else if(e.getSource().equals(items_add_pu_slider)) {       
    10571062      java.util.List<Item> i; 
    1058       if (selected_item!=null ) i = s.getParentOf(selected_item); 
     1063      if (selected_item!=null ) i = s.getParentListOf(selected_item); 
    10591064      else i = s.getWindow(selected_window).getLayout(selected_layout).items;        
    10601065      i.add(new Slider(s));            
     
    10621067    else if(e.getSource().equals(items_add_pu_text)) {       
    10631068      java.util.List<Item> i; 
    1064       if (selected_item!=null ) i = s.getParentOf(selected_item); 
     1069      if (selected_item!=null ) i = s.getParentListOf(selected_item); 
    10651070      else i = s.getWindow(selected_window).getLayout(selected_layout).items;        
    10661071      i.add(new Text(s));            
     
    10681073    else if(e.getSource().equals(items_add_pu_video)) {       
    10691074      java.util.List<Item> i; 
    1070       if (selected_item!=null ) i = s.getParentOf(selected_item); 
     1075      if (selected_item!=null ) i = s.getParentListOf(selected_item); 
    10711076      else i = s.getWindow(selected_window).getLayout(selected_layout).items;        
    10721077      i.add(new Video(s));            
     
    11121117    else if(e.getSource().equals(items_del)) { 
    11131118      if(selected_item!=null) { 
    1114         java.util.List<Item> p = s.getParentOf(selected_item); 
     1119        java.util.List<Item> p = s.getParentListOf(selected_item); 
    11151120        if(p!=null) { 
    11161121          Object[] options= {"Yes","No"}; 
  • trunk/src/vlcskineditor/Resource.java

    r17 r32  
    4444  /** Creates a DefaultMutableTreeNode to be displayed in the resources tree */ 
    4545  public abstract DefaultMutableTreeNode getTreeNode();   
     46  /** If an Resource does contain another Resource of the given id (e.g. a SubBitmap) the containing Resource is returned **/ 
     47  public Resource getParentOf(String id_) { 
     48    return null; 
     49  } 
    4650} 
  • trunk/src/vlcskineditor/Resources/Bitmap.java

    r25 r32  
    9696    id = f_.getName().substring(0,f_.getName().lastIndexOf(".")); 
    9797    file = f_.getPath().replace(s.skinfolder,""); 
    98     s.updateResources(); 
     98    s.updateResources();     
    9999    update(); 
    100100  } 
     
    105105    file = ""; 
    106106    s.updateResources(); 
     107    s.expandResource(id); 
    107108    showOptions(); 
    108109  } 
     
    142143      id=id_; 
    143144      s.updateResources(); 
     145      s.expandResource(id); 
    144146    } 
    145147    update(); 
     
    323325    return node; 
    324326  } 
    325    
     327  public Resource getParentOf(String id_) { 
     328    for(SubBitmap sbmp:SubBitmaps) { 
     329      if(sbmp.id.equals(id_)) return this; 
     330    } 
     331    return null; 
     332  } 
    326333} 
  • trunk/src/vlcskineditor/Resources/Font.java

    r28 r32  
    142142    file=""; 
    143143    s.updateResources(); 
     144    s.expandResource(id); 
    144145    showOptions(); 
    145146  } 
     
    147148    type="Font";     
    148149    file=file_tf.getText(); 
    149     size=Integer.parseInt(size_tf.getText()); 
    150     s.updateResources(); 
     150    size=Integer.parseInt(size_tf.getText());     
    151151    if(!id_tf.getText().equals(id)) { 
    152152      id=id_tf.getText(); 
    153153      s.updateResources(); 
     154      s.expandResource(id); 
    154155    } 
    155156    try {       
  • trunk/src/vlcskineditor/Resources/SubBitmap.java

    r25 r32  
    7575    image = parent.getSubimage(x,y,width,height);     
    7676    s.updateResources();     
     77    s.expandResource(id); 
    7778  } 
    7879  public void update(BufferedImage parent_) { 
  • trunk/src/vlcskineditor/Skin.java

    r28 r32  
    450450  } 
    451451  /** Returns the parent element that contains the item of the given id **/ 
    452   public java.util.List<Item> getParentOf(String id_) { 
    453     return active_layout.getParentOf(id_);     
     452  public java.util.List<Item> getParentListOf(String id_) { 
     453    return active_layout.getParentListOf(id_);     
    454454  } 
    455455  /** Returns the list of the given Group/Panel that contains the items **/ 
     
    559559  } 
    560560  /** Recreates the resource hierarchies **/ 
    561   public void updateResources() {     
    562     m.res_tree_model.setRoot(getResourcesTree());     
     561  public void updateResources() {   
     562    m.res_tree_model.setRoot(getResourcesTree()); 
    563563    m.saved=false; 
     564  } 
     565  /** Make an Resource of the given id visible in the tree (expand the TreePath) **/ 
     566  public void expandResource(String id) {    
     567    Resource r = getResource(id); 
     568    if(r==null) return; 
     569    if(r.type.equals("Bitmap")) { 
     570      TreePath tp = findInTree(m.res_tree,"Root: Bitmaps"); 
     571      m.res_tree.expandPath(tp); 
     572    } 
     573    else if(r.type.equals("Font")) { 
     574      TreePath tp = findInTree(m.res_tree,"Root: Fonts"); 
     575      m.res_tree.expandPath(tp); 
     576    } 
     577    else { 
     578      System.err.println("Resource of the given id is neither a Font nor a Bitmap its a "+r.type); 
     579      return; 
     580    }    
     581    java.util.List<String> parents = new ArrayList<String>(); 
     582     
     583    Resource pr = r; 
     584    while(pr!=null) { 
     585      for(Resource res:resources) { 
     586        pr = res.getParentOf(r.id); 
     587        if(pr!=null) { 
     588          parents.add(pr.id); 
     589          break; 
     590        }         
     591      } 
     592    } 
     593    for(int i=parents.size()-1;i>=0;i--) {       
     594      TreePath tp = findInTree(m.res_tree,parents.get(i)); 
     595      if(tp==null) { 
     596        System.err.println("Could not find Parent: "+parents.get(i)); 
     597        return; 
     598      } 
     599      m.res_tree.expandPath(tp); 
     600      TreePath stp = findInTree(m.res_tree,id); 
     601      if(stp==null) return; 
     602      m.res_tree.setSelectionPath(stp); 
     603    }     
     604  } 
     605  /** Make a Layout of the given id visible **/ 
     606  public void expandLayout(String id) {    
     607    TreePath wtp = findInTree(m.win_tree,active_window.id); 
     608    if(wtp==null) return; 
     609    m.win_tree.expandPath(wtp); 
     610     
     611    TreePath ltp = findInTree(m.win_tree,id); 
     612    if(ltp==null) return; 
     613    m.win_tree.setSelectionPath(ltp); 
    564614  } 
    565615  /** Recreates the window hierarchies **/ 
     
    569619  } 
    570620  /** Recreates the item hierarchies **/ 
    571   public void updateItems() {     
     621  public void updateItems() { 
    572622    m.items_tree_model.setRoot(getItemsTree()); 
    573623    m.saved=false; 
    574   } 
    575   /** Redraws the preview window (deprecated already before it was used) 
    576    *  @Deprecated useless! Preview is now planned to be updated automatically every 1000/25 ms 
    577    **/ 
    578   @Deprecated public void updatePreview() { 
    579     /**empty*/ 
     624  }   
     625  /** Make an item of the given id visible in the tree (expand the TreePath) **/ 
     626  public void expandItem(String id) { 
     627    java.util.List<String> parents = new ArrayList<String>(); 
     628    Item p = getItem(id); 
     629    while((p=active_layout.getParentOf(p.id))!=null) {       
     630      parents.add(p.id); 
     631    } 
     632    for(int i=parents.size()-1;i>=0;i--) {       
     633      TreePath tp = findInTree(m.items_tree,parents.get(i)); 
     634      if(tp==null) { 
     635        System.err.println("Could not find Parent: "+parents.get(i)); 
     636        return; 
     637      } 
     638      m.items_tree.expandPath(tp); 
     639      TreePath stp = findInTree(m.items_tree,id); 
     640      if(stp==null) return; 
     641      m.items_tree.setSelectionPath(stp); 
     642    }     
     643  } 
     644  /** Finds the first occurence of id in the first expanded tree in the given JTree**/ 
     645  public TreePath findInTree(JTree jt, String id) {     
     646    int max = jt.getRowCount();          
     647    int row = 0; 
     648    do { 
     649        TreePath path = jt.getPathForRow(row); 
     650        String text = path.getLastPathComponent().toString(); 
     651        if (text.toUpperCase().indexOf(id.toUpperCase())!=-1) return path; 
     652        row = (row + 1 + max) % max; 
     653    } while (row != 0); 
     654    return null; 
    580655  } 
    581656  /** Updates everything **/ 
     
    583658    updateResources(); 
    584659    updateWindows(); 
    585     updateItems(); 
    586     updatePreview(); 
     660    updateItems();     
    587661    m.saved=false; 
    588662  }