Project

General

Profile

Revision eaff1338

IDeaff13387b8ea194ba8e94df58fbaab85abc9b15
Parent 8faa9f3b
Child 0741ea53

Added by Patrick Plitzner about 3 years ago

ref #6595 refactor selection handling to migrated name editor

View differences:

eu.etaxonomy.taxeditor.editor/META-INF/MANIFEST.MF
7 7
Bundle-Vendor: %Bundle-Vendor.0
8 8
Bundle-Localization: OSGI-INF/l10n/plugin
9 9
Export-Package: eu.etaxonomy.taxeditor.editor,
10
 eu.etaxonomy.taxeditor.editor.e4,
10 11
 eu.etaxonomy.taxeditor.editor.handler,
11 12
 eu.etaxonomy.taxeditor.editor.handler.defaultHandler,
12 13
 eu.etaxonomy.taxeditor.editor.internal,
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/ConceptContentProvider.java
1 1
/**
2 2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5
* 
5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
......
18 18
import eu.etaxonomy.cdm.model.taxon.Taxon;
19 19
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
20 20
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
21
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
21
import eu.etaxonomy.taxeditor.editor.e4.TaxonEditorInputE4;
22 22

  
23 23
/**
24 24
 * @author n.hoffmann
......
29 29

  
30 30
	@Override
31 31
	public void dispose() {
32
		
32

  
33 33
	}
34 34

  
35 35
	@Override
......
39 39
	@Override
40 40
	public Object[] getElements(Object inputElement) {
41 41
		Taxon taxon = null;
42
		if(inputElement instanceof TaxonEditorInput){
43
			taxon = ((TaxonEditorInput) inputElement).getTaxon();
42
		if(inputElement instanceof TaxonEditorInputE4){
43
			taxon = ((TaxonEditorInputE4) inputElement).getTaxon();
44 44
		}
45 45
		else if(inputElement instanceof Taxon){
46 46
			taxon = (Taxon) inputElement;
47 47
		}
48 48
		if(taxon!=null){
49 49
			Map<TaxonRelationship, Taxon> taxonToTaxonRelationsMap = new HashMap<>();
50
			
50

  
51 51
			for (TaxonRelationship relationship : taxon.getTaxonRelations()) {
52 52
				if (! relationship.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR()) ||
53 53
						 relationship.getType().equals(TaxonRelationshipType.TAXONOMICALLY_INCLUDED_IN())) {
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/e4/ConceptViewPartE4.java
28 28
import org.eclipse.jface.viewers.ViewerSorter;
29 29
import org.eclipse.swt.widgets.Composite;
30 30
import org.eclipse.ui.IEditorInput;
31
import org.eclipse.ui.IEditorPart;
32 31

  
33 32
import eu.etaxonomy.cdm.model.taxon.Taxon;
34 33
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
......
90 89
			showEmptyPage();
91 90
		}
92 91
		else if(partObject instanceof TaxonNameEditorE4){
93
		    IEditorInput input = ((IEditorPart) partObject).getEditorInput();
92
		    IEditorInput input = ((TaxonNameEditorE4) partObject).getEditorInput();
94 93
		    showViewer(new StructuredSelection(input), activePart, viewer);
95 94
		}
96 95
		else {
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/e4/handler/CreateConceptRelationHandlerE4.java
27 27
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
28 28
import eu.etaxonomy.cdm.model.taxon.Taxon;
29 29
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
30
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
31
import eu.etaxonomy.taxeditor.editor.Page;
32
import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
30
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
33 31
import eu.etaxonomy.taxeditor.editor.view.concept.e4.ConceptViewPartE4;
34 32
import eu.etaxonomy.taxeditor.editor.view.concept.operation.CreateConceptRelationOperation;
35 33
import eu.etaxonomy.taxeditor.model.AbstractUtility;
......
55 53
        String commandId = menuItem.getCommand().getElementId();
56 54
        UUID uuid = (UUID) menuItem.getTransientData().get(commandId+".taxonRelationshipType.uuid");
57 55
        TaxonRelationshipType taxonRelationshipType = HibernateProxyHelper.deproxy(CdmStore.getService(ITermService.class).load(uuid), TaxonRelationshipType.class);
58
        TaxonNameEditor editor = null;
59 56

  
57
        TaxonNameEditorE4 editor = null;
60 58

  
61 59
        ConceptViewPartE4 conceptView = (ConceptViewPartE4) activePart.getObject();
62 60

  
63 61
        Object e4WrappedPart = WorkbenchUtility.getE4WrappedPart(conceptView.getSelectionProvidingPart());
64
        if(e4WrappedPart instanceof MultiPageTaxonEditor){
65
            editor = (TaxonNameEditor) ((MultiPageTaxonEditor) e4WrappedPart).getPage(Page.NAME);
62
        if(e4WrappedPart instanceof TaxonNameEditorE4){
63
            editor = (TaxonNameEditorE4) e4WrappedPart;
64

  
65
            IUndoContext undoContext = null;
66
            ConversationHolder conversationHolder = null;
67
            Taxon taxon = null;
68
            taxon = editor.getTaxon();
69
            conversationHolder = editor.getConversationHolder();
70
            undoContext = editor.getUndoContext();
71

  
72
            //FIXME should this also be enabled for bulk editor
73
            //		else if(activeEditor instanceof BulkEditor){
74
            //		    BulkEditor bulkEditor = (BulkEditor)activeEditor;
75
            //            ISelection selection = bulkEditor.getSelectionProvider().getSelection();
76
            //		    taxon = (Taxon) ((IStructuredSelection)selection).getFirstElement();
77
            //		    conversationHolder = bulkEditor.getConversationHolder();
78
            //		    undoContext = bulkEditor.getUndoContext();
79
            //		}
80

  
81
            Taxon relatedConcept = TaxonBaseSelectionDialog.selectTaxon(shell, conversationHolder, taxon);
82

  
83

  
84
            if(relatedConcept == null){
85
                return;
86
            }
87
            boolean isInverse = taxonRelationshipType.getInverseLabel().isEmpty()?false:true;
88
            TaxonRelationshipTypeInverseContainer typeInverseContainer =new TaxonRelationshipTypeInverseContainer(taxonRelationshipType, isInverse) ;
89

  
90

  
91
            AbstractPostOperation operation = new CreateConceptRelationOperation(menuItem.getLocalizedLabel(),
92
                    undoContext, taxon, relatedConcept, typeInverseContainer, conceptView);
93
            AbstractUtility.executeOperation(operation);
66 94
        }
67

  
68
        IUndoContext undoContext = null;
69
        ConversationHolder conversationHolder = null;
70
        Taxon taxon = null;
71
        taxon = editor.getTaxon();
72
        conversationHolder = editor.getConversationHolder();
73
        undoContext = editor.getUndoContext();
74

  
75
        //FIXME should this also be enabled for bulk editor
76
        //		else if(activeEditor instanceof BulkEditor){
77
        //		    BulkEditor bulkEditor = (BulkEditor)activeEditor;
78
        //            ISelection selection = bulkEditor.getSelectionProvider().getSelection();
79
        //		    taxon = (Taxon) ((IStructuredSelection)selection).getFirstElement();
80
        //		    conversationHolder = bulkEditor.getConversationHolder();
81
        //		    undoContext = bulkEditor.getUndoContext();
82
        //		}
83

  
84
        Taxon relatedConcept = TaxonBaseSelectionDialog.selectTaxon(shell, conversationHolder, taxon);
85

  
86

  
87
        if(relatedConcept == null){
88
            return;
89
        }
90
        boolean isInverse = taxonRelationshipType.getInverseLabel().isEmpty()?false:true;
91
        TaxonRelationshipTypeInverseContainer typeInverseContainer =new TaxonRelationshipTypeInverseContainer(taxonRelationshipType, isInverse) ;
92

  
93

  
94
        AbstractPostOperation operation = new CreateConceptRelationOperation(menuItem.getLocalizedLabel(),
95
                undoContext, taxon, relatedConcept, typeInverseContainer, conceptView);
96
        AbstractUtility.executeOperation(operation);
97 95
    }
98 96

  
99 97
    @CanExecute
......
103 101
        ConceptViewPartE4 conceptView = (ConceptViewPartE4) activePart.getObject();
104 102

  
105 103
        Object e4WrappedPart = WorkbenchUtility.getE4WrappedPart(conceptView.getSelectionProvidingPart());
106
        canExecute = e4WrappedPart instanceof MultiPageTaxonEditor;
104
        canExecute = e4WrappedPart instanceof TaxonNameEditorE4;
107 105
        menuItem.setVisible(canExecute);
108 106
        return canExecute;
109 107
    }
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/e4/handler/DeleteConceptRelationHandlerE4.java
24 24
import org.eclipse.jface.viewers.ISelection;
25 25

  
26 26
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
27
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
28
import eu.etaxonomy.taxeditor.editor.Page;
29
import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
27
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
30 28
import eu.etaxonomy.taxeditor.editor.view.concept.e4.ConceptViewPartE4;
31 29
import eu.etaxonomy.taxeditor.editor.view.concept.operation.DeleteConceptRelationOperation;
32 30
import eu.etaxonomy.taxeditor.model.AbstractUtility;
......
45 43
    public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart,
46 44
            @Optional@Named(IServiceConstants.ACTIVE_SELECTION) Object selection, MMenuItem menuItem) {
47 45

  
48
        TaxonNameEditor editor = null;
46
        TaxonNameEditorE4 editor = null;
49 47

  
50 48
        ConceptViewPartE4 conceptView = (ConceptViewPartE4) activePart.getObject();
51 49

  
52 50
        Object e4WrappedPart = WorkbenchUtility.getE4WrappedPart(conceptView.getSelectionProvidingPart());
53
        if(e4WrappedPart instanceof MultiPageTaxonEditor){
54
            editor = (TaxonNameEditor) ((MultiPageTaxonEditor) e4WrappedPart).getPage(Page.NAME);
55
        }
51
        if(e4WrappedPart instanceof TaxonNameEditorE4){
52
            editor = (TaxonNameEditorE4) e4WrappedPart;
56 53

  
57
        Set<TaxonRelationship> relations = new HashSet<TaxonRelationship>();
54
            Set<TaxonRelationship> relations = new HashSet<TaxonRelationship>();
58 55

  
59 56

  
60
        // FIXME E4 multiple selection
61
        //			while (iterator.hasNext()){
62
        if(selection instanceof TaxonRelationship){
63
            relations.add((TaxonRelationship) selection);
64
        }
65
        //			}
57
            // FIXME E4 multiple selection
58
            //			while (iterator.hasNext()){
59
            if(selection instanceof TaxonRelationship){
60
                relations.add((TaxonRelationship) selection);
61
            }
62
            //			}
66 63

  
67
        //editor should not be null because this is already checked in canExecute
68
        AbstractPostOperation operation = new DeleteConceptRelationOperation(menuItem.getLocalizedLabel(),
69
                editor.getUndoContext(), editor.getTaxon(), relations, conceptView);
70
        AbstractUtility.executeOperation(operation);
64
            //editor should not be null because this is already checked in canExecute
65
            AbstractPostOperation operation = new DeleteConceptRelationOperation(menuItem.getLocalizedLabel(),
66
                    editor.getUndoContext(), editor.getTaxon(), relations, conceptView);
67
            AbstractUtility.executeOperation(operation);
68
        }
71 69
    }
72 70

  
73 71
	@CanExecute
......
77 75
        ConceptViewPartE4 conceptView = (ConceptViewPartE4) activePart.getObject();
78 76

  
79 77
        Object e4WrappedPart = WorkbenchUtility.getE4WrappedPart(conceptView.getSelectionProvidingPart());
80
        if(e4WrappedPart instanceof MultiPageTaxonEditor){
78
        if(e4WrappedPart instanceof TaxonNameEditorE4){
81 79
            ISelection selection = conceptView.getViewer().getSelection();
82 80
            canExecute = selection!=null && !selection.isEmpty();
83 81
            menuItem.setVisible(canExecute);
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/e4/handler/OpenRelatedConceptHandlerE4.java
23 23
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
24 24
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
25 25
import eu.etaxonomy.taxeditor.editor.EditorUtil;
26
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
27 26
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
27
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
28 28
import eu.etaxonomy.taxeditor.editor.view.concept.e4.ConceptViewPartE4;
29 29
import eu.etaxonomy.taxeditor.model.LineSelection;
30 30
import eu.etaxonomy.taxeditor.model.MessagingUtils;
......
42 42
    public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart,
43 43
            @Optional@Named(IServiceConstants.ACTIVE_SELECTION) TaxonRelationship taxonRelationship) {
44 44

  
45
        MultiPageTaxonEditor editor = null;
45
        TaxonNameEditorE4 editor = null;
46 46
        BulkEditor bulkEditor = null;
47 47

  
48 48
        ConceptViewPartE4 conceptView = (ConceptViewPartE4) activePart.getObject();
49 49

  
50 50
        Object e4WrappedPart = WorkbenchUtility.getE4WrappedPart(conceptView.getSelectionProvidingPart());
51
        if(e4WrappedPart instanceof MultiPageTaxonEditor){
52
            editor = (MultiPageTaxonEditor) e4WrappedPart;
51
        if(e4WrappedPart instanceof TaxonNameEditorE4){
52
            editor = (TaxonNameEditorE4) e4WrappedPart;
53 53
        }
54 54
        else if(e4WrappedPart instanceof BulkEditor){
55 55
            bulkEditor = (BulkEditor) e4WrappedPart;
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateView.java
55 55
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
56 56
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
57 57
import eu.etaxonomy.taxeditor.editor.EditorUtil;
58
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
59 58
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
59
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
60 60
import eu.etaxonomy.taxeditor.editor.view.derivate.searchFilter.DerivateSearchCompositeController;
61 61
import eu.etaxonomy.taxeditor.model.AbstractUtility;
62 62
import eu.etaxonomy.taxeditor.model.IContextListener;
......
507 507
        }
508 508
        if(listenToSelectionChange){
509 509
            selectedTaxon = null;
510
            if(activePart instanceof MultiPageTaxonEditor){
511
                selectedTaxon = ((MultiPageTaxonEditor) activePart).getTaxon();
510
            if(activePart instanceof TaxonNameEditorE4){
511
                selectedTaxon = ((TaxonNameEditorE4) activePart).getTaxon();
512 512
            }
513 513
            else if(selection instanceof IStructuredSelection){
514 514
                Object selectedElement = ((IStructuredSelection) selection).getFirstElement();
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/FactualDataPartE4.java
47 47
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
48 48
import eu.etaxonomy.cdm.model.taxon.Taxon;
49 49
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
50
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
51 50
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
51
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
52 52
import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditor;
53 53
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementDragListener;
54 54
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementDropAdapter;
......
168 168
                }
169 169
            }
170 170
            Object firstElement = structuredSelection.getFirstElement();
171
            if (partObject instanceof MultiPageTaxonEditor){
172
                if (firstElement != ((MultiPageTaxonEditor)partObject).getTaxon()){
171
            if (partObject instanceof TaxonNameEditorE4){
172
                if (firstElement != ((TaxonNameEditorE4)partObject).getTaxon()){
173 173
                    showEmptyPage();
174 174
                    return;
175 175
                }
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/DescriptionsMenuPropertyTesterE4.java
11 11
import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
12 12
import eu.etaxonomy.cdm.model.media.Media;
13 13
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
14
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
14
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
15 15
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
16 16
import eu.etaxonomy.taxeditor.model.AbstractUtility;
17 17
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
......
160 160
	}
161 161

  
162 162
	private boolean isTaxonEditor() {
163
	    if(AbstractUtility.getActiveE4Editor() instanceof MultiPageTaxonEditor){
163
	    if(AbstractUtility.getActiveE4Editor() instanceof TaxonNameEditorE4){
164 164
	        return true;
165 165
	    }
166 166
	    return false;
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/MoveDescriptionElementsHandlerE4.java
38 38
import eu.etaxonomy.cdm.model.taxon.Taxon;
39 39
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
40 40
import eu.etaxonomy.taxeditor.editor.EditorUtil;
41
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
42
import eu.etaxonomy.taxeditor.editor.Page;
43 41
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
44
import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
42
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
45 43
import eu.etaxonomy.taxeditor.editor.view.descriptive.e4.FactualDataPartE4;
46 44
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.MoveDescriptionElementsOperation;
47 45
import eu.etaxonomy.taxeditor.model.AbstractUtility;
......
62 60
 */
