Project

General

Profile

Revision eb00c1c9

IDeb00c1c9cb49f33f269dc5a087b7c1842982c6e0
Parent fb2eefea
Child 6400c878

Added by Andreas Müller over 7 years ago

fix delete problem for open MultiPageEditors

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditorDataChangeBehaviour.java
75 75
	
76 76
	
77 77
	/** {@inheritDoc} */
78
	//we do not really need this anymore as closing the editors is 
79
	//now run before the delete operation in DeleteHandler
78 80
	@Override
79 81
	public void reactOnDelete(Vector<CdmDataChangeEvent> events){
80 82
		for(CdmDataChangeEvent event : events){
81 83
			// close open editors
82
			if(event.getEntity() instanceof TaxonNode){
83
				logger.warn("taxon node");
84
			}
85 84
			if((event.getEntity() instanceof TaxonNode) 
86 85
					&& input.getTaxonNode().equals(event.getEntity())){
87 86
				EditorUtil.close(source);
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/DeleteHandler.java
77 77

  
78 78
		AbstractPostOperation operation = null;
79 79
		try {
80
			operation = new DeleteOperation(
81
					event.getCommand().getName(), NavigationUtil.getUndoContext(),
82
					treeNodes, taxonNavigator, taxonNavigator);
83 80

  
84
			IStatus status = NavigationUtil.executeOperation(operation);
85 81

  
86

  
87
			// FIXME is there a better place for this code?
88
			if (status == Status.OK_STATUS){
89
				for (ITaxonTreeNode treeNode : treeNodes){
90
					if(treeNode instanceof TaxonNode) {
91
						closeObsoleteEditor((TaxonNode) treeNode);
92
					}
82
			boolean allEditorsClosed = true;
83
			for (ITaxonTreeNode treeNode : treeNodes){
84
				if(treeNode instanceof TaxonNode) {
85
					allEditorsClosed &= closeObsoleteEditor((TaxonNode) treeNode);
93 86
				}
94 87
			}
95 88

  
89
			if (allEditorsClosed){
90
				operation = new DeleteOperation(
91
						event.getCommand().getName(), NavigationUtil.getUndoContext(),
92
						treeNodes, taxonNavigator, taxonNavigator);
93
	
94
				NavigationUtil.executeOperation(operation);
95
			}
96

  
97
	
98

  
96 99
		} catch (NotDefinedException e) {
97 100
			NavigationUtil.warn(getClass(), "Command name not set");
98 101
		}
99 102
		return null;
100 103
	}
101 104

  
102
	private void closeObsoleteEditor(TaxonNode taxonNode){
105
	private boolean closeObsoleteEditor(TaxonNode taxonNode){
106
		boolean result = true;
103 107
		for (IEditorReference ref : activePage.getEditorReferences()) {
104 108
			try {
105 109
				IEditorInput input = ref.getEditorInput();
106 110
				if (input instanceof TaxonEditorInput) {
107 111
					TaxonNode node = ((TaxonEditorInput) input).getTaxonNode();
108 112
					if (taxonNode.equals(node)) {
109
						activePage.closeEditor(ref.getEditor(false), false);
113
						result &= activePage.closeEditor(ref.getEditor(false), true);
110 114
					}
111 115
				}
112 116
			} catch (PartInitException e) {
113 117
				continue;
114 118
			}
115 119
		}
120
		return result;
116 121
	}
117 122
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/dnd/CdmAuthorityTableDropTargetListener.java
8 8
*/
9 9
package eu.etaxonomy.taxeditor.dnd;
10 10

  
11
import java.awt.Cursor;
12
import java.util.EnumSet;
13

  
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.dnd.DND;
16 11
import org.eclipse.swt.dnd.DropTargetEvent;
17 12
import org.eclipse.swt.dnd.DropTargetListener;
18 13

  
19 14
import eu.etaxonomy.cdm.model.common.CdmBase;
20
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
21
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
22
import eu.etaxonomy.cdm.persistence.hibernate.permission.CdmAuthority;
23 15
import eu.etaxonomy.taxeditor.dnd.transfer.TaxonNodeTransfer;
24 16
import eu.etaxonomy.taxeditor.ui.group.grantedauthority.CdmAuthorityComposite;
25 17
import eu.etaxonomy.taxeditor.ui.group.grantedauthority.CdmAuthorityCompositeViewer;
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonBaseDetailElement.java
56 56
	 * </p>
57 57
	 *
58 58
	 * @param cdmFormFactory
59
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
60
	 *            object.
59
	 *        a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
61 60
	 * @param formElement
62
	 *            a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
63
	 *            object.
61
	 *        a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
64 62
	 * @param style
65
	 *            a int.
63
	 *        a int.
66 64
	 */
67 65
	public TaxonBaseDetailElement(CdmFormFactory cdmFormFactory,
68 66
			ICdmFormElement formElement, int style) {
......
95 93
			checkbox_unplaced = formFactory.createCheckbox(formElement,
96 94
					"Taxon is unplaced", ((Taxon) entity).isUnplaced(), style);
97 95
		}
96
		
97
		checkbox_doubtful = formFactory.createCheckbox(formElement,
98
				entity.getClass().getSimpleName() + " is doubtful", entity.isDoubtful(), style);
99
		
98 100
		checkbox_published = formFactory.createCheckbox(formElement,
99 101
		        "Taxon is published", ((Taxon) entity).isPublish(), style);
100 102

  
101
		checkbox_doubtful = formFactory.createCheckbox(formElement,
102
				entity.getClass().getSimpleName() + " is doubtful", entity.isDoubtful(), style);
103 103
	}
104 104

  
105 105
	/** {@inheritDoc} */

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)