Revision 458adeaf
Added by Pepe Ciardelli almost 16 years ago
.gitattributes | ||
---|---|---|
425 | 425 |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/cdm/SaveTaxonAction.java -text |
426 | 426 |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/cdm/SwapSynonymAndTaxonAction.java -text |
427 | 427 |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/cdm/TaxonActionFactory.java -text |
428 |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/io/ExportAction.java -text |
|
428 | 429 |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/io/ImportAction.java -text |
429 | 430 |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/ui/AdaptCompositeToGroupAction.java -text |
430 | 431 |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/ui/AddBasionymCompositeAction.java -text |
... | ... | |
537 | 538 |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/namerelationswizard/NameRelationWizard.java -text |
538 | 539 |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/namerelationswizard/NameRelationWizardModel.java -text |
539 | 540 |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/namerelationswizard/NameRelationsListWizard.java -text |
541 |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/reference/NomenclaturalReferencePropertySource.java -text |
|
542 |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/reference/ReferencePropertySource.java -text |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/ApplicationActionBarAdvisor.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.taxeditor; |
11 | 11 |
|
12 |
import java.util.ArrayList; |
|
13 |
import java.util.List; |
|
14 |
|
|
12 | 15 |
import org.apache.log4j.Logger; |
13 | 16 |
import org.eclipse.jface.action.IAction; |
14 | 17 |
import org.eclipse.jface.action.IMenuManager; |
... | ... | |
20 | 23 |
import org.eclipse.ui.application.ActionBarAdvisor; |
21 | 24 |
import org.eclipse.ui.application.IActionBarConfigurer; |
22 | 25 |
|
26 |
import eu.etaxonomy.cdm.io.common.ImportWrapper; |
|
27 |
import eu.etaxonomy.taxeditor.actions.io.ExportAction; |
|
23 | 28 |
import eu.etaxonomy.taxeditor.actions.io.ImportAction; |
24 |
import eu.etaxonomy.taxeditor.actions.ui.OpenNameRelationWizardAction; |
|
25 | 29 |
import eu.etaxonomy.taxeditor.actions.ui.OpenTaxonEditorAction; |
26 | 30 |
|
27 | 31 |
/** |
... | ... | |
46 | 50 |
private IWorkbenchAction undoAction; |
47 | 51 |
|
48 | 52 |
private IAction newNameAction; |
49 |
private IAction importAction; |
|
53 |
|
|
54 |
private List<IAction> importActionList; |
|
55 |
|
|
56 |
private IAction exportJaxbAction; |
|
50 | 57 |
|
51 | 58 |
public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) { |
52 | 59 |
super(configurer); |
... | ... | |
72 | 79 |
newNameAction = new OpenTaxonEditorAction(); |
73 | 80 |
register(newNameAction); |
74 | 81 |
|
75 |
importAction = new ImportAction(); |
|
76 |
register(importAction); |
|
77 |
|
|
78 | 82 |
preferencesAction = ActionFactory.PREFERENCES.create(window); |
83 |
|
|
84 |
makeImportActions(); |
|
85 |
|
|
86 |
exportJaxbAction = new ExportAction(ExportAction.JAXB); |
|
87 |
register(exportJaxbAction); |
|
88 |
} |
|
89 |
|
|
90 |
private void makeImportActions() { |
|
91 |
|
|
92 |
importActionList = new ArrayList<IAction>(); |
|
93 |
|
|
94 |
for (ImportWrapper wrapper : ImportWrapper.list()) { |
|
95 |
IAction importAction = new ImportAction(wrapper); |
|
96 |
register(importAction); |
|
97 |
importActionList.add(importAction); |
|
98 |
} |
|
79 | 99 |
} |
80 | 100 |
|
81 | 101 |
protected void fillMenuBar(IMenuManager menuBar) { |
82 |
MenuManager fileMenu = new MenuManager("&File", |
|
83 |
null); |
|
102 |
|
|
84 | 103 |
// Note: to hook into Eclipse File Menu, to use open File for instance, |
85 | 104 |
// replace NULL with IWorkbenchActionConstants.M_FILE); |
105 |
MenuManager fileMenu = new MenuManager("&File", |
|
106 |
null); |
|
107 |
|
|
108 |
// Create submenu for imports |
|
109 |
MenuManager importMenu = new MenuManager("Import ...", null); |
|
110 |
|
|
111 |
// Create submenu for exports |
|
112 |
MenuManager exportMenu = new MenuManager("Export as ...", null); |
|
86 | 113 |
|
114 |
// Populate file menu |
|
87 | 115 |
menuBar.add(fileMenu); |
88 | 116 |
fileMenu.add(newNameAction); |
89 | 117 |
fileMenu.add(saveAction); |
90 | 118 |
fileMenu.add(undoAction); |
91 | 119 |
fileMenu.add(new Separator()); |
92 |
fileMenu.add(importAction); |
|
120 |
fileMenu.add(importMenu); |
|
121 |
fileMenu.add(exportMenu); |
|
93 | 122 |
fileMenu.add(new Separator()); |
94 | 123 |
fileMenu.add(exitAction); |
95 | 124 |
|
125 |
// Populate submenu for imports |
|
126 |
for (IAction importAction : importActionList) { |
|
127 |
importMenu.add(importAction); |
|
128 |
} |
|
129 |
|
|
130 |
// Populate submenu for exports |
|
131 |
exportMenu.add(exportJaxbAction); |
|
132 |
|
|
133 |
// Populate preferences |
|
96 | 134 |
MenuManager preferencesMenu = new MenuManager("&Preferences", |
97 | 135 |
null); |
98 | 136 |
menuBar.add(preferencesMenu); |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/ApplicationWorkbenchWindowAdvisor.java | ||
---|---|---|
42 | 42 |
configurer.setShowPerspectiveBar(true); |
43 | 43 |
configurer.setTitle("EDIT Taxonomic Editor"); |
44 | 44 |
} |
45 |
|
|
46 |
public void postWindowOpen() { |
|
47 |
|
|
48 |
// Remove "Show adv. properties" and "Show categories" from prop. sheet |
|
49 |
UiUtil.hidePropertySheetToolbar(); |
|
50 |
} |
|
51 |
|
|
45 | 52 |
} |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/FreetextPropertiesPerspective.java | ||
---|---|---|
14 | 14 |
import org.eclipse.ui.IPageLayout; |
15 | 15 |
import org.eclipse.ui.IPerspectiveFactory; |
16 | 16 |
import org.eclipse.ui.actions.ActionFactory; |
17 |
import org.eclipse.ui.views.properties.PropertySheetPage; |
|
17 | 18 |
|
18 | 19 |
import eu.etaxonomy.taxeditor.navigation.RecentNamesView; |
19 | 20 |
import eu.etaxonomy.taxeditor.navigation.TaxonomicTreeView; |
... | ... | |
53 | 54 |
folderLayoutRight.addView(IPageLayout.ID_PROP_SHEET); |
54 | 55 |
|
55 | 56 |
layout.getViewLayout(IPageLayout.ID_PROP_SHEET).setCloseable(false); |
57 |
layout.getViewLayout(IPageLayout.ID_PROP_SHEET); |
|
56 | 58 |
layout.getViewLayout(TaxonomicTreeView.ID).setCloseable(false); |
57 | 59 |
} |
58 | 60 |
} |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/TaxEditorPlugin.java | ||
---|---|---|
49 | 49 |
import eu.etaxonomy.cdm.api.service.INameService; |
50 | 50 |
import eu.etaxonomy.cdm.api.service.ITaxonService; |
51 | 51 |
import eu.etaxonomy.cdm.database.CdmDataSource; |
52 |
import eu.etaxonomy.cdm.database.CdmPersistentDataSource; |
|
53 | 52 |
import eu.etaxonomy.cdm.database.DataSourceNotFoundException; |
54 | 53 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
55 | 54 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/UiUtil.java | ||
---|---|---|
20 | 20 |
import org.eclipse.swt.widgets.Composite; |
21 | 21 |
import org.eclipse.swt.widgets.Control; |
22 | 22 |
import org.eclipse.swt.widgets.Shell; |
23 |
import org.eclipse.ui.IActionBars; |
|
23 | 24 |
import org.eclipse.ui.IEditorInput; |
24 | 25 |
import org.eclipse.ui.IEditorPart; |
25 | 26 |
import org.eclipse.ui.IEditorReference; |
... | ... | |
68 | 69 |
return reference.getView(false); |
69 | 70 |
} |
70 | 71 |
} |
71 |
// PropertySheet ps = new PropertySheet(); |
|
72 | 72 |
return null; |
73 | 73 |
} |
74 | 74 |
|
75 |
/** |
|
76 |
* By default, property sheet has buttons in the toolbar for |
|
77 |
* "Show advanced properties" and "Show categories". |
|
78 |
* <p> |
|
79 |
* This is confusing for the user, hence a method to remove them |
|
80 |
* until such time as advanced properties or categories are implemented. |
|
81 |
*/ |
|
82 |
public static void hidePropertySheetToolbar() { |
|
83 |
PropertySheet propertySheet = (PropertySheet) getPropertySheet(); |
|
84 |
IActionBars actionBars = propertySheet.getViewSite().getActionBars(); |
|
85 |
actionBars.getToolBarManager().removeAll(); |
|
86 |
actionBars.getMenuManager().removeAll(); |
|
87 |
} |
|
88 |
|
|
75 | 89 |
/** |
76 | 90 |
* The property sheet listener ensures only property sheets |
77 | 91 |
* with data cause the Property Sheet to be updated. |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/io/ExportAction.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
|
|
10 |
package eu.etaxonomy.taxeditor.actions.io; |
|
11 |
|
|
12 |
import java.io.File; |
|
13 |
|
|
14 |
import org.apache.log4j.Logger; |
|
15 |
import org.eclipse.jface.action.Action; |
|
16 |
import org.eclipse.jface.resource.ImageDescriptor; |
|
17 |
import org.eclipse.swt.SWT; |
|
18 |
import org.eclipse.swt.widgets.FileDialog; |
|
19 |
|
|
20 |
import eu.etaxonomy.taxeditor.UiUtil; |
|
21 |
|
|
22 |
/** |
|
23 |
* @author p.ciardelli |
|
24 |
* @created 05.11.2008 |
|
25 |
* @version 1.0 |
|
26 |
*/ |
|
27 |
public class ExportAction extends Action { |
|
28 |
private static final Logger logger = Logger.getLogger(ExportAction.class); |
|
29 |
|
|
30 |
private static String text = "Export as ..."; |
|
31 |
private ImageDescriptor image = null; |
|
32 |
public static final String ID = "eu.etaxonomy.taxeditor.actions.io.exportaction"; //$NON-NLS-1$ |
|
33 |
|
|
34 |
public static final String JAXB = "JAXB"; |
|
35 |
|
|
36 |
private FileDialog dialog; |
|
37 |
private File file; |
|
38 |
|
|
39 |
private String exportType; |
|
40 |
|
|
41 |
public ExportAction() { |
|
42 |
super(text); |
|
43 |
setImageDescriptor(image); |
|
44 |
setId(ID); |
|
45 |
} |
|
46 |
|
|
47 |
public ExportAction(String exportType) { |
|
48 |
this(); |
|
49 |
|
|
50 |
this.exportType = exportType; |
|
51 |
setText(exportType); |
|
52 |
} |
|
53 |
|
|
54 |
public void run() { |
|
55 |
|
|
56 |
// Use same title "Import FORMAT" for all message dialogs |
|
57 |
String title = "Export " + getText(); |
|
58 |
|
|
59 |
// Get file from user |
|
60 |
dialog = new FileDialog(UiUtil.getShell(), SWT.SAVE); |
|
61 |
dialog.setFileName("export.xml"); |
|
62 |
String filePath = dialog.open(); |
|
63 |
file = new File(filePath); |
|
64 |
} |
|
65 |
} |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/io/ImportAction.java | ||
---|---|---|
11 | 11 |
|
12 | 12 |
import java.io.File; |
13 | 13 |
import java.net.MalformedURLException; |
14 |
import java.util.UUID; |
|
15 | 14 |
|
16 | 15 |
import org.apache.log4j.Logger; |
17 | 16 |
import org.eclipse.jface.action.Action; |
17 |
import org.eclipse.jface.dialogs.MessageDialog; |
|
18 | 18 |
import org.eclipse.jface.resource.ImageDescriptor; |
19 | 19 |
import org.eclipse.swt.widgets.FileDialog; |
20 | 20 |
|
21 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
|
22 | 21 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
23 |
import eu.etaxonomy.cdm.io.common.CdmDefaultImport; |
|
24 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK; |
|
25 |
import eu.etaxonomy.cdm.io.tcs.TcsImportConfigurator; |
|
22 |
import eu.etaxonomy.cdm.io.common.ImportWrapper; |
|
26 | 23 |
import eu.etaxonomy.taxeditor.TaxEditorPlugin; |
27 | 24 |
import eu.etaxonomy.taxeditor.UiUtil; |
28 |
import eu.etaxonomy.taxeditor.io.InputWizard2; |
|
29 | 25 |
|
30 | 26 |
/** |
31 | 27 |
* @author p.ciardelli |
... | ... | |
40 | 36 |
public static final String ID = "eu.etaxonomy.taxeditor.actions.io.importaction"; //$NON-NLS-1$ |
41 | 37 |
|
42 | 38 |
private FileDialog dialog; |
43 |
|
|
44 | 39 |
private File file; |
45 |
|
|
46 |
private InputWizard2 wizard; |
|
40 |
private ImportWrapper importWrapper; |
|
47 | 41 |
|
48 | 42 |
public ImportAction() { |
49 | 43 |
super(text); |
50 | 44 |
setImageDescriptor(image); |
51 | 45 |
setId(ID); |
52 | 46 |
} |
53 |
|
|
47 |
|
|
48 |
public ImportAction(ImportWrapper importWrapper) { |
|
49 |
this(); |
|
50 |
|
|
51 |
this.importWrapper = importWrapper; |
|
52 |
setText(importWrapper.getLabel()); |
|
53 |
} |
|
54 |
|
|
54 | 55 |
public void run() { |
56 |
|
|
57 |
// Use same title "Import FORMAT" for all message dialogs |
|
58 |
String title = "Import " + getText(); |
|
59 |
|
|
60 |
// Make sure user is aware of the implications of an import |
|
61 |
boolean doProceed = MessageDialog.openConfirm(UiUtil.getShell(), title, |
|
62 |
"Import may require a great deal of time and system resources.\n\n" + |
|
63 |
"Are you sure you would like to proceed?"); |
|
64 |
if (!doProceed) { |
|
65 |
return; |
|
66 |
} |
|
67 |
|
|
68 |
// Get file from user |
|
55 | 69 |
dialog = new FileDialog(UiUtil.getShell()); |
56 | 70 |
String filePath = dialog.open(); |
57 | 71 |
file = new File(filePath); |
58 |
|
|
59 |
// wizard = new InputWizard2(); |
|
60 |
|
|
61 |
// WizardDialog dialog = new WizardDialog(UiUtil.getShell(), wizard); |
|
62 |
// dialog.create(); |
|
63 |
// dialog.open(); |
|
64 |
|
|
72 |
|
|
73 |
// Get current data source |
|
65 | 74 |
ICdmDataSource destination = TaxEditorPlugin.getDefault().getCdmDataSource(); |
75 |
|
|
76 |
// Format file path |
|
66 | 77 |
String source = null; |
67 | 78 |
try { |
68 | 79 |
source = file.toURI().toURL().toString(); |
69 | 80 |
} catch (MalformedURLException e) { |
70 |
// TODO Auto-generated catch block
|
|
71 |
e.printStackTrace();
|
|
81 |
MessageDialog.openError(UiUtil.getShell(), title, "File could not be read.");
|
|
82 |
return;
|
|
72 | 83 |
} |
73 | 84 |
|
74 |
TcsImportConfigurator tcsImportConfigurator = TcsImportConfigurator.NewInstance(source, destination); |
|
75 |
|
|
76 |
// tcsImportConfigurator.setSecUuid(UUID.fromString("5f32b8af-0c97-48ac-8d33-6099ed68c625")); |
|
77 |
// tcsImportConfigurator.setSourceSecId("palm_pub_ed_999999"); |
|
78 |
// |
|
79 |
// tcsImportConfigurator.setDoAuthors(false); |
|
80 |
// tcsImportConfigurator.setDoReferences(DO_REFERENCES.ALL); |
|
81 |
// tcsImportConfigurator.setDoTaxonNames(false); |
|
82 |
// tcsImportConfigurator.setDoRelNames(false); |
|
83 |
//tcsImportConfigurator.setDoNameStatus(doNameStatus); |
|
84 |
//tcsImportConfigurator.setDoTypes(doTypes); |
|
85 |
//tcsImportConfigurator.setDoNameFacts(doNameFacts); |
|
86 |
// |
|
87 |
// tcsImportConfigurator.setDoTaxa(false); |
|
88 |
// tcsImportConfigurator.setDoRelTaxa(false); |
|
89 |
// tcsImportConfigurator.setDoFacts(false); |
|
90 |
|
|
91 |
tcsImportConfigurator.setCheck(CHECK.IMPORT_WITHOUT_CHECK); |
|
92 |
tcsImportConfigurator.setDbSchemaValidation(DbSchemaValidation.CREATE); |
|
85 |
// Start import |
|
86 |
boolean isSuccessfulImport = importWrapper.invoke(source, destination, null); |
|
93 | 87 |
|
88 |
// Tell user whether import was a success or a dismal failure |
|
89 |
String msg = null; |
|
90 |
if (isSuccessfulImport) { |
|
91 |
MessageDialog.openInformation(UiUtil.getShell(), title, "Import successful"); |
|
92 |
} else { |
|
93 |
MessageDialog.openError(UiUtil.getShell(), title, "Import was unsuccessful."); |
|
94 |
} |
|
94 | 95 |
|
95 |
CdmDefaultImport<TcsImportConfigurator> tcsImport = new CdmDefaultImport<TcsImportConfigurator>(); |
|
96 |
//new Test().invoke(tcsImportConfigurator); |
|
97 |
boolean successful = tcsImport.invoke(tcsImportConfigurator); |
|
98 |
logger.warn("Successful? " + successful); |
|
99 | 96 |
} |
100 | 97 |
} |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/model/CdmUtil.java | ||
---|---|---|
414 | 414 |
// return CdmUtils.Nz(nomenclaturalReference.getNomenclaturalCitation(microReference)); |
415 | 415 |
} |
416 | 416 |
|
417 |
/** |
|
418 |
* Checks whether a String is either a valid year |
|
419 |
* or two valid years |
|
420 |
* with the format "XXXX-XXXX". |
|
421 |
* |
|
422 |
* @see #getValidYear(String yearStr) |
|
423 |
* @param refYear |
|
424 |
* @return |
|
425 |
* @throws NumberFormatException |
|
426 |
*/ |
|
417 | 427 |
public static TimePeriod getDatePublished(String refYear) throws NumberFormatException { |
418 |
if (refYear == null){ |
|
428 |
|
|
429 |
if (refYear == null || ("").equals(refYear)){ |
|
419 | 430 |
return null; |
420 | 431 |
} |
421 | 432 |
|
433 |
TimePeriod datePublished = TimePeriod.NewInstance(); |
|
434 |
|
|
435 |
// In case format is "xxxx-xxxx" |
|
422 | 436 |
String[] years = refYear.split("-"); |
423 |
Calendar calStart = null; |
|
424 |
Calendar calEnd = null; |
|
425 |
if (years.length > 2 || years.length <= 0){ |
|
426 |
logger.warn("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX getDatePublished"); |
|
427 |
} else { |
|
428 |
calStart = getCalendar(years[0]); |
|
429 |
if (years.length >= 2){ |
|
430 |
calEnd = getCalendar(years[1]); |
|
431 |
} |
|
437 |
|
|
438 |
// Unlikely case of "xxx-xx-xxx..." |
|
439 |
if (years.length > 2) { |
|
440 |
throw new NumberFormatException(); |
|
432 | 441 |
} |
433 |
TimePeriod result = TimePeriod.NewInstance(calStart, calEnd); |
|
434 |
return result; |
|
442 |
|
|
443 |
// Set startYear |
|
444 |
datePublished.setStartYear(getValidYear(years[0])); |
|
445 |
|
|
446 |
// Format is "xxx-xxxx" |
|
447 |
if (years.length == 2) { |
|
448 |
datePublished.setEndYear(getValidYear(years[1])); |
|
449 |
} |
|
450 |
|
|
451 |
return datePublished; |
|
435 | 452 |
} |
436 | 453 |
|
437 |
public static Calendar getCalendar(String strYear) throws NumberFormatException { |
|
438 | 454 |
|
439 |
//FIXME until now only quick and dirty and wrong |
|
440 |
Calendar cal = Calendar.getInstance(); |
|
441 |
cal.set(9999, Calendar.DECEMBER, 30, 0, 0, 0); |
|
442 |
if (CdmUtils.isNumeric(strYear)){ |
|
443 |
Integer year = Integer.valueOf(strYear.trim()); |
|
444 |
if (year > 1750 && year < 2030){ |
|
445 |
cal.set(year, Calendar.JANUARY, 1, 0, 0, 0); |
|
446 |
} else { |
|
447 |
throw new NumberFormatException(); |
|
448 |
} |
|
449 |
} else throw new NumberFormatException(); |
|
455 |
/** |
|
456 |
* Checks whether a <code>String</code> is a valid year between |
|
457 |
* 1750 and 2030. Throws a <code>NumberFormatException</code> if not. |
|
458 |
* |
|
459 |
* @param yearStr |
|
460 |
* @return |
|
461 |
* @throws NumberFormatException |
|
462 |
*/ |
|
463 |
public static Integer getValidYear(String yearStr) throws NumberFormatException { |
|
464 |
|
|
465 |
Integer yearInt = null; |
|
466 |
|
|
467 |
// Try casting string - don't catch number format exception |
|
468 |
try { |
|
469 |
yearInt = new Integer(yearStr); |
|
470 |
} catch (ClassCastException e) { |
|
471 |
throw new NumberFormatException(); |
|
472 |
} |
|
473 |
|
|
474 |
// Is year in valid range? |
|
475 |
if (yearInt < 1750 || yearInt > 2030) { |
|
476 |
throw new NumberFormatException(); |
|
477 |
} |
|
450 | 478 |
|
451 |
return cal;
|
|
479 |
return yearInt;
|
|
452 | 480 |
} |
453 | 481 |
} |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/TimePeriodPropertySource.java | ||
---|---|---|
13 | 13 |
import java.beans.PropertyChangeSupport; |
14 | 14 |
import java.text.DateFormat; |
15 | 15 |
import java.text.SimpleDateFormat; |
16 |
import java.util.Calendar; |
|
17 | 16 |
import java.util.Vector; |
18 | 17 |
|
19 | 18 |
import org.apache.log4j.Logger; |
... | ... | |
57 | 56 |
new String[] {P_ID_STARTYEAR, P_ID_STARTMONTH, P_ID_STARTDAY, |
58 | 57 |
P_ID_ENDYEAR, P_ID_ENDMONTH, P_ID_ENDDAY}; |
59 | 58 |
|
60 |
private static final String[] P_MONTH_MENU = new String[] {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; |
|
59 |
private static final String[] P_MONTH_MENU = new String[] {"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
|
|
61 | 60 |
|
62 | 61 |
public TimePeriodPropertySource(TimePeriod timePeriod) { |
63 | 62 |
super(); |
... | ... | |
68 | 67 |
this.timePeriod = timePeriod; |
69 | 68 |
|
70 | 69 |
// Add property sheet descriptors |
71 |
addDescriptor(P_ID_STARTYEAR); |
|
72 |
if (!getPropertyValue(P_ID_STARTYEAR).equals("")) { |
|
73 |
|
|
74 |
// Only show start month and start day after start year has been populated |
|
75 |
addDescriptor(P_ID_STARTMONTH); |
|
76 |
addDescriptor(P_ID_STARTDAY); |
|
77 |
|
|
78 |
// Only show end if start has been populated |
|
79 |
addDescriptor(P_ID_ENDYEAR); |
|
80 |
|
|
81 |
if (!getPropertyValue(P_ID_ENDYEAR).equals("")) { |
|
82 |
// Only show end month and end day after end year has been populated |
|
83 |
addDescriptor(P_ID_ENDMONTH); |
|
84 |
addDescriptor(P_ID_ENDDAY); |
|
85 |
} |
|
70 |
for (String key : TOP_LEVEL_PROPERTIES) { |
|
71 |
addDescriptor(key); |
|
86 | 72 |
} |
87 |
// for (String key : TOP_LEVEL_PROPERTIES) { |
|
88 |
// addDescriptor(key); |
|
89 |
// } |
|
90 | 73 |
} |
91 |
|
|
74 |
|
|
92 | 75 |
//static date formatter |
93 | 76 |
private static final DateFormat formatter = new SimpleDateFormat( |
94 | 77 |
"EEEE, MMMM d, yyyy"); //$NON-NLS-1$ |
... | ... | |
149 | 132 |
|
150 | 133 |
public Object getPropertyValue(Object id) { |
151 | 134 |
|
152 |
Calendar start = timePeriod.getStart(); |
|
153 |
Calendar end = timePeriod.getEnd(); |
|
154 |
|
|
155 | 135 |
if (id.equals(P_ID_STARTYEAR)) { |
156 |
return (start == null) ? "" : String.valueOf(start.get(Calendar.YEAR)); |
|
136 |
Integer startYear = timePeriod.getStartYear(); |
|
137 |
return (startYear == null) ? "" : String.valueOf(startYear); |
|
157 | 138 |
} |
158 |
|
|
139 |
|
|
159 | 140 |
if (id.equals(P_ID_STARTMONTH)) { |
160 |
return (start == null) ? 0 : Integer.valueOf(start.get(Calendar.MONTH)); |
|
141 |
Integer startMonth = timePeriod.getStartMonth(); |
|
142 |
return (startMonth == null) ? 0 : startMonth; |
|
161 | 143 |
} |
162 | 144 |
|
163 | 145 |
if (id.equals(P_ID_STARTDAY)) { |
164 |
return (start == null) ? "" : String.valueOf(start.get(Calendar.DAY_OF_MONTH)); |
|
146 |
Integer startDay = timePeriod.getStartDay(); |
|
147 |
return (startDay == null) ? "" : String.valueOf(startDay); |
|
165 | 148 |
} |
166 | 149 |
|
167 | 150 |
if (id.equals(P_ID_ENDYEAR)) { |
168 |
return (end == null) ? "" : String.valueOf(end.get(Calendar.YEAR)); |
|
151 |
Integer endYear = timePeriod.getEndYear(); |
|
152 |
return (endYear == null) ? "" : String.valueOf(endYear); |
|
169 | 153 |
} |
170 | 154 |
|
171 | 155 |
if (id.equals(P_ID_ENDMONTH)) { |
172 |
return (end == null) ? 0 : Integer.valueOf(end.get(Calendar.MONTH)); |
|
156 |
Integer endMonth = timePeriod.getEndMonth(); |
|
157 |
return (endMonth == null) ? 0 : endMonth; |
|
173 | 158 |
} |
174 | 159 |
|
175 | 160 |
if (id.equals(P_ID_ENDDAY)) { |
176 |
return (end == null) ? "" : String.valueOf(end.get(Calendar.DAY_OF_MONTH)); |
|
161 |
Integer endDay = timePeriod.getEndDay(); |
|
162 |
return (endDay == null) ? "" : String.valueOf(endDay); |
|
177 | 163 |
} |
178 | 164 |
|
179 | 165 |
return ""; |
... | ... | |
192 | 178 |
public void resetPropertyValue(Object property) {} |
193 | 179 |
|
194 | 180 |
public void setPropertyValue(Object id, Object value) { |
195 |
Calendar start = timePeriod.getStart(); |
|
196 |
Calendar end = timePeriod.getEnd(); |
|
197 |
|
|
198 |
// Init start if necessary |
|
199 |
if (id.equals(P_ID_STARTYEAR) || id.equals(P_ID_STARTMONTH) || |
|
200 |
id.equals(P_ID_STARTDAY) ) { |
|
201 |
if (start == null) { |
|
202 |
start = Calendar.getInstance(); |
|
203 |
timePeriod.setStart(start); |
|
204 |
|
|
205 |
// Default to January 1 |
|
206 |
start.set(Calendar.DAY_OF_YEAR, 1); |
|
207 |
} |
|
208 |
} |
|
209 | 181 |
|
210 |
// Init end if necessary |
|
211 |
if (id.equals(P_ID_ENDYEAR) || id.equals(P_ID_ENDMONTH) || |
|
212 |
id.equals(P_ID_ENDDAY) ) { |
|
213 |
if (end == null) { |
|
214 |
end = Calendar.getInstance(); |
|
215 |
timePeriod.setEnd(end); |
|
216 |
|
|
217 |
// Default to January 1 |
|
218 |
end.set(Calendar.DAY_OF_YEAR, 1); |
|
219 |
} |
|
220 |
} |
|
182 |
if (id.equals(P_ID_STARTYEAR)) { |
|
183 |
timePeriod.setStartYear(castToInteger(value)); |
|
184 |
} |
|
185 |
|
|
186 |
if (id.equals(P_ID_STARTMONTH)) { |
|
187 |
timePeriod.setStartMonth(castToInteger(value)); |
|
188 |
} |
|
189 |
|
|
190 |
if (id.equals(P_ID_STARTDAY)) { |
|
191 |
timePeriod.setStartDay(castToInteger(value)); |
|
192 |
} |
|
193 |
|
|
194 |
if (id.equals(P_ID_ENDYEAR)) { |
|
195 |
timePeriod.setEndYear(castToInteger(value)); |
|
196 |
} |
|
197 |
|
|
198 |
if (id.equals(P_ID_ENDMONTH)) { |
|
199 |
timePeriod.setEndMonth(castToInteger(value)); |
|
200 |
} |
|
201 |
|
|
202 |
if (id.equals(P_ID_ENDDAY)) { |
|
203 |
timePeriod.setEndDay(castToInteger(value)); |
|
204 |
} |
|
221 | 205 |
|
222 |
if (id.equals(P_ID_STARTYEAR)) { |
|
223 |
|
|
224 |
// Empty year string, set start and end to null |
|
225 |
if (((String) value).equals("")) { |
|
226 |
start = null; |
|
227 |
end = null; |
|
228 |
} else { |
|
229 |
start.set(Calendar.YEAR, castToInteger(value)); |
|
230 |
} |
|
231 |
} |
|
232 |
|
|
233 |
if (id.equals(P_ID_STARTMONTH)) { |
|
234 |
start.set(Calendar.MONTH, (Integer) value); |
|
235 |
} |
|
206 |
propertyChangeSupport.firePropertyChange(ITaxEditorConstants.PROPERTY_SHEET_CHANGE, null, timePeriod); |
|
207 |
} |
|
236 | 208 |
|
237 |
if (id.equals(P_ID_STARTDAY)) { |
|
238 |
start.set(Calendar.DAY_OF_MONTH, castToInteger(value)); |
|
239 |
} |
|
209 |
private Integer castToInteger(Object value) { |
|
240 | 210 |
|
241 |
if (id.equals(P_ID_ENDYEAR)) { |
|
242 |
|
|
243 |
// Empty year string, set end to null |
|
244 |
if (((String) value).equals("")) { |
|
245 |
timePeriod.setEnd(null); |
|
211 |
// Dropdown lists return an Integer index |
|
212 |
if (value instanceof Integer) { |
|
213 |
|
|
214 |
// First entry in dropdown is empty |
|
215 |
if (((Integer) value).equals(0)) { |
|
216 |
return null; |
|
246 | 217 |
} else { |
247 |
end.set(Calendar.YEAR, castToInteger(value));
|
|
218 |
return (Integer) value;
|
|
248 | 219 |
} |
249 | 220 |
} |
250 |
|
|
251 |
if (id.equals(P_ID_ENDMONTH)) { |
|
252 |
end.set(Calendar.MONTH, (Integer) value); |
|
253 |
} |
|
254 |
|
|
255 |
if (id.equals(P_ID_ENDDAY)) { |
|
256 |
end.set(Calendar.DAY_OF_MONTH, castToInteger(value)); |
|
257 |
} |
|
258 |
|
|
259 |
propertyChangeSupport.firePropertyChange(ITaxEditorConstants.PROPERTY_SHEET_CHANGE, null, timePeriod); |
|
260 |
} |
|
261 |
|
|
262 |
private int castToInteger(Object value) { |
|
263 |
Integer integer; |
|
221 |
|
|
222 |
Integer integer = null; |
|
264 | 223 |
try { |
265 | 224 |
integer = new Integer((String) value); |
225 |
|
|
266 | 226 |
} catch (ClassCastException e) { |
267 |
integer = 0; |
|
268 | 227 |
} catch (NumberFormatException e) { |
269 |
// Likely because value = "" |
|
270 |
integer = 0; |
|
271 | 228 |
} |
272 | 229 |
return integer; |
273 | 230 |
} |
... | ... | |
277 | 234 |
* @return java.lang.String |
278 | 235 |
*/ |
279 | 236 |
public String toString() { |
280 |
// Date bday = (new GregorianCalendar(getYear().intValue(), getMonth() |
|
281 |
// .intValue() - 1, getDay().intValue())).getTime(); |
|
282 |
// return formatter.format(bday); |
|
283 | 237 |
return ""; |
284 | 238 |
} |
285 | 239 |
|
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/description/DescriptionElementPropertySource.java | ||
---|---|---|
32 | 32 |
import eu.etaxonomy.cdm.model.description.TextData; |
33 | 33 |
import eu.etaxonomy.cdm.model.reference.Generic; |
34 | 34 |
import eu.etaxonomy.cdm.model.reference.ReferenceBase; |
35 |
import eu.etaxonomy.taxeditor.propertysheet.bibref.ReferencePropertySource;
|
|
35 |
import eu.etaxonomy.taxeditor.propertysheet.reference.ReferencePropertySource;
|
|
36 | 36 |
|
37 | 37 |
/** |
38 | 38 |
* @author p.ciardelli |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/name/NonViralNamePropertySource.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.taxeditor.propertysheet.name; |
11 | 11 |
|
12 |
import java.beans.PropertyChangeEvent; |
|
12 | 13 |
import java.beans.PropertyChangeListener; |
13 | 14 |
import java.beans.PropertyChangeSupport; |
14 | 15 |
import java.util.ArrayList; |
... | ... | |
38 | 39 |
import eu.etaxonomy.cdm.model.reference.BookSection; |
39 | 40 |
import eu.etaxonomy.cdm.model.reference.Generic; |
40 | 41 |
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference; |
42 |
import eu.etaxonomy.cdm.model.reference.ReferenceBase; |
|
41 | 43 |
import eu.etaxonomy.taxeditor.ITaxEditorConstants; |
42 | 44 |
import eu.etaxonomy.taxeditor.TaxEditorPlugin; |
43 | 45 |
import eu.etaxonomy.taxeditor.UiUtil; |
... | ... | |
45 | 47 |
import eu.etaxonomy.taxeditor.propertysheet.AnnotationPropertySource; |
46 | 48 |
import eu.etaxonomy.taxeditor.propertysheet.AnnotationsPropertyDescriptor; |
47 | 49 |
import eu.etaxonomy.taxeditor.propertysheet.MarkersPropertySource; |
50 |
import eu.etaxonomy.taxeditor.propertysheet.reference.NomenclaturalReferencePropertySource; |
|
51 |
import eu.etaxonomy.taxeditor.propertysheet.reference.ReferencePropertySource; |
|
48 | 52 |
|
49 | 53 |
/** |
50 | 54 |
* @author p.ciardelli |
... | ... | |
454 | 458 |
return "none (nonviral name)"; |
455 | 459 |
} |
456 | 460 |
if (id.equals(P_ID_NOMENCLATURAL_REF)) { |
461 |
|
|
457 | 462 |
// INomenclaturalReference nomenclaturalReference = (INomenclaturalReference) name.getNomenclaturalReference(); |
458 |
// if (nomenclaturalReference == null) {
|
|
463 |
// if (name.getNomenclaturalReference() == null) {
|
|
459 | 464 |
// return ""; |
460 |
// } |
|
461 |
// String microReference = name.getNomenclaturalMicroReference(); |
|
462 |
// return CdmUtils.Nz(nomenclaturalReference.getNomenclaturalCitation(microReference)); |
|
465 |
// } else { |
|
466 |
// return new NonViralNamePropertySource(name, P_ID_NOMENCLATURAL_REF, getReferenceFields()); |
|
467 |
// } |
|
468 |
|
|
469 |
ReferenceBase nomRef = (ReferenceBase) name.getNomenclaturalReference(); |
|
463 | 470 |
|
464 |
INomenclaturalReference nomenclaturalReference = (INomenclaturalReference) name.getNomenclaturalReference(); |
|
465 |
if (name.getNomenclaturalReference() == null) { |
|
466 |
return ""; |
|
467 |
} else { |
|
468 |
return new NonViralNamePropertySource(name, P_ID_NOMENCLATURAL_REF, getReferenceFields()); |
|
469 |
} |
|
471 |
// Create nom. reference as necessary |
|
472 |
if (nomRef == null) { |
|
473 |
nomRef = Generic.NewInstance(); |
|
474 |
} |
|
475 |
|
|
476 |
// Create property source for submenu |
|
477 |
ReferencePropertySource nomRefPropertySource = new NomenclaturalReferencePropertySource(nomRef); |
|
478 |
|
|
479 |
// Add listener to notify name of all changes to nom. reference |
|
480 |
nomRefPropertySource.addPropertyChangeListener(new PropertyChangeListener() { |
|
481 |
public void propertyChange(PropertyChangeEvent evt) { |
|
482 |
if (evt.getNewValue() instanceof INomenclaturalReference) { |
|
483 |
name.setNomenclaturalReference((INomenclaturalReference) evt.getNewValue()); |
|
484 |
} |
|
485 |
} |
|
486 |
}); |
|
487 |
return nomRefPropertySource; |
|
488 |
|
|
470 | 489 |
} |
471 | 490 |
if (id.equals(P_ID_NOMENCLATURAL_MICROREF)) { |
472 | 491 |
return CdmUtils.Nz(name.getNomenclaturalMicroReference()); |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/name/TaxonBasePropertySource.java | ||
---|---|---|
17 | 17 |
import org.eclipse.ui.views.properties.IPropertyDescriptor; |
18 | 18 |
import org.eclipse.ui.views.properties.IPropertySource; |
19 | 19 |
import org.eclipse.ui.views.properties.PropertyDescriptor; |
20 |
import org.eclipse.ui.views.properties.TextPropertyDescriptor; |
|
21 | 20 |
|
22 | 21 |
import eu.etaxonomy.cdm.model.name.BotanicalName; |
23 | 22 |
import eu.etaxonomy.cdm.model.name.NonViralName; |
... | ... | |
27 | 26 |
import eu.etaxonomy.cdm.model.reference.Generic; |
28 | 27 |
import eu.etaxonomy.cdm.model.reference.ReferenceBase; |
29 | 28 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
30 |
import eu.etaxonomy.taxeditor.propertysheet.bibref.ReferencePropertySource;
|
|
29 |
import eu.etaxonomy.taxeditor.propertysheet.reference.ReferencePropertySource;
|
|
31 | 30 |
|
32 | 31 |
/** |
33 | 32 |
* @author p.ciardelli |
... | ... | |
93 | 92 |
if (id.equals(P_ID_TAXONNAME)) { |
94 | 93 |
|
95 | 94 |
TaxonNameBase name = taxon.getName(); |
95 |
|
|
96 |
// Create taxon name as necessary |
|
96 | 97 |
if (name == null) { |
97 | 98 |
name = NonViralName.NewInstance(Rank.SPECIES()); |
98 | 99 |
} |
99 | 100 |
|
100 |
// ReferencePropertySource bibRefPropertySource = new ReferencePropertySource(sec); |
|
101 |
// Hmmm ... maybe the listeners on the NameComposite will take care of this ... |
|
102 |
// bibRefPropertySource.addPropertyChangeListener(new PropertyChangeListener() { |
|
103 |
// public void propertyChange(PropertyChangeEvent evt) { |
|
104 |
// if (evt.getNewValue() instanceof TaxonNameBase) { |
|
105 |
// taxon.setName((TaxonNameBase) evt.getNewValue()); |
|
106 |
// ((NonViralName) taxon).setN |
|
107 |
// |
|
108 |
// } |
|
109 |
// } |
|
110 |
// }); |
|
111 |
// return bibRefPropertySource; |
|
101 |
// Send taxon name to appropriate property source for submenu |
|
112 | 102 |
if (name instanceof BotanicalName) { |
113 | 103 |
return new BotanicalNamePropertySource((BotanicalName) name); |
114 | 104 |
} |
... | ... | |
125 | 115 |
if (id.equals(P_ID_TAXONSEC)) { |
126 | 116 |
|
127 | 117 |
ReferenceBase sec = taxon.getSec(); |
118 |
|
|
119 |
// Create sec reference as necessary |
|
128 | 120 |
if (sec == null) { |
129 | 121 |
sec = Generic.NewInstance(); |
130 | 122 |
} |
131 | 123 |
|
124 |
// Create property source for submenu |
|
132 | 125 |
ReferencePropertySource secPropertySource = new ReferencePropertySource(sec); |
126 |
|
|
127 |
// Add listener to notify taxon of all changes to sec |
|
133 | 128 |
secPropertySource.addPropertyChangeListener(new PropertyChangeListener() { |
134 | 129 |
public void propertyChange(PropertyChangeEvent evt) { |
135 | 130 |
if (evt.getNewValue() instanceof ReferenceBase) { |
... | ... | |
159 | 154 |
* @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object) |
160 | 155 |
*/ |
161 | 156 |
public void setPropertyValue(Object id, Object value) { |
162 |
// Edit taxon's name |
|
163 |
if (id.equals(P_ID_TAXONNAME)) { |
|
164 |
|
|
165 |
} |
|
166 |
|
|
167 |
// Edit taxon's sec. reference |
|
168 |
if (id.equals(P_ID_TAXONSEC)) { |
|
169 |
|
|
170 |
} |
|
157 |
// All setting done in submenus |
|
171 | 158 |
} |
172 | 159 |
} |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/reference/NomenclaturalReferencePropertySource.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
|
|
10 |
package eu.etaxonomy.taxeditor.propertysheet.reference; |
|
11 |
|
|
12 |
import java.util.ArrayList; |
|
13 |
import java.util.LinkedHashMap; |
|
14 |
import java.util.List; |
|
15 |
|
|
16 |
import org.apache.log4j.Logger; |
|
17 |
|
|
18 |
import eu.etaxonomy.cdm.model.reference.Article; |
|
19 |
import eu.etaxonomy.cdm.model.reference.BibtexReference; |
|
20 |
import eu.etaxonomy.cdm.model.reference.Book; |
|
21 |
import eu.etaxonomy.cdm.model.reference.BookSection; |
|
22 |
import eu.etaxonomy.cdm.model.reference.Generic; |
|
23 |
import eu.etaxonomy.cdm.model.reference.PrintedUnitBase; |
|
24 |
import eu.etaxonomy.cdm.model.reference.PublicationBase; |
|
25 |
import eu.etaxonomy.cdm.model.reference.ReferenceBase; |
|
26 |
import eu.etaxonomy.cdm.model.reference.SectionBase; |
|
27 |
import eu.etaxonomy.cdm.model.reference.StrictReferenceBase; |
|
28 |
|
|
29 |
/** |
|
30 |
* Quick and dirty subclass of <code>ReferencePropertySource</code>. |
|
31 |
* <p> |
|
32 |
* TODO: reprogram to only use <code>ReferenceBase</code> classes which implement |
|
33 |
* <code>INomenclaturalReference</code>. |
|
34 |
* |
|
35 |
* @author p.ciardelli |
|
36 |
* @created 12.11.2008 |
|
37 |
* @version 1.0 |
|
38 |
*/ |
|
39 |
public class NomenclaturalReferencePropertySource extends |
|
40 |
ReferencePropertySource { |
|
41 |
private static final Logger logger = Logger |
|
42 |
.getLogger(NomenclaturalReferencePropertySource.class); |
|
43 |
|
|
44 |
public NomenclaturalReferencePropertySource(ReferenceBase reference) { |
|
45 |
super(reference); |
|
46 |
} |
|
47 |
|
|
48 |
protected void populateReferenceTypes() { |
|
49 |
|
|
50 |
// LinkedHashMap maintains insertion order |
|
51 |
referenceTypeMap = new LinkedHashMap<Class, String>(); |
|
52 |
|
|
53 |
referenceTypeMap.put(ReferenceBase.class, ""); |
|
54 |
referenceTypeMap.put(BibtexReference.class, "BibTeX Reference"); |
|
55 |
referenceTypeMap.put(Article.class, "Article"); |
|
56 |
referenceTypeMap.put(Generic.class, "Generic"); |
|
57 |
referenceTypeMap.put(Book.class, "Book"); |
|
58 |
referenceTypeMap.put(BookSection.class, "Book Section"); |
|
59 |
} |
|
60 |
|
|
61 |
protected void initDescriptors() { |
|
62 |
|
|
63 |
List<String> displayFields = new ArrayList<String>(); |
|
64 |
|
|
65 |
// Drop-down menu to change reference type |
|
66 |
displayFields.add(P_ID_REFERENCETYPE); |
|
67 |
|
|
68 |
// ReferenceBase fields |
|
69 |
displayFields.add(P_ID_AUTHORTEAM); |
|
70 |
displayFields.add(P_ID_YEAR); |
|
71 |
displayFields.add(P_ID_CITATION); |
|
72 |
displayFields.add(P_ID_URI); |
|
73 |
|
|
74 |
Class referenceClass = reference.getClass(); |
|
75 |
|
|
76 |
if (reference instanceof BibtexReference) { |
|
77 |
|
|
78 |
displayFields.add(P_ID_BIBTEX_ENTRYTYPE); |
|
79 |
displayFields.add(P_ID_JOURNAL); |
|
80 |
displayFields.add(P_ID_BOOKTITLE); |
|
81 |
displayFields.add(P_ID_CHAPTER); |
|
82 |
displayFields.add(P_ID_TITLE); |
|
83 |
displayFields.add(P_ID_SERIES); |
|
84 |
displayFields.add(P_ID_EDITION); |
|
85 |
displayFields.add(P_ID_VOLUME); |
|
86 |
displayFields.add(P_ID_NUMBER); |
|
87 |
displayFields.add(P_ID_PAGES); |
|
88 |
displayFields.add(P_ID_ANNOTE); |
|
89 |
displayFields.add(P_ID_EDITOR); |
|
90 |
displayFields.add(P_ID_INSTITUTION); |
|
91 |
displayFields.add(P_ID_SCHOOL); |
|
92 |
displayFields.add(P_ID_ORGANIZATION); |
|
93 |
displayFields.add(P_ID_PUBLISHER); |
|
94 |
displayFields.add(P_ID_ADDRESS); |
|
95 |
displayFields.add(P_ID_HOWPUBLISHED); |
|
96 |
displayFields.add(P_ID_REPORTTYPE); |
|
97 |
displayFields.add(P_ID_MONTH); |
|
98 |
displayFields.add(P_ID_EPRINT); |
|
99 |
displayFields.add(P_ID_NOTE); |
|
100 |
displayFields.add(P_ID_CROSSREF); |
|
101 |
} |
|
102 |
|
|
103 |
if (reference instanceof StrictReferenceBase) { |
|
104 |
|
|
105 |
displayFields.add(P_ID_DATEPUBLISHED); |
|
106 |
displayFields.add(P_ID_TITLE); |
|
107 |
|
|
108 |
if (referenceClass == Article.class) { |
|
109 |
displayFields.add(P_ID_INJOURNAL); |
|
110 |
displayFields.add(P_ID_PAGES); |
|
111 |
displayFields.add(P_ID_SERIES); |
|
112 |
displayFields.add(P_ID_VOLUME); |
|
113 |
} |
|
114 |
|
|
115 |
if (referenceClass == Generic.class) { |
|
116 |
displayFields.add(P_ID_PAGES); |
|
117 |
displayFields.add(P_ID_SERIES); |
|
118 |
displayFields.add(P_ID_VOLUME); |
|
119 |
displayFields.add(P_ID_EDITOR); |
|
120 |
displayFields.add(P_ID_PLACEPUBLISHED); |
|
121 |
displayFields.add(P_ID_PUBLISHER); |
|
122 |
} |
|
123 |
|
|
124 |
if (reference instanceof PublicationBase) { |
|
125 |
|
|
126 |
displayFields.add(P_ID_PLACEPUBLISHED); |
|
127 |
displayFields.add(P_ID_PUBLISHER); |
|
128 |
|
|
129 |
if (reference instanceof PrintedUnitBase) { |
|
130 |
|
|
131 |
displayFields.add(P_ID_EDITOR); |
|
132 |
displayFields.add(P_ID_INSERIES); |
|
133 |
displayFields.add(P_ID_PAGES); |
|
134 |
displayFields.add(P_ID_SERIESPART); |
|
135 |
displayFields.add(P_ID_VOLUME); |
|
136 |
|
|
137 |
if (referenceClass == Book.class) { |
|
138 |
displayFields.add(P_ID_ISBN); |
|
139 |
displayFields.add(P_ID_EDITION); |
|
140 |
} |
|
141 |
} |
|
142 |
} |
|
143 |
|
|
144 |
if (reference instanceof SectionBase) { |
|
145 |
|
|
146 |
displayFields.add(P_ID_PAGES); |
|
147 |
displayFields.add(P_ID_PRINTEDUNIT); |
|
148 |
|
|
149 |
if (referenceClass == BookSection.class) { |
|
150 |
displayFields.add(P_ID_INBOOK); |
|
151 |
} |
|
152 |
} |
|
153 |
} |
|
154 |
|
|
155 |
for (String field : displayFields) { |
|
156 |
addDescriptor(field); |
|
157 |
} |
|
158 |
} |
|
159 |
} |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/reference/ReferencePropertySource.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
|
|
10 |
package eu.etaxonomy.taxeditor.propertysheet.reference; |
|
11 |
|
|
12 |
import java.beans.PropertyChangeEvent; |
|
13 |
import java.beans.PropertyChangeListener; |
|
14 |
import java.beans.PropertyChangeSupport; |
|
15 |
import java.lang.reflect.Constructor; |
|
16 |
import java.lang.reflect.InvocationTargetException; |
|
17 |
import java.lang.reflect.Method; |
|
18 |
import java.util.ArrayList; |
|
19 |
import java.util.HashMap; |
|
20 |
import java.util.LinkedHashMap; |
|
21 |
import java.util.List; |
|
22 |
import java.util.Vector; |
|
23 |
|
|
24 |
import org.apache.log4j.Logger; |
|
25 |
import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; |
|
26 |
import org.eclipse.ui.views.properties.IPropertyDescriptor; |
|
27 |
import org.eclipse.ui.views.properties.IPropertySource; |
|
28 |
import org.eclipse.ui.views.properties.PropertyDescriptor; |
|
29 |
import org.eclipse.ui.views.properties.TextPropertyDescriptor; |
|
30 |
|
|
31 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
32 |
import eu.etaxonomy.cdm.model.agent.Team; |
|
33 |
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; |
|
34 |
import eu.etaxonomy.cdm.model.common.TimePeriod; |
|
35 |
import eu.etaxonomy.cdm.model.reference.Article; |
|
36 |
import eu.etaxonomy.cdm.model.reference.BibtexReference; |
|
37 |
import eu.etaxonomy.cdm.model.reference.Book; |
|
38 |
import eu.etaxonomy.cdm.model.reference.BookSection; |
|
39 |
import eu.etaxonomy.cdm.model.reference.CdDvd; |
|
40 |
import eu.etaxonomy.cdm.model.reference.Database; |
|
41 |
import eu.etaxonomy.cdm.model.reference.Generic; |
|
42 |
import eu.etaxonomy.cdm.model.reference.InProceedings; |
|
43 |
import eu.etaxonomy.cdm.model.reference.Journal; |
|
44 |
import eu.etaxonomy.cdm.model.reference.Map; |
|
45 |
import eu.etaxonomy.cdm.model.reference.Patent; |
|
46 |
import eu.etaxonomy.cdm.model.reference.PersonalCommunication; |
|
47 |
import eu.etaxonomy.cdm.model.reference.PrintSeries; |
|
48 |
import eu.etaxonomy.cdm.model.reference.PrintedUnitBase; |
|
49 |
import eu.etaxonomy.cdm.model.reference.Proceedings; |
|
50 |
import eu.etaxonomy.cdm.model.reference.PublicationBase; |
|
51 |
import eu.etaxonomy.cdm.model.reference.ReferenceBase; |
|
52 |
import eu.etaxonomy.cdm.model.reference.Report; |
|
53 |
import eu.etaxonomy.cdm.model.reference.SectionBase; |
|
54 |
import eu.etaxonomy.cdm.model.reference.StrictReferenceBase; |
|
55 |
import eu.etaxonomy.cdm.model.reference.Thesis; |
|
56 |
import eu.etaxonomy.cdm.model.reference.WebPage; |
|
57 |
import eu.etaxonomy.taxeditor.ITaxEditorConstants; |
|
58 |
import eu.etaxonomy.taxeditor.model.CdmUtil; |
|
59 |
import eu.etaxonomy.taxeditor.propertysheet.TimePeriodPropertySource; |
|
60 |
import eu.etaxonomy.taxeditor.propertysheet.YearValidator; |
|
61 |
|
|
62 |
/** |
|
63 |
* Supplies the properties of a <code>ReferenceBase</code> object for display by |
|
64 |
* a <code>PropertySheet</code>. |
|
65 |
* <p> |
|
66 |
* Includes a drop-down menu that allows the user to change <code>ReferenceBase</code> |
|
67 |
* subclasses. This causes all fields except <code>TitleCache</code> to be wiped clean. |
|
68 |
* <p> |
|
69 |
* Normally, this would be called from another <code>IPropertySource</code> |
|
70 |
* as follows: |
|
71 |
* <pre> |
|
72 |
* public Object getPropertyValue(Object id) { |
|
73 |
* |
|
74 |
* ... |
|
75 |
* |
|
76 |
* if (id.equals(P_ID_BIBREF)) { |
|
77 |
* ReferenceBase citation = descriptionElement.getCitation(); |
|
78 |
* ReferencePropertySource bibRefPropertySource = new ReferencePropertySource(citation); |
|
79 |
* bibRefPropertySource.addPropertyChangeListener(new PropertyChangeListener() { |
|
80 |
* @Override |
|
81 |
* public void propertyChange(PropertyChangeEvent evt) { |
|
82 |
* descriptionElement.setCitation((ReferenceBase) evt.getNewValue()); |
|
83 |
* } |
|
84 |
* }); |
|
85 |
* return bibRefPropertySource; |
|
86 |
* } |
|
87 |
* </pre> |
|
88 |
* <p> |
|
89 |
* Note: if <code>P_ID_BIBREF</code> in the above example is associated with an editable |
|
90 |
* <code>TextPropertyDescriptor</code>, it will initalize its cell editor by calling |
|
91 |
* <code>getEditableValue()</code>. If associated with a non-editable <code>PropertyDescriptor</code>, |
|
92 |
* it will get its value from <code>getString()</code>. |
|
93 |
* @author p.ciardelli |
|
94 |
* @created 03.11.2008 |
|
95 |
* @version 1.0 |
|
96 |
*/ |
|
97 |
public class ReferencePropertySource implements IPropertySource { |
|
98 |
private static final Logger logger = Logger |
|
99 |
.getLogger(ReferencePropertySource.class); |
|
100 |
|
|
101 |
ReferenceBase reference; |
|
102 |
|
|
103 |
// Property unique keys |
|
104 |
public static final String P_ID_REFERENCETYPE = "P_ID_REFERENCETYPE"; |
|
105 |
public static final String P_ID_AUTHORTEAM = "P_ID_AUTHORTEAM"; |
|
106 |
public static final String P_ID_YEAR = "P_ID_YEAR"; |
|
107 |
public static final String P_ID_CITATION = "P_ID_CITATION"; |
|
108 |
public static final String P_ID_URI = "P_ID_URI"; |
|
109 |
public static final String P_ID_DATEPUBLISHED = "P_ID_DATEPUBLISHED"; |
|
110 |
public static final String P_ID_TITLE = "P_ID_TITLE"; |
|
111 |
public static final String P_ID_INJOURNAL = "P_ID_INJOURNAL"; |
|
112 |
public static final String P_ID_PAGES = "P_ID_PAGES"; |
|
113 |
public static final String P_ID_SERIES = "P_ID_SERIES"; |
|
114 |
public static final String P_ID_VOLUME = "P_ID_VOLUME"; |
|
115 |
public static final String P_ID_EDITOR = "P_ID_EDITOR"; |
|
116 |
public static final String P_ID_PLACEPUBLISHED = "P_ID_PLACEPUBLISHED"; |
|
117 |
public static final String P_ID_PUBLISHER = "P_ID_PUBLISHER"; |
|
118 |
public static final String P_ID_ISSN = "P_ID_ISSN"; |
|
119 |
public static final String P_ID_INSTITUTION = "P_ID_INSTITUTION"; |
|
120 |
public static final String P_ID_SCHOOL = "P_ID_SCHOOL"; |
|
121 |
public static final String P_ID_INSERIES = "P_ID_INSERIES"; |
|
122 |
public static final String P_ID_SERIESPART = "P_ID_SERIESPART"; |
|
123 |
public static final String P_ID_ISBN = "P_ID_ISBN"; |
|
124 |
public static final String P_ID_ORGANIZATION = "P_ID_ORGANIZATION"; |
|
125 |
public static final String P_ID_PRINTEDUNIT = "P_ID_PRINTEDUNIT"; |
|
126 |
public static final String P_ID_INBOOK = "P_ID_INBOOK"; |
|
127 |
public static final String P_ID_INPROCEEDINGS = "P_ID_INPROCEEDINGS"; |
|
128 |
public static final String P_ID_BIBTEX_ENTRYTYPE = "P_ID_BIBTEX_ENTRYTYPE"; |
|
129 |
public static final String P_ID_JOURNAL = "P_ID_JOURNAL"; |
|
130 |
public static final String P_ID_BOOKTITLE = "P_ID_BOOKTITLE"; |
|
131 |
public static final String P_ID_CHAPTER = "P_ID_CHAPTER"; |
|
132 |
public static final String P_ID_EDITION = "P_ID_EDITION"; |
|
133 |
public static final String P_ID_NUMBER = "P_ID_NUMBER"; |
|
134 |
public static final String P_ID_ANNOTE = "P_ID_ANNOTE"; |
|
135 |
public static final String P_ID_ADDRESS = "P_ID_ADDRESS"; |
|
136 |
public static final String P_ID_HOWPUBLISHED = "P_ID_HOWPUBLISHED"; |
|
137 |
public static final String P_ID_REPORTTYPE = "P_ID_REPORTTYPE"; |
|
138 |
public static final String P_ID_MONTH = "P_ID_MONTH"; |
|
139 |
public static final String P_ID_EPRINT = "P_ID_EPRINT"; |
|
140 |
public static final String P_ID_NOTE = "P_ID_NOTE"; |
|
141 |
public static final String P_ID_CROSSREF = "P_ID_CROSSREF"; |
|
142 |
|
|
143 |
// Property display keys |
|
144 |
public static final String P_REFERENCETYPE = "00:Reference Type"; |
|
145 |
public static final String P_AUTHORTEAM = "01:Author Team (Cache)"; |
|
146 |
public static final String P_YEAR = "02:Year"; |
|
147 |
public static final String P_CITATION = "03:Citation"; |
|
148 |
public static final String P_URI = "04:URI"; |
|
149 |
public static final String P_DATEPUBLISHED = "05:Date Published"; |
|
150 |
public static final String P_TITLE = "06:Title"; |
|
151 |
public static final String P_INJOURNAL = "07:In Journal"; |
|
152 |
public static final String P_PAGES = "09:Pages"; |
|
153 |
public static final String P_SERIES = "10:Series"; |
|
154 |
public static final String P_VOLUME = "11:Volume"; |
|
155 |
public static final String P_EDITOR = "12:Editor"; |
|
156 |
public static final String P_PLACEPUBLISHED = "13:Place Published"; |
|
157 |
public static final String P_PUBLISHER = "14:Publisher"; |
|
158 |
public static final String P_ISSN = "15:ISSN"; |
|
159 |
public static final String P_INSTITUTION = "16:Institution"; |
|
160 |
public static final String P_SCHOOL = "17:School"; |
|
161 |
public static final String P_INSERIES = "18:In Series"; |
|
162 |
public static final String P_SERIESPART = "19:Series Part"; |
|
163 |
public static final String P_ISBN = "20:ISBN"; |
|
164 |
public static final String P_ORGANIZATION = "21:Organization"; |
|
165 |
public static final String P_PRINTEDUNIT = "22:Printed Unit"; |
|
166 |
public static final String P_INBOOK = "23:In Book"; |
|
167 |
public static final String P_INPROCEEDINGS = "24:In Proceedings"; |
|
168 |
public static final String P_BIBTEX_ENTRYTYPE = "25:BibTeX Entry Type"; |
|
169 |
public static final String P_JOURNAL = "26:Journal"; |
|
170 |
public static final String P_BOOKTITLE = "27:Book Title"; |
|
171 |
public static final String P_CHAPTER = "28:Chapter"; |
|
172 |
public static final String P_EDITION = "29:Edition"; |
|
173 |
public static final String P_NUMBER = "30:Number"; |
|
174 |
public static final String P_ANNOTE = "31:Annote"; |
|
175 |
public static final String P_ADDRESS = "32:Address"; |
|
176 |
public static final String P_HOWPUBLISHED = "33:How Published"; |
|
177 |
public static final String P_REPORTTYPE = "34:Report Type"; |
|
178 |
public static final String P_MONTH = "35:Month"; |
|
179 |
public static final String P_EPRINT = "36:E-Print"; |
|
180 |
public static final String P_NOTE = "37:Note"; |
|
181 |
public static final String P_CROSSREF = "38:BibTeX Crossref"; |
|
182 |
|
|
183 |
protected static HashMap<Class, String> referenceTypeMap = null; |
|
184 |
|
|
185 |
private static final String[] P_BIBTEX_ENTRYTYPE_MENU = new String[] {"ARTICLE", "BOOK", "BOOKLET", "INBOOK", "INCOLLECTION", "PROCEEDINGS", "INPROCEEDINGS", "CONFERENCE", "MANUAL", "MASTERTHESIS", "PHDTHESIS", "TECHREPORT", "UNPUBLISHED", "MISC"}; |
|
186 |
|
|
187 |
protected void populateReferenceTypes() { |
|
188 |
|
|
189 |
// LinkedHashMap maintains insertion order |
|
190 |
referenceTypeMap = new LinkedHashMap<Class, String>(); |
|
191 |
|
|
192 |
referenceTypeMap.put(ReferenceBase.class, ""); |
|
193 |
referenceTypeMap.put(BibtexReference.class, "BibTeX Reference"); |
|
194 |
referenceTypeMap.put(Article.class, "Article"); |
|
195 |
referenceTypeMap.put(Generic.class, "Generic"); |
|
196 |
referenceTypeMap.put(Patent.class, "Patent"); |
|
197 |
referenceTypeMap.put(PersonalCommunication.class, "Personal Communication"); |
|
198 |
referenceTypeMap.put(CdDvd.class, "CD / DVD"); |
|
199 |
referenceTypeMap.put(Database.class, "Database"); |
|
200 |
referenceTypeMap.put(Journal.class, "Journal"); |
|
201 |
referenceTypeMap.put(Map.class, "Map"); |
|
202 |
referenceTypeMap.put(Book.class, "Book"); |
|
203 |
referenceTypeMap.put(Proceedings.class, "Proceedings"); |
|
204 |
referenceTypeMap.put(PrintSeries.class, "Print Series"); |
|
205 |
referenceTypeMap.put(Report.class, "Report"); |
|
206 |
referenceTypeMap.put(Thesis.class, "Thesis"); |
|
207 |
referenceTypeMap.put(WebPage.class, "Web Page"); |
|
208 |
referenceTypeMap.put(BookSection.class, "Book Section"); |
|
209 |
referenceTypeMap.put(InProceedings.class, "In Proceedings"); |
|
210 |
} |
|
211 |
|
|
212 |
public ReferencePropertySource(ReferenceBase reference) { |
|
213 |
super(); |
|
214 |
|
|
215 |
// Default type of ReferenceBase is Generic |
|
216 |
if (reference == null) { |
|
217 |
reference = Generic.NewInstance(); |
|
218 |
} |
|
219 |
this.reference = reference; |
|
220 |
|
|
221 |
initDescriptors(); |
|
222 |
} |
|
223 |
|
|
224 |
protected void initDescriptors() { |
|
225 |
|
|
226 |
List<String> displayFields = new ArrayList<String>(); |
|
227 |
|
|
228 |
// Drop-down menu to change reference type |
|
229 |
displayFields.add(P_ID_REFERENCETYPE); |
|
230 |
|
|
231 |
// ReferenceBase fields |
|
232 |
displayFields.add(P_ID_AUTHORTEAM); |
|
233 |
displayFields.add(P_ID_YEAR); |
|
234 |
displayFields.add(P_ID_CITATION); |
|
235 |
displayFields.add(P_ID_URI); |
|
236 |
|
|
237 |
Class referenceClass = reference.getClass(); |
|
238 |
|
|
239 |
if (reference instanceof BibtexReference) { |
|
240 |
|
|
241 |
displayFields.add(P_ID_BIBTEX_ENTRYTYPE); |
|
242 |
displayFields.add(P_ID_JOURNAL); |
|
243 |
displayFields.add(P_ID_BOOKTITLE); |
|
244 |
displayFields.add(P_ID_CHAPTER); |
|
245 |
displayFields.add(P_ID_TITLE); |
|
246 |
displayFields.add(P_ID_SERIES); |
|
247 |
displayFields.add(P_ID_EDITION); |
|
248 |
displayFields.add(P_ID_VOLUME); |
|
249 |
displayFields.add(P_ID_NUMBER); |
|
250 |
displayFields.add(P_ID_PAGES); |
|
251 |
displayFields.add(P_ID_ANNOTE); |
|
252 |
displayFields.add(P_ID_EDITOR); |
|
253 |
displayFields.add(P_ID_INSTITUTION); |
|
254 |
displayFields.add(P_ID_SCHOOL); |
|
255 |
displayFields.add(P_ID_ORGANIZATION); |
|
256 |
displayFields.add(P_ID_PUBLISHER); |
|
257 |
displayFields.add(P_ID_ADDRESS); |
|
258 |
displayFields.add(P_ID_HOWPUBLISHED); |
|
259 |
displayFields.add(P_ID_REPORTTYPE); |
|
260 |
displayFields.add(P_ID_MONTH); |
|
261 |
displayFields.add(P_ID_EPRINT); |
|
262 |
displayFields.add(P_ID_NOTE); |
|
263 |
displayFields.add(P_ID_CROSSREF); |
|
264 |
} |
|
265 |
|
|
266 |
if (reference instanceof StrictReferenceBase) { |
|
267 |
|
|
268 |
displayFields.add(P_ID_DATEPUBLISHED); |
|
269 |
displayFields.add(P_ID_TITLE); |
|
270 |
|
|
271 |
if (referenceClass == Article.class) { |
|
272 |
displayFields.add(P_ID_INJOURNAL); |
|
273 |
displayFields.add(P_ID_PAGES); |
|
274 |
displayFields.add(P_ID_SERIES); |
|
275 |
displayFields.add(P_ID_VOLUME); |
|
276 |
} |
|
277 |
|
|
278 |
if (referenceClass == Generic.class) { |
|
279 |
displayFields.add(P_ID_PAGES); |
|
280 |
displayFields.add(P_ID_SERIES); |
|
281 |
displayFields.add(P_ID_VOLUME); |
|
282 |
displayFields.add(P_ID_EDITOR); |
|
283 |
displayFields.add(P_ID_PLACEPUBLISHED); |
|
284 |
displayFields.add(P_ID_PUBLISHER); |
|
285 |
} |
|
286 |
|
|
287 |
if (referenceClass == Patent.class) { |
|
288 |
// No additional fields |
|
289 |
} |
|
290 |
|
|
291 |
if (referenceClass == PersonalCommunication.class) { |
|
292 |
// No additional fields |
|
293 |
} |
|
294 |
if (reference instanceof PublicationBase) { |
|
295 |
|
|
296 |
displayFields.add(P_ID_PLACEPUBLISHED); |
|
297 |
displayFields.add(P_ID_PUBLISHER); |
|
298 |
|
|
299 |
if (referenceClass == CdDvd.class) { |
|
300 |
// No additional fields |
|
301 |
} |
|
302 |
|
|
303 |
if (referenceClass == Database.class) { |
|
304 |
// No additional fields |
|
305 |
} |
|
306 |
|
|
307 |
if (referenceClass == Journal.class) { |
|
308 |
displayFields.add(P_ID_ISSN); |
|
309 |
} |
|
310 |
|
|
311 |
if (referenceClass == Map.class) { |
|
312 |
// No additional fields |
|
313 |
} |
|
314 |
|
|
315 |
if (referenceClass == PrintSeries.class) { |
|
316 |
displayFields.add(P_ID_SERIES); |
|
317 |
} |
|
318 |
|
|
319 |
if (referenceClass == Report.class) { |
|
320 |
displayFields.add(P_ID_INSTITUTION); |
|
321 |
} |
|
322 |
|
|
323 |
if (referenceClass == Thesis.class) { |
|
324 |
displayFields.add(P_ID_SCHOOL); |
|
325 |
} |
|
326 |
|
|
327 |
if (referenceClass == WebPage.class) { |
|
328 |
// No additional fields |
|
329 |
} |
|
330 |
|
|
331 |
if (reference instanceof PrintedUnitBase) { |
|
332 |
|
|
333 |
displayFields.add(P_ID_EDITOR); |
|
334 |
displayFields.add(P_ID_INSERIES); |
|
335 |
displayFields.add(P_ID_PAGES); |
|
336 |
displayFields.add(P_ID_SERIESPART); |
|
337 |
displayFields.add(P_ID_VOLUME); |
|
338 |
|
|
339 |
if (referenceClass == Book.class) { |
|
340 |
displayFields.add(P_ID_ISBN); |
|
341 |
displayFields.add(P_ID_EDITION); |
|
342 |
} |
|
343 |
|
|
344 |
if (referenceClass == Proceedings.class) { |
|
345 |
displayFields.add(P_ID_ORGANIZATION); |
|
346 |
} |
|
347 |
} |
|
348 |
} |
|
349 |
|
|
350 |
if (reference instanceof SectionBase) { |
|
351 |
|
|
352 |
displayFields.add(P_ID_PAGES); |
|
353 |
displayFields.add(P_ID_PRINTEDUNIT); |
|
354 |
|
|
355 |
if (referenceClass == BookSection.class) { |
|
356 |
displayFields.add(P_ID_INBOOK); |
|
357 |
} |
|
358 |
|
|
359 |
if (referenceClass == InProceedings.class) { |
|
360 |
displayFields.add(P_ID_INPROCEEDINGS); |
|
361 |
} |
|
362 |
} |
|
363 |
} |
|
364 |
|
|
365 |
for (String field : displayFields) { |
|
366 |
addDescriptor(field); |
|
367 |
} |
|
368 |
} |
|
369 |
|
|
370 |
protected Vector<PropertyDescriptor> descriptors = new Vector<PropertyDescriptor>(); |
|
371 |
|
|
372 |
protected void addDescriptor(String id) { |
|
373 |
|
|
374 |
// Reference type |
|
375 |
if (id.equals(P_ID_REFERENCETYPE)) { |
|
376 |
if (referenceTypeMap == null) { |
|
377 |
populateReferenceTypes(); |
|
378 |
} |
|
379 |
String[] P_REFERENCETYPE_MENU = referenceTypeMap.values().toArray(new String[] {}); |
|
380 |
descriptors.addElement( |
|
381 |
new ComboBoxPropertyDescriptor(P_ID_REFERENCETYPE, P_REFERENCETYPE, P_REFERENCETYPE_MENU)); |
|
382 |
} |
|
383 |
|
|
384 |
// Author team |
|
385 |
if (id.equals(P_ID_AUTHORTEAM)) { |
|
386 |
descriptors.addElement( |
|
387 |
new TextPropertyDescriptor(P_ID_AUTHORTEAM, P_AUTHORTEAM)); |
|
388 |
} |
|
389 |
|
|
390 |
// Year |
|
391 |
if (id.equals(P_ID_YEAR)) { |
|
392 |
TextPropertyDescriptor yearDescriptor = new TextPropertyDescriptor(P_ID_YEAR, P_YEAR); |
|
393 |
|
|
394 |
// BibtexReference.setYear() takes a String, no need for validation |
|
395 |
if (!(reference instanceof BibtexReference)) { |
|
396 |
yearDescriptor.setValidator(new YearValidator()); |
|
397 |
} |
|
398 |
descriptors.addElement(yearDescriptor); |
|
399 |
} |
|
400 |
|
|
401 |
// Citation |
|
402 |
if (id.equals(P_ID_CITATION)) { |
|
403 |
descriptors.addElement( |
|
404 |
new PropertyDescriptor(P_ID_CITATION, P_CITATION)); |
|
405 |
} |
|
406 |
|
|
407 |
// URI |
|
408 |
if (id.equals(P_ID_URI)) { |
|
409 |
descriptors.addElement( |
|
410 |
new TextPropertyDescriptor(P_ID_URI, P_URI)); |
|
411 |
} |
|
412 |
|
|
413 |
// Date published |
|
414 |
if (id.equals(P_ID_DATEPUBLISHED)) { |
|
415 |
descriptors.addElement( |
|
416 |
new PropertyDescriptor(P_ID_DATEPUBLISHED, P_DATEPUBLISHED)); |
|
417 |
} |
|
418 |
|
|
419 |
// Title |
|
420 |
if (id.equals(P_ID_TITLE)) { |
|
421 |
descriptors.addElement( |
|
422 |
new TextPropertyDescriptor(P_ID_TITLE, P_TITLE)); |
|
423 |
} |
|
424 |
|
|
425 |
// In journal |
|
426 |
if (id.equals(P_ID_INJOURNAL)) { |
|
427 |
descriptors.addElement( |
|
428 |
new TextPropertyDescriptor(P_ID_INJOURNAL, P_INJOURNAL)); |
|
429 |
} |
|
430 |
|
Also available in: Unified diff
1) Added import / export dummy functionality (i.e. CDM library not yet functional) to "File ..." menu. 2) Changes due to new TimePeriod in CDM library