reformat
authorNiki Roo <niki@nikiroo.be>
Thu, 9 Apr 2020 16:41:31 +0000 (18:41 +0200)
committerNiki Roo <niki@nikiroo.be>
Thu, 9 Apr 2020 16:41:31 +0000 (18:41 +0200)
16 files changed:
src/be/nikiroo/fanfix_swing/Actions.java
src/be/nikiroo/fanfix_swing/Main.java
src/be/nikiroo/fanfix_swing/gui/BrowserPanel.java
src/be/nikiroo/fanfix_swing/gui/DetailsPanel.java
src/be/nikiroo/fanfix_swing/gui/MainFrame.java
src/be/nikiroo/fanfix_swing/gui/book/BookBlock.java
src/be/nikiroo/fanfix_swing/gui/book/BookCoverImager.java
src/be/nikiroo/fanfix_swing/gui/book/BookInfo.java
src/be/nikiroo/fanfix_swing/gui/book/BookLine.java
src/be/nikiroo/fanfix_swing/gui/book/BookPopup.java
src/be/nikiroo/fanfix_swing/gui/browser/AuthorTab.java
src/be/nikiroo/fanfix_swing/gui/browser/BasicTab.java
src/be/nikiroo/fanfix_swing/gui/browser/SourceTab.java
src/be/nikiroo/fanfix_swing/gui/browser/TagsTab.java
src/be/nikiroo/fanfix_swing/gui/utils/UiHelper.java
src/be/nikiroo/fanfix_swing/images/IconGenerator.java

