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