2 Copyright (C) 2003 Morten O. Alver
4 All programs in this directory and
5 subdirectories are published under the GNU General Public License as
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 Further information about the GNU GPL is available at:
24 http://www.gnu.org/copyleft/gpl.ja.html
27 Modified for use in JabRef.
31 package net.sf.jabref;
35 import java.util.List;
39 public class GUIGlobals {
42 * Static variables for graphics files and keyboard shortcuts.
46 static int teller = 0;
48 // HashMap containing refs to all open BibtexDatabases.
49 //static HashMap frames = new HashMap();
53 frameTitle = "JabRef",
55 version = Globals.VERSION,
56 stringsTitle = "Strings for database",
57 //untitledStringsTitle = stringsTitle + Globals.lang("untitled"),
58 untitledTitle = "untitled",
59 helpTitle = "JabRef help",
60 TYPE_HEADER = "entrytype",
62 encPrefix = "Encoding: ", // Part of the signature in written bib files.
63 linuxDefaultLookAndFeel = "com.jgoodies.plaf.plastic.Plastic3DLookAndFeel",
64 //"com.shfarr.ui.plaf.fh.FhLookAndFeel",
65 //"net.sourceforge.mlf.metouia.MetouiaLookAndFeel",
66 //"org.compiere.plaf.CompiereLookAndFeel",
67 windowsDefaultLookAndFeel = "com.jgoodies.plaf.windows.ExtWindowsLookAndFeel";
69 public static Font CURRENTFONT,
74 // Signature written at the top of the .bib file.
75 public static final String SIGNATURE =
76 "This file was created with JabRef";
78 // Size of help window.
80 helpSize = new Dimension(700, 600),
81 aboutSize = new Dimension(600, 265),
82 searchPaneSize = new Dimension(430, 70),
83 searchFieldSize = new Dimension(215, 25);
85 // Divider size for BaseFrame split pane. 0 means non-resizable.
86 public static final int
87 SPLIT_PANE_DIVIDER_SIZE = 4,
88 SPLIT_PANE_DIVIDER_LOCATION = 145,
89 TABLE_ROW_PADDING = 4,
91 KEYBIND_COL_1 = 80, // Added to the font size when determining table
92 PREVIEW_PANEL_PADDING = 15, // Extra room given to the preview editor, in addition to its own
93 PREVIEW_PANEL_HEIGHT = 200,
94 MAX_CONTENT_SELECTOR_WIDTH = 240; // The max width of the combobox for content selectors.
95 // calculated preferred size
96 //public static final int[] PREVIEW_HEIGHT = {115, 300};
98 public static final double
99 VERTICAL_DIVIDER_LOCATION = 0.4;
102 public static String //configFile = "preferences.dat",
111 ex = imageSize + extension,
114 fontPath = "/images/font/";
116 static HashMap tableIcons = new HashMap(); // Contains table icon mappings. Set up
118 public static JLabel incompleteLabel; // JLabel with icon signaling an incomplete entry.
119 public static Color activeEditor = new Color(230, 230, 255);
120 public static final String[] DEFAULT_INSPECTION_FIELDS = new String[]
121 {"author", "title", "year"};
123 public static JLabel getTableIcon(String fieldType) {
124 Object o = tableIcons.get(fieldType);
126 Globals.logger("Error: no table icon defined for type '"+fieldType+"'.");
128 } else return (JLabel)o;
134 openIconFile = GUIGlobals.class.getResource(pre + "fldr_obj.gif"),
135 editIconFile = GUIGlobals.class.getResource(pre + "edittsk_tsk.gif"),
136 saveIconFile = GUIGlobals.class.getResource(pre + "save_edit.gif"),
137 saveAsIconFile = GUIGlobals.class.getResource(pre + "saveas_edit.gif"),
138 prefsIconFile = GUIGlobals.class.getResource(pre + "configure2.png"),
139 newIconFile = GUIGlobals.class.getResource(pre + "new_page.gif"),
140 undoIconFile = GUIGlobals.class.getResource(pre + "undo_edit.gif"),
141 redoIconFile = GUIGlobals.class.getResource(pre + "redo_edit.gif"),
142 preambleIconFile = GUIGlobals.class.getResource(pre + "preamble.png"),
143 addIconFile = GUIGlobals.class.getResource(pre + "plus.gif"),
144 delRowIconFile = GUIGlobals.class.getResource(pre + "minus.gif"),
145 showReqIconFile = GUIGlobals.class.getResource(pre + "reqIcon.png"),
146 showOptIconFile = GUIGlobals.class.getResource(pre + "optIcon.png"),
147 showGenIconFile = GUIGlobals.class.getResource(pre + "absIcon.png"),
148 showAbsIconFile = GUIGlobals.class.getResource(pre + "genIcon.png"),
149 sourceIconFile = GUIGlobals.class.getResource(pre + "viewsource.gif"),
150 copyIconFile = GUIGlobals.class.getResource(pre + "copy_edit.gif"),
151 cutIconFile = GUIGlobals.class.getResource(pre + "cut_edit.gif"),
152 copyKeyIconFile = GUIGlobals.class.getResource(pre + "copy_edit.gif"),
153 genKeyIconFile = GUIGlobals.class.getResource(pre + "wizard.png"),
154 lyxIconFile = GUIGlobals.class.getResource(pre + "lyx2.png"),
155 backIconFile = GUIGlobals.class.getResource(pre + "backward_nav.gif"),
156 forwardIconFile = GUIGlobals.class.getResource(pre + "forward_nav.gif"),
157 contentsIconFile = GUIGlobals.class.getResource(pre + "toc_closed.gif"),
158 removeIconFile = GUIGlobals.class.getResource(pre + "delete_edit.gif"),
159 upIconFile = GUIGlobals.class.getResource(pre + "prev_nav.gif"),
160 downIconFile = GUIGlobals.class.getResource(pre + "next_nav.gif"),
161 stringsIconFile = GUIGlobals.class.getResource(pre + "strings.png"),
162 groupsIconFile = GUIGlobals.class.getResource(pre + "queue.png"),
163 groupsHighlightMatchingAnyFile = GUIGlobals.class.getResource(pre + "groupsHighlightAny.png"),
164 groupsHighlightMatchingAllFile = GUIGlobals.class.getResource(pre + "groupsHighlightAll.png"),
165 closeIconFile = GUIGlobals.class.getResource(pre + "fileclose.png"),
166 close2IconFile = GUIGlobals.class.getResource(pre + "fileclose2.png"),
167 refreshSmallIconFile = GUIGlobals.class.getResource(pre + "refresh_nav.gif"),
168 helpSmallIconFile = GUIGlobals.class.getResource(pre + "view.gif"),
169 helpIconFile = GUIGlobals.class.getResource(pre + "view.gif"),
170 aboutIcon = GUIGlobals.class.getResource(pre + "view.gif"),
171 helpContentsIconFile = GUIGlobals.class.getResource(pre + "contents2.png"),
172 newSmallIconFile = GUIGlobals.class.getResource(pre + "new_page.gif"),
173 pasteIconFile = GUIGlobals.class.getResource(pre + "paste_edit.gif"),
174 editEntryIconFile = GUIGlobals.class.getResource(pre + "DocumentDraw.gif"),
175 searchIconFile = GUIGlobals.class.getResource(pre + "search.gif"),
176 previewIconFile = GUIGlobals.class.getResource(pre + "preview.png"),
177 autoGroupIcon = GUIGlobals.class.getResource(pre + "addtsk_tsk.gif"),
178 wwwIcon = GUIGlobals.class.getResource(pre + "www.png"),
179 wwwCiteSeerIcon = GUIGlobals.class.getResource(pre + "wwwciteseer.png"),
180 fetchMedlineIcon = GUIGlobals.class.getResource(pre + "goto.png"),
181 fetchHourglassIcon = GUIGlobals.class.getResource(pre + "Hourglass.png"),
182 pdfIcon = GUIGlobals.class.getResource(pre + "pdf.png"),
183 pdfSmallIcon = GUIGlobals.class.getResource(pre + "pdf_small.gif"),
184 sheetIcon = GUIGlobals.class.getResource(pre + "defaults_ps.gif"),
185 doiIcon = GUIGlobals.class.getResource(pre + "doi.png"),
186 doiSmallIcon = GUIGlobals.class.getResource(pre + "doismall.png"),
187 psIcon = GUIGlobals.class.getResource(pre + "postscript.png"),
188 incompleteIcon = GUIGlobals.class.getResource(pre + "exclamation.gif"),
189 winEdtIcon = GUIGlobals.class.getResource(pre + "winedt.png"),
190 jabreflogo = GUIGlobals.class.getResource(pre + "JabRef-icon.png"),
191 completeTagIcon = GUIGlobals.class.getResource(pre + "completeItem.png"),
192 wrongTagIcon = GUIGlobals.class.getResource(pre + "wrongItem.png"),
193 clearInputArea = GUIGlobals.class.getResource(pre + "new_page.gif"),
194 markIcon = GUIGlobals.class.getResource(pre + "mark.png"),
195 unmarkIcon = GUIGlobals.class.getResource(pre + "unmark.png"),
196 newBibFile = GUIGlobals.class.getResource(pre + "newBibFile.png"),
197 integrityCheck = GUIGlobals.class.getResource(pre + "integrity.png"),
198 integrityInfo = GUIGlobals.class.getResource(pre + "messageInfo.png"),
199 integrityWarn = GUIGlobals.class.getResource(pre + "messageWarn.png"),
200 integrityFail = GUIGlobals.class.getResource(pre + "messageFail.png"),
201 duplicateIcon = GUIGlobals.class.getResource(pre + "duplicate.png"),
202 emacsIcon = GUIGlobals.class.getResource(pre + "emacs.png");
204 public static ImageIcon
205 groupRefiningIcon = new ImageIcon(GUIGlobals.class.getResource(pre +"groupRefining.png")),
206 groupIncludingIcon = new ImageIcon(GUIGlobals.class.getResource(pre +"groupIncluding.png")),
207 groupRegularIcon = null;
209 /*public static incompleteEntryIcon = new ImageIcon(incompleteIcon);
211 incompleteEntryIcon.setTool
214 // Help files (in HTML format):
216 baseFrameHelp = "BaseFrameHelp.html",
217 entryEditorHelp = "EntryEditorHelp.html",
218 stringEditorHelp = "StringEditorHelp.html",
219 helpContents = "Contents.html",
220 searchHelp = "SearchHelp.html",
221 groupsHelp = "GroupsHelp.html",
222 customEntriesHelp = "CustomEntriesHelp.html",
223 contentSelectorHelp = "ContentSelectorHelp.html",
224 labelPatternHelp = "LabelPatterns.html",
225 ownerHelp = "OwnerHelp.html",
226 timeStampHelp = "TimeStampHelp.html",
227 pdfHelp = "ExternalFiles.html",
228 exportCustomizationHelp = "CustomExports.html",
229 importCustomizationHelp = "CustomImports.html",
230 medlineHelp = "MedlineHelp.html",
231 citeSeerHelp = "CiteSeerHelp.html",
232 generalFieldsHelp = "GeneralFields.html",
233 // searchHelp = "SearchHelp.html",
234 aboutPage = "About.html",
235 shortPlainImport="ShortPlainImport.html",
236 importInspectionHelp = "ImportInspectionDialog.html",
237 shortIntegrityCheck="ShortIntegrityCheck.html",
238 remoteHelp = "RemoteHelp.html",
239 journalAbbrHelp = "JournalAbbreviations.html";
244 lightGray = new Color(230, 30, 30), // Light gray background
245 validFieldColor = new Color(100, 100, 150), // Empty field, blue.
246 nullFieldColor = new Color(75, 130, 95), // Valid field, green.
247 invalidFieldColor = new Color(141, 0, 61), // Invalid field, red.
248 // invalidFieldColor = new Color(210, 70, 70), // Invalid field, red.
249 validFieldBackground = Color.white, // Valid field backgnd.
250 //invalidFieldBackground = new Color(210, 70, 70), // Invalid field backgnd.
251 invalidFieldBackground = new Color(255, 100, 100), // Invalid field backgnd.
252 gradientGray = new Color(112, 121, 165), // Title bar gradient color, sidepaneheader
253 gradientBlue = new Color(0, 27, 102), // Title bar gradient color, sidepaneheader
254 //activeTabbed = Color.black, // active Database (JTabbedPane)
255 //inActiveTabbed = Color.gray.darker(), // inactive Database
256 activeTabbed = validFieldColor.darker(), // active Database (JTabbedPane)
257 inActiveTabbed = Color.black, // inactive Database
258 infoField = new Color(254, 255, 225) // color for an info field
262 public static String META_FLAG = "jabref-meta: ";
263 public static String META_FLAG_OLD = "bibkeeper-meta: ";
264 public static String ENTRYTYPE_FLAG = "jabref-entrytype: ";
265 public static String KEY_FIELD = "bibtexkey";
266 public static String[] ALL_FIELDS = new String[] {
302 "citeseercitationcount"
305 public static final Map FIELD_DISPLAYS;
307 Arrays.sort(ALL_FIELDS);
308 FIELD_DISPLAYS = new HashMap();
309 FIELD_DISPLAYS.put("citeseercitationcount","Popularity");
313 // These are the fields that BibTex might want to treat, so these
314 // must conform to BibTex rules.
315 public static String[] BIBTEX_STANDARD_FIELDS = new String[] {
346 // These fields will not be saved to the .bib file.
347 public static String[] NON_WRITABLE_FIELDS = new String[] {
352 // These fields will not be shown inside the source editor panel.
353 public static String[] NON_DISPLAYABLE_FIELDS = new String[] {
359 public static boolean isWriteableField(String field) {
360 for (int i = 0; i < NON_WRITABLE_FIELDS.length; i++) {
361 if (NON_WRITABLE_FIELDS[i].equals(field)) {
368 public static boolean isDisplayableField(String field) {
369 for (int i = 0; i < NON_DISPLAYABLE_FIELDS.length; i++) {
370 if (NON_DISPLAYABLE_FIELDS[i].equals(field)) {
378 * Returns true if the given field is a standard Bibtex field.
380 * @param field a <code>String</code> value
381 * @return a <code>boolean</code> value
383 public static boolean isStandardField(String field) {
384 for (int i = 0; i < BIBTEX_STANDARD_FIELDS.length; i++) {
385 if (BIBTEX_STANDARD_FIELDS[i].equals(field)) {
392 public static double DEFAULT_FIELD_WEIGHT = 1,
393 MAX_FIELD_WEIGHT = 2;
396 SMALL_W = new Double(0.30),
397 MEDIUM_W = new Double(0.5),
398 LARGE_W = new Double(1.5);
399 public static final double PE_HEIGHT = 2;
401 // Size constants for EntryTypeForm; small, medium and large.
402 public static int[] FORM_WIDTH = new int[] {
404 public static int[] FORM_HEIGHT = new int[] {
407 // Constants controlling formatted bibtex output.
408 public static final int
410 LINE_LENGTH = 65; // Maximum
412 public static int DEFAULT_FIELD_LENGTH = 100,
413 NUMBER_COL_LENGTH = 32,
416 // Column widths for export customization dialog table:
417 public static final int
418 EXPORT_DIALOG_COL_0_WIDTH = 50,
419 EXPORT_DIALOG_COL_1_WIDTH = 200,
420 EXPORT_DIALOG_COL_2_WIDTH = 30;
422 // Column widths for import customization dialog table:
423 public static final int
424 IMPORT_DIALOG_COL_0_WIDTH = 200,
425 IMPORT_DIALOG_COL_1_WIDTH = 80,
426 IMPORT_DIALOG_COL_2_WIDTH = 200,
427 IMPORT_DIALOG_COL_3_WIDTH = 200;
429 public static final Map FIELD_WEIGHT;
430 public static final Map FIELD_EXTRAS, LANGUAGES;
431 public static Map fieldLength = new HashMap();
434 LANGUAGES = new HashMap();
435 // LANGUAGES contains mappings for supported languages.
436 LANGUAGES.put("English", "en");
437 LANGUAGES.put("Deutsch", "de");
438 LANGUAGES.put("Fran\u00E7ais", "fr");
439 LANGUAGES.put("Norsk", "no");
441 FIELD_EXTRAS = new HashMap();
442 // fieldExtras contains mappings to tell the EntryEditor to add a specific
443 // function to this field, for instance a "browse" button for the "pdf" field.
444 FIELD_EXTRAS.put("pdf", "browseDoc");
445 FIELD_EXTRAS.put("ps", "browseDocZip");
446 FIELD_EXTRAS.put("url", "external");
447 FIELD_EXTRAS.put("citeseerurl", "external");
448 FIELD_EXTRAS.put("doi", "external");
449 FIELD_EXTRAS.put("journal", "journalNames");
450 //FIELD_EXTRAS.put("keywords", "selector");
453 fieldLength.put("author", new Integer(280));
454 fieldLength.put("editor", new Integer(280));
455 fieldLength.put("title", new Integer(400));
456 fieldLength.put("abstract", new Integer(400));
457 fieldLength.put("booktitle", new Integer(175));
458 fieldLength.put("year", new Integer(60));
459 fieldLength.put("volume", new Integer(60));
460 fieldLength.put("number", new Integer(60));
461 fieldLength.put("entrytype", new Integer(75));
462 fieldLength.put("search", new Integer(75));
463 fieldLength.put("citeseercitationcount", new Integer(75));
464 fieldLength.put(NUMBER_COL, new Integer(32));
466 FIELD_WEIGHT = new HashMap();
467 FIELD_WEIGHT.put("author", MEDIUM_W);
468 FIELD_WEIGHT.put("year", SMALL_W);
469 FIELD_WEIGHT.put("pages", SMALL_W);
470 FIELD_WEIGHT.put("month", SMALL_W);
471 FIELD_WEIGHT.put("url", SMALL_W);
472 FIELD_WEIGHT.put("citeseerurl", SMALL_W);
473 FIELD_WEIGHT.put("crossref", SMALL_W);
474 FIELD_WEIGHT.put("note", MEDIUM_W);
475 FIELD_WEIGHT.put("publisher", MEDIUM_W);
476 FIELD_WEIGHT.put("journal", SMALL_W);
477 FIELD_WEIGHT.put("volume", SMALL_W);
478 FIELD_WEIGHT.put("edition", SMALL_W);
479 FIELD_WEIGHT.put("keywords", SMALL_W);
480 FIELD_WEIGHT.put("doi", SMALL_W);
481 FIELD_WEIGHT.put("eid", SMALL_W);
482 FIELD_WEIGHT.put("pdf", SMALL_W);
483 FIELD_WEIGHT.put("number", SMALL_W);
484 FIELD_WEIGHT.put("chapter", SMALL_W);
485 FIELD_WEIGHT.put("editor", MEDIUM_W);
486 FIELD_WEIGHT.put("series", SMALL_W);
487 FIELD_WEIGHT.put("type", SMALL_W);
488 FIELD_WEIGHT.put("address", SMALL_W);
489 FIELD_WEIGHT.put("howpublished", MEDIUM_W);
490 FIELD_WEIGHT.put("institution", MEDIUM_W);
491 FIELD_WEIGHT.put("organization", MEDIUM_W);
492 FIELD_WEIGHT.put("school", MEDIUM_W);
493 FIELD_WEIGHT.put("comment", MEDIUM_W);
494 FIELD_WEIGHT.put("abstract", LARGE_W);
495 FIELD_WEIGHT.put("annote", LARGE_W);
496 FIELD_WEIGHT.put("citeseercitationcount", SMALL_W);
497 FIELD_WEIGHT.put("owner", SMALL_W);
498 FIELD_WEIGHT.put("timestamp", SMALL_W);
499 //FIELD_WEIGHT = Collections.unmodifiableMap(FIELD_WEIGHT);
503 public static int getPreferredFieldLength(String name) {
504 int l = DEFAULT_FIELD_LENGTH;
505 Object o = fieldLength.get(name.toLowerCase());
507 l = ((Integer)o).intValue();
511 public static double getFieldWeight(String name) {
512 double l = DEFAULT_FIELD_WEIGHT;
513 Object o = FIELD_WEIGHT.get(name.toLowerCase());
515 l = ( (Double) o).doubleValue();
520 public static void setFieldWeight(String fieldName, double weight) {
521 FIELD_WEIGHT.put(fieldName, new Double(weight));
524 /** returns the path to language independent help files */
525 public static String getLocaleHelpPath()
527 JabRefPreferences prefs = JabRefPreferences.getInstance() ;
528 String middle = prefs.get("language")+"/";
529 if (middle.equals("en/")) middle = ""; // english in base help dir.
531 return (helpPre + middle );
536 * Perform initializations that are only used in graphical mode. This is to prevent
537 * the "Xlib: connection to ":0.0" refused by server" error when access to the X server
538 * on Un*x is unavailable.
540 public static void init() {
541 typeNameFont = new Font("arial", Font.ITALIC+Font.BOLD, 24);
542 fieldNameFont = new Font("arial", Font.ITALIC+Font.BOLD, 14);
543 incompleteLabel = new JLabel(new ImageIcon(GUIGlobals.incompleteIcon));
544 incompleteLabel.setToolTipText(Globals.lang("Entry is incomplete"));
546 lab = new JLabel(new ImageIcon(pdfIcon));
547 lab.setToolTipText(Globals.lang("Open")+" PDF");
548 tableIcons.put("pdf", lab);
549 lab = new JLabel(new ImageIcon(wwwIcon));
550 lab.setToolTipText(Globals.lang("Open")+" URL");
551 tableIcons.put("url", lab);
552 lab = new JLabel(new ImageIcon(wwwCiteSeerIcon));
553 lab.setToolTipText(Globals.lang("Open")+" CiteSeer URL");
554 tableIcons.put("citeseerurl", lab);
555 lab = new JLabel(new ImageIcon(doiSmallIcon));
556 lab.setToolTipText(Globals.lang("Open")+" DOI "+Globals.lang("web link"));
557 tableIcons.put("doi", lab);
558 lab = new JLabel(new ImageIcon(psIcon));
559 lab.setToolTipText(Globals.lang("Open")+" PS");
560 tableIcons.put("ps", lab);
562 //jabRefFont = new Font("arial", Font.ITALIC/*+Font.BOLD*/, 20);