- /**
- * Import a {@link Story} into the main {@link LocalLibrary}.
- * <p>
- * Should be called inside the UI thread.
- *
- * @param askUrl
- * TRUE for an {@link URL}, false for a {@link File}
- */
- static public void imprt(final Container parent, boolean askUrl,
- final Runnable onSuccess) {
- JFileChooser fc = new JFileChooser();
-
- Object url;
- if (askUrl) {
- String clipboard = "";
- try {
- clipboard = ("" + Toolkit.getDefaultToolkit()
- .getSystemClipboard().getData(DataFlavor.stringFlavor))
- .trim();
- } catch (Exception e) {
- // No data will be handled
- }
-
- if (clipboard == null || !(clipboard.startsWith("http://") || //
- clipboard.startsWith("https://"))) {
- clipboard = "";
- }
-
- url = JOptionPane.showInputDialog(parent,
- Instance.getInstance().getTransGui()
- .getString(StringIdGui.SUBTITLE_IMPORT_URL),
- Instance.getInstance().getTransGui()
- .getString(StringIdGui.TITLE_IMPORT_URL),
- JOptionPane.QUESTION_MESSAGE, null, null, clipboard);
- } else if (fc.showOpenDialog(parent) != JFileChooser.CANCEL_OPTION) {
- url = fc.getSelectedFile().getAbsolutePath();
- } else {
- url = null;
- }
-
- if (url != null && !url.toString().isEmpty()) {
- imprt(parent, url.toString(), null, null);
- }
- }
-