Changeset 96

Show
Ignore:
Timestamp:
10/02/08 10:45:01 (10 months ago)
Author:
altglass
Message:

Everything can be duplicated

Files:

Legend:

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

    r89 r96  
    129129    return false; 
    130130  } 
     131  /** Renames the item after the copy process **/ 
     132  public void renameForCopy(String p) {     
     133    p = p.replaceAll("%oldid%", id);      
     134    String newid_base = p;      
     135    String newid = newid_base; 
     136    int i = 1; 
     137    while(s.idExists(newid)) { 
     138      i++; 
     139      newid = newid_base+"_"+String.valueOf(i); 
     140    } 
     141    id = newid; 
     142  } 
    131143} 
  • trunk/src/vlcskineditor/Layout.java

    r89 r96  
    446446    return false; 
    447447  } 
     448  /** Renames the Layout and all its content after the copy process **/ 
     449  public void renameForCopy(String p) { 
     450    String p_ = p; 
     451    p = p.replaceAll("%oldid%", id);      
     452    String newid_base = p;      
     453    String newid = newid_base; 
     454    int i = 1; 
     455    while(s.idExists(newid)) { 
     456      i++; 
     457      newid = newid_base+"_"+String.valueOf(i); 
     458    } 
     459    id = newid; 
     460    for(Item it:items) { 
     461        it.renameForCopy(p_); 
     462    } 
     463  } 
    448464} 
  • trunk/src/vlcskineditor/Main.java

    r92 r96  
    2828import java.io.*; 
    2929import javax.swing.*; 
    30 import javax.swing.filechooser.*; 
    3130import javax.swing.tree.*; 
    3231import javax.swing.event.*; 
    3332import javax.swing.border.*; 
    3433import java.util.zip.*; 
    35 import javax.imageio.*;  
    3634import vlcskineditor.items.*; 
    3735import com.ice.tar.*; 
     
    6664  JPopupMenu res_add_bitmap_pu; 
    6765  JMenuItem res_add_bitmap_pu_b, res_add_bitmap_pu_s; 
    68   JButton win_add_window, win_add_layout, win_layout_up, win_layout_down, win_edit, win_del;   
    69   JButton items_add, items_up, items_down, items_edit, items_del; 
     66  JButton win_add_window, win_add_layout, win_layout_up, win_layout_down, win_duplicate, win_edit, win_del;   
     67  JButton items_add, items_up, items_down, items_duplicate, items_edit, items_del; 
    7068  JPopupMenu items_add_pu;   
    7169  JMenu items_add_pu_tp; 
     
    245243    resources = new JInternalFrame("Resources",true,false);     
    246244    resources.setFrameIcon(resources_icon); 
    247     resources.setMinimumSize(new Dimension(150,200));     
     245    resources.setMinimumSize(new Dimension(190,200));     
    248246    SpringLayout res_layout = new SpringLayout(); 
    249247    resources.setLayout(res_layout);      
     
    271269    res_add_font.addActionListener(this); 
    272270    res_duplicate = new JButton("",copy_icon); 
    273     res_duplicate.setToolTipText("Create copy of the selected item"); 
     271    res_duplicate.setToolTipText("Create a copy of the selected resource"); 
    274272    res_duplicate.setPreferredSize(new Dimension(24,24)); 
    275273    res_duplicate.addActionListener(this); 
     
    311309     
    312310    resources.pack(); 
    313     resources.setSize(200,200); 
     311    resources.setSize(190,200); 
    314312    resources.setVisible(true);     
    315313     
    316314    windows = new JInternalFrame("Windows",true,false);  
    317315    windows.setFrameIcon(windows_icon); 
    318     windows.setMinimumSize(new Dimension(150,150));    
     316    windows.setMinimumSize(new Dimension(190,150));    
    319317    SpringLayout win_layout = new SpringLayout(); 
    320318    windows.setLayout(win_layout);      
     
    351349    win_layout_down.setPreferredSize(new Dimension(24,12)); 
    352350    win_layout_down.addActionListener(this); 
     351    win_duplicate = new JButton("",copy_icon); 
     352    win_duplicate.setToolTipText("Create a copy of the selected window or layout"); 
     353    win_duplicate.setMaximumSize(new Dimension(24,24)); 
     354    win_duplicate.setPreferredSize(new Dimension(24,24)); 
     355    win_duplicate.addActionListener(this); 
    353356    win_edit = new JButton("",edit_icon); 
    354357    win_edit.setToolTipText("Edit the selected resource"); 
     
    363366    windows.add(win_add_window); 
    364367    windows.add(win_add_layout); 
     368    windows.add(win_duplicate); 
    365369    windows.add(win_edit); 
    366370    windows.add(win_layout_up); 
     
    373377    win_layout.putConstraint(SpringLayout.NORTH, win_add_layout,5,SpringLayout.SOUTH, win_tree_sp); 
    374378    win_layout.putConstraint(SpringLayout.NORTH, win_layout_up,5,SpringLayout.SOUTH, win_tree_sp); 
    375     win_layout.putConstraint(SpringLayout.NORTH, win_edit,5,SpringLayout.SOUTH, win_tree_sp); 
    376     win_layout.putConstraint(SpringLayout.NORTH, win_del,5,SpringLayout.SOUTH, win_tree_sp);     
    377     win_layout.putConstraint(SpringLayout.NORTH, win_add_window,5,SpringLayout.SOUTH, win_tree_sp); 
    378     win_layout.putConstraint(SpringLayout.NORTH, win_add_layout,5,SpringLayout.SOUTH, win_tree_sp); 
    379     win_layout.putConstraint(SpringLayout.NORTH, win_layout_up,5,SpringLayout.SOUTH, win_tree_sp); 
    380     win_layout.putConstraint(SpringLayout.NORTH, win_layout_down,0,SpringLayout.SOUTH, win_layout_up); 
     379    win_layout.putConstraint(SpringLayout.NORTH, win_layout_down,0,SpringLayout.SOUTH, win_layout_up);     
     380    win_layout.putConstraint(SpringLayout.NORTH, win_duplicate,5,SpringLayout.SOUTH, win_tree_sp); 
    381381    win_layout.putConstraint(SpringLayout.NORTH, win_edit,5,SpringLayout.SOUTH, win_tree_sp);     
    382382    win_layout.putConstraint(SpringLayout.NORTH, win_del,5,SpringLayout.SOUTH, win_tree_sp); 
     
    385385    win_layout.putConstraint(SpringLayout.WEST, win_layout_up,5,SpringLayout.EAST, win_add_layout); 
    386386    win_layout.putConstraint(SpringLayout.WEST, win_layout_down,5,SpringLayout.EAST, win_add_layout); 
    387     win_layout.putConstraint(SpringLayout.WEST, win_edit,5,SpringLayout.EAST, win_layout_up); 
     387    win_layout.putConstraint(SpringLayout.WEST, win_duplicate,5,SpringLayout.EAST, win_layout_up); 
     388    win_layout.putConstraint(SpringLayout.WEST, win_edit,5,SpringLayout.EAST, win_duplicate); 
    388389    win_layout.putConstraint(SpringLayout.WEST, win_del,5,SpringLayout.EAST, win_edit);     
    389390    win_layout.putConstraint(SpringLayout.SOUTH, windows.getContentPane(),24+5+5,SpringLayout.SOUTH, win_tree_sp); 
     
    392393     
    393394    windows.pack(); 
    394     windows.setSize(200,150); 
     395    windows.setSize(190,150); 
    395396    windows.setVisible(true);    
    396397     
    397398    items = new JInternalFrame("Items",true,false);    
    398399    items.setFrameIcon(items_icon); 
    399     items.setMinimumSize(new Dimension(150,150));    
     400    items.setMinimumSize(new Dimension(190,150));    
    400401    SpringLayout items_layout = new SpringLayout(); 
    401402    items.setLayout(items_layout);      
     
    427428    items_down.setPreferredSize(new Dimension(24,12)); 
    428429    items_down.addActionListener(this); 
     430    items_duplicate = new JButton("",copy_icon); 
     431    items_duplicate.setToolTipText("Create a copy of the selected resource"); 
     432    items_duplicate.setMaximumSize(new Dimension(24,24)); 
     433    items_duplicate.setPreferredSize(new Dimension(24,24)); 
     434    items_duplicate.addActionListener(this); 
    429435    items_edit = new JButton("",edit_icon); 
    430     items_edit.setToolTipText("Edit the selected resource"); 
     436    items_edit.setToolTipText("Edit the selected item"); 
    431437    items_edit.setMaximumSize(new Dimension(24,24)); 
    432438    items_edit.setPreferredSize(new Dimension(24,24)); 
    433439    items_edit.addActionListener(this); 
    434440    items_del = new JButton("",delete_icon); 
    435     items_del.setToolTipText("Delete the selected resource"); 
     441    items_del.setToolTipText("Delete the selected item"); 
    436442    items_del.setMaximumSize(new Dimension(24,24)); 
    437443    items_del.setPreferredSize(new Dimension(24,24)); 
     
    440446    items.add(items_up); 
    441447    items.add(items_down); 
     448    items.add(items_duplicate); 
    442449    items.add(items_edit); 
    443450    items.add(items_del);         
    444451     
    445452    items_layout.putConstraint(SpringLayout.WEST, items_tree_sp,5,SpringLayout.WEST, items.getContentPane());    
    446     items_layout.putConstraint(SpringLayout.NORTH, items_tree_sp,5,SpringLayout.NORTH, items.getContentPane());         
    447     items_layout.putConstraint(SpringLayout.NORTH, items_add,5,SpringLayout.SOUTH, items_tree_sp); 
    448     items_layout.putConstraint(SpringLayout.NORTH, items_up,5,SpringLayout.SOUTH, items_tree_sp); 
    449     items_layout.putConstraint(SpringLayout.NORTH, items_edit,5,SpringLayout.SOUTH, items_tree_sp); 
    450     items_layout.putConstraint(SpringLayout.NORTH, items_del,5,SpringLayout.SOUTH, items_tree_sp);     
     453    items_layout.putConstraint(SpringLayout.NORTH, items_tree_sp,5,SpringLayout.NORTH, items.getContentPane());            
    451454    items_layout.putConstraint(SpringLayout.NORTH, items_add,5,SpringLayout.SOUTH, items_tree_sp); 
    452455    items_layout.putConstraint(SpringLayout.NORTH, items_up,5,SpringLayout.SOUTH, items_tree_sp); 
    453456    items_layout.putConstraint(SpringLayout.NORTH, items_down,0,SpringLayout.SOUTH, items_up); 
     457    items_layout.putConstraint(SpringLayout.NORTH, items_duplicate,5,SpringLayout.SOUTH, items_tree_sp); 
    454458    items_layout.putConstraint(SpringLayout.NORTH, items_edit,5,SpringLayout.SOUTH, items_tree_sp); 
    455459    items_layout.putConstraint(SpringLayout.NORTH, items_del,5,SpringLayout.SOUTH, items_tree_sp); 
     
    457461    items_layout.putConstraint(SpringLayout.WEST, items_up,5,SpringLayout.EAST, items_add); 
    458462    items_layout.putConstraint(SpringLayout.WEST, items_down,5,SpringLayout.EAST, items_add); 
    459     items_layout.putConstraint(SpringLayout.WEST, items_edit,5,SpringLayout.EAST, items_up); 
     463    items_layout.putConstraint(SpringLayout.WEST, items_duplicate,5,SpringLayout.EAST, items_up); 
     464    items_layout.putConstraint(SpringLayout.WEST, items_edit,5,SpringLayout.EAST, items_duplicate); 
    460465    items_layout.putConstraint(SpringLayout.WEST, items_edit,5,SpringLayout.EAST, items_down); 
    461466    items_layout.putConstraint(SpringLayout.WEST, items_del,5,SpringLayout.EAST, items_edit);     
     
    465470     
    466471    items.pack(); 
    467     items.setSize(200,200); 
     472    items.setSize(190,200); 
    468473    items.setVisible(true);  
    469474     
     
    10271032      Resource r = s.getResource(selected_resource); 
    10281033      if(r==null) return; 
     1034      String p = JOptionPane.showInputDialog(this, "Please enter the rename pattern for the duplicated object.\n" + 
     1035                "%oldid% will be replaced by the old ID of the resource.", "%oldid%_copy"); 
    10291036      if(r.getClass()==Bitmap.class) { 
    10301037        Bitmap b = (Bitmap)r;         
    1031         Bitmap b2 = new Bitmap(b.returnCode(),s); 
    1032         b2.renameForCopy(); 
     1038        Bitmap b2 = new Bitmap(b.returnCode(),s);         
     1039        b2.renameForCopy(p); 
    10331040        s.resources.add(b2); 
    10341041        s.updateResources(); 
     
    10381045        SubBitmap sb = (SubBitmap)r;         
    10391046        SubBitmap sb2 = new SubBitmap(sb.returnCode(),s,sb.getParentBitmap()); 
    1040         sb2.renameForCopy(); 
     1047        sb2.renameForCopy(p); 
    10411048        sb.getParentBitmap().SubBitmaps.add(sb2); 
    10421049        s.updateResources(); 
     
    10461053        vlcskineditor.resources.Font f = (vlcskineditor.resources.Font)r;         
    10471054        vlcskineditor.resources.Font f2 = new vlcskineditor.resources.Font(f.returnCode(),s); 
    1048         f2.renameForCopy(); 
     1055        f2.renameForCopy(p); 
    10491056        s.resources.add(f2); 
    10501057        s.updateResources(); 
    10511058        s.expandResource(f.id); 
    10521059      } 
     1060    } 
     1061    // </editor-fold> 
     1062    // <editor-fold defaultstate="collapsed" desc="Duplicate window/layout"> 
     1063    else if(e.getSource().equals(win_duplicate)) { 
     1064        if(selected_window==null) return; 
     1065        String p = JOptionPane.showInputDialog(this, "Please enter the rename pattern for the duplicated object.\n" + 
     1066                "%oldid% will be replaced by the old ID of the resource.", "%oldid%_copy"); 
     1067        if(selected_layout==null) { 
     1068            Window w = s.getWindow(selected_window); 
     1069            if(w==null) return; 
     1070            Window w_ = new Window(w.returnCode(), s); 
     1071            w_.renameForCopy(p); 
     1072            s.windows.add(w_); 
     1073            s.updateWindows(); 
     1074        } 
     1075        else { 
     1076            Window w = s.getWindow(selected_window); 
     1077            Layout l = w.getLayout(selected_layout); 
     1078            Layout l_ = new Layout(l.returnCode(), w, s); 
     1079            l_.renameForCopy(p); 
     1080            w.layouts.add(l_); 
     1081            s.updateWindows(); 
     1082            s.expandLayout(l_.id); 
     1083        } 
     1084    } 
     1085    // </editor-fold> 
     1086    // <editor-fold defaultstate="collapsed" desc="Duplicate item"> 
     1087    else if(e.getSource().equals(items_duplicate)) { 
     1088        if(selected_item==null) return; 
     1089        String p = JOptionPane.showInputDialog(this, "Please enter the rename pattern for the duplicated object.\n" + 
     1090                "%oldid% will be replaced by the old ID of the resource.", "%oldid%_copy"); 
     1091        Item i = s.getItem(selected_item); 
     1092        if(i==null) return;         
     1093        if(i.getClass()==Anchor.class) { 
     1094            Anchor a = new Anchor(i.returnCode(), s); 
     1095            //Because IDs of Anchors are not stored in the XML and can thus not be copied via returnCode() 
     1096            a.id = i.id; 
     1097            a.renameForCopy(p); 
     1098            s.getParentListOf(i.id).add(a); 
     1099            s.updateItems(); 
     1100            s.expandItem(a.id); 
     1101        } 
     1102        else if(i.getClass()==vlcskineditor.items.Button.class) { 
     1103            vlcskineditor.items.Button b = new vlcskineditor.items.Button(i.returnCode(), s); 
     1104            b.renameForCopy(p); 
     1105            s.getParentListOf(i.id).add(b); 
     1106            s.updateItems(); 
     1107            s.expandItem(b.id); 
     1108        } 
     1109        else if(i.getClass()==vlcskineditor.items.Checkbox.class) { 
     1110            vlcskineditor.items.Checkbox c = new vlcskineditor.items.Checkbox(i.returnCode(), s); 
     1111            c.renameForCopy(p); 
     1112            s.getParentListOf(i.id).add(c); 
     1113            s.updateItems(); 
     1114            s.expandItem(c.id); 
     1115        } 
     1116        else if(i.getClass()==Group.class) { 
     1117            Group g = new Group(i.returnCode(), s); 
     1118            g.renameForCopy(p); 
     1119            s.getParentListOf(i.id).add(g); 
     1120            s.updateItems(); 
     1121            s.expandItem(g.id); 
     1122        }         
     1123        else if(i.getClass()==vlcskineditor.items.Image.class) { 
     1124            vlcskineditor.items.Image im = new vlcskineditor.items.Image(i.returnCode(), s); 
     1125            im.renameForCopy(p); 
     1126            s.getParentListOf(i.id).add(im); 
     1127            s.updateItems(); 
     1128            s.expandItem(im.id); 
     1129        } 
     1130        else if(i.getClass()==vlcskineditor.items.Panel.class) { 
     1131            vlcskineditor.items.Panel pa = new vlcskineditor.items.Panel(i.returnCode(), s); 
     1132            pa.renameForCopy(p); 
     1133            s.getParentListOf(i.id).add(pa); 
     1134            s.updateItems(); 
     1135            s.expandItem(pa.id); 
     1136        } 
     1137        else if(i.getClass()==Playtree.class) { 
     1138            Playtree pl = new Playtree(i.returnCode(), s); 
     1139            pl.renameForCopy(p); 
     1140            s.getParentListOf(i.id).add(pl); 
     1141            s.updateItems(); 
     1142            s.expandItem(pl.id); 
     1143        } 
     1144        else if(i.getClass()==RadialSlider.class) { 
     1145            RadialSlider r = new RadialSlider(i.returnCode(), s); 
     1146            r.renameForCopy(p); 
     1147            s.getParentListOf(i.id).add(r); 
     1148            s.updateItems(); 
     1149            s.expandItem(r.id); 
     1150        } 
     1151        else if(i.getClass()==Slider.class) { 
     1152            Slider sl = new Slider(i.returnCode(), s); 
     1153            sl.renameForCopy(p); 
     1154            java.util.List<Item> l = s.getParentListOf(i.id); 
     1155            if(l!=null) { 
     1156                l.add(sl); 
     1157                s.updateItems(); 
     1158                s.expandItem(sl.id); 
     1159            } 
     1160            else { 
     1161                //The selected slider seems to be in a playtree 
     1162                JOptionPane.showMessageDialog(this,"A PlayTree cannot contain more than one slider!","Slider could not be duplicated",JOptionPane.INFORMATION_MESSAGE);  
     1163            }             
     1164        } 
     1165        else if(i.getClass()==SliderBackground.class) { 
     1166           //A slider can only have one slider background! 
     1167           JOptionPane.showMessageDialog(this,"A slider cannot contain more than one background!","SliderBackgrounds cannot be duplicated",JOptionPane.INFORMATION_MESSAGE);  
     1168        } 
     1169        else if(i.getClass()==Text.class) { 
     1170            Text t = new Text(i.returnCode(), s); 
     1171            t.renameForCopy(p); 
     1172            s.getParentListOf(i.id).add(t); 
     1173            s.updateItems(); 
     1174            s.expandItem(t.id); 
     1175        } 
     1176        else if(i.getClass()==Video.class) { 
     1177            Video v = new Video(i.returnCode(), s); 
     1178            v.renameForCopy(p); 
     1179            s.getParentListOf(i.id).add(v); 
     1180            s.updateItems(); 
     1181            s.expandItem(v.id); 
     1182        }         
    10531183    } 
    10541184    // </editor-fold> 
  • trunk/src/vlcskineditor/Resource.java

    r91 r96  
    5151  } 
    5252  /** Renames the Resource after the copy process **/ 
    53   public void renameForCopy() { 
    54     if(id.indexOf("_copy")!=-1) { 
    55       id = id.substring(0,id.indexOf("_copy")); 
    56     }  
    57     String newid_base = id+="_copy";      
     53  public void renameForCopy(String p) {     
     54    p = p.replaceAll("%oldid%", id);      
     55    String newid_base = p;      
    5856    String newid = newid_base; 
    5957    int i = 1; 
  • trunk/src/vlcskineditor/Window.java

    r72 r96  
    288288    return node; 
    289289  } 
     290  /** Renames the Layout and all its content after the copy process **/ 
     291  public void renameForCopy(String p) {  
     292    String p_ = p; 
     293    p = p.replaceAll("%oldid%", id);      
     294    String newid_base = p;      
     295    String newid = newid_base; 
     296    int i = 1; 
     297    while(s.idExists(newid)) { 
     298      i++; 
     299      newid = newid_base+"_"+String.valueOf(i); 
     300    } 
     301    id = newid; 
     302    for(Layout l:layouts) { 
     303        l.renameForCopy(p_); 
     304    } 
     305  } 
    290306} 
  • trunk/src/vlcskineditor/items/Group.java

    r92 r96  
    317317    return false; 
    318318  } 
     319  @Override   
     320  public void renameForCopy(String p) {     
     321    String p_ = p; 
     322    super.renameForCopy(p); 
     323    for(Item i:items) { 
     324        i.renameForCopy(p_); 
     325    } 
     326  } 
    319327} 
  • trunk/src/vlcskineditor/items/Panel.java

    r92 r96  
    435435    return false; 
    436436  } 
     437  @Override   
     438  public void renameForCopy(String p) {     
     439    String p_ = p; 
     440    super.renameForCopy(p); 
     441    for(Item i:items) { 
     442        i.renameForCopy(p_); 
     443    } 
     444  } 
    437445} 
  • trunk/src/vlcskineditor/items/Playtree.java

    r92 r96  
    761761    return (((slider!=null)?slider.uses(id_):false)||bgimage.equals(id_)||openimage.equals(id_)||closedimage.equals(id_)||itemimage.equals(id_)||font.equals(id_)); 
    762762  } 
     763  @Override   
     764  public void renameForCopy(String p) {     
     765    String p_ = p; 
     766    super.renameForCopy(p); 
     767    slider.renameForCopy(p_); 
     768  } 
    763769} 
  • trunk/src/vlcskineditor/items/Slider.java

    r92 r96  
    601601    return(((sbg!=null)?sbg.uses(id_):false)||up.equals(id_)||over.equals(id_)||down.equals(id_)); 
    602602  } 
     603  @Override   
     604  public void renameForCopy(String p) {     
     605    String p_ = p; 
     606    super.renameForCopy(p); 
     607    sbg.renameForCopy(p_); 
     608  } 
    603609} 
  • trunk/src/vlcskineditor/resources/Bitmap.java

    r92 r96  
    382382  } 
    383383  @Override 
    384   public void renameForCopy() { 
    385     super.renameForCopy(); 
    386     for(SubBitmap sb:SubBitmaps) sb.renameForCopy(); 
     384  public void renameForCopy(String p) { 
     385    String p_ = p; 
     386    super.renameForCopy(p); 
     387    for(SubBitmap sb:SubBitmaps) sb.renameForCopy(p_); 
    387388  } 
    388389}