1
package org.herac.tuxguitar.gui.editors.chord;
6
import org.herac.tuxguitar.gui.editors.chord.xml.ChordReader;
7
import org.herac.tuxguitar.gui.editors.chord.xml.ChordWriter;
8
import org.herac.tuxguitar.gui.util.TuxGuitarFileUtils;
9
import org.herac.tuxguitar.song.models.Chord;
11
public class CustomChordManager {
12
private long lastEdit;
15
public CustomChordManager(){
16
this.chords = ChordReader.getChords(getUserFileName());
20
public int countChords(){
21
return this.chords.size();
24
public Chord getChord(int index){
25
if(index >= 0 && index < countChords()){
26
return ((Chord)((Chord)this.chords.get(index)).clone());
31
public void addChord(Chord chord){
32
this.chords.add(chord);
36
public void removeChord(int index){
37
if(index >= 0 && index < countChords()){
38
this.chords.remove(index);
43
public void renameChord(int index,String name){
44
if(index >= 0 && index < countChords()){
45
((Chord)this.chords.get(index)).setName(name);
50
public boolean existOtherEqualCustomChord(String name,int index){
51
for(int i = 0;i < countChords();i ++){
52
Chord chord = getChord(i);
53
if(chord.getName().equals(name) && index != i){
61
ChordWriter.setChords(chords,getUserFileName());
64
private static String getUserFileName(){
65
return TuxGuitarFileUtils.USER_CONFIG_PREFIX + File.separator + "customchords.xml";
68
private void setLastEdit(){
69
this.lastEdit = System.currentTimeMillis();
72
public long getLastEdit(){