index 5df9b2eb84f64894d15bc8c98aba84eed9096a63..10c79dd1d9cd82ff37ceffb8911f6105fc39cb18 100644 (file)
@@ -28,8 +28,8 @@ import be.nikiroo.fanfix_swing.gui.utils.UiHelper;
 import be.nikiroo.utils.Progress;
 
 public class Actions {
-       static public void openExternal(final BasicLibrary lib, MetaData meta, final Container parent,
-                       final Runnable onDone) {
+       static public void openExternal(final BasicLibrary lib, MetaData meta,
+                       final Container parent, final Runnable onDone) {
                Container parentWindow = parent;
                while (!(parentWindow instanceof Window) && parentWindow != null) {
                        parentWindow = parentWindow.getParent();
@@ -82,7 +82,8 @@ public class Actions {
                                        openExternal(target, isImageDocument);
                                } catch (Exception e) {
                                        // TODO: i18n
-                                       UiHelper.error(parent, e.getLocalizedMessage(), "Cannot open the story", e);
+                                       UiHelper.error(parent, e.getLocalizedMessage(),
+                                                       "Cannot open the story", e);
                                }
 
                                synchronized (waitLock) {
@@ -102,21 +103,26 @@ public class Actions {
        }
 
        /**
-        * Open the {@link Story} with an external reader (the program will be passed
-        * the given target file).
+        * Open the {@link Story} with an external reader (the program will be
+        * passed the given target file).
         * 
-        * @param target          the target {@link File}
-        * @param isImageDocument TRUE for image documents, FALSE for not-images
-        *                        documents
+        * @param target
+        *            the target {@link File}
+        * @param isImageDocument
+        *            TRUE for image documents, FALSE for not-images documents
         * 
-        * @throws IOException in case of I/O error
+        * @throws IOException
+        *             in case of I/O error
         */
-       static public void openExternal(File target, boolean isImageDocument) throws IOException {
+       static public void openExternal(File target, boolean isImageDocument)
+                       throws IOException {
                String program = null;
                if (isImageDocument) {
-                       program = Instance.getInstance().getUiConfig().getString(UiConfig.IMAGES_DOCUMENT_READER);
+                       program = Instance.getInstance().getUiConfig()
+                                       .getString(UiConfig.IMAGES_DOCUMENT_READER);
                } else {
-                       program = Instance.getInstance().getUiConfig().getString(UiConfig.NON_IMAGES_DOCUMENT_READER);
+                       program = Instance.getInstance().getUiConfig()
+                                       .getString(UiConfig.NON_IMAGES_DOCUMENT_READER);
                }
 
                if (program != null && program.trim().isEmpty()) {
@@ -127,35 +133,46 @@ public class Actions {
        }
 
        /**
-        * Start a file and open it with the given program if given or the first default
-        * system starter we can find.
+        * Start a file and open it with the given program if given or the first
+        * default system starter we can find.
         * 
-        * @param target  the target to open
-        * @param program the program to use or NULL for the default system starter
-        * @param sync    execute the process synchronously (wait until it is terminated
-        *                before returning)
+        * @param target
+        *            the target to open
+        * @param program
+        *            the program to use or NULL for the default system starter
+        * @param sync
+        *            execute the process synchronously (wait until it is terminated
+        *            before returning)
         * 
-        * @throws IOException in case of I/O error
+        * @throws IOException
+        *             in case of I/O error
         */
-       static protected void start(File target, String program, boolean sync) throws IOException {
+       static protected void start(File target, String program, boolean sync)
+                       throws IOException {
                Process proc = null;
                if (program == null) {
                        boolean ok = false;
-                       for (String starter : new String[] { "xdg-open", "open", "see", "start", "run" }) {
+                       for (String starter : new String[] { "xdg-open", "open", "see",
+                                       "start", "run" }) {
                                try {
-                                       Instance.getInstance().getTraceHandler().trace("starting external program");
-                                       proc = Runtime.getRuntime().exec(new String[] { starter, target.getAbsolutePath() });
+                                       Instance.getInstance().getTraceHandler()
+                                                       .trace("starting external program");
+                                       proc = Runtime.getRuntime().exec(
+                                                       new String[] { starter, target.getAbsolutePath() });
                                        ok = true;
                                        break;
                                } catch (IOException e) {
                                }
                        }
                        if (!ok) {
-                               throw new IOException("Cannot find a program to start the file");
+                               throw new IOException(
+                                               "Cannot find a program to start the file");
                        }
                } else {
-                       Instance.getInstance().getTraceHandler().trace("starting external program");
-                       proc = Runtime.getRuntime().exec(new String[] { program, target.getAbsolutePath() });
+                       Instance.getInstance().getTraceHandler()
+                                       .trace("starting external program");
+                       proc = Runtime.getRuntime()
+                                       .exec(new String[] { program, target.getAbsolutePath() });
                }
 
                if (proc != null && sync) {
@@ -171,17 +188,20 @@ public class Actions {
         * <p>
         * Should be called inside the UI thread.
         * 
-        * @param askUrl TRUE for an {@link URL}, false for a {@link File}
+        * @param askUrl
+        *            TRUE for an {@link URL}, false for a {@link File}
         */
-       static public void imprt(final Container parent, boolean askUrl, final Runnable onSuccess) {
+       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();
+                               clipboard = ("" + Toolkit.getDefaultToolkit()
+                                               .getSystemClipboard().getData(DataFlavor.stringFlavor))
+                                                               .trim();
                        } catch (Exception e) {
                                // No data will be handled
                        }
@@ -192,8 +212,10 @@ public class Actions {
                        }
 
                        url = JOptionPane.showInputDialog(parent,
-                                       Instance.getInstance().getTransGui().getString(StringIdGui.SUBTITLE_IMPORT_URL),
-                                       Instance.getInstance().getTransGui().getString(StringIdGui.TITLE_IMPORT_URL),
+                                       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();
@@ -211,12 +233,15 @@ public class Actions {
         * <p>
         * Should be called inside the UI thread.
         * 
-        * @param url             the {@link Story} to import by {@link URL}
-        * @param onSuccess       Action to execute on success
-        * @param onSuccessPgName the name to use for the onSuccess progress bar
+        * @param url
+        *            the {@link Story} to import by {@link URL}
+        * @param onSuccess
+        *            Action to execute on success
+        * @param onSuccessPgName
+        *            the name to use for the onSuccess progress bar
         */
-       static public void imprt(final Container parent, final String url, final Runnable onSuccess,
-                       String onSuccessPgName) {
+       static public void imprt(final Container parent, final String url,
+                       final Runnable onSuccess, String onSuccessPgName) {
                final Progress pg = new Progress();
                final Progress pgImprt = new Progress();
                final Progress pgOnSuccess = new Progress(onSuccessPgName);
@@ -229,7 +254,8 @@ public class Actions {
                                Exception ex = null;
                                MetaData meta = null;
                                try {
-                                       meta = Instance.getInstance().getLibrary().imprt(BasicReader.getUrl(url), pgImprt);
+                                       meta = Instance.getInstance().getLibrary()
+                                                       .imprt(BasicReader.getUrl(url), pgImprt);
                                } catch (IOException e) {
                                        e.printStackTrace();
                                        ex = e;
@@ -243,14 +269,20 @@ public class Actions {
                                if (!ok) {
                                        if (e instanceof UnknownHostException) {
                                                UiHelper.error(parent,
-                                                               Instance.getInstance().getTransGui().getString(StringIdGui.ERROR_URL_NOT_SUPPORTED,
+                                                               Instance.getInstance().getTransGui().getString(
+                                                                               StringIdGui.ERROR_URL_NOT_SUPPORTED,
                                                                                url),
-                                                               Instance.getInstance().getTransGui().getString(StringIdGui.TITLE_ERROR), null);
+                                                               Instance.getInstance().getTransGui().getString(
+                                                                               StringIdGui.TITLE_ERROR),
+                                                               null);
                                        } else {
                                                UiHelper.error(parent,
-                                                               Instance.getInstance().getTransGui().getString(StringIdGui.ERROR_URL_IMPORT_FAILED, url,
-                                                                               e.getMessage()),
-                                                               Instance.getInstance().getTransGui().getString(StringIdGui.TITLE_ERROR), e);
+                                                               Instance.getInstance().getTransGui().getString(
+                                                                               StringIdGui.ERROR_URL_IMPORT_FAILED,
+                                                                               url, e.getMessage()),
+                                                               Instance.getInstance().getTransGui()
+                                                                               .getString(StringIdGui.TITLE_ERROR),
+                                                               e);
                                        }
                                } else {
                                        if (onSuccess != null) {
@@ -258,7 +290,7 @@ public class Actions {
                                        }
                                }
                                pgOnSuccess.done();
-                               
+
                                return null;
                        }
                }.execute();
index c3d87a1c34c956f99eaac56f8436dbacd4be18cf..cf83537f7aac5b392ba588a6c94dbcc927cd8063 100644 (file)
@@ -27,7 +27,8 @@ public class Main {
                                @Override
                                public DataLoader getCache() {
                                        if (cache == null) {
-                                               cache = new DataLoader(getConfig().getString(Config.NETWORK_USER_AGENT));
+                                               cache = new DataLoader(getConfig()
+                                                               .getString(Config.NETWORK_USER_AGENT));
                                        }
 
                                        return cache;
index c8b171367749d778f595b8926f51430b8ead8cb9..ac7eaff4d32bd794dac53cf0ee6fcc451f6ae468 100644 (file)
@@ -34,30 +34,30 @@ public class BrowserPanel extends ListenerPanel {
 
        /**
         * The {@link ActionEvent} you receive from
-        * {@link BrowserPanel#addActionListener(ActionListener)} can return this as a
-        * command (see {@link ActionEvent#getActionCommand()}) if they were created in
-        * the scope of a source.
+        * {@link BrowserPanel#addActionListener(ActionListener)} can return this as
+        * a command (see {@link ActionEvent#getActionCommand()}) if they were
+        * created in the scope of a source.
         */
        static public final String SOURCE_SELECTION = "source_selection";
        /**
         * The {@link ActionEvent} you receive from
-        * {@link BrowserPanel#addActionListener(ActionListener)} can return this as a
-        * command (see {@link ActionEvent#getActionCommand()}) if they were created in
-        * the scope of an author.
+        * {@link BrowserPanel#addActionListener(ActionListener)} can return this as
+        * a command (see {@link ActionEvent#getActionCommand()}) if they were
+        * created in the scope of an author.
         */
        static public final String AUTHOR_SELECTION = "author_selection";
        /**
         * The {@link ActionEvent} you receive from
-        * {@link BrowserPanel#addActionListener(ActionListener)} can return this as a
-        * command (see {@link ActionEvent#getActionCommand()}) if they were created in
-        * the scope of a tag.
+        * {@link BrowserPanel#addActionListener(ActionListener)} can return this as
+        * a command (see {@link ActionEvent#getActionCommand()}) if they were
+        * created in the scope of a tag.
         */
        static public final String TAGS_SELECTION = "tags_selection";
        /**
         * The {@link ActionEvent} you receive from
-        * {@link BrowserPanel#addActionListener(ActionListener)} can return this as a
-        * command (see {@link ActionEvent#getActionCommand()}) if they were created in
-        * the scope of a tab change.
+        * {@link BrowserPanel#addActionListener(ActionListener)} can return this as
+        * a command (see {@link ActionEvent#getActionCommand()}) if they were
+        * created in the scope of a tab change.
         */
        static public final String TAB_CHANGE = "tab_change";
 
@@ -131,7 +131,8 @@ public class BrowserPanel extends ListenerPanel {
                }
        }
 
-       private void configureTab(JTabbedPane tabs, @SuppressWarnings("rawtypes") BasicTab tab, String name,
+       private void configureTab(JTabbedPane tabs,
+                       @SuppressWarnings("rawtypes") BasicTab tab, String name,
                        String tooltip) {
                tab.setBaseTitle(name);
                tabs.setTitleAt(tab.getIndex(), tab.getTitle());
@@ -139,7 +140,8 @@ public class BrowserPanel extends ListenerPanel {
                listenTabs(tabs, tab);
        }
 
-       private void listenTabs(final JTabbedPane tabs, @SuppressWarnings("rawtypes") final BasicTab tab) {
+       private void listenTabs(final JTabbedPane tabs,
+                       @SuppressWarnings("rawtypes") final BasicTab tab) {
                tab.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
@@ -153,8 +155,8 @@ public class BrowserPanel extends ListenerPanel {
         * Get the {@link BookInfo} to highlight, even if none or more than one are
         * selected.
         * <p>
-        * Return a special "all" {@link BookInfo} of the correct type when nothing is
-        * selected.
+        * Return a special "all" {@link BookInfo} of the correct type when nothing
+        * is selected.
         * 
         * @return the {@link BookInfo} to highlight, can be NULL
         */
@@ -163,7 +165,8 @@ public class BrowserPanel extends ListenerPanel {
                Component selectedTab = tabs.getSelectedComponent();
                if (selectedTab instanceof BasicTab) {
                        @SuppressWarnings({ "unchecked", "rawtypes" })
-                       List<String> selectedAll = ((BasicTab) selectedTab).getSelectedElements();
+                       List<String> selectedAll = ((BasicTab) selectedTab)
+                                       .getSelectedElements();
                        if (!selectedAll.isEmpty()) {
                                selected1 = selectedAll.get(0);
                        }
index 751e37f511c5ed58fda8a7f7aa1885495755e5ea..e3185a6a81c3dc39796bde9ad22f638820327e51 100644 (file)
@@ -60,8 +60,10 @@ public class DetailsPanel extends JPanel {
        /**
         * Configure a {@link JLabel} with the given colour.
         * 
-        * @param label the label to configure
-        * @param color the colour to use
+        * @param label
+        *            the label to configure
+        * @param color
+        *            the colour to use
         * 
         * @return the (same) configured label
         */
@@ -76,7 +78,8 @@ public class DetailsPanel extends JPanel {
        /**
         * Set the {@link BookInfo} you want to see displayed here.
         * 
-        * @param info the {@link BookInfo} to display
+        * @param info
+        *            the {@link BookInfo} to display
         */
        public void setBook(final BookInfo info) {
                this.info = info;
@@ -86,7 +89,8 @@ public class DetailsPanel extends JPanel {
                        name.setText(null);
                        opt.setText(null);
                } else if (info.getMainInfo() == null) {
-                       name.setText("All the " + info.getType().toString().toLowerCase() + "s");
+                       name.setText(
+                                       "All the " + info.getType().toString().toLowerCase() + "s");
                        opt.setText(info.getSecondaryInfo(true));
                } else {
                        final String myId = info.getId();
@@ -101,7 +105,8 @@ public class DetailsPanel extends JPanel {
 
                                        BookInfo current = DetailsPanel.this.info;
                                        if (current != null && current.getId().equals(myId)) {
-                                               return BookBlock.generateCoverImage(Instance.getInstance().getLibrary(), info);
+                                               return BookBlock.generateCoverImage(
+                                                               Instance.getInstance().getLibrary(), info);
                                        }
 
                                        return null;
index 39762a8710ae4abc389966b3be66beac87e9d799..9d25169c3e6276199324ed6423f1cecab101d9c2 100644 (file)
@@ -52,7 +52,9 @@ public class MainFrame extends JFrame {
                browser.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
-                               books.load(browser.getSelectedSources(), browser.getSelectedAuthors(), browser.getSelectedTags());
+                               books.load(browser.getSelectedSources(),
+                                               browser.getSelectedAuthors(),
+                                               browser.getSelectedTags());
                                details.setBook(browser.getHighlight());
                        }
                });
@@ -70,10 +72,12 @@ public class MainFrame extends JFrame {
                this.add(split);
        }
 
-       private JSplitPane split(JComponent leftTop, JComponent rightBottom, boolean horizontal, double ratio,
-                       double weight) {
-               JSplitPane split = new JSplitPane(horizontal ? JSplitPane.HORIZONTAL_SPLIT : JSplitPane.VERTICAL_SPLIT, leftTop,
-                               rightBottom);
+       private JSplitPane split(JComponent leftTop, JComponent rightBottom,
+                       boolean horizontal, double ratio, double weight) {
+               JSplitPane split = new JSplitPane(
+                               horizontal ? JSplitPane.HORIZONTAL_SPLIT
+                                               : JSplitPane.VERTICAL_SPLIT,
+                               leftTop, rightBottom);
                split.setOneTouchExpandable(true);
                split.setResizeWeight(weight);
                split.setContinuousLayout(true);
@@ -96,7 +100,8 @@ public class MainFrame extends JFrame {
                                        @Override
                                        public void run() {
                                                browser.reloadData();
-                                               books.load(browser.getSelectedSources(), browser.getSelectedAuthors(),
+                                               books.load(browser.getSelectedSources(),
+                                                               browser.getSelectedAuthors(),
                                                                browser.getSelectedTags());
                                                details.setBook(browser.getHighlight());
                                        }
@@ -112,7 +117,8 @@ public class MainFrame extends JFrame {
                                        @Override
                                        public void run() {
                                                browser.reloadData();
-                                               books.load(browser.getSelectedSources(), browser.getSelectedAuthors(),
+                                               books.load(browser.getSelectedSources(),
+                                                               browser.getSelectedAuthors(),
                                                                browser.getSelectedTags());
                                                details.setBook(browser.getHighlight());
                                        }
index 8c83144f54dc6451e55de3fb1dca4bec99198c80..595f42ba7051d65ac80df1d906d20ad2d96bc064 100644 (file)
@@ -21,7 +21,8 @@ import be.nikiroo.fanfix_swing.gui.BooksPanel;
  */
 public class BookBlock extends BookLine {
        static private final long serialVersionUID = 1L;
-       static private Image empty = BookCoverImager.generateCoverImage(null, (BookInfo) null);
+       static private Image empty = BookCoverImager.generateCoverImage(null,
+                       (BookInfo) null);
 
        private JLabel title;
        private Image coverImage;
@@ -29,8 +30,10 @@ public class BookBlock extends BookLine {
        /**
         * Create a new {@link BookBlock} item for the given {@link Story}.
         * 
-        * @param info         the information about the story to represent
-        * @param seeWordCount TRUE to see word counts, FALSE to see authors
+        * @param info
+        *            the information about the story to represent
+        * @param seeWordCount
+        *            TRUE to see word counts, FALSE to see authors
         */
        public BookBlock(BookInfo info, boolean seeWordCount) {
                super(info, seeWordCount);
@@ -43,7 +46,8 @@ public class BookBlock extends BookLine {
                updateMeta();
 
                JPanel filler = new JPanel();
-               filler.setPreferredSize(new Dimension(BookCoverImager.getCoverWidth(), BookCoverImager.getCoverHeight()));
+               filler.setPreferredSize(new Dimension(BookCoverImager.getCoverWidth(),
+                               BookCoverImager.getCoverHeight()));
                filler.setOpaque(false);
 
                setLayout(new BorderLayout(10, 10));
@@ -55,7 +59,8 @@ public class BookBlock extends BookLine {
         * the cover image to use a base (see
         * {@link BookCoverImager#generateCoverImage(BasicLibrary, BookInfo)})
         * 
-        * @param coverImage the image
+        * @param coverImage
+        *            the image
         */
        public void setCoverImage(Image coverImage) {
                this.coverImage = coverImage;
@@ -64,32 +69,41 @@ public class BookBlock extends BookLine {
        @Override
        public void paint(Graphics g) {
                super.paint(g);
-               g.drawImage(coverImage, BookCoverImager.TEXT_WIDTH - BookCoverImager.COVER_WIDTH, 0, null);
-               BookCoverImager.paintOverlay(g, isEnabled(), isSelected(), isHovered(), getInfo().isCached());
+               g.drawImage(coverImage,
+                               BookCoverImager.TEXT_WIDTH - BookCoverImager.COVER_WIDTH, 0,
+                               null);
+               BookCoverImager.paintOverlay(g, isEnabled(), isSelected(), isHovered(),
+                               getInfo().isCached());
        }
 
        @Override
        protected void updateMeta() {
                String main = getInfo().getMainInfo();
                String optSecondary = getInfo().getSecondaryInfo(isSeeWordCount());
-               String color = String.format("#%X%X%X", AUTHOR_COLOR.getRed(), AUTHOR_COLOR.getGreen(), AUTHOR_COLOR.getBlue());
-               title.setText(String.format(
-                               "<html>" + "<body style='width: %d px; height: %d px; text-align: center;'>" + "%s" + "<br>"
-                                               + "<span style='color: %s;'>" + "%s" + "</span>" + "</body>" + "</html>",
-                               BookCoverImager.TEXT_WIDTH, BookCoverImager.TEXT_HEIGHT, main, color, optSecondary));
+               String color = String.format("#%X%X%X", AUTHOR_COLOR.getRed(),
+                               AUTHOR_COLOR.getGreen(), AUTHOR_COLOR.getBlue());
+               title.setText(String.format("<html>"
+                               + "<body style='width: %d px; height: %d px; text-align: center;'>"
+                               + "%s" + "<br>" + "<span style='color: %s;'>" + "%s" + "</span>"
+                               + "</body>" + "</html>", BookCoverImager.TEXT_WIDTH,
+                               BookCoverImager.TEXT_HEIGHT, main, color, optSecondary));
 
-               setBackground(BookCoverImager.getBackground(isEnabled(), isSelected(), isHovered()));
+               setBackground(BookCoverImager.getBackground(isEnabled(), isSelected(),
+                               isHovered()));
        }
 
        /**
         * Generate a cover icon based upon the given {@link BookInfo}.
         * 
-        * @param lib  the library the meta comes from
-        * @param info the {@link BookInfo}
+        * @param lib
+        *            the library the meta comes from
+        * @param info
+        *            the {@link BookInfo}
         * 
         * @return the image
         */
-       static public java.awt.Image generateCoverImage(BasicLibrary lib, BookInfo info) {
+       static public java.awt.Image generateCoverImage(BasicLibrary lib,
+                       BookInfo info) {
                return BookCoverImager.generateCoverImage(lib, info);
        }
 }
index 95e0aabca17acfdcdd760ffbe36eda9065261f5f..3c92694c32862546e1cd99ad46b65bea4e402188 100644 (file)
@@ -38,15 +38,16 @@ class BookCoverImager {
        static final Color SPINE_COLOR_RIGHT = new Color(100, 100, 100);
        static final Color BORDER = Color.black;
 
-       public static final Color UNCACHED_ICON_COLOR = Color.green.darker(); 
-                       // new Color(0, 80, 220);
+       public static final Color UNCACHED_ICON_COLOR = Color.green.darker();
+       // new Color(0, 80, 220);
 
        public static final int TEXT_HEIGHT = 50;
        public static final int TEXT_WIDTH = COVER_WIDTH + 40;
 
        //
 
-       static public Color getBackground(boolean enabled, boolean selected, boolean hovered) {
+       static public Color getBackground(boolean enabled, boolean selected,
+                       boolean hovered) {
                Color color = new Color(255, 255, 255, 0);
                if (!enabled) {
                } else if (selected && !hovered) {
@@ -61,17 +62,23 @@ class BookCoverImager {
        }
 
        /**
-        * Draw a partially transparent overlay if needed depending upon the selection
-        * and mouse-hover states on top of the normal component, as well as a possible
-        * "cached" icon if the item is cached.
+        * Draw a partially transparent overlay if needed depending upon the
+        * selection and mouse-hover states on top of the normal component, as well
+        * as a possible "cached" icon if the item is cached.
         * 
-        * @param g        the {@link Graphics} to paint onto
-        * @param enabled  draw an enabled overlay
-        * @param selected draw a selected overlay
-        * @param hovered  draw a hovered overlay
-        * @param cached   draw a non-cached overlay if needed
+        * @param g
+        *            the {@link Graphics} to paint onto
+        * @param enabled
+        *            draw an enabled overlay
+        * @param selected
+        *            draw a selected overlay
+        * @param hovered
+        *            draw a hovered overlay
+        * @param cached
+        *            draw a non-cached overlay if needed
         */
-       static public void paintOverlay(Graphics g, boolean enabled, boolean selected, boolean hovered, boolean cached) {
+       static public void paintOverlay(Graphics g, boolean enabled,
+                       boolean selected, boolean hovered, boolean cached) {
                Rectangle clip = g.getClipBounds();
                if (clip.getWidth() <= 0 || clip.getHeight() <= 0) {
                        return;
@@ -92,12 +99,16 @@ class BookCoverImager {
                        yOffset++;
                }
 
-               int[] xs = new int[] { xOffset, xOffset + SPINE_WIDTH, xOffset + w + SPINE_WIDTH, xOffset + w };
-               int[] ys = new int[] { yOffset + h, yOffset + h + SPINE_HEIGHT, yOffset + h + SPINE_HEIGHT, yOffset + h };
+               int[] xs = new int[] { xOffset, xOffset + SPINE_WIDTH,
+                               xOffset + w + SPINE_WIDTH, xOffset + w };
+               int[] ys = new int[] { yOffset + h, yOffset + h + SPINE_HEIGHT,
+                               yOffset + h + SPINE_HEIGHT, yOffset + h };
                g.setColor(SPINE_COLOR_BOTTOM);
                g.fillPolygon(new Polygon(xs, ys, xs.length));
-               xs = new int[] { xOffset + w, xOffset + w + SPINE_WIDTH, xOffset + w + SPINE_WIDTH, xOffset + w };
-               ys = new int[] { yOffset, yOffset + SPINE_HEIGHT, yOffset + h + SPINE_HEIGHT, yOffset + h };
+               xs = new int[] { xOffset + w, xOffset + w + SPINE_WIDTH,
+                               xOffset + w + SPINE_WIDTH, xOffset + w };
+               ys = new int[] { yOffset, yOffset + SPINE_HEIGHT,
+                               yOffset + h + SPINE_HEIGHT, yOffset + h };
                g.setColor(SPINE_COLOR_RIGHT);
                g.fillPolygon(new Polygon(xs, ys, xs.length));
 
@@ -106,7 +117,8 @@ class BookCoverImager {
                g.setColor(color);
                g.fillRect(clip.x, clip.y, clip.width, clip.height);
 
-               UIUtils.drawEllipse3D(g, UNCACHED_ICON_COLOR, COVER_WIDTH + HOFFSET + 30, 10, 20, 20, cached);
+               UIUtils.drawEllipse3D(g, UNCACHED_ICON_COLOR,
+                               COVER_WIDTH + HOFFSET + 30, 10, 20, 20, cached);
        }
 
        /**
@@ -130,12 +142,15 @@ class BookCoverImager {
        /**
         * Generate a cover icon based upon the given {@link GuiReaderBookInfo}.
         * 
-        * @param lib  the library the meta comes from (can be NULL)
-        * @param info the {@link GuiReaderBookInfo}
+        * @param lib
+        *            the library the meta comes from (can be NULL)
+        * @param info
+        *            the {@link GuiReaderBookInfo}
         * 
         * @return the image
         */
-       static public java.awt.Image generateCoverImage(BasicLibrary lib, BookInfo info) {
+       static public java.awt.Image generateCoverImage(BasicLibrary lib,
+                       BookInfo info) {
                BufferedImage resizedImage = null;
                String id = getIconId(info);
 
@@ -157,21 +172,26 @@ class BookCoverImager {
                                        cover = info.getBaseImage(lib);
                                }
 
-                               resizedImage = new BufferedImage(getCoverWidth(), getCoverHeight(), BufferedImage.TYPE_4BYTE_ABGR);
+                               resizedImage = new BufferedImage(getCoverWidth(),
+                                               getCoverHeight(), BufferedImage.TYPE_4BYTE_ABGR);
 
                                Graphics2D g = resizedImage.createGraphics();
                                try {
                                        if (info != null && info.supportsCover()) {
                                                g.setColor(Color.white);
                                                g.fillRect(0, HOFFSET, COVER_WIDTH, COVER_HEIGHT);
-                                               
+
                                                if (cover != null) {
-                                                       BufferedImage coverb = ImageUtilsAwt.fromImage(cover);
-                                                       g.drawImage(coverb, 0, HOFFSET, COVER_WIDTH, COVER_HEIGHT, null);
+                                                       BufferedImage coverb = ImageUtilsAwt
+                                                                       .fromImage(cover);
+                                                       g.drawImage(coverb, 0, HOFFSET, COVER_WIDTH,
+                                                                       COVER_HEIGHT, null);
                                                } else {
                                                        g.setColor(Color.black);
-                                                       g.drawLine(0, HOFFSET, COVER_WIDTH, HOFFSET + COVER_HEIGHT);
-                                                       g.drawLine(COVER_WIDTH, HOFFSET, 0, HOFFSET + COVER_HEIGHT);
+                                                       g.drawLine(0, HOFFSET, COVER_WIDTH,
+                                                                       HOFFSET + COVER_HEIGHT);
+                                                       g.drawLine(COVER_WIDTH, HOFFSET, 0,
+                                                                       HOFFSET + COVER_HEIGHT);
                                                }
                                        }
                                } finally {
@@ -201,7 +221,8 @@ class BookCoverImager {
        /**
         * Manually clear the icon set for this item.
         * 
-        * @param info the info about the story or source/type or author
+        * @param info
+        *            the info about the story or source/type or author
         */
        static public void clearIcon(BookInfo info) {
                String id = getIconId(info);
@@ -209,14 +230,16 @@ class BookCoverImager {
        }
 
        /**
-        * Get a unique ID from this {@link GuiReaderBookInfo} (note that it can be a
-        * story, a fake item for a source/type or a fake item for an author).
+        * Get a unique ID from this {@link GuiReaderBookInfo} (note that it can be
+        * story, a fake item for a source/type or a fake item for an author).
         * 
-        * @param info the info or NULL for a generic (non unique!) ID
+        * @param info
+        *            the info or NULL for a generic (non unique!) ID
         * @return the unique ID
         */
        static private String getIconId(BookInfo info) {
-               return (info == null ? "" : info.getId() + ".") + "book-thumb_" + SPINE_WIDTH + "x" + COVER_WIDTH + "+"
-                               + SPINE_HEIGHT + "+" + COVER_HEIGHT + "@" + HOFFSET;
+               return (info == null ? "" : info.getId() + ".") + "book-thumb_"
+                               + SPINE_WIDTH + "x" + COVER_WIDTH + "+" + SPINE_HEIGHT + "+"
+                               + COVER_HEIGHT + "@" + HOFFSET;
        }
 }
index 72aee900d51893a25b31b8b1bacbc9878a2bd49a..bde9abbc34b547f4598f88bf4eb77a090c453cf2 100644 (file)
@@ -21,8 +21,8 @@ import be.nikiroo.utils.StringUtils;
  */
 public class BookInfo {
        /**
-        * The type of {@link Book} (i.e., related to a story or to something else that
-        * can encompass stories).
+        * The type of {@link Book} (i.e., related to a story or to something else
+        * that can encompass stories).
         * 
         * @author niki
         */
@@ -30,8 +30,8 @@ public class BookInfo {
                /** A normal story, which can be "read". */
                STORY,
                /**
-                * A special, empty story that represents a source/type common to one or more
-                * normal stories.
+                * A special, empty story that represents a source/type common to one or
+                * more normal stories.
                 */
                SOURCE,
                /** A special, empty story that represents an author. */
@@ -52,10 +52,13 @@ public class BookInfo {
        /**
         * For private use; see the "fromXXX" constructors instead for public use.
         * 
-        * @param type  the type of book
-        * @param id    the main id, which must uniquely identify this book and will be
-        *              used as a unique ID later on
-        * @param value the main value to show (see {@link BookInfo#getMainInfo()})
+        * @param type
+        *            the type of book
+        * @param id
+        *            the main id, which must uniquely identify this book and will
+        *            be used as a unique ID later on
+        * @param value
+        *            the main value to show (see {@link BookInfo#getMainInfo()})
         */
        protected BookInfo(Type type, String id, String value) {
                this.type = type;
@@ -73,12 +76,12 @@ public class BookInfo {
        }
 
        /**
-        * Get the main info to display for this book (a title, an author, a source/type
-        * name...).
+        * Get the main info to display for this book (a title, an author, a
+        * source/type name...).
         * <p>
-        * Note that when {@link MetaData} about the book are present, the title inside
-        * is returned instead of the actual value (that way, we can update the
-        * {@link MetaData} and see the changes here).
+        * Note that when {@link MetaData} about the book are present, the title
+        * inside is returned instead of the actual value (that way, we can update
+        * the {@link MetaData} and see the changes here).
         * 
         * @return the main info, usually the title
         */
@@ -93,7 +96,8 @@ public class BookInfo {
        /**
         * Get the secondary info, of the given type.
         * 
-        * @param seeCount TRUE for word/image/story count, FALSE for author name
+        * @param seeCount
+        *            TRUE for word/image/story count, FALSE for author name
         * 
         * @return the secondary info, never NULL
         */
@@ -131,7 +135,8 @@ public class BookInfo {
        /**
         * This item library cache state.
         * 
-        * @param cached TRUE if it is present in the {@link CacheLibrary} cache
+        * @param cached
+        *            TRUE if it is present in the {@link CacheLibrary} cache
         */
        public void setCached(boolean cached) {
                this.cached = cached;
@@ -156,11 +161,14 @@ public class BookInfo {
         * <p>
         * It can be NULL if no image can be found for this book.
         * 
-        * @param lib the {@link BasicLibrary} to use to fetch the image (can be NULL)
+        * @param lib
+        *            the {@link BasicLibrary} to use to fetch the image (can be
+        *            NULL)
         * 
         * @return the base image, or NULL if no library or no image
         * 
-        * @throws IOException in case of I/O error
+        * @throws IOException
+        *             in case of I/O error
         */
        public Image getBaseImage(BasicLibrary lib) throws IOException {
                if (lib != null) {
@@ -186,7 +194,7 @@ public class BookInfo {
 
                return null;
        }
-       
+
        /**
         * This {@link BookInfo} could have a cover (so we need to somehow represent
         * that to the user).
@@ -200,9 +208,11 @@ public class BookInfo {
        /**
         * Create a new book describing the given {@link Story}.
         * 
-        * @param lib  the {@link BasicLibrary} to use to retrieve some more information
-        *             about the source
-        * @param meta the {@link MetaData} representing the {@link Story}
+        * @param lib
+        *            the {@link BasicLibrary} to use to retrieve some more
+        *            information about the source
+        * @param meta
+        *            the {@link MetaData} representing the {@link Story}
         * 
         * @return the book
         */
@@ -221,7 +231,8 @@ public class BookInfo {
                info.count = StringUtils.formatNumber(meta.getWords());
                if (!info.count.isEmpty()) {
                        info.count = Instance.getInstance().getTransGui().getString(
-                                       meta.isImageDocument() ? StringIdGui.BOOK_COUNT_IMAGES : StringIdGui.BOOK_COUNT_WORDS,
+                                       meta.isImageDocument() ? StringIdGui.BOOK_COUNT_IMAGES
+                                                       : StringIdGui.BOOK_COUNT_WORDS,
                                        new Object[] { info.count });
                }
 
@@ -237,14 +248,17 @@ public class BookInfo {
        /**
         * Create a new book describing the given source/type.
         * 
-        * @param lib    the {@link BasicLibrary} to use to retrieve some more
-        *               information about the source
-        * @param source the source name
+        * @param lib
+        *            the {@link BasicLibrary} to use to retrieve some more
+        *            information about the source
+        * @param source
+        *            the source name
         * 
         * @return the book
         */
        static public BookInfo fromSource(BasicLibrary lib, String source) {
-               BookInfo info = new BookInfo(Type.SOURCE, "source_" + (source == null ? "" : source), source);
+               BookInfo info = new BookInfo(Type.SOURCE,
+                               "source_" + (source == null ? "" : source), source);
 
                int size = 0;
                try {
@@ -254,7 +268,8 @@ public class BookInfo {
 
                info.count = StringUtils.formatNumber(size);
                if (!info.count.isEmpty()) {
-                       info.count = Instance.getInstance().getTransGui().getString(StringIdGui.BOOK_COUNT_STORIES,
+                       info.count = Instance.getInstance().getTransGui().getString(
+                                       StringIdGui.BOOK_COUNT_STORIES,
                                        new Object[] { info.count });
                }
 
@@ -264,14 +279,17 @@ public class BookInfo {
        /**
         * Create a new book describing the given author.
         * 
-        * @param lib    the {@link BasicLibrary} to use to retrieve some more
-        *               information about the author
-        * @param author the author name
+        * @param lib
+        *            the {@link BasicLibrary} to use to retrieve some more
+        *            information about the author
+        * @param author
+        *            the author name
         * 
         * @return the book
         */
        static public BookInfo fromAuthor(BasicLibrary lib, String author) {
-               BookInfo info = new BookInfo(Type.AUTHOR, "author_" + (author == null ? "" : author), author);
+               BookInfo info = new BookInfo(Type.AUTHOR,
+                               "author_" + (author == null ? "" : author), author);
 
                int size = 0;
                try {
@@ -281,7 +299,8 @@ public class BookInfo {
 
                info.count = StringUtils.formatNumber(size);
                if (!info.count.isEmpty()) {
-                       info.count = Instance.getInstance().getTransGui().getString(StringIdGui.BOOK_COUNT_STORIES,
+                       info.count = Instance.getInstance().getTransGui().getString(
+                                       StringIdGui.BOOK_COUNT_STORIES,
                                        new Object[] { info.count });
                }
 
@@ -291,14 +310,17 @@ public class BookInfo {
        /**
         * Create a new book describing the given tag.
         * 
-        * @param lib the {@link BasicLibrary} to use to retrieve some more information
-        *            about the tag
-        * @param tag the tag name
+        * @param lib
+        *            the {@link BasicLibrary} to use to retrieve some more
+        *            information about the tag
+        * @param tag
+        *            the tag name
         * 
         * @return the book
         */
        static public BookInfo fromTag(BasicLibrary lib, String tag) {
-               BookInfo info = new BookInfo(Type.TAG, "tag_" + (tag == null ? "" : tag), tag);
+               BookInfo info = new BookInfo(Type.TAG,
+                               "tag_" + (tag == null ? "" : tag), tag);
 
                int size = 0;
                try {
@@ -308,7 +330,8 @@ public class BookInfo {
 
                info.count = StringUtils.formatNumber(size);
                if (!info.count.isEmpty()) {
-                       info.count = Instance.getInstance().getTransGui().getString(StringIdGui.BOOK_COUNT_STORIES,
+                       info.count = Instance.getInstance().getTransGui().getString(
+                                       StringIdGui.BOOK_COUNT_STORIES,
                                        new Object[] { info.count });
                }
 
index beb4c973674eb2b6483e28aa28bc6647224710e7..f7926a0212d3dd36db60bf13c9c61b6e0c6308b3 100644 (file)
@@ -38,8 +38,10 @@ public class BookLine extends JPanel {
        /**
         * Create a new {@link BookLine} item for the given {@link Story}.
         * 
-        * @param info         the information about the story to represent
-        * @param seeWordCount TRUE to see word counts, FALSE to see authors
+        * @param info
+        *            the information about the story to represent
+        * @param seeWordCount
+        *            TRUE to see word counts, FALSE to see authors
         */
        public BookLine(BookInfo info, boolean seeWordCount) {
                this.info = info;
@@ -92,7 +94,8 @@ public class BookLine extends JPanel {
        /**
         * The book current selection state,
         * 
-        * @param selected TRUE if it is selected
+        * @param selected
+        *            TRUE if it is selected
         */
        public void setSelected(boolean selected) {
                if (this.selected != selected) {
@@ -113,7 +116,8 @@ public class BookLine extends JPanel {
        /**
         * The item mouse-hover state.
         * 
-        * @param hovered TRUE if it is mouse-hovered
+        * @param hovered
+        *            TRUE if it is mouse-hovered
         */
        public void setHovered(boolean hovered) {
                if (this.hovered != hovered) {
@@ -134,7 +138,8 @@ public class BookLine extends JPanel {
        /**
         * The secondary value content: word count or author.
         * 
-        * @param seeWordCount TRUE to see word counts, FALSE to see authors
+        * @param seeWordCount
+        *            TRUE to see word counts, FALSE to see authors
         */
        public void setSeeWordCount(boolean seeWordCount) {
                if (this.seeWordCount != seeWordCount) {
@@ -172,11 +177,13 @@ public class BookLine extends JPanel {
                title.setText(main);
                secondary.setText(optSecondary + " ");
 
-               setBackground(BookCoverImager.getBackground(isEnabled(), isSelected(), isHovered()));
+               setBackground(BookCoverImager.getBackground(isEnabled(), isSelected(),
+                               isHovered()));
 
                remove(iconCached);
                remove(iconNotCached);
-               add(getInfo().isCached() ? iconCached : iconNotCached, BorderLayout.WEST);
+               add(getInfo().isCached() ? iconCached : iconNotCached,
+                               BorderLayout.WEST);
                validate();
        }
 }
index c99e2730c45917359cd8e01043772414d6a08035..eccdde59e1960b238bee2be565439ee9da727238 100644 (file)
@@ -113,7 +113,8 @@ public class BookPopup extends JPopupMenu {
                item.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
-                               ConfigEditor<Config> ed = new ConfigEditor<Config>(Config.class, Instance.getInstance().getConfig(),
+                               ConfigEditor<Config> ed = new ConfigEditor<Config>(Config.class,
+                                               Instance.getInstance().getConfig(),
                                                trans(StringIdGui.SUBTITLE_CONFIG));
                                JFrame frame = new JFrame(title);
                                frame.add(ed);
@@ -138,8 +139,9 @@ public class BookPopup extends JPopupMenu {
                item.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
-                               ConfigEditor<UiConfig> ed = new ConfigEditor<UiConfig>(UiConfig.class,
-                                               Instance.getInstance().getUiConfig(), trans(StringIdGui.SUBTITLE_CONFIG_UI));
+                               ConfigEditor<UiConfig> ed = new ConfigEditor<UiConfig>(
+                                               UiConfig.class, Instance.getInstance().getUiConfig(),
+                                               trans(StringIdGui.SUBTITLE_CONFIG_UI));
                                JFrame frame = new JFrame(title);
                                frame.add(ed);
                                frame.setSize(800, 600);
@@ -180,22 +182,28 @@ public class BookPopup extends JPopupMenu {
                }
                //
 
-               JMenuItem export = new JMenuItem(trans(StringIdGui.MENU_FILE_EXPORT), KeyEvent.VK_S);
+               JMenuItem export = new JMenuItem(trans(StringIdGui.MENU_FILE_EXPORT),
+                               KeyEvent.VK_S);
                export.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                                final BookInfo book = informer.getUniqueSelected();
                                if (book != null) {
-                                       fc.showDialog(BookPopup.this.getParent(), trans(StringIdGui.TITLE_SAVE));
+                                       fc.showDialog(BookPopup.this.getParent(),
+                                                       trans(StringIdGui.TITLE_SAVE));
                                        if (fc.getSelectedFile() != null) {
-                                               final OutputType type = otherFilters.get(fc.getFileFilter());
-                                               final String path = fc.getSelectedFile().getAbsolutePath() + type.getDefaultExtension(false);
+                                               final OutputType type = otherFilters
+                                                               .get(fc.getFileFilter());
+                                               final String path = fc.getSelectedFile()
+                                                               .getAbsolutePath()
+                                                               + type.getDefaultExtension(false);
                                                final Progress pg = new Progress();
 
                                                new SwingWorker<Void, Void>() {
                                                        @Override
                                                        protected Void doInBackground() throws Exception {
-                                                               lib.export(book.getMeta().getLuid(), type, path, pg);
+                                                               lib.export(book.getMeta().getLuid(), type, path,
+                                                                               pg);
                                                                return null;
                                                        }
 
@@ -204,8 +212,9 @@ public class BookPopup extends JPopupMenu {
                                                                try {
                                                                        get();
                                                                } catch (Exception e) {
-                                                                       UiHelper.error(BookPopup.this.getParent(), e.getLocalizedMessage(), "IOException",
-                                                                                       e);
+                                                                       UiHelper.error(BookPopup.this.getParent(),
+                                                                                       e.getLocalizedMessage(),
+                                                                                       "IOException", e);
                                                                }
                                                        }
                                                }.execute();
@@ -221,7 +230,8 @@ public class BookPopup extends JPopupMenu {
         * Create a {@link FileFilter} that accepts all files and return the given
         * description.
         * 
-        * @param desc the description
+        * @param desc
+        *            the description
         * 
         * @return the filter
         */
@@ -245,7 +255,8 @@ public class BookPopup extends JPopupMenu {
         * @return the item
         */
        private JMenuItem createMenuItemClearCache() {
-               JMenuItem refresh = new JMenuItem(trans(StringIdGui.MENU_EDIT_CLEAR_CACHE), KeyEvent.VK_C);
+               JMenuItem refresh = new JMenuItem(
+                               trans(StringIdGui.MENU_EDIT_CLEAR_CACHE), KeyEvent.VK_C);
                refresh.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
@@ -269,7 +280,9 @@ public class BookPopup extends JPopupMenu {
                                                                        informer.setCached(book, false);
                                                                }
                                                        } catch (Exception e) {
-                                                               UiHelper.error(BookPopup.this.getParent(), e.getLocalizedMessage(), "IOException", e);
+                                                               UiHelper.error(BookPopup.this.getParent(),
+                                                                               e.getLocalizedMessage(), "IOException",
+                                                                               e);
                                                        }
                                                }
                                        }.execute();
@@ -293,10 +306,12 @@ public class BookPopup extends JPopupMenu {
                try {
                        groupedSources = lib.getSourcesGrouped();
                } catch (IOException e) {
-                       UiHelper.error(BookPopup.this.getParent(), e.getLocalizedMessage(), "IOException", e);
+                       UiHelper.error(BookPopup.this.getParent(), e.getLocalizedMessage(),
+                                       "IOException", e);
                }
 
-               JMenuItem item = new JMenuItem(trans(StringIdGui.MENU_FILE_MOVE_TO_NEW_TYPE));
+               JMenuItem item = new JMenuItem(
+                               trans(StringIdGui.MENU_FILE_MOVE_TO_NEW_TYPE));
                item.addActionListener(createMoveAction(ChangeAction.SOURCE, null));
                changeTo.add(item);
                changeTo.addSeparator();
@@ -305,7 +320,8 @@ public class BookPopup extends JPopupMenu {
                        List<String> list = groupedSources.get(type);
                        if (list.size() == 1 && list.get(0).isEmpty()) {
                                item = new JMenuItem(type);
-                               item.addActionListener(createMoveAction(ChangeAction.SOURCE, type));
+                               item.addActionListener(
+                                               createMoveAction(ChangeAction.SOURCE, type));
                                changeTo.add(item);
                        } else {
                                JMenu dir = new JMenu(type);
@@ -318,7 +334,8 @@ public class BookPopup extends JPopupMenu {
                                        }
 
                                        item = new JMenuItem(itemName);
-                                       item.addActionListener(createMoveAction(ChangeAction.SOURCE, actualType));
+                                       item.addActionListener(
+                                                       createMoveAction(ChangeAction.SOURCE, actualType));
                                        dir.add(item);
                                }
                                changeTo.add(dir);
@@ -338,7 +355,8 @@ public class BookPopup extends JPopupMenu {
                changeTo.setMnemonic(KeyEvent.VK_A);
 
                // New author
-               JMenuItem newItem = new JMenuItem(trans(StringIdGui.MENU_FILE_MOVE_TO_NEW_AUTHOR));
+               JMenuItem newItem = new JMenuItem(
+                               trans(StringIdGui.MENU_FILE_MOVE_TO_NEW_AUTHOR));
                changeTo.add(newItem);
                changeTo.addSeparator();
                newItem.addActionListener(createMoveAction(ChangeAction.AUTHOR, null));
@@ -349,7 +367,8 @@ public class BookPopup extends JPopupMenu {
                try {
                        groupedAuthors = lib.getAuthorsGrouped();
                } catch (IOException e) {
-                       UiHelper.error(BookPopup.this.getParent(), e.getLocalizedMessage(), "IOException", e);
+                       UiHelper.error(BookPopup.this.getParent(), e.getLocalizedMessage(),
+                                       "IOException", e);
                        groupedAuthors = new HashMap<String, List<String>>();
 
                }
@@ -358,16 +377,22 @@ public class BookPopup extends JPopupMenu {
                        for (String key : groupedAuthors.keySet()) {
                                JMenu group = new JMenu(key);
                                for (String value : groupedAuthors.get(key)) {
-                                       JMenuItem item = new JMenuItem(value.isEmpty() ? trans(StringIdGui.MENU_AUTHORS_UNKNOWN) : value);
-                                       item.addActionListener(createMoveAction(ChangeAction.AUTHOR, value));
+                                       JMenuItem item = new JMenuItem(value.isEmpty()
+                                                       ? trans(StringIdGui.MENU_AUTHORS_UNKNOWN)
+                                                       : value);
+                                       item.addActionListener(
+                                                       createMoveAction(ChangeAction.AUTHOR, value));
                                        group.add(item);
                                }
                                changeTo.add(group);
                        }
                } else if (groupedAuthors.size() == 1) {
                        for (String value : groupedAuthors.values().iterator().next()) {
-                               JMenuItem item = new JMenuItem(value.isEmpty() ? trans(StringIdGui.MENU_AUTHORS_UNKNOWN) : value);
-                               item.addActionListener(createMoveAction(ChangeAction.AUTHOR, value));
+                               JMenuItem item = new JMenuItem(value.isEmpty()
+                                               ? trans(StringIdGui.MENU_AUTHORS_UNKNOWN)
+                                               : value);
+                               item.addActionListener(
+                                               createMoveAction(ChangeAction.AUTHOR, value));
                                changeTo.add(item);
                        }
                }
@@ -387,7 +412,8 @@ public class BookPopup extends JPopupMenu {
                return changeTo;
        }
 
-       private ActionListener createMoveAction(final ChangeAction what, final String type) {
+       private ActionListener createMoveAction(final ChangeAction what,
+                       final String type) {
                return new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
@@ -408,8 +434,10 @@ public class BookPopup extends JPopupMenu {
                                                        }
                                                }
 
-                                               Object rep = JOptionPane.showInputDialog(BookPopup.this.getParent(),
-                                                               trans(StringIdGui.SUBTITLE_MOVE_TO), trans(StringIdGui.TITLE_MOVE_TO),
+                                               Object rep = JOptionPane.showInputDialog(
+                                                               BookPopup.this.getParent(),
+                                                               trans(StringIdGui.SUBTITLE_MOVE_TO),
+                                                               trans(StringIdGui.TITLE_MOVE_TO),
                                                                JOptionPane.QUESTION_MESSAGE, null, null, init);
 
                                                if (rep == null) {
@@ -440,16 +468,22 @@ public class BookPopup extends JPopupMenu {
                                                @Override
                                                protected void done() {
                                                        try {
-                                                               // this can create new sources/authors, so a simple fireElementChanged is not
-                                                               // enough, we need to clear the whole cache (for BrowserPanel for instance)
+                                                               // this can create new sources/authors, so a
+                                                               // simple fireElementChanged is not
+                                                               // enough, we need to clear the whole cache (for
+                                                               // BrowserPanel for instance)
                                                                informer.invalidateCache();
 
-                                                               // TODO: also refresh the Sources/Authors(/Tags?) list
+                                                               // TODO: also refresh the
+                                                               // Sources/Authors(/Tags?) list
 
-                                                               // Even if problems occurred, still invalidate the cache
+                                                               // Even if problems occurred, still invalidate
+                                                               // the cache
                                                                get();
                                                        } catch (Exception e) {
-                                                               UiHelper.error(BookPopup.this.getParent(), e.getLocalizedMessage(), "IOException", e);
+                                                               UiHelper.error(BookPopup.this.getParent(),
+                                                                               e.getLocalizedMessage(), "IOException",
+                                                                               e);
                                                        }
                                                }
                                        }.execute();
@@ -464,22 +498,24 @@ public class BookPopup extends JPopupMenu {
         * @return the item
         */
        private JMenuItem createMenuItemRedownload() {
-               JMenuItem refresh = new JMenuItem(trans(StringIdGui.MENU_EDIT_REDOWNLOAD), KeyEvent.VK_R);
+               JMenuItem refresh = new JMenuItem(
+                               trans(StringIdGui.MENU_EDIT_REDOWNLOAD), KeyEvent.VK_R);
                refresh.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
-//                             final GuiReaderBook selectedBook = mainPanel.getSelectedBook();
-//                             if (selectedBook != null) {
-//                                     final MetaData meta = selectedBook.getInfo().getMeta();
-//                                     mainPanel.imprt(meta.getUrl(), new MetaDataRunnable() {
-//                                             @Override
-//                                             public void run(MetaData newMeta) {
-//                                                     if (!newMeta.getSource().equals(meta.getSource())) {
-//                                                             reader.changeSource(newMeta.getLuid(), meta.getSource());
-//                                                     }
-//                                             }
-//                                     }, trans(StringIdGui.PROGRESS_CHANGE_SOURCE));
-//                             }
+                               // final GuiReaderBook selectedBook =
+                               // mainPanel.getSelectedBook();
+                               // if (selectedBook != null) {
+                               // final MetaData meta = selectedBook.getInfo().getMeta();
+                               // mainPanel.imprt(meta.getUrl(), new MetaDataRunnable() {
+                               // @Override
+                               // public void run(MetaData newMeta) {
+                               // if (!newMeta.getSource().equals(meta.getSource())) {
+                               // reader.changeSource(newMeta.getLuid(), meta.getSource());
+                               // }
+                               // }
+                               // }, trans(StringIdGui.PROGRESS_CHANGE_SOURCE));
+                               // }
                        }
                });
 
@@ -492,7 +528,8 @@ public class BookPopup extends JPopupMenu {
         * @return the item
         */
        private JMenuItem createMenuItemDownloadToCache() {
-               JMenuItem refresh = new JMenuItem(trans(StringIdGui.MENU_EDIT_DOWNLOAD_TO_CACHE), KeyEvent.VK_T);
+               JMenuItem refresh = new JMenuItem(
+                               trans(StringIdGui.MENU_EDIT_DOWNLOAD_TO_CACHE), KeyEvent.VK_T);
                refresh.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
@@ -509,17 +546,20 @@ public class BookPopup extends JPopupMenu {
                                                                luids.add(book.getMeta().getLuid());
                                                                break;
                                                        case SOURCE:
-                                                               for (MetaData meta : lib.getList().filter(book.getMainInfo(), null, null)) {
+                                                               for (MetaData meta : lib.getList().filter(
+                                                                               book.getMainInfo(), null, null)) {
                                                                        luids.add(meta.getLuid());
                                                                }
                                                                break;
                                                        case AUTHOR:
-                                                               for (MetaData meta : lib.getList().filter(null, book.getMainInfo(), null)) {
+                                                               for (MetaData meta : lib.getList().filter(null,
+                                                                               book.getMainInfo(), null)) {
                                                                        luids.add(meta.getLuid());
                                                                }
                                                                break;
                                                        case TAG:
-                                                               for (MetaData meta : lib.getList().filter(null, null, book.getMainInfo())) {
+                                                               for (MetaData meta : lib.getList().filter(null,
+                                                                               null, book.getMainInfo())) {
                                                                        luids.add(meta.getLuid());
                                                                }
                                                                break;
@@ -547,7 +587,8 @@ public class BookPopup extends JPopupMenu {
                                                                informer.setCached(book, true);
                                                        }
                                                } catch (Exception e) {
-                                                       UiHelper.error(BookPopup.this.getParent(), e.getLocalizedMessage(), "IOException", e);
+                                                       UiHelper.error(BookPopup.this.getParent(),
+                                                                       e.getLocalizedMessage(), "IOException", e);
                                                }
                                        }
                                }.execute();
@@ -563,28 +604,33 @@ public class BookPopup extends JPopupMenu {
         * @return the item
         */
        private JMenuItem createMenuItemDelete() {
-               JMenuItem delete = new JMenuItem(trans(StringIdGui.MENU_EDIT_DELETE), KeyEvent.VK_D);
+               JMenuItem delete = new JMenuItem(trans(StringIdGui.MENU_EDIT_DELETE),
+                               KeyEvent.VK_D);
                delete.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
-//                             final GuiReaderBook selectedBook = mainPanel.getSelectedBook();
-//                             if (selectedBook != null && selectedBook.getInfo().getMeta() != null) {
-//
-//                                     final MetaData meta = selectedBook.getInfo().getMeta();
-//                                     int rep = JOptionPane.showConfirmDialog(GuiReaderFrame.this,
-//                                                     trans(StringIdGui.SUBTITLE_DELETE, meta.getLuid(), meta.getTitle()),
-//                                                     trans(StringIdGui.TITLE_DELETE), JOptionPane.OK_CANCEL_OPTION);
-//
-//                                     if (rep == JOptionPane.OK_OPTION) {
-//                                             mainPanel.outOfUi(null, true, new Runnable() {
-//                                                     @Override
-//                                                     public void run() {
-//                                                             reader.delete(meta.getLuid());
-//                                                             mainPanel.unsetSelectedBook();
-//                                                     }
-//                                             });
-//                                     }
-//                             }
+                               // final GuiReaderBook selectedBook =
+                               // mainPanel.getSelectedBook();
+                               // if (selectedBook != null && selectedBook.getInfo().getMeta()
+                               // != null) {
+                               //
+                               // final MetaData meta = selectedBook.getInfo().getMeta();
+                               // int rep = JOptionPane.showConfirmDialog(GuiReaderFrame.this,
+                               // trans(StringIdGui.SUBTITLE_DELETE, meta.getLuid(),
+                               // meta.getTitle()),
+                               // trans(StringIdGui.TITLE_DELETE),
+                               // JOptionPane.OK_CANCEL_OPTION);
+                               //
+                               // if (rep == JOptionPane.OK_OPTION) {
+                               // mainPanel.outOfUi(null, true, new Runnable() {
+                               // @Override
+                               // public void run() {
+                               // reader.delete(meta.getLuid());
+                               // mainPanel.unsetSelectedBook();
+                               // }
+                               // });
+                               // }
+                               // }
                        }
                });
 
@@ -597,20 +643,23 @@ public class BookPopup extends JPopupMenu {
         * @return the item
         */
        private JMenuItem createMenuItemProperties() {
-               JMenuItem delete = new JMenuItem(trans(StringIdGui.MENU_FILE_PROPERTIES), KeyEvent.VK_P);
+               JMenuItem delete = new JMenuItem(
+                               trans(StringIdGui.MENU_FILE_PROPERTIES), KeyEvent.VK_P);
                delete.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
-//                             final GuiReaderBook selectedBook = mainPanel.getSelectedBook();
-//                             if (selectedBook != null) {
-//                                     mainPanel.outOfUi(null, false, new Runnable() {
-//                                             @Override
-//                                             public void run() {
-//                                                     new GuiReaderPropertiesFrame(lib, selectedBook.getInfo().getMeta())
-//                                                                     .setVisible(true);
-//                                             }
-//                                     });
-//                             }
+                               // final GuiReaderBook selectedBook =
+                               // mainPanel.getSelectedBook();
+                               // if (selectedBook != null) {
+                               // mainPanel.outOfUi(null, false, new Runnable() {
+                               // @Override
+                               // public void run() {
+                               // new GuiReaderPropertiesFrame(lib,
+                               // selectedBook.getInfo().getMeta())
+                               // .setVisible(true);
+                               // }
+                               // });
+                               // }
                        }
                });
 
@@ -623,18 +672,20 @@ public class BookPopup extends JPopupMenu {
         * @return the item
         */
        public JMenuItem createMenuItemOpenBook() {
-               JMenuItem open = new JMenuItem(trans(StringIdGui.MENU_FILE_OPEN), KeyEvent.VK_O);
+               JMenuItem open = new JMenuItem(trans(StringIdGui.MENU_FILE_OPEN),
+                               KeyEvent.VK_O);
                open.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                                final BookInfo book = informer.getUniqueSelected();
                                if (book != null) {
-                                       Actions.openExternal(lib, book.getMeta(), BookPopup.this.getParent(), new Runnable() {
-                                               @Override
-                                               public void run() {
-                                                       informer.setCached(book, true);
-                                               }
-                                       });
+                                       Actions.openExternal(lib, book.getMeta(),
+                                                       BookPopup.this.getParent(), new Runnable() {
+                                                               @Override
+                                                               public void run() {
+                                                                       informer.setCached(book, true);
+                                                               }
+                                                       });
                                }
                        }
                });
@@ -643,30 +694,35 @@ public class BookPopup extends JPopupMenu {
        }
 
        /**
-        * Create the SetCover menu item for a book to change the linked source cover.
+        * Create the SetCover menu item for a book to change the linked source
+        * cover.
         * 
         * @return the item
         */
        private JMenuItem createMenuItemSetCoverForSource() {
-               JMenuItem open = new JMenuItem(trans(StringIdGui.MENU_EDIT_SET_COVER_FOR_SOURCE), KeyEvent.VK_C);
+               JMenuItem open = new JMenuItem(
+                               trans(StringIdGui.MENU_EDIT_SET_COVER_FOR_SOURCE),
+                               KeyEvent.VK_C);
                open.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent ae) {
-//                             final GuiReaderBook selectedBook = mainPanel.getSelectedBook();
-//                             if (selectedBook != null) {
-//                                     BasicLibrary lib = lib;
-//                                     String luid = selectedBook.getInfo().getMeta().getLuid();
-//                                     String source = selectedBook.getInfo().getMeta().getSource();
-//
-//                                     try {
-//                                             lib.setSourceCover(source, luid);
-//                                     } catch (IOException e) {
-//                                             error(e.getLocalizedMessage(), "IOException", e);
-//                                     }
-//
-//                                     GuiReaderBookInfo sourceInfo = GuiReaderBookInfo.fromSource(lib, source);
-//                                     GuiReaderCoverImager.clearIcon(sourceInfo);
-//                             }
+                               // final GuiReaderBook selectedBook =
+                               // mainPanel.getSelectedBook();
+                               // if (selectedBook != null) {
+                               // BasicLibrary lib = lib;
+                               // String luid = selectedBook.getInfo().getMeta().getLuid();
+                               // String source = selectedBook.getInfo().getMeta().getSource();
+                               //
+                               // try {
+                               // lib.setSourceCover(source, luid);
+                               // } catch (IOException e) {
+                               // error(e.getLocalizedMessage(), "IOException", e);
+                               // }
+                               //
+                               // GuiReaderBookInfo sourceInfo =
+                               // GuiReaderBookInfo.fromSource(lib, source);
+                               // GuiReaderCoverImager.clearIcon(sourceInfo);
+                               // }
                        }
                });
 
@@ -674,29 +730,34 @@ public class BookPopup extends JPopupMenu {
        }
 
        /**
-        * Create the SetCover menu item for a book to change the linked source cover.
+        * Create the SetCover menu item for a book to change the linked source
+        * cover.
         * 
         * @return the item
         */
        private JMenuItem createMenuItemSetCoverForAuthor() {
-               JMenuItem open = new JMenuItem(trans(StringIdGui.MENU_EDIT_SET_COVER_FOR_AUTHOR), KeyEvent.VK_A);
+               JMenuItem open = new JMenuItem(
+                               trans(StringIdGui.MENU_EDIT_SET_COVER_FOR_AUTHOR),
+                               KeyEvent.VK_A);
                open.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent ae) {
-//                             final GuiReaderBook selectedBook = mainPanel.getSelectedBook();
-//                             if (selectedBook != null) {
-//                                     String luid = selectedBook.getInfo().getMeta().getLuid();
-//                                     String author = selectedBook.getInfo().getMeta().getAuthor();
-//
-//                                     try {
-//                                             lib.setAuthorCover(author, luid);
-//                                     } catch (IOException e) {
-//                                             error(e.getLocalizedMessage(), "IOException", e);
-//                                     }
-//
-//                                     GuiReaderBookInfo authorInfo = GuiReaderBookInfo.fromAuthor(lib, author);
-//                                     GuiReaderCoverImager.clearIcon(authorInfo);
-//                             }
+                               // final GuiReaderBook selectedBook =
+                               // mainPanel.getSelectedBook();
+                               // if (selectedBook != null) {
+                               // String luid = selectedBook.getInfo().getMeta().getLuid();
+                               // String author = selectedBook.getInfo().getMeta().getAuthor();
+                               //
+                               // try {
+                               // lib.setAuthorCover(author, luid);
+                               // } catch (IOException e) {
+                               // error(e.getLocalizedMessage(), "IOException", e);
+                               // }
+                               //
+                               // GuiReaderBookInfo authorInfo =
+                               // GuiReaderBookInfo.fromAuthor(lib, author);
+                               // GuiReaderCoverImager.clearIcon(authorInfo);
+                               // }
                        }
                });
 
index f93b1d49ebfcce6d8f3293b6b91ff9230b0638dc..0323b770ab56ffa3c1407a3eb240d89b42cbd827 100644 (file)
@@ -21,7 +21,8 @@ public class AuthorTab extends BasicTab<List<String>> {
        @Override
        protected void fillData(List<String> data) {
                try {
-                       List<String> authors = Instance.getInstance().getLibrary().getAuthors();
+                       List<String> authors = Instance.getInstance().getLibrary()
+                                       .getAuthors();
                        for (String author : authors) {
                                data.add(author);
                        }
@@ -39,17 +40,20 @@ public class AuthorTab extends BasicTab<List<String>> {
        @Override
        protected String keyToDisplay(String key) {
                if (key.trim().isEmpty()) {
-                       key = Instance.getInstance().getTransGui().getString(StringIdGui.MENU_AUTHORS_UNKNOWN);
+                       key = Instance.getInstance().getTransGui()
+                                       .getString(StringIdGui.MENU_AUTHORS_UNKNOWN);
                }
-               
+
                return key;
        }
 
        @Override
-       protected int loadData(DefaultMutableTreeNode root, List<String> authors, String filter) {
+       protected int loadData(DefaultMutableTreeNode root, List<String> authors,
+                       String filter) {
                for (String author : authors) {
                        if (checkFilter(filter, author)) {
-                               DefaultMutableTreeNode sourceNode = new DefaultMutableTreeNode(author);
+                               DefaultMutableTreeNode sourceNode = new DefaultMutableTreeNode(
+                                               author);
                                root.add(sourceNode);
                        }
                }
index 86b4a02062ff4da9cf16a2bfa35893fbbedbc4ea..e89acc36d3dd63e468eb10ec3595eb469693d94f 100644 (file)
@@ -53,7 +53,8 @@ public abstract class BasicTab<T> extends ListenerPanel {
 
                tree = new JTree(root);
                tree.setUI(new BasicTreeUI());
-               TreeCellSpanner spanner = new TreeCellSpanner(tree, generateCellRenderer());
+               TreeCellSpanner spanner = new TreeCellSpanner(tree,
+                               generateCellRenderer());
                tree.setCellRenderer(spanner);
                tree.setRootVisible(false);
                tree.setShowsRootHandles(false);
@@ -103,18 +104,21 @@ public abstract class BasicTab<T> extends ListenerPanel {
                        protected boolean isSamePath(TreePath oldPath, TreePath newPath) {
                                String oldString = oldPath.toString();
                                if (oldString.endsWith("/]"))
-                                       oldString = oldString.substring(0, oldString.length() - 2) + "]";
+                                       oldString = oldString.substring(0, oldString.length() - 2)
+                                                       + "]";
 
                                String newString = newPath.toString();
                                if (newString.endsWith("/]"))
-                                       newString = newString.substring(0, newString.length() - 2) + "]";
+                                       newString = newString.substring(0, newString.length() - 2)
+                                                       + "]";
 
                                return oldString.equals(newString);
                        }
                };
                SwingWorker<Map<String, List<String>>, Integer> worker = new SwingWorker<Map<String, List<String>>, Integer>() {
                        @Override
-                       protected Map<String, List<String>> doInBackground() throws Exception {
+                       protected Map<String, List<String>> doInBackground()
+                                       throws Exception {
                                fillData(data);
                                return null;
                        }
@@ -165,7 +169,8 @@ public abstract class BasicTab<T> extends ListenerPanel {
                String count = "";
                if (totalCount > 0) {
                        int selected = selectedElements.size();
-                       count = " (" + (selected > 0 ? selected + "/" : "") + totalCount + ")";
+                       count = " (" + (selected > 0 ? selected + "/" : "") + totalCount
+                                       + ")";
                }
 
                return title + count;
@@ -180,7 +185,8 @@ public abstract class BasicTab<T> extends ListenerPanel {
        }
 
        protected boolean checkFilter(String filter, String value) {
-               return (filter == null || filter.isEmpty() || value.toLowerCase().contains(filter.toLowerCase()));
+               return (filter == null || filter.isEmpty()
+                               || value.toLowerCase().contains(filter.toLowerCase()));
        }
 
        protected boolean checkFilter(String filter, List<String> list) {
@@ -199,12 +205,14 @@ public abstract class BasicTab<T> extends ListenerPanel {
 
        protected abstract String keyToDisplay(String key);
 
-       protected abstract int loadData(DefaultMutableTreeNode root, T data, String filter);
+       protected abstract int loadData(DefaultMutableTreeNode root, T data,
+                       String filter);
 
        private TreeCellRenderer generateCellRenderer() {
                DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer() {
                        @Override
-                       public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded,
+                       public Component getTreeCellRendererComponent(JTree tree,
+                                       Object value, boolean selected, boolean expanded,
                                        boolean leaf, int row, boolean hasFocus) {
                                if (value instanceof DefaultMutableTreeNode) {
                                        if (((DefaultMutableTreeNode) value).getLevel() > 1) {
@@ -218,7 +226,8 @@ public abstract class BasicTab<T> extends ListenerPanel {
                                String display = value == null ? "" : value.toString();
                                display = keyToDisplay(display);
 
-                               return super.getTreeCellRendererComponent(tree, display, selected, expanded, leaf, row, hasFocus);
+                               return super.getTreeCellRendererComponent(tree, display,
+                                               selected, expanded, leaf, row, hasFocus);
                        }
                };
 
index ffa5e416abfd9936ee47264cd787e62ac46a0da6..8ac5c1ef96ab4c56b6bd1a98a462d87693bb3891 100644 (file)
@@ -21,7 +21,8 @@ public class SourceTab extends BasicTab<Map<String, List<String>>> {
        @Override
        protected void fillData(Map<String, List<String>> data) {
                try {
-                       Map<String, List<String>> sourcesGrouped = Instance.getInstance().getLibrary().getSourcesGrouped();
+                       Map<String, List<String>> sourcesGrouped = Instance.getInstance()
+                                       .getLibrary().getSourcesGrouped();
                        for (String group : sourcesGrouped.keySet()) {
                                data.put(group, sourcesGrouped.get(group));
                        }
@@ -62,22 +63,30 @@ public class SourceTab extends BasicTab<Map<String, List<String>>> {
        }
 
        @Override
-       protected int loadData(DefaultMutableTreeNode root, Map<String, List<String>> sourcesGrouped, String filter) {
+       protected int loadData(DefaultMutableTreeNode root,
+                       Map<String, List<String>> sourcesGrouped, String filter) {
                int count = 0;
                for (String source : sourcesGrouped.keySet()) {
-                       if (checkFilter(filter, source) || checkFilter(filter, sourcesGrouped.get(source))) {
+                       if (checkFilter(filter, source)
+                                       || checkFilter(filter, sourcesGrouped.get(source))) {
                                List<String> children = sourcesGrouped.get(source);
                                boolean hasChildren = (children.size() > 1)
-                                               || (children.size() == 1 && !children.get(0).trim().isEmpty());
-                               DefaultMutableTreeNode sourceNode = new DefaultMutableTreeNode(">" + source + (hasChildren ? "/" : ""));
+                                               || (children.size() == 1
+                                                               && !children.get(0).trim().isEmpty());
+                               DefaultMutableTreeNode sourceNode = new DefaultMutableTreeNode(
+                                               ">" + source + (hasChildren ? "/" : ""));
                                root.add(sourceNode);
                                for (String subSource : children) {
-                                       if (checkFilter(filter, source) || checkFilter(filter, subSource)) {
+                                       if (checkFilter(filter, source)
+                                                       || checkFilter(filter, subSource)) {
                                                count = count + 1;
-                                               if (subSource.isEmpty() && sourcesGrouped.get(source).size() > 1) {
-                                                       sourceNode.add(new DefaultMutableTreeNode(" " + source));
+                                               if (subSource.isEmpty()
+                                                               && sourcesGrouped.get(source).size() > 1) {
+                                                       sourceNode.add(
+                                                                       new DefaultMutableTreeNode(" " + source));
                                                } else if (!subSource.isEmpty()) {
-                                                       sourceNode.add(new DefaultMutableTreeNode(" " + source + "/" + subSource));
+                                                       sourceNode.add(new DefaultMutableTreeNode(
+                                                                       " " + source + "/" + subSource));
                                                }
                                        }
                                }
index 90c82192fc48d0b7b3ae7bfce7d722a6ff9d1d8b..49fcc27f609b7706e8ae4a9a75caac5e5bbf1c4f 100644 (file)
@@ -23,7 +23,8 @@ public class TagsTab extends BasicTab<List<String>> {
        @Override
        protected void fillData(List<String> data) {
                try {
-                       MetaResultList metas = Instance.getInstance().getLibrary().getList();
+                       MetaResultList metas = Instance.getInstance().getLibrary()
+                                       .getList();
                        // TODO: getTagList, getAuthorList... ?
                        for (MetaData meta : metas.getMetas()) {
                                List<String> tags = meta.getTags();
@@ -50,17 +51,20 @@ public class TagsTab extends BasicTab<List<String>> {
        protected String keyToDisplay(String key) {
                if (key.trim().isEmpty()) {
                        // TODO: new TAG_UNKNOWN needed
-                       key = Instance.getInstance().getTransGui().getString(StringIdGui.MENU_AUTHORS_UNKNOWN);
+                       key = Instance.getInstance().getTransGui()
+                                       .getString(StringIdGui.MENU_AUTHORS_UNKNOWN);
                }
 
                return key;
        }
 
        @Override
-       protected int loadData(DefaultMutableTreeNode root, List<String> tags, String filter) {
+       protected int loadData(DefaultMutableTreeNode root, List<String> tags,
+                       String filter) {
                for (String tag : tags) {
                        if (checkFilter(filter, tag)) {
-                               DefaultMutableTreeNode sourceNode = new DefaultMutableTreeNode(tag);
+                               DefaultMutableTreeNode sourceNode = new DefaultMutableTreeNode(
+                                               tag);
                                root.add(sourceNode);
                        }
                }
index 5d23ab50a9a635b5dd537400bc6efcb0d3a34ede..08a65b0710b76e0cca1d2aaa7ceabbad89d2fbf0 100644 (file)
@@ -40,19 +40,25 @@ public class UiHelper {
        static public JComponent scroll(JComponent pane) {
                JScrollPane scroll = new JScrollPane(pane);
                scroll.getVerticalScrollBar().setUnitIncrement(16);
-               scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+               scroll.setHorizontalScrollBarPolicy(
+                               JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
                return scroll;
        }
 
        /**
         * Display an error message and log the linked {@link Exception}.
         * 
-        * @param owner   the owner of the error (to link the messagebox to it)
-        * @param message the message
-        * @param title   the title of the error message
-        * @param e       the exception to log if any
+        * @param owner
+        *            the owner of the error (to link the messagebox to it)
+        * @param message
+        *            the message
+        * @param title
+        *            the title of the error message
+        * @param e
+        *            the exception to log if any
         */
-       static public void error(final Component owner, final String message, final String title, Exception e) {
+       static public void error(final Component owner, final String message,
+                       final String title, Exception e) {
                Instance.getInstance().getTraceHandler().error(title + ": " + message);
                if (e != null) {
                        Instance.getInstance().getTraceHandler().error(e);
@@ -61,7 +67,8 @@ public class UiHelper {
                SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
-                               JOptionPane.showMessageDialog(owner, message, title, JOptionPane.ERROR_MESSAGE);
+                               JOptionPane.showMessageDialog(owner, message, title,
+                                               JOptionPane.ERROR_MESSAGE);
                        }
                });
        }
index 780b1bbd050556e1a42cd45cfe97dc3ae5bdb47a..c8d126a83e1a9cbe1048514085da4abedabda719 100644 (file)
@@ -79,14 +79,17 @@ public class IconGenerator {
        /**
         * Generate a new image.
         * 
-        * @param name the name of the resource
-        * @param size the requested size
+        * @param name
+        *            the name of the resource
+        * @param size
+        *            the requested size
         * 
         * @return the image, or NULL if it does not exist or does not exist at that
         *         size
         */
        static public ImageIcon get(Icon name, Size size) {
-               String key = String.format("%s-%dx%d.png", name.name(), size.getSize(), size.getSize());
+               String key = String.format("%s-%dx%d.png", name.name(), size.getSize(),
+                               size.getSize());
                if (!map.containsKey(key)) {
                        map.put(key, generate(key));
                }
@@ -97,14 +100,16 @@ public class IconGenerator {
        /**
         * Generate a new image.
         * 
-        * @param filename the file name of the resource (no directory)
+        * @param filename
+        *            the file name of the resource (no directory)
         * 
         * @return the image, or NULL if it does not exist or does not exist at that
         *         size
         */
        static private ImageIcon generate(String filename) {
                try {
-                       InputStream in = IOUtils.openResource(IconGenerator.class, filename);
+                       InputStream in = IOUtils.openResource(IconGenerator.class,
+                                       filename);
                        if (in != null) {
                                try {
                                        return new ImageIcon(IOUtils.toByteArray(in));