Project

General

Profile

« Previous | Next » 

Revision 5e588b6d

Added by Patrick Plitzner over 6 years ago

ref #6913 Remove IEditorInput dependency from alignment editor input

View differences:

eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/editor/AlignmentEditorInput.java
13 13
import java.util.List;
14 14
import java.util.UUID;
15 15

  
16
import org.eclipse.jface.resource.ImageDescriptor;
17
import org.eclipse.ui.IEditorInput;
18
import org.eclipse.ui.IPersistableElement;
19

  
20 16
import eu.etaxonomy.cdm.api.service.molecular.ISequenceService;
21 17
import eu.etaxonomy.cdm.model.molecular.Sequence;
22 18
import eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput;
23
import eu.etaxonomy.taxeditor.molecular.l10n.Messages;
24 19
import eu.etaxonomy.taxeditor.store.CdmStore;
25 20

  
26 21

  
......
30 25
 * @author Ben Stöver
31 26
 * @date 04.08.2014
32 27
 */
33
public class AlignmentEditorInput extends CdmEntitySessionInput implements IEditorInput {
34
    private static final String name = Messages.AlignmentEditorInput_EDITOR_NAME;
35

  
28
public class AlignmentEditorInput extends CdmEntitySessionInput {
36 29

  
37 30
    private final UUID sequenceNodeUuid;
38 31
    private Sequence sequenceNode;
......
44 37
	}
45 38

  
46 39

  
47
	/* (non-Javadoc)
48
     * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
49
     */
50
    @Override
51
    public Object getAdapter(Class adapter) {
52
        // TODO Auto-generated method stub
53
        return null;
54
    }
55

  
56

  
57
    /* (non-Javadoc)
58
     * @see org.eclipse.ui.IEditorInput#exists()
59
     */
60
    @Override
61
    public boolean exists() {
62
        // TODO Auto-generated method stub
63
        return false;
64
    }
65

  
66

  
67
    /* (non-Javadoc)
68
     * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
69
     */
70
    @Override
71
    public ImageDescriptor getImageDescriptor() {
72
        // TODO Auto-generated method stub
73
        return null;
74
    }
75

  
76

  
77
    /* (non-Javadoc)
78
     * @see org.eclipse.ui.IEditorInput#getName()
79
     */
80
    @Override
81
    public String getName() {
82
        return name;
83
    }
84

  
85

  
86
    /* (non-Javadoc)
87
     * @see org.eclipse.ui.IEditorInput#getPersistable()
88
     */
89
    @Override
90
    public IPersistableElement getPersistable() {
91
        return null;
92
    }
93

  
94

  
95
    /* (non-Javadoc)
96
     * @see org.eclipse.ui.IEditorInput#getToolTipText()
97
     */
98
    @Override
99
    public String getToolTipText() {
100
        return name;
101
    }
102

  
103

  
104 40
	/**
105 41
	 * Returns the {@link UUID} of the sequence CDM node that should be edited by the {@link AlignmentEditor} this object
106 42
	 * is used with.
......
164 100
    @Override
165 101
    public void merge() {
166 102
        CdmStore.getService(ISequenceService.class).merge(sequenceNode, true);
167
        
103

  
168 104
    }
169 105
}
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/handler/EditSequenceHandler.java
9 9
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
10 10
import org.eclipse.e4.ui.services.IServiceConstants;
11 11
import org.eclipse.jface.viewers.TreeNode;
12
import org.eclipse.ui.PartInitException;
13 12

  
14 13
import eu.etaxonomy.cdm.model.molecular.Sequence;
15
import eu.etaxonomy.taxeditor.molecular.TaxeditorMolecularPlugin;
16
import eu.etaxonomy.taxeditor.molecular.editor.AlignmentEditor;
17
import eu.etaxonomy.taxeditor.molecular.editor.AlignmentEditorInput;
18
import eu.etaxonomy.taxeditor.molecular.l10n.Messages;
19 14

  
20 15

  
21 16

  
......
32 27
    @Execute
33 28
    public void execute(@Optional@Named(IServiceConstants.ACTIVE_SELECTION)TreeNode treeNodeOfSelection) {
34 29
        if(treeNodeOfSelection != null && treeNodeOfSelection.getValue() instanceof Sequence){
35
            AlignmentEditorInput input = new AlignmentEditorInput(((Sequence)treeNodeOfSelection.getValue()).getUuid());  //TODO Should there always be a new instance created here? What if the specified CDM node is already opened in an AlignmentEditor? => Possible create Singleton that keeps instances by sequence objects in a map.
36
            try {
37
                TaxeditorMolecularPlugin.getDefault().getWorkbench()
38
                .getActiveWorkbenchWindow().getActivePage().openEditor(input, AlignmentEditor.ID);
39
            }
40
            catch (PartInitException e) {
41
                logger.error(Messages.EditSequenceHandler_COULD_NOT_OPEN, e);
42
            }
30
//            AlignmentEditorInput input = new AlignmentEditorInput(((Sequence)treeNodeOfSelection.getValue()).getUuid());  //TODO Should there always be a new instance created here? What if the specified CDM node is already opened in an AlignmentEditor? => Possible create Singleton that keeps instances by sequence objects in a map.
31
//            try {
32
//                TaxeditorMolecularPlugin.getDefault().getWorkbench()
33
//                .getActiveWorkbenchWindow().getActivePage().openEditor(input, AlignmentEditor.ID);
34
//            }
35
//            catch (PartInitException e) {
36
//                logger.error(Messages.EditSequenceHandler_COULD_NOT_OPEN, e);
37
//            }
43 38
        }
44 39
    }
45 40

  

Also available in: Unified diff