Merge chapters (#1)
This commit is contained in:
BIN
resources/uk/co/majenko/audiobookrecorder/icons/star.png
Normal file
BIN
resources/uk/co/majenko/audiobookrecorder/icons/star.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
@@ -775,6 +775,32 @@ public class AudiobookRecorder extends JFrame {
|
||||
JMenuObject peak = new JMenuObject("Auto-trim all (Peak)", c);
|
||||
JMenuObject moveUp = new JMenuObject("Move Up", c);
|
||||
JMenuObject moveDown = new JMenuObject("Move Down", c);
|
||||
JMenu mergeWith = new JMenu("Merge chapter with");
|
||||
|
||||
for (Enumeration<Chapter> bc = book.children(); bc.hasMoreElements();) {
|
||||
Chapter chp = bc.nextElement();
|
||||
if (chp.getId().equals(c.getId())) {
|
||||
continue;
|
||||
}
|
||||
JMenuObject2 m = new JMenuObject2(chp.getName(), c, chp);
|
||||
m.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JMenuObject2 ob = (JMenuObject2)e.getSource();
|
||||
Chapter source = (Chapter)ob.getObject1();
|
||||
Chapter target = (Chapter)ob.getObject2();
|
||||
|
||||
DefaultMutableTreeNode n = source.getFirstLeaf();
|
||||
while (n instanceof Sentence) {
|
||||
bookTreeModel.removeNodeFromParent(n);
|
||||
bookTreeModel.insertNodeInto(n, target, target.getChildCount());
|
||||
n = source.getFirstLeaf();
|
||||
}
|
||||
}
|
||||
});
|
||||
mergeWith.add(m);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int idNumber = s2i(c.getId());
|
||||
|
||||
@@ -835,6 +861,9 @@ public class AudiobookRecorder extends JFrame {
|
||||
menu.add(moveUp);
|
||||
menu.add(moveDown);
|
||||
|
||||
menu.addSeparator();
|
||||
menu.add(mergeWith);
|
||||
|
||||
menu.addSeparator();
|
||||
|
||||
menu.add(peak);
|
||||
|
||||
@@ -10,12 +10,17 @@ public class BookTreeRenderer extends DefaultTreeCellRenderer {
|
||||
JLabel ret = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
|
||||
if (value instanceof Sentence) {
|
||||
Sentence s = (Sentence)value;
|
||||
|
||||
if (s.isLocked()) {
|
||||
ret.setForeground(new Color(0x20, 0x00, 0x00));
|
||||
ret.setIcon(Icons.locked);
|
||||
} else {
|
||||
ret.setIcon(Icons.sentence);
|
||||
}
|
||||
|
||||
if (s.isInSample()) {
|
||||
ret.setIcon(Icons.star);
|
||||
}
|
||||
} else if (value instanceof Chapter) {
|
||||
ret.setIcon(Icons.chapter);
|
||||
} else if (value instanceof Book) {
|
||||
|
||||
@@ -20,5 +20,6 @@ public class Icons {
|
||||
static public ImageIcon peak = new ImageIcon(Icons.class.getResource("icons/peak.png"));
|
||||
static public ImageIcon locked = new ImageIcon(Icons.class.getResource("icons/locked.png"));
|
||||
static public ImageIcon appIcon = new ImageIcon(Icons.class.getResource("icons/appIcon.png"));
|
||||
static public ImageIcon star = new ImageIcon(Icons.class.getResource("icons/star.png"));
|
||||
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ public class Sentence extends DefaultMutableTreeNode {
|
||||
|
||||
boolean recording;
|
||||
|
||||
boolean inSample;
|
||||
|
||||
TargetDataLine line;
|
||||
AudioInputStream inputStream;
|
||||
|
||||
@@ -520,4 +522,12 @@ public class Sentence extends DefaultMutableTreeNode {
|
||||
public boolean isLocked() {
|
||||
return locked;
|
||||
}
|
||||
|
||||
public void setInSample(boolean s) {
|
||||
inSample = s;
|
||||
}
|
||||
|
||||
public boolean isInSample() {
|
||||
return inSample;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user