add DEP3 headers to debian/patches/mrDlib.patch
[debian/jabref.git] / debian / patches / mrDlib.patch
1 Description: This is the diff between the debian and the beta_2.9 branches
2  in upstream git; the debian branch was created for us with the purpose to
3  disable the mrDlib functionality which needs libraries not packaged in
4  Debian yet.
5 Origin: upstream git
6 Author: Oliver Kopp <oliver.kopp@gmail.com>
7 Reviewed-by: gregor herrmann <gregoa@debian.org>
8 Last-Update: 2012-10-29
9
10 --- a/src/java/net/sf/jabref/ImportSettingsTab.java
11 +++ b/src/java/net/sf/jabref/ImportSettingsTab.java
12 @@ -44,10 +44,8 @@
13         
14      private JRadioButton radioButtonXmp;
15         private JRadioButton radioButtonPDFcontent;
16 -    private JRadioButton radioButtonMrDlib;
17      private JRadioButton radioButtonNoMeta;
18         private JRadioButton radioButtononlyAttachPDF;
19 -       private JRadioButton radioButtonUpdateEmptyFields;
20         private JCheckBox useDefaultPDFImportStyle;
21         
22         private JTextField fileNamePattern;
23 @@ -59,17 +57,12 @@
24          radioButtonNoMeta = new JRadioButton(Globals.lang("Create_blank_entry_linking_the_PDF"));
25          radioButtonXmp = new JRadioButton(Globals.lang("Create_entry_based_on_XMP_data"));
26          radioButtonPDFcontent = new JRadioButton(Globals.lang("Create_entry_based_on_content"));
27 -        radioButtonMrDlib = new JRadioButton(Globals.lang("Create_entry_based_on_data_fetched_from")+" Mr.DLib");
28          radioButtononlyAttachPDF = new JRadioButton(Globals.lang("Only_attach_PDF"));
29 -        radioButtonUpdateEmptyFields = new JRadioButton(Globals.lang("Update_empty_fields_with_data_fetched_from")
30 -            +" Mr.DLib");
31          ButtonGroup bg = new ButtonGroup();
32          bg.add(radioButtonNoMeta);
33          bg.add(radioButtonXmp);
34          bg.add(radioButtonPDFcontent);
35 -        bg.add(radioButtonMrDlib);
36          bg.add(radioButtononlyAttachPDF);
37 -        bg.add(radioButtonUpdateEmptyFields);
38  
39          useDefaultPDFImportStyle = new JCheckBox(Globals.lang("Always use this PDF import style (and do not ask for each import)"));
40                 
41 @@ -96,15 +89,9 @@
42                 builder.append(radioButtonPDFcontent);
43          builder.nextLine();
44          builder.append(pan);
45 -               builder.append(radioButtonMrDlib);
46 -        builder.nextLine();
47 -        builder.append(pan);
48                 builder.append(radioButtononlyAttachPDF);
49          builder.nextLine();
50          builder.append(pan);
51 -               builder.append(radioButtonUpdateEmptyFields);
52 -        builder.nextLine();
53 -        builder.append(pan);
54                 builder.append(useDefaultPDFImportStyle);
55          builder.nextLine();
56                 
57 @@ -136,15 +123,9 @@
58                 case ImportDialog.CONTENT:
59                         radioButtonPDFcontent.setSelected(true);
60                         break;
61 -               case ImportDialog.MRDLIB:
62 -                       radioButtonMrDlib.setSelected(true);
63 -                       break;
64                 case ImportDialog.ONLYATTACH:
65                         radioButtononlyAttachPDF.setSelected(true);
66                         break;
67 -               case ImportDialog.UPDATEEMPTYFIELDS:
68 -                       radioButtonUpdateEmptyFields.setSelected(true);
69 -                       break;
70                 default:
71                         // fallback
72                         radioButtonPDFcontent.setSelected(true);
73 @@ -162,12 +143,9 @@
74                         style = ImportDialog.XMP;
75                 else if (radioButtonPDFcontent.isSelected())
76                         style = ImportDialog.CONTENT;
77 -               else if (radioButtonMrDlib.isSelected())
78 -                       style = ImportDialog.MRDLIB;
79                 else if (radioButtononlyAttachPDF.isSelected())
80                         style = ImportDialog.ONLYATTACH;
81 -               else if (radioButtonUpdateEmptyFields.isSelected())
82 -                       style = ImportDialog.UPDATEEMPTYFIELDS;
83 +               else throw new IllegalStateException();
84                 Globals.prefs.putInt(PREF_IMPORT_DEFAULT_PDF_IMPORT_STYLE, style);
85                 Globals.prefs.put(PREF_IMPORT_FILENAMEPATTERN, fileNamePattern.getText());
86         }
87 --- a/src/java/spl/DocumentWrapper.java
88 +++ /dev/null
89 @@ -1,272 +0,0 @@
90 -package spl;\r
91 -\r
92 -import java.util.List;\r
93 -\r
94 -import org.sciplore.beans.Abstract;\r
95 -import org.sciplore.beans.Author;\r
96 -import org.sciplore.beans.Authors;\r
97 -import org.sciplore.beans.Document;\r
98 -import org.sciplore.formatter.Bean;\r
99 -import org.sciplore.formatter.SimpleTypeElementBean;\r
100 -\r
101 -/**\r
102 - * Created by IntelliJ IDEA.\r
103 - * User: Christoph Arbeit\r
104 - * Date: 10.09.2010\r
105 - * Time: 20:02:51\r
106 - * To change this template use File | Settings | File Templates.\r
107 - */\r
108 -public class DocumentWrapper {\r
109 -\r
110 -    Document xmlDocument;\r
111 -\r
112 -    public DocumentWrapper(Document xmlDocument) {\r
113 -        this.xmlDocument = xmlDocument;\r
114 -    }\r
115 -\r
116 -    public Document getXmlDocument() {\r
117 -        return xmlDocument;\r
118 -    }\r
119 -\r
120 -    public void setXmlDocument(Document xmlDocument) {\r
121 -        this.xmlDocument = xmlDocument;\r
122 -    }\r
123 -\r
124 -    public String getTitle(){\r
125 -        if(this.hasTitle()){\r
126 -            return xmlDocument.getTitle().getValue();\r
127 -        }\r
128 -        else{\r
129 -            return "";\r
130 -        }\r
131 -    }\r
132 -\r
133 -    public boolean hasTitle(){\r
134 -        return (xmlDocument.getTitle() != null && xmlDocument.getTitle().getValue() != null && !xmlDocument.getTitle().getValue().isEmpty());\r
135 -    }\r
136 -\r
137 -    public String getAbstract(){\r
138 -        if(this.hasAbstract()){\r
139 -            return ((Abstract)xmlDocument.getAbstract()).getValue();\r
140 -        }\r
141 -        else{\r
142 -            return "";\r
143 -        }\r
144 -    }\r
145 -\r
146 -    public boolean hasAbstract(){\r
147 -        return (xmlDocument.getAbstract() != null && ((Abstract)xmlDocument.getAbstract()).getValue() != null && !((Abstract)xmlDocument.getAbstract()).getValue().isEmpty());\r
148 -    }\r
149 -\r
150 -   public String getAuthors(String seperator){\r
151 -        if(this.hasAuthors()){\r
152 -               List<Bean> authors = xmlDocument.getAuthors().getCollection();\r
153 -            authors = this.sortAuthors(authors);\r
154 -            String value = "";\r
155 -            int i = 1;\r
156 -            for(Bean author : authors){\r
157 -                if(i < authors.size()){\r
158 -                    value = value + getNameComplete((Author)author);\r
159 -                    value = value + " " + seperator + " ";\r
160 -                }\r
161 -                else{\r
162 -                    value = value + getNameComplete((Author)author);\r
163 -                }\r
164 -                i++;\r
165 -            }\r
166 -            return value;\r
167 -        }\r
168 -        else{\r
169 -            return "";\r
170 -        }\r
171 -    }\r
172 -\r
173 -    public boolean hasAuthors(){\r
174 -        return (xmlDocument.getAuthors() != null && xmlDocument.getAuthors().getCollection() != null && !xmlDocument.getAuthors().getCollection().isEmpty());\r
175 -    }\r
176 -\r
177 -    /* public String getKeyWords(){\r
178 -        if(this.hasKeyWords()){\r
179 -            List<XmlKeyword> keywords = xmlDocument.getKeywords().getKeywords();\r
180 -            String value = "";\r
181 -            int i = 1;\r
182 -            for(XmlKeyword keyword : keywords){\r
183 -                if(i < keywords.size()){\r
184 -                    value = value + keyword.getValue();\r
185 -                    value = value + ", ";\r
186 -                }\r
187 -                else{\r
188 -                    value = value + keyword.getValue();\r
189 -                }\r
190 -                i++;\r
191 -            }\r
192 -            return value;\r
193 -        }\r
194 -        else{\r
195 -            return "";\r
196 -        }\r
197 -    }\r
198 -\r
199 -    public boolean hasKeyWords(){\r
200 -        return (xmlDocument.getKeywords() != null && xmlDocument.getKeywords().getKeywords() != null && !xmlDocument.getKeywords().getKeywords().isEmpty());\r
201 -    }\r
202 -*/\r
203 -\r
204 -    public String getDoi(){\r
205 -        if(this.hasDoi()){\r
206 -            return this.getSimpleTypeValue(xmlDocument.getDoi());\r
207 -        }\r
208 -        else{\r
209 -            return "";\r
210 -        }\r
211 -    }\r
212 -\r
213 -    public boolean hasDoi(){\r
214 -        return (xmlDocument.getDoi() != null && this.getSimpleTypeValue(xmlDocument.getDoi()) != null && !this.getSimpleTypeValue(xmlDocument.getDoi()).isEmpty());\r
215 -    }\r
216 -/*\r
217 -    public String getPages(){\r
218 -        if(this.hasPages()){\r
219 -            return xmlDocument.getPages().getValue();\r
220 -        }\r
221 -        else{\r
222 -            return "";\r
223 -        }\r
224 -    }\r
225 -\r
226 -    public boolean hasPages(){\r
227 -        return (xmlDocument.getPages() != null && xmlDocument.getPages().getValue() != null && !xmlDocument.getPages().getValue().isEmpty());\r
228 -    }\r
229 -\r
230 -    public String getVolume(){\r
231 -        if(this.hasVolume()){\r
232 -            return xmlDocument.getVolume().getValue();\r
233 -        }\r
234 -        else{\r
235 -            return "";\r
236 -        }\r
237 -    }\r
238 -\r
239 -    public boolean hasVolume(){\r
240 -        return (xmlDocument.getVolume() != null && xmlDocument.getVolume().getValue() != null && !xmlDocument.getVolume().getValue().isEmpty());\r
241 -    }\r
242 -\r
243 -    public String getNumber(){\r
244 -        if(this.hasNumber()){\r
245 -            return xmlDocument.getNumber().getValue();\r
246 -        }\r
247 -        else{\r
248 -            return "";\r
249 -        }\r
250 -    }\r
251 -\r
252 -    public boolean hasNumber(){\r
253 -        return (xmlDocument.getNumber() != null && xmlDocument.getNumber().getValue() != null && !xmlDocument.getNumber().getValue().isEmpty());\r
254 -    }\r
255 -*/\r
256 -    \r
257 -    public String getYear(){\r
258 -        if(this.hasYear()){\r
259 -            return this.getSimpleTypeValue(xmlDocument.getYear());\r
260 -        }\r
261 -        else{\r
262 -            return "";\r
263 -        }\r
264 -    }\r
265 -\r
266 -    public boolean hasYear(){\r
267 -        return (this.getSimpleTypeValue(xmlDocument.getYear()) != null && !this.getSimpleTypeValue(xmlDocument.getYear()).isEmpty() && !this.getSimpleTypeValue(xmlDocument.getYear()).equalsIgnoreCase("null"));\r
268 -    }\r
269 -    \r
270 -/*\r
271 -     public String getMonth(){\r
272 -        if(this.hasMonth()){\r
273 -            return xmlDocument.getPublishdate().getMonth();\r
274 -        }\r
275 -        else{\r
276 -            return "";\r
277 -        }\r
278 -    }\r
279 -\r
280 -    public boolean hasMonth(){\r
281 -        return (xmlDocument.getPublishdate() != null && xmlDocument.getPublishdate().getMonth() != null && !xmlDocument.getPublishdate().getMonth().isEmpty());\r
282 -    }\r
283 -\r
284 -    public String getDay(){\r
285 -        if(this.hasDay()){\r
286 -            return xmlDocument.getPublishdate().getDay();\r
287 -        }\r
288 -        else{\r
289 -            return "";\r
290 -        }\r
291 -    }\r
292 -\r
293 -    public boolean hasDay(){\r
294 -        return (xmlDocument.getPublishdate() != null && xmlDocument.getPublishdate().getDay() != null && !xmlDocument.getPublishdate().getDay().isEmpty());\r
295 -    }\r
296 -    \r
297 -       /*\r
298 -    public String getVenue() {\r
299 -        if(this.hasVenue()){\r
300 -            return xmlDocument.getVenue().getValue();\r
301 -        }\r
302 -        else{\r
303 -            return "";\r
304 -        }\r
305 -    }\r
306 -\r
307 -    public boolean hasVenue(){\r
308 -        return (xmlDocument.getVenue() != null && xmlDocument.getVenue().getValue() != null && !xmlDocument.getVenue().getValue().isEmpty());\r
309 -    }*/\r
310 -    \r
311 -    private String getNameComplete(Author author){\r
312 -       if(author == null) return "";\r
313 -       String result = "";\r
314 -       if(getSimpleTypeValue(author.getName_First()) != null)\r
315 -               result = result + getSimpleTypeValue(author.getName_First()).trim() + " ";\r
316 -       if(getSimpleTypeValue(author.getName_Middle()) != null)\r
317 -               result = result + getSimpleTypeValue(author.getName_Middle()).trim() + " ";\r
318 -       if(getSimpleTypeValue(author.getName_Last_Prefix()) != null)\r
319 -               result = result + getSimpleTypeValue(author.getName_Last_Prefix()).trim() + " ";\r
320 -       if(getSimpleTypeValue(author.getName_Last()) != null)\r
321 -               result = result + getSimpleTypeValue(author.getName_Last()).trim() + " ";\r
322 -       if(getSimpleTypeValue(author.getName_Last_Suffix()) != null)\r
323 -               result = result + getSimpleTypeValue(author.getName_Last_Suffix()).trim() + " ";\r
324 -       return result.trim();\r
325 -    }\r
326 -    \r
327 -    private String getSimpleTypeValue(Bean bean){\r
328 -       if(bean == null || !(bean instanceof SimpleTypeElementBean)) return null;\r
329 -       SimpleTypeElementBean simpleTypeElementBean = (SimpleTypeElementBean)bean;\r
330 -       if(simpleTypeElementBean.getValue() == null || simpleTypeElementBean.getValue().equalsIgnoreCase("null") || simpleTypeElementBean.getValue().length() <= 0) return null;\r
331 -       return simpleTypeElementBean.getValue();\r
332 -    }\r
333 -    \r
334 -    private List<Bean> sortAuthors(List<Bean> authors){\r
335 -        boolean unsorted = true;\r
336 -        Bean temp;\r
337 -        \r
338 -        while (unsorted){\r
339 -                unsorted = false;\r
340 -                for (int i = 0; i < authors.size() - 1; i++){\r
341 -                        int rank = 99;\r
342 -                        int otherRank = 99;\r
343 -                        if(((Author)authors.get(i)).getRank() != null && !((Author)authors.get(i)).getRank().equalsIgnoreCase("null")){\r
344 -                                rank = Integer.parseInt(((Author)authors.get(i)).getRank());\r
345 -                        }                       \r
346 -                        if(((Author)authors.get(i + 1)).getRank() != null && !((Author)authors.get(i + 1)).getRank().equalsIgnoreCase("null")){\r
347 -                                otherRank = Integer.parseInt(((Author)authors.get(i + 1)).getRank());\r
348 -                        }                       \r
349 -                        \r
350 -                        if (rank > otherRank) {                      \r
351 -                 temp       = authors.get(i);\r
352 -                 authors.set(i, authors.get(i + 1));\r
353 -                 authors.set(i + 1, temp);                 \r
354 -                 unsorted = true;\r
355 -              }          \r
356 -               }        \r
357 -       } \r
358 -       \r
359 -       return authors;\r
360 -   }\r
361 -}\r
362 --- a/src/java/spl/DocumentsWrapper.java
363 +++ /dev/null
364 @@ -1,132 +0,0 @@
365 -package spl;\r
366 -\r
367 -import java.util.ArrayList;\r
368 -import java.util.List;\r
369 -import java.util.Vector;\r
370 -\r
371 -import org.sciplore.beans.Author;\r
372 -import org.sciplore.beans.Document;\r
373 -import org.sciplore.beans.Year;\r
374 -import org.sciplore.formatter.Bean;\r
375 -import org.sciplore.formatter.SimpleTypeElementBean;\r
376 -\r
377 -/**\r
378 - * Created by IntelliJ IDEA.\r
379 - * User: Christoph Arbeit\r
380 - * Date: 09.09.2010\r
381 - * Time: 10:56:50\r
382 - * To change this template use File | Settings | File Templates.\r
383 - */\r
384 -public class DocumentsWrapper {\r
385 -\r
386 -    Document xmlDocuments;\r
387 -\r
388 -    public DocumentsWrapper(Document documents) {\r
389 -        this.xmlDocuments = documents;\r
390 -    }\r
391 -\r
392 -    public Document getXmlDocuments() {\r
393 -        return xmlDocuments;\r
394 -    }\r
395 -\r
396 -    public void setXmlDocuments(Document xmlDocuments) {\r
397 -        this.xmlDocuments = xmlDocuments;\r
398 -    }\r
399 -\r
400 -    public List<Vector> getDocuments(){\r
401 -        List<Vector> documents = new ArrayList<Vector>();\r
402 -        //List<XmlDocument> xmlDocuments = this.xmlDocuments.getDocuments();\r
403 -        //for(XmlDocument xmlDocument : xmlDocuments){\r
404 -               Document xmlDocument = xmlDocuments;\r
405 -            Vector<String> vector = new Vector<String>();\r
406 -            if(xmlDocument.getTitle() != null){\r
407 -                vector.add(xmlDocument.getTitle().getValue());\r
408 -            }\r
409 -            else{\r
410 -                vector.add("");\r
411 -            }\r
412 -            if(xmlDocument.getAuthors() != null){\r
413 -                List<Bean> authors = xmlDocument.getAuthors().getCollection();\r
414 -                authors = this.sortAuthors(authors);\r
415 -                String value = "";\r
416 -                int i = 1;\r
417 -                for(Bean author : authors){\r
418 -                    if(i < authors.size()){\r
419 -                        value = value + getNameComplete(((Author)author));\r
420 -                        value = value + ", ";\r
421 -                    }\r
422 -                    else{\r
423 -                        value = value + getNameComplete(((Author)author));\r
424 -                    }\r
425 -                    i++;\r
426 -                }\r
427 -                vector.add(value);\r
428 -            }\r
429 -            else{\r
430 -                vector.add("");\r
431 -            }\r
432 -            if(xmlDocument.getYear() != null && ((Year)xmlDocument.getYear()).getValue() != null && !((Year)xmlDocument.getYear()).getValue().equalsIgnoreCase("null")){\r
433 -                vector.add(((Year)xmlDocument.getYear()).getValue());\r
434 -            }\r
435 -            /*if(xmlDocument.getPublishdate() != null && xmlDocument.getPublishdate().getYear() != null && !xmlDocument.getPublishdate().getYear().equalsIgnoreCase("null")){\r
436 -                vector.add(xmlDocument.getPublishdate().getYear());\r
437 -            }*/\r
438 -            else{\r
439 -                vector.add("");\r
440 -            }\r
441 -            documents.add(vector);\r
442 -        //}\r
443 -        return documents;\r
444 -    }\r
445 -    \r
446 -    private String getNameComplete(Author author){\r
447 -       if(author == null) return "";\r
448 -       String result = "";\r
449 -       if(getSimpleTypeValue(author.getName_First()) != null)\r
450 -               result = result + getSimpleTypeValue(author.getName_First()).trim() + " ";\r
451 -       if(getSimpleTypeValue(author.getName_Middle()) != null)\r
452 -               result = result + getSimpleTypeValue(author.getName_Middle()).trim() + " ";\r
453 -       if(getSimpleTypeValue(author.getName_Last_Prefix()) != null)\r
454 -               result = result + getSimpleTypeValue(author.getName_Last_Prefix()).trim() + " ";\r
455 -       if(getSimpleTypeValue(author.getName_Last()) != null)\r
456 -               result = result + getSimpleTypeValue(author.getName_Last()).trim() + " ";\r
457 -       if(getSimpleTypeValue(author.getName_Last_Suffix()) != null)\r
458 -               result = result + getSimpleTypeValue(author.getName_Last_Suffix()).trim() + " ";\r
459 -       return result.trim();\r
460 -    }\r
461 -    \r
462 -    private String getSimpleTypeValue(Bean bean){\r
463 -       if(bean == null || !(bean instanceof SimpleTypeElementBean)) return null;\r
464 -       SimpleTypeElementBean simpleTypeElementBean = (SimpleTypeElementBean)bean;\r
465 -       if(simpleTypeElementBean.getValue() == null || simpleTypeElementBean.getValue().equalsIgnoreCase("null") || simpleTypeElementBean.getValue().length() <= 0) return null;\r
466 -       return simpleTypeElementBean.getValue();\r
467 -    }\r
468 -    \r
469 -    private List<Bean> sortAuthors(List<Bean> authors){\r
470 -        boolean unsorted = true;\r
471 -         Bean temp;\r
472 -         \r
473 -         while (unsorted){\r
474 -                unsorted = false;\r
475 -                for (int i = 0; i < authors.size() - 1; i++){\r
476 -                        int rank = 99;\r
477 -                        int otherRank = 99;\r
478 -                        if(((Author)authors.get(i)).getRank() != null && !((Author)authors.get(i)).getRank().equalsIgnoreCase("null")){\r
479 -                                rank = Integer.parseInt(((Author)authors.get(i)).getRank());\r
480 -                        }                       \r
481 -                        if(((Author)authors.get(i + 1)).getRank() != null && !((Author)authors.get(i + 1)).getRank().equalsIgnoreCase("null")){\r
482 -                                otherRank = Integer.parseInt(((Author)authors.get(i + 1)).getRank());\r
483 -                        }                       \r
484 -                        \r
485 -                        if (rank > otherRank) {                      \r
486 -                  temp       = authors.get(i);\r
487 -                  authors.set(i, authors.get(i + 1));\r
488 -                  authors.set(i + 1, temp);                 \r
489 -                  unsorted = true;\r
490 -               }          \r
491 -               }        \r
492 -        } \r
493 -       \r
494 -       return authors;\r
495 -    }\r
496 -}\r
497 --- a/src/java/spl/PdfImporter.java
498 +++ b/src/java/spl/PdfImporter.java
499 @@ -21,15 +21,9 @@
500  import net.sf.jabref.undo.UndoableInsertEntry;\r
501  import net.sf.jabref.util.XMPUtil;\r
502  \r
503 -import org.sciplore.beans.Document;\r
504 -\r
505  import spl.filter.PdfFileFilter;\r
506  import spl.gui.ImportDialog;\r
507 -import spl.gui.MetaDataListDialog;\r
508  \r
509 -import java.util.ArrayList;\r
510 -import java.util.Arrays;\r
511 -import java.util.List;\r
512  import java.util.Set;\r
513  \r
514  \r
515 @@ -113,7 +107,6 @@
516                 BibtexEntryType type;\r
517                  InputStream in = null;\r
518                  List<BibtexEntry> res = null;\r
519 -               MetaDataListDialog metaDataListDialog;\r
520                  switch (choice) {\r
521                         case ImportDialog.XMP:\r
522                      //SplDatabaseChangeListener dataListener = new SplDatabaseChangeListener(frame, panel, entryTable, fileName);\r
523 @@ -200,84 +193,9 @@
524                          panel.adjustSplitter();\r
525                      }\r
526                      break;\r
527 -                       case ImportDialog.MRDLIB:\r
528 -                    metaDataListDialog = new MetaDataListDialog(fileName, true);\r
529 -                    Tools.centerRelativeToWindow(metaDataListDialog, frame);\r
530 -                    metaDataListDialog.showDialog();\r
531 -                    Document document = metaDataListDialog.getXmlDocuments();\r
532 -                    if(document != null /*&& documents.getDocuments() != null && documents.getDocuments().size() > 0*/ && metaDataListDialog.getResult() == JOptionPane.OK_OPTION){\r
533 -                        int selected = metaDataListDialog.getTableMetadata().getSelectedRow();\r
534 -                        if(selected > -1 /*&& selected < documents.getDocuments().size()*/){\r
535 -                            //Document document = documents/*.getDocuments().get(selected)*/;\r
536 -                            String id = Util.createNeutralId();\r
537 -                            entry = new BibtexEntry(id);\r
538 -                            if(fieldExists(document.getType())){\r
539 -                                type = BibtexEntryType.getStandardType(document.getType());\r
540 -                                if(type == null){\r
541 -                                    type = BibtexEntryType.ARTICLE;\r
542 -                                }\r
543 -                                entry.setType(type);\r
544 -                            }\r
545 -                            else{\r
546 -                                entry.setType(BibtexEntryType.ARTICLE);\r
547 -                            }\r
548 -                            ArrayList<BibtexEntry> list = new ArrayList<BibtexEntry>();\r
549 -                            list.add(entry);\r
550 -                            Util.setAutomaticFields(list, true, true, false);\r
551 -                            //insertFields(entry.getRequiredFields(), entry, document);\r
552 -                            insertFields(BibtexFields.getAllFieldNames(), entry, document);\r
553 -                            //insertFields(entry.getOptionalFields(), entry, document);\r
554 -                            panel.database().insertEntry(entry);\r
555 -                            dfh = new DroppedFileHandler(frame, panel);\r
556 -                            dfh.linkPdfToEntry(fileName, entryTable, entry);\r
557 -                            LabelPatternUtil.makeLabel(panel.metaData(), panel.database(), entry);\r
558 -                        }\r
559 -                        else{\r
560 -                            createNewBlankEntry(fileName);\r
561 -                        }\r
562 -                    }\r
563 -                    else if(metaDataListDialog.getResult() == JOptionPane.CANCEL_OPTION ){\r
564 -                        continue;\r
565 -                    }\r
566 -                    else if(metaDataListDialog.getResult() == JOptionPane.NO_OPTION ){\r
567 -                        createNewBlankEntry(fileName);\r
568 -                    }\r
569 -                    else if(document == null /*|| document.getDocuments() == null || document.getDocuments().size() <= 0*/ && metaDataListDialog.getResult() == JOptionPane.OK_OPTION){\r
570 -                        createNewBlankEntry(fileName);\r
571 -                    }\r
572 -                    break;\r
573                         case ImportDialog.NOMETA:\r
574                      createNewBlankEntry(fileName);\r
575                      break;\r
576 -                       case ImportDialog.UPDATEEMPTYFIELDS:\r
577 -                    metaDataListDialog = new MetaDataListDialog(fileName, false);                   \r
578 -                    Tools.centerRelativeToWindow(metaDataListDialog, frame);\r
579 -                    metaDataListDialog.showDialog();\r
580 -                    document = metaDataListDialog.getXmlDocuments();\r
581 -                    if(document != null /*&& document.getDocuments() != null && document.getDocuments().size() > 0*/ && metaDataListDialog.getResult() == JOptionPane.OK_OPTION){\r
582 -                        int selected = metaDataListDialog.getTableMetadata().getSelectedRow();\r
583 -                        if(selected > -1 /*&& selected < document.getDocuments().size()*/){\r
584 -                            //XmlDocument document = documents.getDocuments().get(selected);\r
585 -                            entry = entryTable.getEntryAt(dropRow);\r
586 -                            if(fieldExists(document.getType())){\r
587 -                                type = BibtexEntryType.getStandardType(document.getType());\r
588 -                                if(type != null){\r
589 -                                    entry.setType(type);\r
590 -                                }\r
591 -                            }\r
592 -                            //insertFields(entry.getRequiredFields(), entry, document);\r
593 -                            insertFields(BibtexFields.getAllFieldNames(), entry, document);\r
594 -                            //insertFields(entry.getOptionalFields(), entry, document);\r
595 -\r
596 -                            dfh = new DroppedFileHandler(frame, panel);\r
597 -                            dfh.linkPdfToEntry(fileName, entryTable, dropRow);\r
598 -                        }\r
599 -                    }\r
600 -                    break;\r
601 -                       case ImportDialog.ONLYATTACH:\r
602 -                    dfh = new DroppedFileHandler(frame, panel);\r
603 -                    dfh.linkPdfToEntry(fileName, entryTable, dropRow);\r
604 -                    break;\r
605                  }\r
606              }\r
607  \r
608 @@ -295,58 +213,6 @@
609          }\r
610      }\r
611  \r
612 -    private void insertFields(String[] fields, BibtexEntry entry, Document xmlDocument) {\r
613 -        DocumentWrapper document = new DocumentWrapper(xmlDocument);\r
614 -        for(String field : fields){\r
615 -            if(entry.getField(field) != null){\r
616 -                continue;\r
617 -            }\r
618 -            if(field.equalsIgnoreCase("author")){\r
619 -                entry.setField(field, document.getAuthors("and"));\r
620 -            }\r
621 -            if(field.equalsIgnoreCase("title")){\r
622 -                entry.setField(field, document.getTitle());\r
623 -            }\r
624 -            if(field.equalsIgnoreCase("abstract")){\r
625 -                entry.setField(field, document.getAbstract());\r
626 -            }\r
627 -            /*if(field.equalsIgnoreCase("keywords")){\r
628 -                entry.setField(field, document.getKeyWords());\r
629 -            }*/\r
630 -            if(field.equalsIgnoreCase("doi")){\r
631 -                entry.setField(field, document.getDoi());\r
632 -            }\r
633 -            /*if(field.equalsIgnoreCase("pages")){\r
634 -                entry.setField(field, document.getPages());\r
635 -            }\r
636 -            if(field.equalsIgnoreCase("volume")){\r
637 -                entry.setField(field, document.getVolume());\r
638 -            }\r
639 -            if(field.equalsIgnoreCase("number")){\r
640 -                entry.setField(field, document.getNumber());\r
641 -            }*/\r
642 -            if(field.equalsIgnoreCase("year")){\r
643 -                entry.setField(field, document.getYear());\r
644 -            }\r
645 -            /*if(field.equalsIgnoreCase("month")){\r
646 -                entry.setField(field, document.getMonth());\r
647 -            }\r
648 -            if(field.equalsIgnoreCase("day")){\r
649 -                entry.setField(field, document.getDay());\r
650 -            }\r
651 -            if(field.equalsIgnoreCase("booktitle")){\r
652 -                entry.setField(field, document.getVenue());\r
653 -            }\r
654 -            if(field.equalsIgnoreCase("journal")){\r
655 -                entry.setField(field, document.getVenue());\r
656 -            }*/\r
657 -        }\r
658 -    }\r
659 -\r
660 -    private boolean fieldExists(String string) {\r
661 -        return string != null && !string.isEmpty();\r
662 -    }\r
663 -\r
664      private BibtexEntry createNewEntry() {\r
665  \r
666          // Find out what type is wanted.\r
667 --- a/src/java/spl/SplWebClient.java
668 +++ /dev/null
669 @@ -1,196 +0,0 @@
670 -package spl;\r
671 -\r
672 -import java.io.ByteArrayInputStream;\r
673 -import java.io.File;\r
674 -import java.io.FileInputStream;\r
675 -import java.io.InputStream;\r
676 -import java.io.UnsupportedEncodingException;\r
677 -\r
678 -import javax.ws.rs.core.MediaType;\r
679 -import javax.xml.bind.JAXB;\r
680 -\r
681 -import org.sciplore.beans.Author;\r
682 -import org.sciplore.beans.Document;\r
683 -import org.sciplore.deserialize.creator.AuthorBeanCreator;\r
684 -import org.sciplore.deserialize.creator.AuthorsBeanCreator;\r
685 -import org.sciplore.deserialize.creator.DefaultStringCreator;\r
686 -import org.sciplore.deserialize.creator.DocumentBeanCreator;\r
687 -import org.sciplore.deserialize.creator.DocumentsBeanCreator;\r
688 -import org.sciplore.deserialize.creator.ObjectCreator;\r
689 -import org.sciplore.deserialize.creator.TitleBeanCreator;\r
690 -import org.sciplore.deserialize.creator.YearBeanCreator;\r
691 -import org.sciplore.deserialize.reader.ObjectCreatorMapper;\r
692 -import org.sciplore.deserialize.reader.XmlResourceReader;\r
693 -import org.sciplore.formatter.Bean;\r
694 -import org.sciplore.formatter.SimpleTypeElementBean;\r
695 -\r
696 -import com.sun.jersey.api.client.Client;\r
697 -import com.sun.jersey.api.client.ClientResponse;\r
698 -import com.sun.jersey.api.client.WebResource;\r
699 -import com.sun.jersey.multipart.FormDataMultiPart;\r
700 -\r
701 -/**\r
702 - * Created by IntelliJ IDEA.\r
703 - * User: Christoph Arbeit\r
704 - * Date: 09.09.2010\r
705 - * Time: 10:35:20\r
706 - * To change this template use File | Settings | File Templates.\r
707 - */\r
708 -public class SplWebClient {\r
709 -\r
710 -    private static Client CLIENT = Client.create();\r
711 -    static{\r
712 -        CLIENT.setConnectTimeout(1000);\r
713 -        CLIENT.setReadTimeout(70000);\r
714 -    }\r
715 -    private static WebResource WEBRESOURCE = CLIENT.resource( "http://api.mr-dlib.org/" );\r
716 -    private static WebResource INTERNETRESOURCE = CLIENT.resource( "http://www.google.com" );\r
717 -    //private static WebResource WEBRESOURCE = CLIENT.resource( "http://localhost:8080/rest/" );\r
718 -\r
719 -    public static Document metadata;\r
720 -\r
721 -    public static WebServiceStatus getMetaData(File file){\r
722 -        try{\r
723 -            if(isWebServiceAvailable() == false){\r
724 -                if(isInternetAvailable()){\r
725 -                    return  WebServiceStatus.WEBSERVICE_DOWN;\r
726 -                }\r
727 -                else{\r
728 -                    return  WebServiceStatus.NO_INTERNET;\r
729 -                }\r
730 -            }\r
731 -            if(isWebServiceOutDated()){\r
732 -                return  WebServiceStatus.OUTDATED;\r
733 -            }\r
734 -            if(isMetaDataServiceAvailable() == false){\r
735 -                return  WebServiceStatus.UNAVAILABLE;\r
736 -            }\r
737 -            FileInputStream fin = new FileInputStream(file);      \r
738 -            byte[] data = new byte[(int)file.length()];          \r
739 -            fin.read(data);           \r
740 -            \r
741 -            FormDataMultiPart formDataMultiPart = new FormDataMultiPart();            \r
742 -            formDataMultiPart.field("file", data,  MediaType.APPLICATION_OCTET_STREAM_TYPE);            \r
743 -            formDataMultiPart.field("source", "jabref",  MediaType.TEXT_PLAIN_TYPE);\r
744 -            formDataMultiPart.field("filename", file.getName(), MediaType.TEXT_PLAIN_TYPE);\r
745 -           \r
746 -           \r
747 -            ClientResponse response = WEBRESOURCE.path("documents").type(MediaType.MULTIPART_FORM_DATA_TYPE).post(ClientResponse.class, formDataMultiPart);\r
748 -            //System.out.println(response.getEntity(String.class));\r
749 -            if(response.getClientResponseStatus() == ClientResponse.Status.OK && response.hasEntity()){\r
750 -                String entity = response.getEntity(String.class);\r
751 -                byte[] bytes = new byte[0];\r
752 -                try {\r
753 -                    bytes = entity.getBytes("UTF-8");\r
754 -                } catch (UnsupportedEncodingException e) {\r
755 -                    return null;\r
756 -                }\r
757 -                InputStream is = new ByteArrayInputStream(bytes);\r
758 -                if(is != null){\r
759 -                       ObjectCreatorMapper resourceMapper = new ObjectCreatorMapper();\r
760 -                       ObjectCreator stringCreator = new DefaultStringCreator();\r
761 -                       // initialize Mapper    \r
762 -                         resourceMapper.addCreator("documents", new DocumentsBeanCreator());\r
763 -                         resourceMapper.addCreator("authors", new AuthorsBeanCreator());\r
764 -                         resourceMapper.addCreator("document", new DocumentBeanCreator());\r
765 -                         resourceMapper.addCreator("title", new TitleBeanCreator());\r
766 -                         resourceMapper.addCreator("year", new YearBeanCreator());\r
767 -                         resourceMapper.addCreator("author", new AuthorBeanCreator());\r
768 -                         \r
769 -                         resourceMapper.addCreator("name_first", stringCreator);\r
770 -                         resourceMapper.addCreator("name_middle", stringCreator);\r
771 -                         resourceMapper.addCreator("name_last", stringCreator);\r
772 -                         resourceMapper.addCreator("name_last_prefix", stringCreator);\r
773 -                         resourceMapper.addCreator("name_last_suffix", stringCreator);\r
774 -                         \r
775 -                         // initialize xml reader\r
776 -                         XmlResourceReader<?> reader = new XmlResourceReader(resourceMapper);\r
777 -                         \r
778 -                         // parse given file -> create object tree\r
779 -                         Document docs =  (Document)reader.parse(is);\r
780 -                         for(Bean author : docs.getAuthors().getCollection()){\r
781 -                                 Author temp = (Author)author;\r
782 -                                 System.out.println(((SimpleTypeElementBean)temp.getName_Last()).getValue() + " " + temp.getRank());\r
783 -                         }\r
784 -                   // XmlDocuments documents = JAXB.unmarshal(is, XmlDocuments.class);\r
785 -                    SplWebClient.metadata = docs;\r
786 -                    return WebServiceStatus.OK;\r
787 -                }\r
788 -                else{\r
789 -                    return WebServiceStatus.NO_METADATA;\r
790 -                }\r
791 -            }\r
792 -            if(response.getClientResponseStatus() == ClientResponse.Status.SERVICE_UNAVAILABLE){\r
793 -                return  WebServiceStatus.UNAVAILABLE;\r
794 -            }\r
795 -        }catch(Exception e){\r
796 -            System.out.println(Tools.getStackTraceAsString(e));\r
797 -            //Todo logging\r
798 -        }\r
799 -        return WebServiceStatus.NO_METADATA;\r
800 -    }\r
801 -\r
802 -    public static boolean isWebServiceOutDated(){\r
803 -        try{\r
804 -            ClientResponse response =  WEBRESOURCE.path("service/versioncheck/" + Tools.WEBSERVICE_APP_ID + "/current").get(ClientResponse.class);\r
805 -            if(response.getClientResponseStatus() == ClientResponse.Status.OK && response.hasEntity()){\r
806 -                String entity = response.getEntity(String.class);\r
807 -                byte[] bytes = entity.getBytes();\r
808 -                InputStream is = new ByteArrayInputStream(bytes);\r
809 -                if(is != null){\r
810 -                    /*XmlApplication app = JAXB.unmarshal(is, XmlApplication.class);\r
811 -                    if(app != null){\r
812 -                        if(app.getVersion() != null && !app.getVersion().equalsIgnoreCase(Tools.WEBSERVICE_VERSION_SHORT)){\r
813 -                            return true;\r
814 -                        }\r
815 -                    }*/\r
816 -                }\r
817 -            }\r
818 -        }catch(Exception e){\r
819 -            //Todo logging\r
820 -        }\r
821 -        return false;\r
822 -    }\r
823 -\r
824 -    public static boolean isMetaDataServiceAvailable(){\r
825 -        try{\r
826 -            ClientResponse response =  WEBRESOURCE.path("service/metadata/available").get(ClientResponse.class);\r
827 -            if(response.getClientResponseStatus() == ClientResponse.Status.OK && response.hasEntity()){\r
828 -                String entity = response.getEntity(String.class);\r
829 -                if(entity != null && entity.equalsIgnoreCase("false")){\r
830 -                    return false;\r
831 -                }\r
832 -            }\r
833 -        }catch(Exception e){\r
834 -            //Todo logging\r
835 -        }\r
836 -        return true;\r
837 -    }\r
838 -\r
839 -    public static boolean isWebServiceAvailable(){\r
840 -        try{\r
841 -            ClientResponse response =  WEBRESOURCE.path("service/metadata/available").get(ClientResponse.class);\r
842 -        }catch(Exception e){\r
843 -            return false;\r
844 -        }\r
845 -        return true;\r
846 -    }\r
847 -\r
848 -    public static boolean isInternetAvailable(){\r
849 -        try{\r
850 -            ClientResponse response =  INTERNETRESOURCE.get(ClientResponse.class);\r
851 -        }catch(Exception e){\r
852 -            return false;\r
853 -        }\r
854 -        return true;\r
855 -    }\r
856 -\r
857 -    public enum WebServiceStatus {\r
858 -        OK,\r
859 -        NO_METADATA,\r
860 -        UNAVAILABLE,\r
861 -        OUTDATED,\r
862 -        WEBSERVICE_DOWN,\r
863 -        NO_INTERNET\r
864 -    }\r
865 -}\r
866 --- a/src/java/spl/gui/ImportDialog.java
867 +++ b/src/java/spl/gui/ImportDialog.java
868 @@ -20,9 +20,7 @@
869         public final static int NOMETA = 0;\r
870         public final static int XMP = 1;\r
871         public final static int CONTENT = 2;\r
872 -       public final static int MRDLIB = 3;\r
873         public final static int ONLYATTACH = 4;\r
874 -       public final static int UPDATEEMPTYFIELDS = 5;\r
875         \r
876      private JPanel contentPane;\r
877      private JLabel labelSubHeadline;\r
878 @@ -32,14 +30,10 @@
879         private JCheckBox useDefaultPDFImportStyle;\r
880      private JRadioButton radioButtonXmp;\r
881         private JRadioButton radioButtonPDFcontent;\r
882 -    private JRadioButton radioButtonMrDlib;\r
883      private JRadioButton radioButtonNoMeta;\r
884      private JLabel labelHeadline;\r
885      private JLabel labelFileName;\r
886      private JRadioButton radioButtononlyAttachPDF;\r
887 -    private JRadioButton radioButtonUpdateEmptyFields;\r
888 -    private JLabel labelMrDlib1;\r
889 -    private JLabel labelMrDlib2;\r
890      private int result;\r
891      private int dropRow;\r
892      private String fileName;\r
893 @@ -71,15 +65,7 @@
894          radioButtonNoMeta = new JRadioButton(Globals.lang("Create_blank_entry_linking_the_PDF"));\r
895          radioButtonXmp = new JRadioButton(Globals.lang("Create_entry_based_on_XMP_data"));\r
896          radioButtonPDFcontent = new JRadioButton(Globals.lang("Create_entry_based_on_content"));\r
897 -        radioButtonMrDlib = new JRadioButton(Globals.lang("Create_entry_based_on_data_fetched_from"));\r
898          radioButtononlyAttachPDF = new JRadioButton(Globals.lang("Only_attach_PDF"));\r
899 -        radioButtonUpdateEmptyFields = new JRadioButton(Globals.lang("Update_empty_fields_with_data_fetched_from"));\r
900 -        labelMrDlib1 = new JLabel("Mr._dLib");\r
901 -        labelMrDlib1.setFont(new Font(labelMrDlib1.getFont().getName(), Font.BOLD, 13));\r
902 -        labelMrDlib1.setForeground(new Color(-16776961));\r
903 -        labelMrDlib2 = new JLabel("Mr._dLib");\r
904 -        labelMrDlib2.setFont(new Font(labelMrDlib1.getFont().getName(), Font.BOLD, 13));\r
905 -        labelMrDlib2.setForeground(new Color(-16776961));\r
906          buttonOK = new JButton(Globals.lang("Ok"));\r
907          buttonCancel = new JButton(Globals.lang("Cancel"));\r
908          checkBoxDoNotShowAgain = new JCheckBox(Globals.lang("Do not show this box again for this import"));\r
909 @@ -89,12 +75,8 @@
910          b.append(radioButtonNoMeta, 3);\r
911          b.append(radioButtonXmp, 3);\r
912          b.append(radioButtonPDFcontent, 3);\r
913 -        b.append(radioButtonMrDlib);\r
914 -        b.append(labelMrDlib1);\r
915          b.appendSeparator(Globals.lang("Update_Existing_Entry"));\r
916          b.append(radioButtononlyAttachPDF, 3);\r
917 -        b.append(radioButtonUpdateEmptyFields);\r
918 -        b.append(labelMrDlib2);\r
919          b.nextLine();\r
920          b.append(checkBoxDoNotShowAgain);\r
921          b.append(useDefaultPDFImportStyle);\r
922 @@ -114,8 +96,6 @@
923          //this.setText();\r
924          if (this.dropRow < 0) {\r
925              this.radioButtononlyAttachPDF.setEnabled(false);\r
926 -            this.radioButtonUpdateEmptyFields.setEnabled(false);\r
927 -            this.labelMrDlib2.setEnabled(false);\r
928          }\r
929          this.fileName = fileName;\r
930          String name = new File(this.fileName).getName();\r
931 @@ -124,8 +104,6 @@
932          } else {\r
933              this.labelFileName.setText(new File(this.fileName).getName().substring(0, 33) + "...");\r
934          }\r
935 -        this.labelMrDlib1.addMouseListener(new LabelLinkListener(this.labelMrDlib1, "www.mr-dlib.org/docs/pdf_metadata_extraction.php"));\r
936 -        this.labelMrDlib2.addMouseListener(new LabelLinkListener(this.labelMrDlib2, "www.mr-dlib.org/docs/pdf_metadata_extraction.php"));\r
937          this.setTitle(LocalizationSupport.message("Import_Metadata_From_PDF"));\r
938  \r
939          setModal(true);\r
940 @@ -136,9 +114,7 @@
941          bg.add(radioButtonNoMeta);\r
942          bg.add(radioButtonXmp);\r
943          bg.add(radioButtonPDFcontent);\r
944 -        bg.add(radioButtonMrDlib);\r
945          bg.add(radioButtononlyAttachPDF);\r
946 -        bg.add(radioButtonUpdateEmptyFields);\r
947  \r
948          buttonOK.addActionListener(new ActionListener() {\r
949              public void actionPerformed(ActionEvent e) {\r
950 @@ -175,15 +151,9 @@
951                 case CONTENT:\r
952                         radioButtonPDFcontent.setSelected(true);\r
953                         break;\r
954 -               case MRDLIB:\r
955 -                       radioButtonMrDlib.setSelected(true);\r
956 -                       break;\r
957                 case ONLYATTACH:\r
958                         radioButtononlyAttachPDF.setSelected(true);\r
959                         break;\r
960 -               case UPDATEEMPTYFIELDS:\r
961 -                       radioButtonUpdateEmptyFields.setSelected(true);\r
962 -                       break;\r
963                 default:\r
964                         // fallback\r
965                         radioButtonPDFcontent.setSelected(true);\r
966 @@ -218,14 +188,10 @@
967                 return XMP;\r
968         else if (radioButtonPDFcontent.isSelected())\r
969                 return CONTENT;\r
970 -       else if (radioButtonMrDlib.isSelected())\r
971 -               return MRDLIB;\r
972         else if (radioButtonNoMeta.isSelected())\r
973                 return NOMETA;\r
974         else if (radioButtononlyAttachPDF.isSelected())\r
975                 return ONLYATTACH;\r
976 -       else if (radioButtonUpdateEmptyFields.isSelected())\r
977 -               return UPDATEEMPTYFIELDS;\r
978         else throw new IllegalStateException();\r
979      }\r
980  \r
981 --- a/src/java/spl/gui/MetaDataListDialog.java
982 +++ /dev/null
983 @@ -1,314 +0,0 @@
984 -package spl.gui;\r
985 -\r
986 -\r
987 -import java.awt.BorderLayout;\r
988 -import java.awt.CardLayout;\r
989 -import java.awt.Color;\r
990 -import java.awt.Component;\r
991 -import java.awt.Dimension;\r
992 -import java.awt.Font;\r
993 -import java.awt.event.ActionEvent;\r
994 -import java.awt.event.ActionListener;\r
995 -import java.awt.event.KeyEvent;\r
996 -import java.awt.event.WindowAdapter;\r
997 -import java.awt.event.WindowEvent;\r
998 -import java.io.File;\r
999 -import java.io.IOException;\r
1000 -import java.util.List;\r
1001 -import java.util.Vector;\r
1002 -\r
1003 -import javax.swing.BorderFactory;\r
1004 -import javax.swing.ImageIcon;\r
1005 -import javax.swing.JButton;\r
1006 -import javax.swing.JComponent;\r
1007 -import javax.swing.JDialog;\r
1008 -import javax.swing.JLabel;\r
1009 -import javax.swing.JOptionPane;\r
1010 -import javax.swing.JPanel;\r
1011 -import javax.swing.JScrollPane;\r
1012 -import javax.swing.JTable;\r
1013 -import javax.swing.KeyStroke;\r
1014 -import javax.swing.ListSelectionModel;\r
1015 -import javax.swing.SwingWorker;\r
1016 -import javax.swing.table.DefaultTableModel;\r
1017 -\r
1018 -import net.sf.jabref.Globals;\r
1019 -import net.sf.jabref.MetaData;\r
1020 -import net.sf.jabref.Util;\r
1021 -\r
1022 -import org.sciplore.beans.Document;\r
1023 -\r
1024 -import spl.DocumentsWrapper;\r
1025 -import spl.SplWebClient;\r
1026 -import spl.listener.LabelLinkListener;\r
1027 -import spl.localization.LocalizationSupport;\r
1028 -\r
1029 -import com.jgoodies.forms.builder.ButtonBarBuilder2;\r
1030 -\r
1031 -public class MetaDataListDialog extends JDialog {\r
1032 -    private JPanel contentPane;\r
1033 -    private JTable tableMetadata;\r
1034 -    private JButton buttonOK;\r
1035 -    private JButton buttonCancel;\r
1036 -    private JScrollPane scrollPane;\r
1037 -    private JPanel panelWait;\r
1038 -    private JLabel labelFetch;\r
1039 -    private JLabel iconLabel;\r
1040 -    private JButton blankButton;\r
1041 -    private JLabel labelLogo;\r
1042 -    private JButton moreInformationButton;\r
1043 -    private JPanel panelMetadata;\r
1044 -    private DefaultTableModel tableModel;\r
1045 -    private int result;\r
1046 -    private Document xmlDocuments;\r
1047 -    private String fileName;\r
1048 -    private SplWebClient.WebServiceStatus webserviceStatus;\r
1049 -    private Component thisDialog;\r
1050 -    private boolean showBlankButton;\r
1051 -    private CardLayout cardLayou = new CardLayout();\r
1052 -\r
1053 -    public MetaDataListDialog(String fileName, boolean showBlankButton) {\r
1054 -        $$$setupUI$$$();\r
1055 -        this.showBlankButton = showBlankButton;\r
1056 -        this.thisDialog = this;\r
1057 -        this.fileName = fileName;\r
1058 -        this.labelLogo.addMouseListener(new LabelLinkListener(this.labelLogo, "www.mr-dlib.org"));\r
1059 -        this.setTitle(LocalizationSupport.message("Mr._dLib_Metadata_Entries_Associated_With_PDF_File"));\r
1060 -        this.tableMetadata.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
1061 -        setContentPane(contentPane);\r
1062 -        pack();\r
1063 -        setModal(true);\r
1064 -        getRootPane().setDefaultButton(buttonOK);\r
1065 -\r
1066 -        buttonOK.addActionListener(new ActionListener() {\r
1067 -            public void actionPerformed(ActionEvent e) {\r
1068 -                onOK();\r
1069 -            }\r
1070 -        });\r
1071 -\r
1072 -        buttonCancel.addActionListener(new ActionListener() {\r
1073 -            public void actionPerformed(ActionEvent e) {\r
1074 -                onCancel();\r
1075 -            }\r
1076 -        });\r
1077 -\r
1078 -        blankButton.addActionListener(new ActionListener() {\r
1079 -            public void actionPerformed(ActionEvent e) {\r
1080 -                onBlank();\r
1081 -            }\r
1082 -        });\r
1083 -\r
1084 -        moreInformationButton.addActionListener(new ActionListener() {\r
1085 -            public void actionPerformed(ActionEvent e) {\r
1086 -                onInfo();\r
1087 -            }\r
1088 -        });\r
1089 -\r
1090 -        setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);\r
1091 -        addWindowListener(new WindowAdapter() {\r
1092 -            public void windowClosing(WindowEvent e) {\r
1093 -                onCancel();\r
1094 -            }\r
1095 -        });\r
1096 -\r
1097 -        contentPane.registerKeyboardAction(new ActionListener() {\r
1098 -            public void actionPerformed(ActionEvent e) {\r
1099 -                onCancel();\r
1100 -            }\r
1101 -        }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);\r
1102 -\r
1103 -        cardLayou.show(panelMetadata, "panelWait");\r
1104 -        //this.scrollPane.setVisible(false);\r
1105 -        //this.blankButton.setVisible(false);\r
1106 -        this.moreInformationButton.setVisible(true);\r
1107 -        this.setSize(616, 366);\r
1108 -    }\r
1109 -\r
1110 -    private void onInfo() {\r
1111 -        try {\r
1112 -            Util.openExternalViewer(new MetaData(), "http://www.mr-dlib.org/docs/jabref_metadata_extraction_alpha.php", "url");\r
1113 -        } catch (IOException exc) {\r
1114 -            exc.printStackTrace();\r
1115 -        }\r
1116 -    }\r
1117 -\r
1118 -    private void onBlank() {\r
1119 -        this.result = JOptionPane.NO_OPTION;\r
1120 -        dispose();\r
1121 -    }\r
1122 -\r
1123 -    private void onOK() {\r
1124 -        this.result = JOptionPane.OK_OPTION;\r
1125 -        dispose();\r
1126 -    }\r
1127 -\r
1128 -    private void onCancel() {\r
1129 -        this.result = JOptionPane.CANCEL_OPTION;\r
1130 -        dispose();\r
1131 -    }\r
1132 -\r
1133 -    public void showDialog() {\r
1134 -        SwingWorker worker = new SwingWorker<Void, Void>() {\r
1135 -            @Override\r
1136 -            public Void doInBackground() {\r
1137 -                System.out.println("Starting Webclient...");\r
1138 -                webserviceStatus = SplWebClient.getMetaData(new File(fileName));\r
1139 -                return null;\r
1140 -            }\r
1141 -\r
1142 -            @Override\r
1143 -            public void done() {\r
1144 -                if (webserviceStatus == SplWebClient.WebServiceStatus.OK) {\r
1145 -                    xmlDocuments = SplWebClient.metadata;\r
1146 -                    if (xmlDocuments != null /*&& xmlDocuments.getDocuments() != null && xmlDocuments.getDocuments().size() > 0*/) {\r
1147 -                        DocumentsWrapper documents = new DocumentsWrapper(xmlDocuments);\r
1148 -                        List<Vector> vectorList = documents.getDocuments();\r
1149 -                        for (Vector vector : vectorList) {\r
1150 -                            tableModel.addRow(vector);\r
1151 -                        }\r
1152 -\r
1153 -                        tableMetadata.getSelectionModel().setSelectionInterval(0, 0);\r
1154 -                        cardLayou.show(panelMetadata, "scrollPane");\r
1155 -                        //panelWait.setVisible(false);\r
1156 -                        //scrollPane.setVisible(true);\r
1157 -                        moreInformationButton.setVisible(true);\r
1158 -                    } else {\r
1159 -                        iconLabel.setVisible(false);\r
1160 -                        labelFetch.setText(LocalizationSupport.message("No_metadata_found."));\r
1161 -                        blankButton.setVisible(showBlankButton);\r
1162 -                    }\r
1163 -                }\r
1164 -                if (webserviceStatus == SplWebClient.WebServiceStatus.NO_METADATA) {\r
1165 -                    iconLabel.setVisible(false);\r
1166 -                    labelFetch.setText(LocalizationSupport.message("No_metadata_found."));\r
1167 -                    blankButton.setVisible(showBlankButton);\r
1168 -                }\r
1169 -                if (webserviceStatus == SplWebClient.WebServiceStatus.UNAVAILABLE) {\r
1170 -                    iconLabel.setVisible(false);\r
1171 -                    labelFetch.setText(LocalizationSupport.message("Mr._dLib_web_service_is_temporarily_unavailable."));\r
1172 -                    blankButton.setVisible(showBlankButton);\r
1173 -                }\r
1174 -                if (webserviceStatus == SplWebClient.WebServiceStatus.OUTDATED) {\r
1175 -                    iconLabel.setVisible(false);\r
1176 -                    labelFetch.setText(LocalizationSupport.message("The_Mr._dLib_web_service_version_you_trying_to_access_is_outdated."));\r
1177 -                    blankButton.setVisible(showBlankButton);\r
1178 -                    JOptionPane.showMessageDialog(thisDialog, LocalizationSupport.message("This_JabRef_version_is_trying_to_access_an_old_version_of_Mr._dLib's_webservice_that_is_not_working_any_more.\\nPlease_visit_http://jabref.sourceforge.net_or_http://www.mr-dlib.org_for_more_information_and_updates.\\n\\n\\n"), LocalizationSupport.message("Web_Service_Version_Outdated"), JOptionPane.INFORMATION_MESSAGE);\r
1179 -                }\r
1180 -                if (webserviceStatus == SplWebClient.WebServiceStatus.WEBSERVICE_DOWN) {\r
1181 -                    iconLabel.setVisible(false);\r
1182 -                    labelFetch.setText(LocalizationSupport.message("Mr._dLib_web_service_is_temporarily_down._Please_try_again_later."));\r
1183 -                    blankButton.setVisible(showBlankButton);\r
1184 -                }\r
1185 -                if (webserviceStatus == SplWebClient.WebServiceStatus.NO_INTERNET) {\r
1186 -                    iconLabel.setVisible(false);\r
1187 -                    labelFetch.setText(LocalizationSupport.message("No_Internet_Connection."));\r
1188 -                    blankButton.setVisible(showBlankButton);\r
1189 -                    JOptionPane.showMessageDialog(thisDialog, LocalizationSupport.message("You_are_not_connected_to_the_Internet._To_access_Mr._dLib_web_service_an_internet_connection_is_needed."), LocalizationSupport.message("No_Internet_Connection."), JOptionPane.INFORMATION_MESSAGE);\r
1190 -                }\r
1191 -            }\r
1192 -        };\r
1193 -        worker.execute();\r
1194 -        this.pack();\r
1195 -        this.setVisible(true);\r
1196 -    }\r
1197 -\r
1198 -    public Document getXmlDocuments() {\r
1199 -        return xmlDocuments;\r
1200 -    }\r
1201 -\r
1202 -    private void createUIComponents() {\r
1203 -        this.tableModel = new MyTableModel();\r
1204 -        this.tableModel.addColumn(LocalizationSupport.message("Title"));\r
1205 -        this.tableModel.addColumn(LocalizationSupport.message("Author(s)"));\r
1206 -        this.tableModel.addColumn(LocalizationSupport.message("Published_Year"));\r
1207 -        this.tableMetadata = new JTable(this.tableModel);\r
1208 -    }\r
1209 -\r
1210 -    public JTable getTableMetadata() {\r
1211 -        return tableMetadata;\r
1212 -    }\r
1213 -\r
1214 -    public int getResult() {\r
1215 -        return result;\r
1216 -    }\r
1217 -\r
1218 -    public JButton getBlankButton() {\r
1219 -        return blankButton;\r
1220 -    }\r
1221 -\r
1222 -    private void $$$setupUI$$$() {\r
1223 -        createUIComponents();\r
1224 -        contentPane = new JPanel();\r
1225 -        contentPane.setLayout(new BorderLayout());\r
1226 -        labelLogo = new JLabel();\r
1227 -        labelLogo.setIcon(new ImageIcon(getClass().getResource("/spl/gui/mrdlib header.png")));\r
1228 -        labelLogo.setText("");\r
1229 -        contentPane.add(labelLogo, BorderLayout.NORTH);\r
1230 -        panelMetadata = new JPanel();\r
1231 -        panelMetadata.setLayout(cardLayou);\r
1232 -\r
1233 -\r
1234 -        panelMetadata.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), null));\r
1235 -        scrollPane = new JScrollPane();\r
1236 -        scrollPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLoweredBevelBorder(), null));\r
1237 -        tableMetadata.setAutoCreateRowSorter(false);\r
1238 -        tableMetadata.setEnabled(true);\r
1239 -        tableMetadata.setFillsViewportHeight(true);\r
1240 -        tableMetadata.setShowVerticalLines(true);\r
1241 -        scrollPane.setViewportView(tableMetadata);\r
1242 -        panelMetadata.add(scrollPane, "scrollPane");\r
1243 -        panelWait = new JPanel();\r
1244 -        panelWait.setLayout(new BorderLayout());\r
1245 -        panelWait.setBackground(new Color(-1));\r
1246 -        panelMetadata.add(panelWait, "panelWait");\r
1247 -        panelWait.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLoweredBevelBorder(), null));\r
1248 -        iconLabel = new JLabel();\r
1249 -        iconLabel.setBackground(new Color(-1));\r
1250 -        iconLabel.setHorizontalAlignment(0);\r
1251 -        iconLabel.setHorizontalTextPosition(11);\r
1252 -        iconLabel.setIcon(new ImageIcon(getClass().getResource("/spl/gui/ajax-loader.gif")));\r
1253 -        iconLabel.setText("");\r
1254 -        panelWait.add(iconLabel, BorderLayout.CENTER);\r
1255 -        labelFetch = new JLabel();\r
1256 -        labelFetch.setHorizontalAlignment(JLabel.CENTER);\r
1257 -        labelFetch.setFont(new Font(labelFetch.getFont().getName(), labelFetch.getFont().getStyle(), 13));\r
1258 -        labelFetch.setText(Globals.lang("Fetching Metadata..."));\r
1259 -        panelWait.add(labelFetch, BorderLayout.SOUTH);\r
1260 -\r
1261 -        cardLayou.show(panelMetadata, "panelWait");\r
1262 -        panelMetadata.setPreferredSize(new Dimension(400, 200));\r
1263 -        contentPane.add(panelMetadata, BorderLayout.CENTER);\r
1264 -\r
1265 -        buttonOK = new JButton(Globals.lang("Ok"));\r
1266 -        buttonCancel = new JButton(Globals.lang("Cancel"));\r
1267 -        moreInformationButton = new JButton(Globals.lang("More information"));\r
1268 -        ButtonBarBuilder2 bb = new ButtonBarBuilder2();\r
1269 -        bb.addGlue();\r
1270 -        bb.addButton(moreInformationButton);\r
1271 -        bb.addButton(buttonOK);\r
1272 -        bb.addButton(buttonCancel);\r
1273 -        bb.addGlue();\r
1274 -        blankButton = new JButton();\r
1275 -        blankButton.setText("");\r
1276 -        contentPane.add(bb.getPanel(), BorderLayout.SOUTH);\r
1277 -        iconLabel.setLabelFor(scrollPane);\r
1278 -\r
1279 -\r
1280 -    }\r
1281 -\r
1282 -    /**\r
1283 -     * @noinspection ALL\r
1284 -     */\r
1285 -    public JComponent $$$getRootComponent$$$() {\r
1286 -        return contentPane;\r
1287 -    }\r
1288 -\r
1289 -    public class MyTableModel extends DefaultTableModel {\r
1290 -\r
1291 -        @Override\r
1292 -        public boolean isCellEditable(int row, int column) {\r
1293 -            return false;\r
1294 -        }\r
1295 -    }\r
1296 -\r
1297 -}\r