Project

General

Profile

« Previous | Next » 

Revision 361d0a66

Added by Niels Hoffmann over 12 years ago

Transfering workplace to new machine

View differences:

eu.etaxonomy.taxeditor.cdmlib/.classpath
3 3
	<classpathentry exported="true" kind="lib" path="lib/cdmlib-commons-3.0.9-SNAPSHOT.jar"/>
4 4
	<classpathentry exported="true" kind="lib" path="lib/cdmlib-ext-3.0.9-SNAPSHOT.jar"/>
5 5
	<classpathentry exported="true" kind="lib" path="lib/cdmlib-io-3.0.9-SNAPSHOT.jar"/>
6
	<classpathentry exported="true" kind="lib" path="lib/cdmlib-model-3.0.9-SNAPSHOT.jar"/>
6
	<classpathentry exported="true" kind="lib" path="lib/cdmlib-model-3.0.9-SNAPSHOT.jar" sourcepath="/Users/n.hoffmann/.m2/repository/eu/etaxonomy/cdmlib-model/3.0.9-SNAPSHOT/cdmlib-model-3.0.9-SNAPSHOT-sources.jar"/>
7 7
	<classpathentry exported="true" kind="lib" path="lib/cdmlib-persistence-3.0.9-SNAPSHOT.jar" sourcepath="/Users/n.hoffmann/.m2/repository/eu/etaxonomy/cdmlib-persistence/3.0.9-SNAPSHOT/cdmlib-persistence-3.0.9-SNAPSHOT-sources.jar"/>
8 8
	<classpathentry exported="true" kind="lib" path="lib/cdmlib-print-3.0.9-SNAPSHOT.jar"/>
9 9
	<classpathentry exported="true" kind="lib" path="lib/cdmlib-remote-3.0.9-SNAPSHOT.jar"/>
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditor.java
1 1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
4
* http://www.e-taxonomy.eu
5
* 
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
2
 * Copyright (C) 2007 EDIT
3
 * European Distributed Institute of Taxonomy 
4
 * http://www.e-taxonomy.eu
5
 * 
6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7
 * See LICENSE.TXT at the top of this package for the full license terms.
8
 */
9 9

  
10 10
package eu.etaxonomy.taxeditor.editor;
11 11

  
......
40 40
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
41 41

  
42 42
/**
43
 *
44
 * Generates the tabbed editor with <code>TaxonNameEditor</code> on top and tabs for
45
 *  "Descriptions", "Concepts", "Geography", etc.
46
 *
43
 * 
44
 * Generates the tabbed editor with <code>TaxonNameEditor</code> on top and tabs
45
 * for "Descriptions", "Concepts", "Geography", etc.
46
 * 
47 47
 * @author p.ciardelli
48 48
 * @author n.hoffmann
49 49
 * @created 15.05.2008
50 50
 * @version 1.0
51 51
 */
