git://git.nikiroo.be
/
nikiroo-utils.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Woopsie
[nikiroo-utils.git]
/
src
/
be
/
nikiroo
/
fanfix
/
reader
/
GuiReaderFrame.java
diff --git
a/src/be/nikiroo/fanfix/reader/GuiReaderFrame.java
b/src/be/nikiroo/fanfix/reader/GuiReaderFrame.java
index 3b5fca34bc9de09aeb2dadea9d67a3889dad9838..39db588bee8ff225974663a0f445ffb642f70610 100644
(file)
--- a/
src/be/nikiroo/fanfix/reader/GuiReaderFrame.java
+++ b/
src/be/nikiroo/fanfix/reader/GuiReaderFrame.java
@@
-22,6
+22,7
@@
import java.util.Map.Entry;
import javax.swing.BoxLayout;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.BoxLayout;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
+import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
@@
-29,6
+30,7
@@
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
+import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.SwingUtilities;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;
@@
-66,6
+68,21
@@
class GuiReaderFrame extends JFrame {
private GuiReaderBook selectedBook;
private boolean words; // words or authors (secondary info on books)
private GuiReaderBook selectedBook;
private boolean words; // words or authors (secondary info on books)
+ /**
+ * A {@link Runnable} with a {@link Story} parameter.
+ *
+ * @author niki
+ */
+ private interface StoryRunnable {
+ /**
+ * Run the action.
+ *
+ * @param story
+ * the story
+ */
+ public void run(Story story);
+ }
+
/**
* Create a new {@link GuiReaderFrame}.
*
/**
* Create a new {@link GuiReaderFrame}.
*
@@
-97,6
+114,12
@@
class GuiReaderFrame extends JFrame {
scroll.getVerticalScrollBar().setUnitIncrement(16);
add(scroll, BorderLayout.CENTER);
scroll.getVerticalScrollBar().setUnitIncrement(16);
add(scroll, BorderLayout.CENTER);
+ String message = reader.getLibrary().getLibraryName();
+ if (!message.isEmpty()) {
+ JLabel name = new JLabel(message, SwingConstants.CENTER);
+ add(name, BorderLayout.NORTH);
+ }
+
pgBar = new ProgressBar();
add(pgBar, BorderLayout.SOUTH);
pgBar = new ProgressBar();
add(pgBar, BorderLayout.SOUTH);
@@
-678,11
+701,16
@@
class GuiReaderFrame extends JFrame {
public void actionPerformed(ActionEvent e) {
if (selectedBook != null) {
final MetaData meta = selectedBook.getMeta();
public void actionPerformed(ActionEvent e) {
if (selectedBook != null) {
final MetaData meta = selectedBook.getMeta();
- imprt(meta.getUrl(), new Runnable() {
+ imprt(meta.getUrl(), new
Story
Runnable() {
@Override
@Override
- public void run() {
+ public void run(
Story story
) {
reader.delete(meta.getLuid());
GuiReaderFrame.this.selectedBook = null;
reader.delete(meta.getLuid());
GuiReaderFrame.this.selectedBook = null;
+ MetaData newMeta = story.getMeta();
+ if (!newMeta.getSource().equals(meta.getSource())) {
+ reader.changeType(newMeta.getLuid(),
+ meta.getSource());
+ }
}
}, "Removing old copy");
}
}
}, "Removing old copy");
}
@@
-882,7
+910,7
@@
class GuiReaderFrame extends JFrame {
* @param onSuccess
* Action to execute on success
*/
* @param onSuccess
* Action to execute on success
*/
- private void imprt(final String url, final Runnable onSuccess,
+ private void imprt(final String url, final
Story
Runnable onSuccess,
String onSuccessPgName) {
final Progress pg = new Progress();
final Progress pgImprt = new Progress();
String onSuccessPgName) {
final Progress pg = new Progress();
final Progress pgImprt = new Progress();
@@
-894,8
+922,10
@@
class GuiReaderFrame extends JFrame {
@Override
public void run() {
Exception ex = null;
@Override
public void run() {
Exception ex = null;
+ Story story = null;
try {
try {
- reader.getLibrary().imprt(BasicReader.getUrl(url), pgImprt);
+ story = reader.getLibrary().imprt(BasicReader.getUrl(url),
+ pgImprt);
} catch (IOException e) {
ex = e;
}
} catch (IOException e) {
ex = e;
}
@@
-917,7
+947,7
@@
class GuiReaderFrame extends JFrame {
});
} else {
if (onSuccess != null) {
});
} else {
if (onSuccess != null) {
- onSuccess.run();
+ onSuccess.run(
story
);
}
}
pgOnSuccess.done();
}
}
pgOnSuccess.done();