Added book info edit option
This commit is contained in:
@@ -1 +1 @@
|
|||||||
version=0.1.1
|
version=0.1.2
|
||||||
|
|||||||
@@ -1054,6 +1054,40 @@ public class AudiobookRecorder extends JFrame {
|
|||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
menu.add(deleteChapter);
|
menu.add(deleteChapter);
|
||||||
|
|
||||||
|
menu.show(bookTree, e.getX(), e.getY());
|
||||||
|
} else if (node instanceof Book) {
|
||||||
|
JPopupMenu menu = new JPopupMenu();
|
||||||
|
|
||||||
|
JMenuItem editData = new JMenuItem("Edit Data...");
|
||||||
|
editData.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
BookInfoPanel info = new BookInfoPanel(
|
||||||
|
book.getName(),
|
||||||
|
book.getAuthor(),
|
||||||
|
book.getGenre(),
|
||||||
|
book.getComment(),
|
||||||
|
book.getACX()
|
||||||
|
);
|
||||||
|
int r = JOptionPane.showConfirmDialog(AudiobookRecorder.this, info, "Edit Book", JOptionPane.OK_CANCEL_OPTION);
|
||||||
|
if (r != JOptionPane.OK_OPTION) return;
|
||||||
|
|
||||||
|
String tit = info.getTitle();
|
||||||
|
String aut = info.getAuthor();
|
||||||
|
String gen = info.getGenre();
|
||||||
|
String com = info.getComment();
|
||||||
|
String acx = info.getACX();
|
||||||
|
|
||||||
|
book.setAuthor(aut);
|
||||||
|
book.setGenre(gen);
|
||||||
|
book.setComment(com);
|
||||||
|
book.setACX(acx);
|
||||||
|
if (!(book.getName().equals(tit))) {
|
||||||
|
book.renameBook(tit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
menu.add(editData);
|
||||||
|
|
||||||
menu.show(bookTree, e.getX(), e.getY());
|
menu.show(bookTree, e.getX(), e.getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
public String getAuthor() { return author; }
|
public String getAuthor() { return author; }
|
||||||
public String getGenre() { return genre; }
|
public String getGenre() { return genre; }
|
||||||
public String getComment() { return comment; }
|
public String getComment() { return comment; }
|
||||||
public String getACX() { return ACX; }
|
public String getACX() { if (ACX == null) return ""; return ACX; }
|
||||||
|
|
||||||
public Chapter getClosingCredits() {
|
public Chapter getClosingCredits() {
|
||||||
return getChapterById("close");
|
return getChapterById("close");
|
||||||
@@ -112,24 +112,28 @@ public class Book extends DefaultMutableTreeNode {
|
|||||||
public void setUserObject(Object o) {
|
public void setUserObject(Object o) {
|
||||||
if (o instanceof String) {
|
if (o instanceof String) {
|
||||||
String newName = (String)o;
|
String newName = (String)o;
|
||||||
|
if (newName.equals(name)) return;
|
||||||
|
renameBook(newName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
File oldDir = new File(Options.get("path.storage"), name);
|
public void renameBook(String newName) {
|
||||||
File newDir = new File(Options.get("path.storage"), newName);
|
File oldDir = new File(Options.get("path.storage"), name);
|
||||||
|
File newDir = new File(Options.get("path.storage"), newName);
|
||||||
|
|
||||||
if (newDir.exists()) {
|
if (newDir.exists()) {
|
||||||
JOptionPane.showMessageDialog(AudiobookRecorder.window, "Book already exists", "Error", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(AudiobookRecorder.window, "Book already exists", "Error", JOptionPane.ERROR_MESSAGE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldDir.exists() && oldDir.isDirectory()) {
|
if (oldDir.exists() && oldDir.isDirectory()) {
|
||||||
oldDir.renameTo(newDir);
|
oldDir.renameTo(newDir);
|
||||||
name = newName;
|
name = newName;
|
||||||
AudiobookRecorder.window.saveBookStructure();
|
AudiobookRecorder.window.saveBookStructure();
|
||||||
AudiobookRecorder.window.bookTreeModel.reload(this);
|
AudiobookRecorder.window.bookTreeModel.reload(this);
|
||||||
Options.set("path.last-book", name);
|
Options.set("path.last-book", name);
|
||||||
Options.savePreferences();
|
Options.savePreferences();
|
||||||
AudiobookRecorder.window.setTitle("AudioBook Recorder :: " + name);
|
AudiobookRecorder.window.setTitle("AudioBook Recorder :: " + name);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user