63 61
public class MoveDescriptionElementsHandlerE4 implements IPostOperationEnabled{
64 62
    private UUID newAcceptedTaxonNodeUuid;
65
    private TaxonNameEditor editor;
63
    private TaxonNameEditorE4 editor;
66 64

  
67 65
    @Execute
68 66
    public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart,
......
71 69

  
72 70
        FactualDataPartE4 factualDataPart = (FactualDataPartE4) activePart.getObject();
73 71
        Object e4WrappedPart = WorkbenchUtility.getE4WrappedPart(factualDataPart.getSelectionProvidingPart());
74
        if(e4WrappedPart instanceof MultiPageTaxonEditor){
75
            editor = (TaxonNameEditor) ((MultiPageTaxonEditor) e4WrappedPart).getPage(Page.NAME);
72
        if(e4WrappedPart instanceof TaxonNameEditorE4){
73
            editor = (TaxonNameEditorE4) e4WrappedPart;
76 74
        }
77 75
        Taxon actualTaxon= null;
78 76

  
......
127 125
            }
128 126
            newAcceptedTaxonNodeUuid = newAcceptedTaxonNode.getUuid();
129 127

  
130
            String moveMessage = String.format(Messages.MoveDescriptionElementsHandler_ELEMENTS_MOVED, editor.getEditor().getTaxon());
128
            String moveMessage = String.format(Messages.MoveDescriptionElementsHandler_ELEMENTS_MOVED, editor.getTaxon());
131 129

  
132 130
            AbstractPostOperation operation = new MoveDescriptionElementsOperation(
133 131
                    menuItem.getLocalizedLabel(), EditorUtil.getUndoContext(),
......
150 148
                //AbstractUtility.close(editor.getMultiPageTaxonEditor());
151 149

  
152 150
                try {
153
                    MultiPageTaxonEditor possibleOpenEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(newAcceptedTaxonNodeUuid);
154
                    if(possibleOpenEditor != null){
155
                        AbstractUtility.close(possibleOpenEditor);
156
                    }
151
                    //FIXME E4 migrate
152
//                    MultiPageTaxonEditor possibleOpenEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(newAcceptedTaxonNodeUuid);
153
//                    if(possibleOpenEditor != null){
154
//                        AbstractUtility.close(possibleOpenEditor);
155
//                    }
157 156
                    EditorUtil.openTaxonNodeE4(newAcceptedTaxonNodeUuid);
158 157
                } catch (PartInitException e) {
159 158
                    MessagingUtils.error(this.getClass(), e);
......
181 180
        FactualDataPartE4 factualDataPart = (FactualDataPartE4) activePart.getObject();
182 181

  
183 182
        Object e4WrappedPart = WorkbenchUtility.getE4WrappedPart(factualDataPart.getSelectionProvidingPart());
184
        if(e4WrappedPart instanceof MultiPageTaxonEditor){
183
        if(e4WrappedPart instanceof TaxonNameEditorE4){
185 184
            ISelection selection = factualDataPart.getViewer().getSelection();
186 185
            if(selection instanceof IStructuredSelection){
187 186
                Object firstElement = ((IStructuredSelection) selection).getFirstElement();
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/MoveDescriptionToOtherTaxonHandlerE4.java
21 21
import org.eclipse.jface.viewers.IStructuredSelection;
22 22
import org.eclipse.swt.widgets.Display;
23 23
import org.eclipse.swt.widgets.Shell;
24
import org.eclipse.ui.PartInitException;
25 24

  
26 25
import eu.etaxonomy.cdm.model.common.CdmBase;
27 26
import eu.etaxonomy.cdm.model.description.DescriptionBase;
......
31 30
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
32 31
import eu.etaxonomy.taxeditor.editor.EditorUtil;
33 32
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
34
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
35 33
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
34
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
36 35
import eu.etaxonomy.taxeditor.editor.view.descriptive.e4.FactualDataPartE4;
37 36
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.MoveDescriptionToOtherTaxonOperation;
38 37
import eu.etaxonomy.taxeditor.model.AbstractUtility;
39 38
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
40 39
import eu.etaxonomy.taxeditor.model.MessagingUtils;
41 40
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
42
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
43 41
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
44 42
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
45 43

  
......
54 52
    private MoveDescriptionToOtherTaxonOperation operation;
55 53

  
56 54
    private UUID newAcceptedTaxonNodeUuid;
57
    private MultiPageTaxonEditor editor;
55
    private TaxonNameEditorE4 editor;
58 56

  
59 57
    @Execute
60 58
    public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart,
......
64 62

  
65 63
        FactualDataPartE4 factualDataPart = (FactualDataPartE4) activePart.getObject();
66 64
        Object e4WrappedPart = WorkbenchUtility.getE4WrappedPart(factualDataPart.getSelectionProvidingPart());
67
        if(e4WrappedPart instanceof MultiPageTaxonEditor){
68
            editor = (MultiPageTaxonEditor) e4WrappedPart;
65
        if(e4WrappedPart instanceof TaxonNameEditorE4){
66
            editor = (TaxonNameEditorE4) e4WrappedPart;
69 67
            if (this.editor.isDirty()){
70 68
                boolean proceed = MessageDialog.openQuestion(null,
71 69
                        Messages.MoveDescriptionToOtherTaxonHandler_SAVE_CHANGES, Messages.MoveDescriptionToOtherTaxonHandler_SAVE_CHANGES_MESSAGE);
72 70
                if (proceed) {
73
                    editor.doSave(AbstractUtility.getMonitor());
71
                    editor.save(AbstractUtility.getMonitor());
74 72
                } else {
75 73
                    return;
76 74
                }
......
90 88

  
91 89
        // Choose the target taxon
92 90
        List<UUID> excludeTaxa = new ArrayList<UUID>();
93
        
91

  
94 92
        excludeTaxa.add(descriptions.get(0).getTaxon().getUuid());
95 93

  
96 94
        //get current taxon node
97 95
        TaxonNode node = null;
98 96
        Classification classification = null;
99
        MultiPageTaxonEditor taxonEditor = EditorUtil.getActiveMultiPageTaxonEditor();
100
        if(taxonEditor!=null){
101
            node = ((TaxonEditorInput) taxonEditor.getEditorInput()).getTaxonNode();
97
        if(editor!=null){
98
            node = editor.getEditorInput().getTaxonNode();
102 99
            classification = node.getClassification();
103 100
        }
104 101
        TaxonNode newAcceptedTaxonNode = TaxonNodeSelectionDialog.select(shell,
......
121 118
                    newAcceptedTaxonNode,
122 119
                    this,
123 120
                    editor,
124
                    (ICdmEntitySessionEnabled)editor.getEditorInput());
121
                    editor.getEditorInput());
125 122
            AbstractUtility.executeOperation(operation);
126 123
        }
127 124

  
......
135 132

  
136 133
            @Override
137 134
            public void run() {
138
                AbstractUtility.close(editor);
139

  
135
                //FIXME E4 migrate
136
//                AbstractUtility.close(editor);
137
//
140 138
                try {
141
                    MultiPageTaxonEditor possibleOpenEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(newAcceptedTaxonNodeUuid);
142
                    if(possibleOpenEditor != null){
143
                        AbstractUtility.close(possibleOpenEditor);
144
                    }
139
//                    MultiPageTaxonEditor possibleOpenEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(newAcceptedTaxonNodeUuid);
140
//                    if(possibleOpenEditor != null){
141
//                        AbstractUtility.close(possibleOpenEditor);
142
//                    }
145 143
                    EditorUtil.openTaxonNodeE4(newAcceptedTaxonNodeUuid);
146
                } catch (PartInitException e) {
147
                    MessagingUtils.error(this.getClass(), e);
148
                    throw new RuntimeException(e);
144
//                } catch (PartInitException e) {
145
//                    MessagingUtils.error(this.getClass(), e);
146
//                    throw new RuntimeException(e);
149 147
                } catch (Exception e) {
150 148
                    MessagingUtils.warningDialog(Messages.MoveDescriptionToOtherTaxonHandler_CREATE_FAILED, this, e.getMessage());
151 149
                }
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/e4/MediaViewPartE4.java
29 29
import org.eclipse.swt.widgets.Tree;
30 30

  
31 31
import eu.etaxonomy.cdm.model.description.IDescribable;
32
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
33 32
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
33
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
34 34
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart;
35 35
import eu.etaxonomy.taxeditor.editor.view.media.MediaContentProvider;
36 36
import eu.etaxonomy.taxeditor.editor.view.media.MediaLabelProvider;
......
104 104
	        }
105 105

  
106 106
	        Object firstElement = structuredSelection.getFirstElement();
107
	        if (partObject instanceof MultiPageTaxonEditor){
108
	            if (firstElement != ((MultiPageTaxonEditor)partObject).getTaxon()){
107
	        if (partObject instanceof TaxonNameEditorE4){
108
	            if (firstElement != ((TaxonNameEditorE4)partObject).getTaxon()){
109 109
	                showEmptyPage();
110 110
	                return;
111 111
	            }
eu.etaxonomy.taxeditor.printpublisher/src/main/java/eu/etaxonomy/taxeditor/printpublisher/handler/GeneratePdfHandler.java
1 1
/**
2 2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5
* 
5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
......
20 20
import org.eclipse.ui.handlers.HandlerUtil;
21 21
import org.jdom.Element;
22 22

  
23
import eu.etaxonomy.cdm.api.application.ICdmRepository;
24 23
import eu.etaxonomy.cdm.print.IXMLEntityFactory;
25 24
import eu.etaxonomy.cdm.print.PublishConfigurator;
26 25
import eu.etaxonomy.cdm.print.out.pdf.PdfOutputModule;
27 26
import eu.etaxonomy.cdm.print.out.xml.XMLOutputModule;
28
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
27
import eu.etaxonomy.taxeditor.editor.e4.TaxonEditorInputE4;
29 28
import eu.etaxonomy.taxeditor.model.MessagingUtils;
30
import eu.etaxonomy.taxeditor.printpublisher.PrintUtil;
31 29
import eu.etaxonomy.taxeditor.printpublisher.wizard.DirectPublishingWizard;
32 30
import eu.etaxonomy.taxeditor.store.CdmStore;
33 31

  
......
39 37
 * @version 1.0
40 38
 */
41 39
public class GeneratePdfHandler extends AbstractHandler {
42
	
40

  
43 41
	private PublishConfigurator configurator;
44 42

  
45 43
	/** {@inheritDoc} */
46
	public Object execute(ExecutionEvent event) throws ExecutionException {
44
	@Override
45
    public Object execute(ExecutionEvent event) throws ExecutionException {
47 46
		// make the editors taxon the selected taxon to export
48
		IEditorPart editor = HandlerUtil.getActiveEditor(event);	
47
		IEditorPart editor = HandlerUtil.getActiveEditor(event);
49 48

  
50 49
		IEditorInput input = editor.getEditorInput();
51
		
52
		if(!(input instanceof TaxonEditorInput)){
50

  
51
		if(!(input instanceof TaxonEditorInputE4)){
53 52
			MessagingUtils.warningDialog("PDF generation not supported for selected input", this, "Generating PDF output is not supported for the current active editor");
54
			
53

  
55 54
			return null;
56 55
		}
57
		
58
		configurator = PublishConfigurator.NewLocalInstance((ICdmRepository) CdmStore.getCurrentApplicationConfiguration());
59
		
60
		Element taxonNodeElement = getTaxonNodeElement((TaxonEditorInput) input);
56

  
57
		configurator = PublishConfigurator.NewLocalInstance(CdmStore.getCurrentApplicationConfiguration());
58

  
59
		Element taxonNodeElement = getTaxonNodeElement((TaxonEditorInputE4) input);
61 60
		configurator.addSelectedTaxonNodeElements(taxonNodeElement);
62
		
61

  
63 62
		configurator.setDoPublishEntireBranches(false);
64
		
63

  
65 64
		configurator.addOutputModule(new PdfOutputModule());
66 65
		configurator.addOutputModule(new XMLOutputModule());
67
		
66

  
68 67
		DirectPublishingWizard wizard = new DirectPublishingWizard(configurator);
69 68
		WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), wizard);
70
		
69

  
71 70
		dialog.open();
72
		
71

  
73 72
		return null;
74 73
	}
75
	
76
	private Element getTaxonNodeElement(TaxonEditorInput input){
77
		
74

  
75
	private Element getTaxonNodeElement(TaxonEditorInputE4 input){
76

  
78 77
		UUID taxonNodeUuid = input.getTaxonNode().getUuid();
79
		
78

  
80 79
		IXMLEntityFactory factory = configurator.getFactory();
81
		
80

  
82 81
		Element taxonNodeElement = factory.getTaxonNode(taxonNodeUuid);
83
		
82

  
84 83
		return taxonNodeElement;
85 84
	}
86 85
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)