Project

General

Profile

Revision 200e8530

ID200e853051d0d68a418515d40acbdc69625919cd
Parent 15cd5e08
Child b02af7f6

Added by Patrick Plitzner almost 2 years ago

ref #6595 Use only e4 handler for opening name editor

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorStateManager.java
180 180

  
181 181
		for(UUID uuid : uuids){
182 182
			try {
183
				EditorUtil.openTaxonNode(uuid);
183
				EditorUtil.openTaxonNodeE4(uuid);
184 184
			} catch (Exception e) {
185 185
				// TODO Auto-generated catch block
186 186
				e.printStackTrace();
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java
142 142
	 * @throws java.lang.Exception
143 143
	 *             if any.
144 144
	 */
145
	public static void openTaxonNode(UUID taxonNodeUuid) throws Exception {
146
	    TaxonEditorInput input = TaxonEditorInput.NewInstance(taxonNodeUuid);
147
	    open(input);
148
	}
149

  
150 145
	public static void openTaxonNodeE4(UUID taxonNodeUuid) throws Exception {
151
	    //FIXME E4 this can be removed when fully migrated
146
	    //FIXME E4 this can probably be removed when fully migrated
152 147
        TaxonEditorInputE4 input = TaxonEditorInputE4.NewInstance(taxonNodeUuid);
153 148
        EPartService partService = TaxeditorEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getService(EPartService.class);
154 149
        MPart part = partService.createPart("eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4");
......
157 152
        editor.init(input);
158 153
	}
159 154

  
160
	public static void openTaxonBase(UUID taxonBaseUuid)
161
			throws PartInitException {
162
	    TaxonBase taxonBase = CdmStore.getService(ITaxonService.class).find(taxonBaseUuid);
163
        if (taxonBase != null && taxonBase.isOrphaned()) {
164
            if(taxonBase.isInstanceOf(Synonym.class)){
165
                MessagingUtils.warningDialog(Messages.EditorUtil_ORPHAN_ACCEPTED_TAXON, TaxonEditorInput.class, Messages.EditorUtil_ORPHAN_ACCEPTED_TAXON_MESSAGE);
166
                return;
167
            }
168
            else{
169
                MessagingUtils.warningDialog(Messages.EditorUtil_ORPHAN_TAXON, TaxonEditorInput.class, Messages.EditorUtil_ORPHAN_TAXON_MESSAGE);
170
                return;
171
            }
172
        }
173
		TaxonEditorInput input = TaxonEditorInput
174
				.NewInstanceFromTaxonBase(taxonBaseUuid);
175
		if(input!=null && input.getTaxonNode()!=null){
176
		    open(input);
177
		}
178
	}
179

  
180 155
	public static void openTaxonBaseE4(UUID taxonBaseUuid) throws PartInitException{
156
	    //FIXME E4 this can probably be removed when fully migrated
181 157
	    TaxonBase taxonBase = CdmStore.getService(ITaxonService.class).find(taxonBaseUuid);
182 158

  
183 159
	    if (taxonBase != null && taxonBase.isOrphaned()) {
......
190 166
	            return;
191 167
	        }
192 168
	    }
169

  
193 170
	    TaxonEditorInputE4 input = TaxonEditorInputE4.NewInstanceFromTaxonBase(taxonBaseUuid);
194
	    if(input!=null && input.getTaxonNode()!=null){
195
	        EPartService partService = TaxeditorEditorPlugin.getDefault().getWorkbench().getService(EPartService.class);
196
	        MPart part = partService.createPart("eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4");
197
	        partService.showPart(part, PartState.ACTIVATE);
198
	        TaxonNameEditorE4 editor = (TaxonNameEditorE4) part.getObject();
199
	        editor.init(input);
200
	    }
171
	    EPartService partService = TaxeditorEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getService(EPartService.class);
172
	    MPart part = partService.createPart("eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4");
173
	    partService.showPart(part, PartState.ACTIVATE);
174
	    TaxonNameEditorE4 editor = (TaxonNameEditorE4) part.getObject();
175
	    editor.init(input);
201 176
	}
202 177

  
203 178
	/**
......
227 202
	 * @param parentNodeUuid
228 203
	 *            a {@link java.util.UUID} object.
229 204
	 */
230
	public static void openEmpty(UUID parentNodeUuid) throws PartInitException {
231
		TaxonEditorInput input = TaxonEditorInput
205
	public static void openEmptyE4(UUID parentNodeUuid) throws PartInitException {
206
		TaxonEditorInputE4 input = TaxonEditorInputE4
232 207
				.NewEmptyInstance(parentNodeUuid);
233
		open(input, MultiPageTaxonEditor.ID);
234

  
235
		getActiveMultiPageTaxonEditor().changed(null);
236

  
208
        EPartService partService = TaxeditorEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getService(EPartService.class);
209
        MPart part = partService.createPart("eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4");
210
        partService.showPart(part, PartState.ACTIVATE);
211
        TaxonNameEditorE4 editor = (TaxonNameEditorE4) part.getObject();
212
        editor.init(input);
237 213
	}
238 214

  
239 215
	/**
......
479 455
        return null;
480 456
    }
481 457

  
482
    /**
483
     * Opens a taxon editor for the given object if the given object is a valid input.
484
     * @param object the object for which the editor will be opened
485
     * @throws PartInitException
486
     */
487
    public static void openTaxonEditor(Object object) throws PartInitException {
488
        if(object instanceof TaxonBase<?>){
489
            openTaxonBase(((TaxonBase<?>) object).getUuid());
490
        }
491
    }
492

  
493 458
    public static boolean closeObsoleteEditor(TaxonNode taxonNode, IWorkbenchPage activePage){
494 459
        boolean result = true;
495 460
        for (IEditorReference ref : activePage.getEditorReferences()) {
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/EditNewTaxonHandler.java
39 39
		logger.debug("Handler called: " + this.getClass().getCanonicalName()); //$NON-NLS-1$
40 40
		
41 41
		try {
42
			EditorUtil.openEmpty(null);
42
			EditorUtil.openEmptyE4(null);
43 43
		} catch (PartInitException e) {
44 44
			e.printStackTrace();
45 45
		}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/defaultHandler/DefaultOpenTaxonEditorForTaxonBaseHandler.java
23 23
    @Override
24 24
    protected void open(ExecutionEvent event, TaxonBase entity) {
25 25
        try {
26
            EditorUtil.openTaxonBase(entity.getUuid());
26
            EditorUtil.openTaxonBaseE4(entity.getUuid());
27 27
        } catch (PartInitException e) {
28 28
            MessagingUtils.error(DefaultOpenTaxonEditorForTaxonBaseHandler.class, Messages.DefaultOpenTaxonEditorForTaxonBaseHandler_COULD_NOT_OPEN+entity, e);
29 29
        }
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyListEditor.java
100 100
		            Taxon taxon = getItemTaxon(node);
101 101
		            if (taxon != null) {
102 102
		                try {
103
		                    EditorUtil.openTaxonBase((taxon).getUuid());
103
		                    EditorUtil.openTaxonBaseE4((taxon).getUuid());
104 104
		                } catch (PartInitException e) {
105 105
		                    MessagingUtils.error(getClass(), e);
106 106
		                }
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyListItem.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
 */
......
58 58
		// layoutComposite.setBackground(Display.getDefault().getSystemColor(
59 59
		// SWT.COLOR_CYAN));
60 60

  
61
		this.entity = (PolytomousKeyNode) HibernateProxyHelper.deproxy(entity);
61
		this.entity = HibernateProxyHelper.deproxy(entity);
62 62

  
63 63
		Label label_nodeNumber = new Label(getLayoutComposite(), SWT.NULL);
64 64
		label_nodeNumber.setText(getItemNumber());
......
88 88
			linkSelectionListener = new SelectionAdapter() {
89 89
				/*
90 90
				 * (non-Javadoc)
91
				 * 
91
				 *
92 92
				 * @see
93 93
				 * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org
94 94
				 * .eclipse.swt.events.SelectionEvent)
......
99 99

  
100 100
					if (data instanceof Taxon) {
101 101
						try {
102
							EditorUtil.openTaxonBase(((Taxon) data).getUuid());
102
							EditorUtil.openTaxonBaseE4(((Taxon) data).getUuid());
103 103
						} catch (PartInitException e1) {
104 104
							// TODO Auto-generated catch block
105 105
							e1.printStackTrace();
......
172 172

  
173 173
	/*
174 174
	 * (non-Javadoc)
175
	 * 
175
	 *
176 176
	 * @see
177 177
	 * org.eclipse.ui.forms.IFormPart#initialize(org.eclipse.ui.forms.IManagedForm
178 178
	 * )
......
185 185

  
186 186
	/*
187 187
	 * (non-Javadoc)
188
	 * 
188
	 *
189 189
	 * @see org.eclipse.ui.forms.IFormPart#isDirty()
190 190
	 */
191 191
	@Override
......
195 195

  
196 196
	/*
197 197
	 * (non-Javadoc)
198
	 * 
198
	 *
199 199
	 * @see org.eclipse.ui.forms.IFormPart#commit(boolean)
200 200
	 */
201 201
	@Override
......
206 206

  
207 207
	/*
208 208
	 * (non-Javadoc)
209
	 * 
209
	 *
210 210
	 * @see org.eclipse.ui.forms.IFormPart#setFormInput(java.lang.Object)
211 211
	 */
212 212
	@Override
......
217 217

  
218 218
	/*
219 219
	 * (non-Javadoc)
220
	 * 
220
	 *
221 221
	 * @see org.eclipse.ui.forms.IFormPart#setFocus()
222 222
	 */
223 223
	@Override
......
228 228

  
229 229
	/*
230 230
	 * (non-Javadoc)
231
	 * 
231
	 *
232 232
	 * @see org.eclipse.ui.forms.IFormPart#isStale()
233 233
	 */
234 234
	@Override
......
239 239

  
240 240
	/*
241 241
	 * (non-Javadoc)
242
	 * 
242
	 *
243 243
	 * @see org.eclipse.ui.forms.IFormPart#refresh()
244 244
	 */
245 245
	@Override
......
250 250

  
251 251
	/*
252 252
	 * (non-Javadoc)
253
	 * 
253
	 *
254 254
	 * @see org.eclipse.ui.forms.IFormPart#dispose()
255 255
	 */
256 256
	@Override
......
265 265
	public PolytomousKeyNode getEntity() {
266 266
		return entity;
267 267
	}
268
	
268

  
269 269
	@Override
270 270
	public void setSelected(boolean selected) {
271 271
		setBackground(selected ? SELECTED : getPersistentBackground());
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeSynonymToAcceptedTaxonHandler.java
82 82
		// Get taxon
83 83
		Taxon taxon = ((TaxonEditorInput) input).getTaxon();
84 84

  
85
		TaxonNode parentNode = (TaxonNode) HibernateProxyHelper.deproxy(((TaxonEditorInput) input).getTaxonNode().getParent());
85
		TaxonNode parentNode = HibernateProxyHelper.deproxy(((TaxonEditorInput) input).getTaxonNode().getParent());
86 86

  
87 87
		List<UUID> excludeTaxa = new ArrayList<>();
88 88
		//excludeTaxa.add(taxon.getUuid());//there are some cases where the accepted taxon should be the parent of the new created accepted taxon
......
128 128
				 *  CdmStore.getTaxonService().getTaxonNodeByUuid(taxonNodeUuid);
129 129
				 *  doesn't work yet.
130 130
				 */
131
				EditorUtil.openTaxonNode(newNode.getUuid());
131
				EditorUtil.openTaxonBaseE4(newNode.getUuid());
132 132

  
133 133
			} catch (PartInitException e) {
134 134
				// TODO Auto-generated catch block
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/SwapSynonymAndAcceptedHandler.java
107 107
			@Override
108 108
            public void run() {
109 109
				try {
110
					EditorUtil.openTaxonBase(taxon.getUuid());
110
					EditorUtil.openTaxonBaseE4(taxon.getUuid());
111 111

  
112 112
				} catch (Exception e) {
113 113
					MessagingUtils.warningDialog(Messages.SwapSynonymAndAcceptedHandler_COULD_NOT_OPEN, this, e.getMessage());
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/e4/handler/OpenRelatedConceptHandlerE4.java
82 82
     */
83 83
    protected void openConcept(TaxonBase<?> relatedTaxon) {
84 84
        try {
85
            EditorUtil.openTaxonBase(relatedTaxon.getUuid());
85
            EditorUtil.openTaxonBaseE4(relatedTaxon.getUuid());
86 86
        } catch (PartInitException e) {
87 87
            MessagingUtils.messageDialog(Messages.OpenRelatedConceptHandler_COULD_NOT_OPEN, getClass(),
88 88
                    String.format(Messages.OpenRelatedConceptHandler_COULD_NOT_OPEN_MESSAGE ,relatedTaxon), e);
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/handler/OpenRelatedConceptHandler.java
77 77
     */
78 78
    protected void openConcept(TaxonBase<?> relatedTaxon) {
79 79
        try {
80
            EditorUtil.openTaxonBase(relatedTaxon.getUuid());
80
            EditorUtil.openTaxonBaseE4(relatedTaxon.getUuid());
81 81
        } catch (PartInitException e) {
82 82
            MessagingUtils.messageDialog(Messages.OpenRelatedConceptHandler_COULD_NOT_OPEN, getClass(),
83 83
                    String.format(Messages.OpenRelatedConceptHandler_COULD_NOT_OPEN_MESSAGE ,relatedTaxon), e);
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/MoveDescriptionElementsHandler.java
154 154
                    if(possibleOpenEditor != null){
155 155
                        AbstractUtility.close(possibleOpenEditor);
156 156
                    }
157
                    EditorUtil.openTaxonNode(newAcceptedTaxonNodeUuid);
157
                    EditorUtil.openTaxonNodeE4(newAcceptedTaxonNodeUuid);
158 158
                } catch (PartInitException e) {
159 159
                    MessagingUtils.error(this.getClass(), e);
160 160
                    throw new RuntimeException(e);
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/MoveDescriptionToOtherTaxonHandler.java
134 134
                    if(possibleOpenEditor != null){
135 135
                        AbstractUtility.close(possibleOpenEditor);
136 136
                    }
137
                    EditorUtil.openTaxonNode(newAcceptedTaxonNodeUuid);
137
                    EditorUtil.openTaxonNodeE4(newAcceptedTaxonNodeUuid);
138 138
                } catch (PartInitException e) {
139 139
                    MessagingUtils.error(this.getClass(), e);
140 140
                    throw new RuntimeException(e);
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/MoveDescriptionElementsHandler.java
154 154
					if(possibleOpenEditor != null){
155 155
						AbstractUtility.close(possibleOpenEditor);
156 156
					}
157
					EditorUtil.openTaxonNode(newAcceptedTaxonNodeUuid);
157
					EditorUtil.openTaxonBaseE4(newAcceptedTaxonNodeUuid);
158 158
				} catch (PartInitException e) {
159 159
					MessagingUtils.error(this.getClass(), e);
160 160
					throw new RuntimeException(e);
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/MoveDescriptionToOtherTaxonHandler.java
163 163
					if(possibleOpenEditor != null){
164 164
						AbstractUtility.close(possibleOpenEditor);
165 165
					}
166
					EditorUtil.openTaxonNode(newAcceptedTaxonNodeUuid);
166
					EditorUtil.openTaxonBaseE4(newAcceptedTaxonNodeUuid);
167 167
				} catch (PartInitException e) {
168 168
					MessagingUtils.error(this.getClass(), e);
169 169
					throw new RuntimeException(e);
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/NavigationUtil.java
124 124
					openInBulkEditor(taxonBase);
125 125
				}
126 126
				else{
127
					EditorUtil.openTaxonBase(entityUuid);
127
					EditorUtil.openTaxonBaseE4(entityUuid);
128 128
				}
129 129
			}else if(selectedObject instanceof TaxonName){
130 130
				openInBulkEditor(selectedObject);
......
178 178
	 */
179 179
	public static void openEmpty(UUID parentNodeUuid) {
180 180
		try {
181
			EditorUtil.openEmpty(parentNodeUuid);
181
			EditorUtil.openEmptyE4(parentNodeUuid);
182 182
		} catch (PartInitException e) {
183 183
			MessagingUtils.error(NavigationUtil.class, ERROR_OPENING_THE_EDITOR, e);
184 184
		}
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/ChangeAcceptedTaxonToSynonymHandler.java
165 165
					if(possibleOpenEditor != null){
166 166
						EditorUtil.close(possibleOpenEditor);
167 167
					}
168
					EditorUtil.openTaxonNode(newAcceptedTaxonNodeUuid);
168
					EditorUtil.openTaxonNodeE4(newAcceptedTaxonNodeUuid);
169 169
				} catch (PartInitException e) {
170 170
					MessagingUtils.error(this.getClass(), e);
171 171
					throw new RuntimeException(e);
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/MoveFactualDataHandler.java
91 91
                                    AbstractUtility.close(sourceEditor);
92 92
                                    AbstractUtility.close(targetEditor);
93 93
                                }
94
                                EditorUtil.openTaxonNode(sourceTaxonNode.getUuid());
95
                                EditorUtil.openTaxonNode(targetTaxonNode.getUuid());
94
                                EditorUtil.openTaxonNodeE4(sourceTaxonNode.getUuid());
95
                                EditorUtil.openTaxonNodeE4(targetTaxonNode.getUuid());
96 96
                            } catch (PartInitException e) {
97 97
                                MessagingUtils.error(this.getClass(), e);
98 98
                                throw new RuntimeException(e);
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/RemotingMoveFactualDataHandler.java
138 138
                        AbstractUtility.close(sourceEditor);
139 139
                        AbstractUtility.close(targetEditor);
140 140
                    }
141
                    EditorUtil.openTaxonNode(sourceTaxonNode.getUuid());
142
                    EditorUtil.openTaxonNode(targetTaxonNode.getUuid());
141
                    EditorUtil.openTaxonNodeE4(sourceTaxonNode.getUuid());
142
                    EditorUtil.openTaxonNodeE4(targetTaxonNode.getUuid());
143 143
                } catch (PartInitException e) {
144 144
                    MessagingUtils.error(this.getClass(), e);
145 145
                    throw new RuntimeException(e);

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)