52
public class MultiPageTaxonEditor extends FormEditor implements IConversationEnabled, IPostOperationEnabled, IDirtyMarkableSelectionProvider, IPartContentHasDetails {	
52
public class MultiPageTaxonEditor extends FormEditor implements
53
		IConversationEnabled, IPostOperationEnabled,
54
		IDirtyMarkableSelectionProvider, IPartContentHasDetails {
53 55

  
54 56
	/** Constant <code>ID="eu.etaxonomy.taxeditor.editor.taxon"{trunked}</code> */
55 57
	public static final String ID = "eu.etaxonomy.taxeditor.editor.taxon";
......
61 63
	private IUndoContext undoContext;
62 64

  
63 65
	private TaxonEditorInput input;
64
	
66

  
65 67
	/**
66
	 * <p>Constructor for MultiPageTaxonEditor.</p>
68
	 * <p>
69
	 * Constructor for MultiPageTaxonEditor.
70
	 * </p>
67 71
	 */
68 72
	public MultiPageTaxonEditor() {
69
		super();		
73
		super();
70 74
		undoContext = new UndoContext();
71 75
	}
72
	
76

  
73 77
	/** {@inheritDoc} */
74 78
	@Override
75 79
	public void dispose() {
76 80
		conversation.unregisterForDataStoreChanges(this);
77 81
		conversation.close();
78
		super.dispose();		
82
		super.dispose();
79 83
	}
80 84

  
81
	/* (non-Javadoc)
85
	/*
86
	 * (non-Javadoc)
87
	 * 
82 88
	 * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
83 89
	 */
84 90
	/** {@inheritDoc} */
......
87 93
		input = (TaxonEditorInput) getEditorInput();
88 94
		conversation = input.getConversationHolder();
89 95
		conversation.registerForDataStoreChanges(this);
90
		
96

  
91 97
		try {
92
			addPage(Page.NAME.getIndex(), new TaxonNameEditor(this), getEditorInput());
93
//			setPageText(Page.NAME.getIndex(), Page.NAME.getTitle());
94
			
98
			addPage(Page.NAME.getIndex(), new TaxonNameEditor(this),
99
					getEditorInput());
100
			// setPageText(Page.NAME.getIndex(), Page.NAME.getTitle());
101

  
95 102
			// TODO lazy create
96
//			addPage(Page.DESCRIPTIVE.getIndex(), new TaxonDescriptionTreeEditor(this), getEditorInput());
97
//			setPageText(Page.DESCRIPTIVE.getIndex(), Page.DESCRIPTIVE.getTitle());
98
			
99
//			EditorUtil.showPropertySheet();
100
					
103
			// addPage(Page.DESCRIPTIVE.getIndex(), new
104
			// TaxonDescriptionTreeEditor(this), getEditorInput());
105
			// setPageText(Page.DESCRIPTIVE.getIndex(),
106
			// Page.DESCRIPTIVE.getTitle());
107

  
108
			// EditorUtil.showPropertySheet();
109

  
101 110
		} catch (PartInitException e) {
102 111
			EditorUtil.error(getClass(), e);
103 112
		}
104 113
	}
105
	
106
	
114

  
107 115
	/** {@inheritDoc} */
108 116
	@Override
109 117
	public void doSave(IProgressMonitor monitor) {
110 118
		monitor.beginTask("Saving Editor", 4);
111
		try{
112
			if( ! conversation.isBound()){
119
		try {
120
			if (!conversation.isBound()) {
113 121
				conversation.bind();
114 122
			}
115 123
			monitor.worked(1);
116
			
117
			for(IEditorPart editorPage : getPages()){
118
				if(editorPage instanceof TaxonNameEditor){
119
					if(((TaxonNameEditor) editorPage).checkForEmptyNames()){
120
						MessageDialog.openWarning(EditorUtil.getShell(), "No Name Specified", "An attempt was made to save a taxon or synonym with " +
121
						"an empty name. Operation was cancelled.");
124

  
125
			for (IEditorPart editorPage : getPages()) {
126
				if (editorPage instanceof TaxonNameEditor) {
127
					if (((TaxonNameEditor) editorPage).checkForEmptyNames()) {
128
						MessageDialog
129
								.openWarning(
130
										EditorUtil.getShell(),
131
										"No Name Specified",
132
										"An attempt was made to save a taxon or synonym with "
133
												+ "an empty name. Operation was cancelled.");
122 134
						return;
123 135
					}
124 136
				}
125
	
137

  
126 138
				editorPage.doSave(monitor);
127 139
				monitor.worked(1);
128 140
			}
129
			
141

  
130 142
			// commit the conversation and start a new transaction immediately
131 143
			conversation.commit(true);
132 144
			monitor.worked(1);
133
			
145

  
134 146
			this.setDirty(false);
135 147
			monitor.worked(1);
136
		}catch(Exception e){
137
			EditorUtil.errorDialog("An error occurred while saving", getClass(), "An error occurred while saving the editor. Please close and reopen the taxon again.", e);
148
		} catch (Exception e) {
149
			setFocus();
150
			EditorUtil
151
					.errorDialog(
152
							"An error occurred while saving",
153
							getClass(),
154
							"An error occurred while saving the editor. Please close and reopen the taxon again.",
155
							e);
138 156
			disableEditor();
139
		}finally{
157
		} finally {
140 158
			monitor.done();
141 159
		}
142 160
	}
143 161

  
144

  
145 162
	private void disableEditor() {
146
		for(IMultiPageTaxonEditorPage editorPage : getPages()){
163
		for (IMultiPageTaxonEditorPage editorPage : getPages()) {
147 164
			editorPage.setDisabled();
148 165
		}
149 166
		setDirty(false);
150
		getSite().getSelectionProvider().setSelection(new StructuredSelection());
151
		getSite().setSelectionProvider(null);
152 167
	}
153 168

  
154 169
	private void setDirty(boolean dirty) {
155 170
		this.dirty = dirty;
156 171
		firePropertyChange(PROP_DIRTY);
157 172
	}
158
	
159
	/* (non-Javadoc)
173

  
174
	/*
175
	 * (non-Javadoc)
176
	 * 
160 177
	 * @see org.eclipse.ui.part.MultiPageEditorPart#isDirty()
161 178
	 */
162 179
	/**
163
	 * <p>isDirty</p>
164
	 *
180
	 * <p>
181
	 * isDirty
182
	 * </p>
183
	 * 
165 184
	 * @return a boolean.
166 185
	 */
167 186
	public boolean isDirty() {
168 187
		return dirty;
169 188
	}
170 189

  
171
	/* (non-Javadoc)
190
	/*
191
	 * (non-Javadoc)
192
	 * 
172 193
	 * @see org.eclipse.ui.forms.editor.FormEditor#editorDirtyStateChanged()
173 194
	 */
174 195
	/** {@inheritDoc} */
......
177 198
		dirty = true;
178 199
		super.editorDirtyStateChanged();
179 200
	}
180
	
181
	
201

  
182 202
	/**
183 203
	 * {@inheritDoc}
184
	 *
185
	 * Checks whether nested editors are calling <code>firePropertyChange(PROP_DIRTY)</code>
186
	 * to signal an edit has taken place before passing property change along to
204
	 * 
205
	 * Checks whether nested editors are calling
206
	 * <code>firePropertyChange(PROP_DIRTY)</code> to signal an edit has taken
207
	 * place before passing property change along to
187 208
	 * <code>super.handlePropertyChange(int propertyId)</code>.
188 209
	 */
189
	/* (non-Javadoc)
210
	/*
211
	 * (non-Javadoc)
212
	 * 
190 213
	 * @see org.eclipse.ui.part.MultiPageEditorPart#handlePropertyChange(int)
191 214
	 */
192 215
	protected void handlePropertyChange(int propertyId) {
......
195 218
		}
196 219
		super.handlePropertyChange(propertyId);
197 220
	}
198
	
221

  
199 222
	/** {@inheritDoc} */
200 223
	@Override
201
	public void doSaveAs() {}
224
	public void doSaveAs() {
225
	}
202 226

  
203 227
	/** {@inheritDoc} */
204 228
	@Override
......
208 232

  
209 233
	/** {@inheritDoc} */
210 234
	@Override
211
	public void init(IEditorSite site, IEditorInput input) throws PartInitException {
212
		
235
	public void init(IEditorSite site, IEditorInput input)
236
			throws PartInitException {
237

  
213 238
		if (!(input instanceof TaxonEditorInput))
214 239
			throw new PartInitException(
215 240
					"Invalid Input: Must be TaxonEditorInput");
216
		
241

  
217 242
		this.input = (TaxonEditorInput) input;
218 243

  
219
//		try {
220
//			// Listen for name changes, 
221
//			//  change tab for this taxon editor accordingly
222
//			getTaxon().addPropertyChangeListener("name",
223
//					new PropertyChangeListener() {
224
//						public void propertyChange(PropertyChangeEvent e) {
225
//							setPartName();
226
//						}
227
//					});
228
//		} catch (NullPointerException e) {
229
//			EditorUtil.warn(getClass(), "Caught an NPE while initing an editor. This is most " +
230
//					"likely due to the unsuccesful attempt to restore the former " +
231
//					"state of the application. We ignore this because the workbench " +
232
//					"will simply be reset.");
233
//		}
244
		// try {
245
		// // Listen for name changes,
246
		// // change tab for this taxon editor accordingly
247
		// getTaxon().addPropertyChangeListener("name",
248
		// new PropertyChangeListener() {
249
		// public void propertyChange(PropertyChangeEvent e) {
250
		// setPartName();
251
		// }
252
		// });
253
		// } catch (NullPointerException e) {
254
		// EditorUtil.warn(getClass(),
255
		// "Caught an NPE while initing an editor. This is most " +
256
		// "likely due to the unsuccesful attempt to restore the former " +
257
		// "state of the application. We ignore this because the workbench " +
258
		// "will simply be reset.");
259
		// }
234 260
		setPartName();
235
		
261

  
236 262
		super.init(site, input);
237 263
	}
238
		
239
    /**
240
     * Calls <code>MultiPageEditorPart.setPartName(String partName)</code>
241
     *  with text appropriate to the state of the taxon: any taxon that has
242
     *  been saved will by necessity have a name to display; a new taxon
243
     *  should display "New taxon" in the editor tab.
244
     */
245
    protected void setPartName() {
246
        
247
    	String partName = null;
248
    	TaxonNameBase<?, ?> name = getTaxon().getName();
249
    	
250
    	if (name != null) {
251
    		partName = name.getTitleCache();
252
    	}
253
    	
254
    	if (partName == null || partName.equals("")) {
255
    		partName = ("New taxon");
256
    	}
257

  
258
        setPartName(partName);
259
    }
260
    
261
    /**
262
     * {@inheritDoc}
263
     *
264
     * Editor pages call this in their postOperation to notify the MultiPageTaxonEditor
265
     * of unsaved changes
266
     */
267
    public void changed(Object element) {
268
//    	setDirty(true);
264

  
265
	/**
266
	 * Calls <code>MultiPageEditorPart.setPartName(String partName)</code> with
267
	 * text appropriate to the state of the taxon: any taxon that has been saved
268
	 * will by necessity have a name to display; a new taxon should display
269
	 * "New taxon" in the editor tab.
270
	 */
271
	protected void setPartName() {
272

  
273
		String partName = null;
274
		TaxonNameBase<?, ?> name = getTaxon().getName();
275

  
276
		if (name != null) {
277
			partName = name.getTitleCache();
278
		}
279

  
280
		if (partName == null || partName.equals("")) {
281
			partName = ("New taxon");
282
		}
283

  
284
		setPartName(partName);
285
	}
286

  
287
	/**
288
	 * {@inheritDoc}
289
	 * 
290
	 * Editor pages call this in their postOperation to notify the
291
	 * MultiPageTaxonEditor of unsaved changes
292
	 */
293
	public void changed(Object element) {
294
		// setDirty(true);
269 295
		dirty = true;
270 296
		super.editorDirtyStateChanged();
271
		if(element instanceof TaxonBase){
297
		if (element instanceof TaxonBase) {
272 298
			TaxonNameEditor page = (TaxonNameEditor) getPage(Page.NAME);
273
			AbstractGroupedContainer container = page.getContainer((TaxonBase) element);
274
			if(container != null){
299
			AbstractGroupedContainer container = page
300
					.getContainer((TaxonBase) element);
301
			if (container != null) {
275 302
				container.refresh();
276 303
			}
277 304
		}
278
    }
279
    
280
    /**
281
     * The accepted taxon that is the input for this editor
282
     *
283
     * @return the accepted taxon
284
     */
285
    public Taxon getTaxon(){
286
    	return input.getTaxon();
287
    }
288

  
289
    /*
290
     * (non-Javadoc)
291
     * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
292
     */
305
	}
306

  
307
	/**
308
	 * The accepted taxon that is the input for this editor
309
	 * 
310
	 * @return the accepted taxon
311
	 */
312
	public Taxon getTaxon() {
313
		return input.getTaxon();
314
	}
315

  
316
	/*
317
	 * (non-Javadoc)
318
	 * 
319
	 * @see
320
	 * eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder
321
	 * ()
322
	 */
293 323
	/**
294
	 * <p>getConversationHolder</p>
295
	 *
296
	 * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
324
	 * <p>
325
	 * getConversationHolder
326
	 * </p>
327
	 * 
328
	 * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
329
	 *         object.
297 330
	 */
298 331
	public ConversationHolder getConversationHolder() {
299 332
		return conversation;
300 333
	}
301
	
334

  
302 335
	/**
303
	 * <p>setConversationHolder</p>
304
	 *
305
	 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
336
	 * <p>
337
	 * setConversationHolder
338
	 * </p>
339
	 * 
340
	 * @param conversation
341
	 *            a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
342
	 *            object.
306 343
	 */
307
	public void setConversationHolder(ConversationHolder conversation){
344
	public void setConversationHolder(ConversationHolder conversation) {
308 345
		this.conversation = conversation;
309 346
	}
310 347

  
311

  
312 348
	/**
313
	 * <p>Getter for the field <code>undoContext</code>.</p>
314
	 *
315
	 * @return a {@link org.eclipse.core.commands.operations.IUndoContext} object.
349
	 * <p>
350
	 * Getter for the field <code>undoContext</code>.
351
	 * </p>
352
	 * 
353
	 * @return a {@link org.eclipse.core.commands.operations.IUndoContext}
354
	 *         object.
316 355
	 */
317 356
	public IUndoContext getUndoContext() {
318 357
		return undoContext;
319 358
	}
320 359

  
321 360
	/**
322
	 * <p>Setter for the field <code>undoContext</code>.</p>
323
	 *
324
	 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
361
	 * <p>
362
	 * Setter for the field <code>undoContext</code>.
363
	 * </p>
364
	 * 
365
	 * @param undoContext
366
	 *            a {@link org.eclipse.core.commands.operations.IUndoContext}
367
	 *            object.
325 368
	 */
326 369
	public void setUndoContext(IUndoContext undoContext) {
327 370
		this.undoContext = undoContext;
328 371
	}
329
	
372

  
330 373
	/** {@inheritDoc} */
331 374
	@Override
332
	public void setFocus(){
333
		//logger.warn("Setting focus to editor");
375
	public void setFocus() {
376
		// logger.warn("Setting focus to editor");
334 377
		// bind the conversation
335 378
		getConversationHolder().bind();
336 379
		// pass focus to the active editor page
......
339 382

  
340 383
	/*
341 384
	 * (non-Javadoc)
342
	 * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostCrudObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmCrudEvent)
385
	 * 
386
	 * @see
387
	 * eu.etaxonomy.cdm.persistence.hibernate.ICdmPostCrudObserver#update(eu
388
	 * .etaxonomy.cdm.persistence.hibernate.CdmCrudEvent)
343 389
	 */
344 390
	/** {@inheritDoc} */
345 391
	public void update(CdmDataChangeMap events) {
346
		if(dataChangeBehavior == null){
347
			dataChangeBehavior = new MultiPageTaxonEditorDataChangeBehaviour(this);
392
		if (dataChangeBehavior == null) {
393
			dataChangeBehavior = new MultiPageTaxonEditorDataChangeBehaviour(
394
					this);
348 395
		}
349
		
396

  
350 397
		DataChangeBridge.handleDataChange(events, dataChangeBehavior);
351 398
	}
352 399

  
353

  
354 400
	/*
355 401
	 * (non-Javadoc)
356
	 * @see eu.etaxonomy.taxeditor.store.operations.IPostOperationEnabled#postOperation()
402
	 * 
403
	 * @see
404
	 * eu.etaxonomy.taxeditor.store.operations.IPostOperationEnabled#postOperation
405
	 * ()
357 406
	 */
358 407
	/** {@inheritDoc} */
359 408
	public boolean postOperation(CdmBase objectAffectedByOperation) {
360 409
		setDirty(true);
361
		
362
		for(IEditorPart editor : this.getPages()){
410

  
411
		for (IEditorPart editor : this.getPages()) {
363 412
			if (editor instanceof IPostOperationEnabled) {
364
				((IPostOperationEnabled) editor).postOperation(objectAffectedByOperation);
413
				((IPostOperationEnabled) editor)
414
						.postOperation(objectAffectedByOperation);
365 415
			} else {
366
				EditorUtil.warn(getClass(), "postOperation not enabled for editor " + editor);
416
				EditorUtil.warn(getClass(),
417
						"postOperation not enabled for editor " + editor);
367 418
			}
368 419
		}
369
		EditorUtil.warn(getClass(), "postOperation called on MultiPageTaxonEditor. Can you make it more specific?");
370
		
420
		EditorUtil
421
				.warn(getClass(),
422
						"postOperation called on MultiPageTaxonEditor. Can you make it more specific?");
423

  
371 424
		return false;
372 425
	}
373
	
426

  
374 427
	/**
375 428
	 * Returns an <code>IEditorPart</code> implementation by type
376
	 *
377
	 * @param page the page type
378
	 * @return a {@link eu.etaxonomy.taxeditor.editor.IMultiPageTaxonEditorPage} object.
429
	 * 
430
	 * @param page
431
	 *            the page type
432
	 * @return a {@link eu.etaxonomy.taxeditor.editor.IMultiPageTaxonEditorPage}
433
	 *         object.
379 434
	 */
380
	public IMultiPageTaxonEditorPage getPage(Page page){
381
		for(IEditorPart editor : this.getPages()){
382
		 	if(editor.getClass().equals(page.getClazz())){
383
		 		return (IMultiPageTaxonEditorPage) editor;
384
		 	}
435
	public IMultiPageTaxonEditorPage getPage(Page page) {
436
		for (IEditorPart editor : this.getPages()) {
437
			if (editor.getClass().equals(page.getClazz())) {
438
				return (IMultiPageTaxonEditorPage) editor;
439
			}
385 440
		}
386 441
		return null;
387 442
	}
388
	
443

  
389 444
	/**
390 445
	 * Return a list of <code>AbstractTaxonEditor</code>s registered with this
391 446
	 * <code>MultiPageTaxonEditor</code>.
392
	 *
447
	 * 
393 448
	 * @return a {@link java.util.List} object.
394 449
	 */
395
	public List<IMultiPageTaxonEditorPage> getPages(){
450
	public List<IMultiPageTaxonEditorPage> getPages() {
396 451
		ArrayList<IMultiPageTaxonEditorPage> editors = new ArrayList<IMultiPageTaxonEditorPage>();
397
		for(int i = 0; i < this.getPageCount(); i++){
398
			
399
		 	editors.add((IMultiPageTaxonEditorPage) this.getEditor(i));
452
		for (int i = 0; i < this.getPageCount(); i++) {
453

  
454
			editors.add((IMultiPageTaxonEditorPage) this.getEditor(i));
400 455
		}
401 456
		return editors;
402 457
	}
403
	
458

  
404 459
	/**
405 460
	 * Refreshes a certain page of the MultipageTaxonEditor
406
	 *
407
	 * @param page a {@link eu.etaxonomy.taxeditor.editor.Page} object.
461
	 * 
462
	 * @param page
463
	 *            a {@link eu.etaxonomy.taxeditor.editor.Page} object.
408 464
	 * @return a boolean.
409 465
	 */
410
	public boolean redraw(Page page){
466
	public boolean redraw(Page page) {
411 467
		return redraw(page, true);
412 468
	}
413
	
469

  
414 470
	/**
415
	 * Refreshes a certain page of the MultipageTaxonEditor and
416
	 * sets focus to that page
417
	 *
418
	 * @param page a {@link eu.etaxonomy.taxeditor.editor.Page} object.
419
	 * @param focus a boolean.
471
	 * Refreshes a certain page of the MultipageTaxonEditor and sets focus to
472
	 * that page
473
	 * 
474
	 * @param page
475
	 *            a {@link eu.etaxonomy.taxeditor.editor.Page} object.
476
	 * @param focus
477
	 *            a boolean.
420 478
	 * @return a boolean.
421 479
	 */
422
	public boolean redraw(Page page, boolean focus){
480
	public boolean redraw(Page page, boolean focus) {
423 481
		IMultiPageTaxonEditorPage editorPage = getPage(page);
424 482
		return editorPage != null && editorPage.redraw(focus);
425 483
	}
426 484

  
427 485
	/**
428
	 * <p>onComplete</p>
429
	 *
486
	 * <p>
487
	 * onComplete
488
	 * </p>
489
	 * 
430 490
	 * @return a boolean.
431 491
	 */
432 492
	public boolean onComplete() {
......
434 494
	}
435 495

  
436 496
	/**
437
	 * Reloads the data for this 
497
	 * Reloads the data for this
438 498
	 */
439 499
	public void reload() {
440
		if(isDirty()){
441
			EditorUtil.warningDialog("Editor has unsaved data", getClass(), "This editor can not be " +
442
					"refreshed because it contains unsaved data. Refreshing " +
443
					"this editor would discard the changes. Please save this editor, " +
444
					"close and reopen it manually in order to get the latest content");
445
		}else{
500
		if (isDirty()) {
501
			EditorUtil
502
					.warningDialog(
503
							"Editor has unsaved data",
504
							getClass(),
505
							"This editor can not be "
506
									+ "refreshed because it contains unsaved data. Refreshing "
507
									+ "this editor would discard the changes. Please save this editor, "
508
									+ "close and reopen it manually in order to get the latest content");
509
		} else {
446 510
			TaxonEditorInput input = (TaxonEditorInput) getEditorInput();
447
			
511

  
448 512
			UUID uuid = input.getTaxonNode().getUuid();
449
			
513

  
450 514
			conversation.clear();
451
			
515

  
452 516
			try {
453 517
				TaxonEditorInput newInput = TaxonEditorInput.NewInstance(uuid);
454 518
				setInput(newInput);
455
				for(IMultiPageTaxonEditorPage editorPart : getPages()){
519
				for (IMultiPageTaxonEditorPage editorPart : getPages()) {
456 520
					editorPart.redraw();
457 521
				}
458 522
			} catch (Exception e) {
459
				EditorUtil.errorDialog("Error refreshing editor", getClass(), "Could not refresh this editor", e);
523
				EditorUtil.errorDialog("Error refreshing editor", getClass(),
524
						"Could not refresh this editor", e);
460 525
			}
461 526
		}
462 527
	}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/SimpleSelectionProvider.java
9 9

  
10 10
package eu.etaxonomy.taxeditor.editor;
11 11

  
12
import java.util.HashSet;
13
import java.util.Set;
14

  
12 15
import org.eclipse.core.runtime.IProgressMonitor;
13 16
import org.eclipse.core.runtime.IStatus;
14
import org.eclipse.core.runtime.ListenerList;
15 17
import org.eclipse.core.runtime.Status;
16 18
import org.eclipse.core.runtime.jobs.Job;
17 19
import org.eclipse.jface.util.SafeRunnable;
......
32 34
 */
33 35
public class SimpleSelectionProvider implements ISelectionProvider {
34 36

  
35
	private ListenerList selectionChangedListeners = new ListenerList();
37
	private Set<ISelectionChangedListener> selectionChangedListeners = new HashSet<ISelectionChangedListener>();
36 38
	private ISelection selection;
37 39
	private Job job;
38 40
	
......
84 86
		
85 87
		// cancel previous selection setting
86 88
		if(job != null){
87
			job.cancel();
89
			if(job.getState() != Job.NONE){
90
				job.cancel();
91
			}
88 92
			job = null;
89 93
		}
90 94
		
......
101 105
						display.asyncExec(new Runnable() {
102 106
					 
103 107
							public void run() {
104
								fireSelectionChanged(selectionChangedEvent);
108
								SimpleSelectionProvider.this.fireSelectionChanged(selectionChangedEvent);
105 109
							}
106 110
						});
107 111
					}
......
119 123

  
120 124
	private void fireSelectionChanged(final SelectionChangedEvent event) {
121 125
		
122
		Object[] listeners = selectionChangedListeners.getListeners();
123
		for (int i = 0; i < listeners.length; ++i) {
124
			final ISelectionChangedListener l = (ISelectionChangedListener) listeners[i];
126
		for (final ISelectionChangedListener listener : selectionChangedListeners) {
125 127
			SafeRunnable.run(new SafeRunnable() {
126 128
				public void run() {
127
					l.selectionChanged(event);
129
					listener.selectionChanged(event);
128 130
				}
129 131
			});
130 132
		}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/TaxonNameEditor.java
98 98
	private ManagedForm managedForm;
99 99
	private ScrolledForm scrolledForm;
100 100
	private Composite parent;
101
	private ISelectionProvider selectionProvider;
101
	private ISelectionProvider simpleSelectionProvider;
102 102

  
103 103
	private final MultiPageTaxonEditor editor;
104 104

  
......
191 191
				if (input instanceof AbstractGroupedContainer) {
192 192
					selection = ((AbstractGroupedContainer) input).getData();
193 193
					getSite().getSelectionProvider().setSelection(new StructuredSelection(selection));
194
				}else if(input == null){
195
					selection = null;
196
					getSite().getSelectionProvider().setSelection(new StructuredSelection());
194 197
				}
198
				
199
				
195 200
				return super.setInput(input);
196 201
			}
197 202
		};
......
493 498
		setSite(site);
494 499
		setInput(input);
495 500

  
496
		selectionProvider = new SimpleSelectionProvider();
497
		getSite().setSelectionProvider(selectionProvider);
501
		simpleSelectionProvider = new SimpleSelectionProvider();
502
		getSite().setSelectionProvider(simpleSelectionProvider);
498 503
	}
499 504

  
500 505
	/**
......
918 923
		}
919 924
		
920 925
		// send an empty selection to the current provider
921
		selectionProvider.setSelection(new StructuredSelection());
922
		
923
		// decide on the new selection provider
924
		
925
		ISelectionProvider newSelectionProvider = enabled ? selectionProvider : new ISelectionProvider() {
926
			
927
			@Override
928
			public void setSelection(ISelection selection) {
929
				
930
			}
931
			
932
			@Override
933
			public void removeSelectionChangedListener(
934
					ISelectionChangedListener listener) {
935
				
936
			}
937
			
938
			@Override
939
			public ISelection getSelection() {
940
				return null;
941
			}
942
			
943
			@Override
944
			public void addSelectionChangedListener(ISelectionChangedListener listener) {
945
				
946
			}
947
		};
948
		
949
		getSite().setSelectionProvider(newSelectionProvider);
950
		
951
		System.out.println("SELECTION PROVIDER" + getSite().getSelectionProvider());
926
		getManagedForm().setInput(null);
952 927
	}
953 928
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/AbstractCdmEditorViewPart.java
33 33

  
34 34
		super.createPartControl(parent);
35 35

  
36
		// show viewer if there is an open editor
37
		// if(getEditor() != null){
38
		// showViewer(getEditor(), new StructuredSelection(getInitialInput()));
39
		// }
40 36
	}
41 37

  
42 38
	/**

Also available in: Unified diff