import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.navigator.CommonViewer;
-import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.common.ICdmBase;
+import eu.etaxonomy.cdm.model.common.UuidAndTitleCache;
import eu.etaxonomy.cdm.model.description.PolytomousKey;
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
import eu.etaxonomy.cdm.model.taxon.Synonym;
*
* @param selectedObject a {@link eu.etaxonomy.cdm.model.common.CdmBase} object.
*/
- public static void openEditor(CdmBase selectedObject){
+ public static void openEditor(ICdmBase selectedObject){
UUID entityUuid = selectedObject.getUuid();
try {
if(selectedObject instanceof TaxonNode){
}
}
+ public static void openEditor(Object selectedObject){
+ if (selectedObject instanceof UuidAndTitleCache){
+ Class type = ((UuidAndTitleCache) selectedObject).getType();
+ if(type == Taxon.class || type == Synonym.class){
+ try {
+ EditorUtil.openTaxonBase(((UuidAndTitleCache) selectedObject).getUuid());
+ } catch (PartInitException e) {
+ NavigationUtil.error(NavigationUtil.class, "Error opening the editor", e);
+ }
+ }
+ }
+ }
+
/**
* <p>openEmpty</p>
*
import org.eclipse.ui.handlers.HandlerUtil;
import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.common.UuidAndTitleCache;
import eu.etaxonomy.cdm.model.taxon.Classification;
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
import eu.etaxonomy.taxeditor.wizard.ClassificationWizard;
protected IStatus run(IProgressMonitor monitor) {
for(final Object selectedObject : structuredSelection.toArray()){
- if(selectedObject instanceof CdmBase){
- // let the openEditor() method handle everything from now on
- Display.getDefault().asyncExec(new Runnable(){
+ Display.getDefault().asyncExec(new Runnable(){
- public void run() {
- NavigationUtil.openEditor((CdmBase) selectedObject);
- }
-
- });
- }else{
- throw new IllegalArgumentException("selectedObject is not of type CdmBase");
- }
+ public void run() {
+ NavigationUtil.openEditor(selectedObject);
+ }
+
+ });
}
return Status.OK_STATUS;
}
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
+import eu.etaxonomy.cdm.model.common.UuidAndTitleCache;
import eu.etaxonomy.cdm.model.taxon.Synonym;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
/** {@inheritDoc} */
public String getText(Object element) {
- if(element instanceof TaxonBase<?>){
- return ((TaxonBase<?>) element).getTitleCache();
+ if(element instanceof UuidAndTitleCache){
+ return ((UuidAndTitleCache) element).getTitleCache();
}
return element.toString();
}
/** {@inheritDoc} */
@Override
public Color getForeground(Object element) {
- if(element instanceof Taxon){
- return NavigationUtil.getColorRegistry().get("eu.etaxonomy.taxeditor.preferences.searchResult.fontColorAccepted");
- }else if(element instanceof Synonym){
- return NavigationUtil.getColorRegistry().get("eu.etaxonomy.taxeditor.preferences.searchResult.fontColorSynonym");
- }else{
- return NavigationUtil.getColorRegistry().get("eu.etaxonomy.taxeditor.preferences.searchResult.fontColorDefault");
+ if(element instanceof UuidAndTitleCache){
+ Class type = ((UuidAndTitleCache) element).getType();
+ if(type == Taxon.class){
+ return NavigationUtil.getColorRegistry().get("eu.etaxonomy.taxeditor.preferences.searchResult.fontColorAccepted");
+ }else if(type == Synonym.class){
+ return NavigationUtil.getColorRegistry().get("eu.etaxonomy.taxeditor.preferences.searchResult.fontColorSynonym");
+ }
}
+ return NavigationUtil.getColorRegistry().get("eu.etaxonomy.taxeditor.preferences.searchResult.fontColorDefault");
}
/* (non-Javadoc)
/** {@inheritDoc} */
@Override
public Image getImage(Object element) {
- if(element instanceof Taxon){
- Taxon taxon = (Taxon) element;
- if(taxon.isMisapplication()){
- return ImageResources.getImage(ImageResources.MISAPPLIED_NAME_ICON);
- }else{
+ if(element instanceof UuidAndTitleCache){
+ Class type = ((UuidAndTitleCache) element).getType();
+ // unfortunately we can not distinct misapplication anymore
+// if(taxon.isMisapplication()){
+// return ImageResources.getImage(ImageResources.MISAPPLIED_NAME_ICON);
+// }else{
+ if(type == Taxon.class){
return ImageResources.getImage(ImageResources.BLACK_SQUARE_ICON);
+ }else if(type == Synonym.class){
+ return ImageResources.getImage(ImageResources.HETEROTYPIC_SYN_ICON);
}
- }else if(element instanceof Synonym){
-// Synonym synonym = (Synonym) element;
- return ImageResources.getImage(ImageResources.HETEROTYPIC_SYN_ICON);
}
return super.getImage(element);
}