eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/name/NameRelationsPropertySource.java -text
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/name/NomStatusPropertySource.java -text
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/name/NonViralNamePropertySource.java -text
+eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/name/ScientificNamePropertySource.java -text
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/name/TaxonBasePropertySource.java -text
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/name/ZoologicalNamePropertySource.java -text
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/propertysheet/namerelationswizard/ChooseRelatedNameWizardPage.java -text
preferencesAction = ActionFactory.PREFERENCES.create(window);
-// makeImportActions();
+ makeImportActions();
-// exportJaxbAction = new ExportAction(ExportAction.JAXB);
-// register(exportJaxbAction);
+ exportJaxbAction = new ExportAction(ExportAction.JAXB);
+ register(exportJaxbAction);
}
private void makeImportActions() {
MenuManager fileMenu = new MenuManager("&File",
null);
-// // Create submenu for imports
-// MenuManager importMenu = new MenuManager("Import ...", null);
-//
-// // Create submenu for exports
-// MenuManager exportMenu = new MenuManager("Export as ...", null);
+ // Create submenu for imports
+ MenuManager importMenu = new MenuManager("Import ...", null);
+
+ // Create submenu for exports
+ MenuManager exportMenu = new MenuManager("Export as ...", null);
// Populate file menu
menuBar.add(fileMenu);
fileMenu.add(newNameAction);
fileMenu.add(saveAction);
fileMenu.add(undoAction);
-// fileMenu.add(new Separator());
+ fileMenu.add(new Separator());
// fileMenu.add(importMenu);
// fileMenu.add(exportMenu);
- fileMenu.add(new Separator());
+// fileMenu.add(new Separator());
fileMenu.add(exitAction);
-// // Populate submenu for imports
-// for (IAction importAction : importActionList) {
-// importMenu.add(importAction);
-// }
-//
-// // Populate submenu for exports
-// exportMenu.add(exportJaxbAction);
+ // Populate submenu for imports
+ for (IAction importAction : importActionList) {
+ importMenu.add(importAction);
+ }
+
+ // Populate submenu for exports
+ exportMenu.add(exportJaxbAction);
// Populate preferences
MenuManager preferencesMenu = new MenuManager("&Preferences",
menuBar.add(preferencesMenu);
preferencesMenu.add(preferencesAction);
}
-
-}
+}
\ No newline at end of file
IFolderLayout folderLayoutRight = layout.createFolder("rightfolder", IPageLayout.RIGHT, 0.5f, editorArea);
folderLayoutRight.addView(IPageLayout.ID_PROP_SHEET);
+// folderLayoutRight.addView(IPageLayout.ID_PROBLEM_VIEW);
layout.getViewLayout(IPageLayout.ID_PROP_SHEET).setCloseable(false);
layout.getViewLayout(IPageLayout.ID_PROP_SHEET);
list.add(NomenclaturalStatusType.VALID());\r
for (NomenclaturalStatusType status : list){\r
cdmApp.getTermService().saveTerm(status);\r
- logger.warn(status.getRepresentations().size());\r
+// logger.warn(status.getRepresentations().size());\r
}\r
}\r
}\r
return type1.getLabel();\r
}\r
}\r
- return "joemama";\r
+ return "";\r
}\r
+\r
+ static boolean isSaving = false;\r
+\r
+ public static void setIsSaving(boolean isSavin) {\r
+ isSaving = isSavin;\r
+ }\r
+ \r
+ public static boolean getIsSaving() {\r
+ return isSaving;\r
+ } \r
}
\ No newline at end of file
* @see IWorkbenchWindowActionDelegate#run
*/
public void run(IAction action) {
-
- TaxEditorPlugin.getDefault();
+
+ UiUtil.setIsSaving(true);
// Get all open windows
for (IEditorPart taxonEditor : UiUtil.getOpenTaxonEditors()) {
if (taxonEditor.isDirty()) {
IEditorInput input = taxonEditor.getEditorInput();
if (input.getAdapter(Taxon.class) != null) {
- Taxon taxon = (Taxon) input.getAdapter(Taxon.class); // Already trunc'ed
+ Taxon taxon = (Taxon) input.getAdapter(Taxon.class);
new SaveTaxonAction(taxon).run();
if (taxonEditor instanceof MultiPageTaxonEditor) {
((MultiPageTaxonEditor) taxonEditor).setDirtyExtern(false);
for (Object taxon : TaxEditorPlugin.getDefault().getObservableSessionTaxa()) {
CdmUtil.getTaxonService().saveTaxon((Taxon) taxon);
}
+
+ UiUtil.setIsSaving(false);
}
/**
import org.eclipse.jface.resource.ImageDescriptor;\r
import org.eclipse.swt.widgets.FileDialog;\r
\r
+import eu.etaxonomy.cdm.api.application.CdmApplicationController;\r
import eu.etaxonomy.cdm.database.ICdmDataSource;\r
import eu.etaxonomy.cdm.io.common.ImportWrapper;\r
import eu.etaxonomy.taxeditor.TaxEditorPlugin;\r
String filePath = dialog.open();\r
file = new File(filePath);\r
\r
+ // Get plugin application controller\r
+ CdmApplicationController cdmapp = TaxEditorPlugin.getDefault().getCdmApp();\r
+ \r
// Get current data source\r
ICdmDataSource destination = TaxEditorPlugin.getDefault().getCdmDataSource();\r
\r
// Format file path \r
String source = null;\r
try {\r
- source = file.toURI().toURL().toString();\r
- } catch (MalformedURLException e) {\r
+ //source = file.toURI().toURL().toString();\r
+ source = file.toString();\r
+ } catch (/*MalformedURL*/Exception e) {\r
MessageDialog.openError(UiUtil.getShell(), title, "File could not be read.");\r
return;\r
}\r
// Tell user whether import was a success or a dismal failure\r
if (isSuccessfulImport) {\r
MessageDialog.openInformation(UiUtil.getShell(), title, "Import successful");\r
+ UiUtil.getTreeViewer().refresh();\r
} else {\r
MessageDialog.openError(UiUtil.getShell(), title, "Import was unsuccessful.");\r
}\r
return;\r
}\r
\r
+ if (UiUtil.getIsSaving()) {\r
+ return;\r
+ }\r
+ \r
deactivateParser();\r
((NameViewer) getTextViewer()).setText(name.getFullTitleCache());\r
activateParser();\r
name.addPropertyChangeListener("fullTitleCache", listener);\r
name.addPropertyChangeListener("nomenclaturalMicroReference", listener);\r
\r
- name.addPropertyChangeListener(ITaxEditorConstants.REFRESH_NAMEVIEWER, listener);\r
+// name.addPropertyChangeListener(ITaxEditorConstants.REFRESH_NAMEVIEWER, listener);\r
\r
StrictReferenceBase reference = (StrictReferenceBase) name.getNomenclaturalReference();\r
if (reference != null) {\r
\r
import org.apache.log4j.Logger;\r
import org.eclipse.core.commands.operations.IUndoContext;\r
+import org.eclipse.core.resources.IMarker;\r
+import org.eclipse.core.resources.IWorkspaceRunnable;\r
+import org.eclipse.core.resources.ResourcesPlugin;\r
import org.eclipse.core.runtime.Assert;\r
+import org.eclipse.core.runtime.CoreException;\r
+import org.eclipse.core.runtime.IProgressMonitor;\r
import org.eclipse.jface.text.Document;\r
import org.eclipse.jface.text.ILineTracker;\r
import org.eclipse.jface.text.IUndoManager;\r
import org.eclipse.jface.text.Position;\r
import org.eclipse.jface.text.TextViewerUndoManager;\r
import org.eclipse.jface.text.source.Annotation;\r
-import org.eclipse.jface.text.source.AnnotationBarHoverManager;\r
import org.eclipse.jface.text.source.AnnotationModel;\r
import org.eclipse.jface.text.source.AnnotationPainter;\r
-import org.eclipse.jface.text.source.AnnotationRulerColumn;\r
-import org.eclipse.jface.text.source.CompositeRuler;\r
-import org.eclipse.jface.text.source.DefaultAnnotationHover;\r
import org.eclipse.jface.text.source.IAnnotationAccess;\r
import org.eclipse.jface.text.source.SourceViewer;\r
import org.eclipse.swt.SWT;\r
this.getAnnotationModel().addAnnotation(\r
new ErrorAnnotation(0, text), \r
new Position(0, text.length())); \r
- \r
}\r
}\r
\r
\r
this.getAnnotationModel().addAnnotation(\r
new ErrorAnnotation(0, text), \r
- new Position(start, length)); \r
+ new Position(start, length));\r
+ \r
+ // Successful test of markers which show up in ProblemView \r
+// try {\r
+// IWorkspaceRunnable editorMarker = new IWorkspaceRunnable() {\r
+// public void run(IProgressMonitor monitor) throws CoreException { \r
+// IMarker marker = ResourcesPlugin.getWorkspace().getRoot().createMarker(IMarker.PROBLEM);\r
+// marker.setAttribute(IMarker.MESSAGE, "Testeroo");\r
+// marker.setAttribute(IMarker.PRIORITY, IMarker.PRIORITY_HIGH);\r
+// marker.setAttribute(IMarker.LINE_NUMBER, 1);\r
+// marker.setAttribute(IMarker.TRANSIENT, false);\r
+// marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR); \r
+// }\r
+// };\r
+// ResourcesPlugin.getWorkspace().run(editorMarker, null); \r
+// \r
+// } catch (CoreException e) {\r
+// // TODO Auto-generated catch block\r
+// e.printStackTrace();\r
+// }\r
+ \r
}\r
}\r
\r
import org.eclipse.ui.views.properties.TextPropertyDescriptor;\r
\r
import eu.etaxonomy.cdm.common.CdmUtils;\r
-import eu.etaxonomy.cdm.model.common.Annotation;\r
import eu.etaxonomy.cdm.model.common.TermVocabulary;\r
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;\r
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;\r
public static final String P_ID_PARSED = "parsed";\r
public static final String P_ID_RANK = "rank";\r
public static final String P_ID_TITLECACHE = "titlecache";\r
- public static final String P_ID_UNINOMIAL = "uninomial";\r
- public static final String P_ID_INFRAGENERICEP = "infragenericep";\r
- public static final String P_ID_SPECIESEP = "speciesep";\r
- public static final String P_ID_INFRASPECIFICEP = "infraspecificep";\r
- public static final String P_ID_APPENDEDPHRASE = "appendedphrase";\r
public static final String P_ID_HOMOTYPICALGROUP = "homogroup";\r
- public static final String P_ID_AUTHORSHIPCACHE = "authorshipcache";\r
public static final String P_ID_NAMERELATIONS = "namerelations";\r
public static final String P_ID_TYPE = "type";\r
public static final String P_ID_ANNOTATIONS = "annotations";\r
public static final String P_PARSED = "00:Parsing Status";\r
public static final String P_RANK = "02:Rank";\r
public static final String P_TITLECACHE = "03:Name Cache";\r
- public static final String P_UNINOMIAL = "04:Uninomial";\r
- public static final String P_INFRAGENERICEP = "05:Infrageneric Epithet";\r
- public static final String P_SPECIESEP = "06:Specific Epithet";\r
- public static final String P_INFRASPECIFICEP = "07:Infraspecific Epithet";\r
- public static final String P_APPENDEDPHRASE = "09:Appended Phrase";\r
public static final String P_HOMOTYPICALGROUP = "09:Homotypical Group";\r
- public static final String P_AUTHORSHIPCACHE = "08:Authorship";\r
public static final String P_NAMERELATIONS = "11:Name Relations";\r
public static final String P_TYPE = "12:Type";\r
public static final String P_ANNOTATIONS = "14:Annotations";\r
descriptors.addElement(\r
new PropertyDescriptor(P_ID_TITLECACHE, P_TITLECACHE));\r
}\r
- \r
- // Uninomial (aka Genus)\r
- if (id.equals(P_ID_UNINOMIAL)) {\r
- descriptors.addElement(\r
- new TextPropertyDescriptor(P_ID_UNINOMIAL, P_UNINOMIAL));\r
- }\r
- \r
- // Infrageneric epithet\r
- if (id.equals(P_ID_INFRAGENERICEP)) {\r
- descriptors.addElement(\r
- new TextPropertyDescriptor(P_ID_INFRAGENERICEP, P_INFRAGENERICEP));\r
- }\r
- \r
- // Specific epithet\r
- if (id.equals(P_ID_SPECIESEP)) {\r
- descriptors.addElement(\r
- new TextPropertyDescriptor(P_ID_SPECIESEP, P_SPECIESEP));\r
- }\r
- \r
- // Infraspecific epithet\r
- if (id.equals(P_ID_INFRASPECIFICEP)) {\r
- descriptors.addElement(\r
- new TextPropertyDescriptor(P_ID_INFRASPECIFICEP, P_INFRASPECIFICEP));\r
- }\r
- \r
- // Appended phrase\r
- if (id.equals(P_ID_APPENDEDPHRASE)) {\r
- descriptors.addElement(\r
- new TextPropertyDescriptor(P_ID_APPENDEDPHRASE, P_APPENDEDPHRASE));\r
- }\r
- \r
- // Authorship cache\r
- if (id.equals(P_ID_AUTHORSHIPCACHE)) {\r
- descriptors.addElement(\r
- new TextPropertyDescriptor(P_ID_AUTHORSHIPCACHE, P_AUTHORSHIPCACHE));\r
- }\r
- \r
+ \r
// Homotypical group\r
if (id.equals(P_ID_HOMOTYPICALGROUP)) {\r
descriptors.addElement(\r
if (id.equals(P_ID_TITLECACHE)) {\r
\r
// If the name has not been parsed, only show the title cache\r
-// if (name.getHasProblem()) {\r
if (name.getRank() == null) {\r
return CdmUtils.Nz(name.getTitleCache());\r
} else {\r
- return new NonViralNamePropertySource(name, P_ID_TITLECACHE, getNameFields());\r
+ \r
+ // Create property source for submenu\r
+ ScientificNamePropertySource nameFieldsPropertySource = new ScientificNamePropertySource(name);\r
+ \r
+ // Add listener to notify name of all changes to nom. reference\r
+ nameFieldsPropertySource.addPropertyChangeListener(new PropertyChangeListener() {\r
+ public void propertyChange(PropertyChangeEvent evt) {\r
+// if (evt.getNewValue() instanceof INomenclaturalReference) {\r
+// name.setNomenclaturalReference((INomenclaturalReference) evt.getNewValue());\r
+// }\r
+ }\r
+ });\r
+ return nameFieldsPropertySource;\r
}\r
}\r
- \r
- // Uninomial (aka Genus) \r
- if (id.equals(P_ID_UNINOMIAL)) {\r
- return CdmUtils.Nz(name.getGenusOrUninomial());\r
- }\r
- \r
- // Infrageneric epithet \r
- if (id.equals(P_ID_INFRAGENERICEP)) {\r
- return CdmUtils.Nz(name.getInfraGenericEpithet());\r
- }\r
- \r
- // Specific epithet \r
- if (id.equals(P_ID_SPECIESEP)) {\r
- return CdmUtils.Nz(name.getSpecificEpithet());\r
- }\r
- \r
- // Infraspecific epithet \r
- if (id.equals(P_ID_INFRASPECIFICEP)) {\r
- return CdmUtils.Nz(name.getInfraSpecificEpithet());\r
- }\r
- \r
- // Appended phrase \r
- if (id.equals(P_ID_APPENDEDPHRASE)) {\r
- return CdmUtils.Nz(name.getAppendedPhrase());\r
- }\r
- \r
- // Authorship cache \r
- if (id.equals(P_ID_AUTHORSHIPCACHE)) {\r
- return CdmUtils.Nz(name.getAuthorshipCache());\r
- }\r
- \r
+ \r
// Homotypical group \r
if (id.equals(P_ID_HOMOTYPICALGROUP)) {\r
return CdmUtils.Nz(name.getHomotypicalGroup().getUuid().toString());\r
return null;\r
}\r
\r
- /**\r
- * The fields displayed under the title cache are dependent on rank.\r
- * \r
- * @return\r
- */\r
- private String[] getNameFields() {\r
- \r
- // An unparsed name has no name fields, only a cache. \r
- // Therefore, if rank is null, the name is unparsed.\r
- if (name.getRank() == null) {\r
- return null;\r
- }\r
- \r
- List<String> nameFields = new ArrayList<String>();\r
- nameFields.add(P_ID_UNINOMIAL);\r
- if (name.isSupraGeneric() || name.isGenus()) { // Rank is higher than GENUS or equals GENUS\r
- }\r
- else if (name.isInfraGeneric()) { // lower than GENUS and higher than SPECIES\r
- nameFields.add(P_ID_INFRAGENERICEP);\r
- } \r
- else if (name.isSpecies()) { // Rank equals SPECIES\r
- nameFields.add(P_ID_SPECIESEP);\r
- }\r
- else if (name.isInfraSpecific()) { // Rank is lower than SPECIES\r
- nameFields.add(P_ID_SPECIESEP);\r
- nameFields.add(P_ID_INFRASPECIFICEP);\r
- } else {\r
- nameFields.add(P_ID_SPECIESEP);\r
- }\r
- nameFields.add(P_ID_AUTHORSHIPCACHE);\r
- nameFields.add(P_ID_APPENDEDPHRASE);\r
- return nameFields.toArray(new String[nameFields.size()]);\r
- }\r
\r
private Object formatDate(Date date) {\r
return String.format("%1$tm-%1$td-%1$tY %1$tH:%1$tM:%1$tS", date);\r
int index = ((Integer) value).intValue();\r
name.setRank(ranks[index]);\r
}\r
- \r
- // Uninomial (aka Genus) \r
- if (id.equals(P_ID_UNINOMIAL)) {\r
- name.setGenusOrUninomial((String) value);\r
- }\r
- \r
- // Infrageneric epithet \r
- if (id.equals(P_ID_INFRAGENERICEP)) {\r
- name.setInfraGenericEpithet((String) value);\r
- }\r
- \r
- // Specific epithet \r
- if (id.equals(P_ID_SPECIESEP)) {\r
- name.setSpecificEpithet((String) value);\r
- }\r
- \r
- // Infraspecific epithet \r
- if (id.equals(P_ID_INFRASPECIFICEP)) {\r
- name.setInfraSpecificEpithet((String) value);\r
- }\r
- \r
- // Appended phrase \r
- if (id.equals(P_ID_APPENDEDPHRASE)) {\r
- name.setAppendedPhrase((String) value);\r
- }\r
- \r
- // Authorship cache \r
- if (id.equals(P_ID_AUTHORSHIPCACHE)) {\r
-// name.setProtectedAuthorshipCache(true);\r
- name.setAuthorshipCache((String) value);\r
- }\r
- \r
+ \r
// Nomenclatural status \r
if (id.equals(P_ID_NOMSTATUS)) {\r
NomenclaturalStatus nomStatus;\r
name.setFullTitleCache(name.generateFullTitle(), false);\r
}\r
\r
- name.firePropertyChange(ITaxEditorConstants.REFRESH_NAMEVIEWER, null, null);\r
+// name.firePropertyChange(ITaxEditorConstants.REFRESH_NAMEVIEWER, null, null);\r
\r
}\r
\r
--- /dev/null
+/**\r
+* Copyright (C) 2007 EDIT\r
+* European Distributed Institute of Taxonomy \r
+* http://www.e-taxonomy.eu\r
+* \r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/\r
+\r
+package eu.etaxonomy.taxeditor.propertysheet.name;\r
+\r
+import java.beans.PropertyChangeListener;\r
+import java.beans.PropertyChangeSupport;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import java.util.Vector;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor;\r
+import org.eclipse.ui.views.properties.IPropertyDescriptor;\r
+import org.eclipse.ui.views.properties.IPropertySource;\r
+import org.eclipse.ui.views.properties.PropertyDescriptor;\r
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;\r
+\r
+import eu.etaxonomy.cdm.common.CdmUtils;\r
+import eu.etaxonomy.cdm.model.name.NonViralName;\r
+import eu.etaxonomy.taxeditor.ITaxEditorConstants;\r
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;\r
+\r
+/**\r
+ * @author p.ciardelli\r
+ * @created 03.11.2008\r
+ * @version 1.0\r
+ */\r
+public class ScientificNamePropertySource implements IPropertySource {\r
+ private static final Logger logger = Logger\r
+ .getLogger(ScientificNamePropertySource.class);\r
+\r
+ NonViralName name;\r
+ \r
+ // Property unique keys\r
+ public static final String P_ID_SEARCH = "P_ID_SEARCH";\r
+ public static final String P_ID_EDITABLECACHE = "P_ID_EDITABLECACHE"; \r
+ public static final String P_ID_UNINOMIAL = "P_ID_UNINOMIAL";\r
+ public static final String P_ID_INFRAGENERICEP = "P_ID_INFRAGENERICEP";\r
+ public static final String P_ID_INFRASPECIFICEP = "P_ID_INFRASPECIFICEP";\r
+ public static final String P_ID_SPECIESEP = "P_ID_SPECIESEP";\r
+ public static final String P_ID_PROTECT_CACHE = "P_ID_PROTECT_CACHE";\r
+ public static final String P_ID_APPENDEDPHRASE = "P_ID_APPENDEDPHRASE";\r
+ public static final String P_ID_AUTHORSHIPCACHE = "P_ID_AUTHORSHIPCACHE";\r
+ \r
+ // Property display keys\r
+ public static final String P_SEARCH = "001:Search";\r
+ public static final String P_EDITABLECACHE = "002:Editable Cache";\r
+ public static final String P_PROTECT_CACHE = "0020:Protect Cache from overwriting?";\r
+ public static final String P_UNINOMIAL = "04:Uninomial";\r
+ public static final String P_INFRAGENERICEP = "05:Infrageneric Epithet";\r
+ public static final String P_INFRASPECIFICEP = "07:Infraspecific Epithet";\r
+ public static final String P_SPECIESEP = "06:Specific Epithet";\r
+ public static final String P_AUTHORSHIPCACHE = "08:Authorship";\r
+ public static final String P_APPENDEDPHRASE = "09:Appended Phrase";\r
+ \r
+ private static final int CACHE_NOT_PROTECTED = 0;\r
+ private static final int CACHE_PROTECTED = 1; \r
+ \r
+ public ScientificNamePropertySource(NonViralName name) {\r
+ \r
+ // Default type of ReferenceBase is Generic\r
+ if (name == null) {\r
+ name = PreferencesUtil.getInstanceOfPreferredNameClass();\r
+ } \r
+ this.name = name;\r
+\r
+ initDescriptors();\r
+ }\r
+\r
+ protected void initDescriptors() {\r
+ \r
+ List<String> displayFields = new ArrayList<String>();\r
+ \r
+ // Cache fields\r
+// displayFields.add(P_ID_SEARCH);\r
+// displayFields.add(P_ID_EDITABLECACHE);\r
+// displayFields.add(P_ID_PROTECT_CACHE);\r
+ \r
+ // Uninomial\r
+ displayFields.add(P_ID_UNINOMIAL);\r
+ \r
+ if (name.isSupraGeneric() || name.isGenus()) { // Rank is higher than GENUS or equals GENUS\r
+ }\r
+ else if (name.isInfraGeneric()) { // lower than GENUS and higher than SPECIES\r
+ displayFields.add(P_ID_INFRAGENERICEP);\r
+ } \r
+ else if (name.isSpecies()) { // Rank equals SPECIES\r
+ displayFields.add(P_ID_SPECIESEP);\r
+ }\r
+ else if (name.isInfraSpecific()) { // Rank is lower than SPECIES\r
+ displayFields.add(P_ID_SPECIESEP);\r
+ displayFields.add(P_ID_INFRASPECIFICEP);\r
+ } else {\r
+ displayFields.add(P_ID_SPECIESEP);\r
+ }\r
+ displayFields.add(P_ID_AUTHORSHIPCACHE);\r
+ displayFields.add(P_ID_APPENDEDPHRASE);\r
+ \r
+ \r
+ for (String field : displayFields) {\r
+ addDescriptor(field);\r
+ }\r
+ }\r
+\r
+ protected Vector<PropertyDescriptor> descriptors = new Vector<PropertyDescriptor>();\r
+ \r
+ protected void addDescriptor(String id) {\r
+ \r
+ // Reference search\r
+ if (id.equals(P_ID_SEARCH)) {\r
+// descriptors.addElement(\r
+// new ReferenceSearchDescriptor(P_ID_SEARCH, P_SEARCH, getSearchType()) {\r
+// protected void saveReference(ReferenceBase reference) {\r
+// setPropertyValue(P_ID_SEARCH, reference);\r
+// }\r
+// });\r
+ }\r
+ \r
+ // Editable cache\r
+ if (id.equals(P_ID_EDITABLECACHE)) {\r
+ descriptors.addElement(\r
+ new TextPropertyDescriptor(P_ID_EDITABLECACHE, P_EDITABLECACHE));\r
+ }\r
+ \r
+ // Protect cache?\r
+ if (id.equals(P_ID_PROTECT_CACHE)) {\r
+ descriptors.addElement(\r
+ new ComboBoxPropertyDescriptor(P_ID_PROTECT_CACHE, P_PROTECT_CACHE, \r
+ new String[] {"no", "yes"}));\r
+ }\r
+ \r
+ // Uninomial (aka Genus)\r
+ if (id.equals(P_ID_UNINOMIAL)) {\r
+ descriptors.addElement(\r
+ new TextPropertyDescriptor(P_ID_UNINOMIAL, P_UNINOMIAL));\r
+ }\r
+ \r
+ // Infrageneric epithet\r
+ if (id.equals(P_ID_INFRAGENERICEP)) {\r
+ descriptors.addElement(\r
+ new TextPropertyDescriptor(P_ID_INFRAGENERICEP, P_INFRAGENERICEP));\r
+ }\r
+ \r
+ // Specific epithet\r
+ if (id.equals(P_ID_SPECIESEP)) {\r
+ descriptors.addElement(\r
+ new TextPropertyDescriptor(P_ID_SPECIESEP, P_SPECIESEP));\r
+ }\r
+ \r
+ // Infraspecific epithet\r
+ if (id.equals(P_ID_INFRASPECIFICEP)) {\r
+ descriptors.addElement(\r
+ new TextPropertyDescriptor(P_ID_INFRASPECIFICEP, P_INFRASPECIFICEP));\r
+ }\r
+ \r
+ // Appended phrase\r
+ if (id.equals(P_ID_APPENDEDPHRASE)) {\r
+ descriptors.addElement(\r
+ new TextPropertyDescriptor(P_ID_APPENDEDPHRASE, P_APPENDEDPHRASE));\r
+ }\r
+ \r
+ // Authorship cache\r
+ if (id.equals(P_ID_AUTHORSHIPCACHE)) {\r
+ descriptors.addElement(\r
+ new TextPropertyDescriptor(P_ID_AUTHORSHIPCACHE, P_AUTHORSHIPCACHE));\r
+ } \r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()\r
+ */\r
+ public Object getEditableValue() {\r
+ return CdmUtils.Nz(name.getTitleCache());\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()\r
+ */\r
+ public IPropertyDescriptor[] getPropertyDescriptors() {\r
+ return (IPropertyDescriptor[]) descriptors.toArray(\r
+ new IPropertyDescriptor[descriptors.size()]);\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)\r
+ */\r
+ public Object getPropertyValue(Object id) {\r
+ \r
+ // Editable cache\r
+ if (id.equals(P_ID_EDITABLECACHE)) {\r
+ return (CdmUtils.Nz(name.getTitleCache()));\r
+ }\r
+ \r
+ // Protect cache?\r
+ if (id.equals(P_ID_PROTECT_CACHE)) {\r
+ if (name.isProtectedTitleCache()) {\r
+ return CACHE_PROTECTED;\r
+ } else {\r
+ return CACHE_NOT_PROTECTED;\r
+ }\r
+ }\r
+ \r
+ // Uninomial (aka Genus) \r
+ if (id.equals(P_ID_UNINOMIAL)) {\r
+ return CdmUtils.Nz(name.getGenusOrUninomial());\r
+ }\r
+ \r
+ // Infrageneric epithet \r
+ if (id.equals(P_ID_INFRAGENERICEP)) {\r
+ return CdmUtils.Nz(name.getInfraGenericEpithet());\r
+ }\r
+ \r
+ // Specific epithet \r
+ if (id.equals(P_ID_SPECIESEP)) {\r
+ return CdmUtils.Nz(name.getSpecificEpithet());\r
+ }\r
+ \r
+ // Infraspecific epithet \r
+ if (id.equals(P_ID_INFRASPECIFICEP)) {\r
+ return CdmUtils.Nz(name.getInfraSpecificEpithet());\r
+ }\r
+ \r
+\r
+ // Appended phrase \r
+ if (id.equals(P_ID_APPENDEDPHRASE)) {\r
+ return CdmUtils.Nz(name.getAppendedPhrase());\r
+ }\r
+ \r
+ // Authorship cache \r
+ if (id.equals(P_ID_AUTHORSHIPCACHE)) {\r
+ return CdmUtils.Nz(name.getAuthorshipCache());\r
+ }\r
+ \r
+ return "";\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)\r
+ */\r
+ public boolean isPropertySet(Object id) {\r
+ return false;\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)\r
+ */\r
+ public void resetPropertyValue(Object id) {}\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)\r
+ */\r
+ public void setPropertyValue(Object id, Object value) {\r
+ \r
+ // Search result\r
+ if (id.equals(P_ID_SEARCH)) {\r
+ if (value instanceof NonViralName) {\r
+ name = (NonViralName) value;\r
+ }\r
+ }\r
+\r
+ // Protect cache? \r
+ if (id.equals(P_ID_PROTECT_CACHE)) {\r
+ if (((Integer) value).intValue() == CACHE_PROTECTED) {\r
+ name.setProtectedTitleCache(true);\r
+ } else {\r
+ name.setProtectedTitleCache(false);\r
+ }\r
+ }\r
+ \r
+ // Uninomial (aka Genus) \r
+ if (id.equals(P_ID_UNINOMIAL)) {\r
+ name.setGenusOrUninomial((String) value);\r
+ }\r
+ \r
+ // Infrageneric epithet \r
+ if (id.equals(P_ID_INFRAGENERICEP)) {\r
+ name.setInfraGenericEpithet((String) value);\r
+ }\r
+ \r
+ // Specific epithet \r
+ if (id.equals(P_ID_SPECIESEP)) {\r
+ name.setSpecificEpithet((String) value);\r
+ }\r
+ \r
+ // Infraspecific epithet \r
+ if (id.equals(P_ID_INFRASPECIFICEP)) {\r
+ name.setInfraSpecificEpithet((String) value);\r
+ }\r
+ \r
+ // Appended phrase \r
+ if (id.equals(P_ID_APPENDEDPHRASE)) {\r
+ name.setAppendedPhrase((String) value);\r
+ }\r
+ \r
+ // Authorship cache \r
+ if (id.equals(P_ID_AUTHORSHIPCACHE)) {\r
+// name.setProtectedAuthorshipCache(true);\r
+ name.setAuthorshipCache((String) value);\r
+ }\r
+ \r
+ // Editable cache\r
+ if (id.equals(P_ID_EDITABLECACHE)) {\r
+ name.setTitleCache((String) value);\r
+ } else {\r
+ name.setTitleCache(name.generateTitle(), name.isProtectedTitleCache());\r
+ }\r
+ \r
+ propertyChangeSupport.firePropertyChange(ITaxEditorConstants.PROPERTY_SHEET_CHANGE, null, name);\r
+ }\r
+ \r
+\r
+ public String toString() {\r
+ return CdmUtils.Nz(name.getTitleCache());\r
+ }\r
+\r
+ private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);\r
+ \r
+ public void addPropertyChangeListener(\r
+ PropertyChangeListener listener) {\r
+ propertyChangeSupport.addPropertyChangeListener(listener);\r
+ }\r
+}
\ No newline at end of file