Project

General

Profile

« Previous | Next » 

Revision 662c457c

Added by Cherian Mathew about 9 years ago

merge from trunk

View differences:

eu.etaxonomy.taxeditor.bulkeditor/plugin.xml
39 39
         <menu
40 40
               id="bulkeditor.menus.openmenu"
41 41
               label="%menu.label">
42
            <visibleWhen
43
                  checkEnabled="true">
44
               <reference
45
                     definitionId="isCdmStoreConnected">
46
               </reference>
47
            </visibleWhen>
42 48
         </menu>
43 49
         <menu
44 50
               label="%menu.label.0">
51
            <visibleWhen
52
                  checkEnabled="true">
53
               <reference
54
                     definitionId="isCdmStoreConnected">
55
               </reference>
56
            </visibleWhen>
45 57
         </menu>
46 58
      </menuContribution>
47 59
      <menuContribution
......
49 61
         <dynamic
50 62
               class="eu.etaxonomy.taxeditor.bulkeditor.command.OpenBulkEditorContributionItem"
51 63
               id="taxeditor-bulkeditor.dynamicopenmenu">
64
            <visibleWhen
65
                  checkEnabled="true">
66
               <reference
67
                     definitionId="isCdmStoreConnected">
68
               </reference>
69
            </visibleWhen>
52 70
         </dynamic>
53 71
         <!--command
54 72
               commandId="taxeditor-nameeditor.commands.open"
......
69 87
            <dynamic
70 88
                  class="eu.etaxonomy.taxeditor.bulkeditor.command.DynamicNewObjectMenu"
71 89
                  id="eu.etaxonomy.taxeditor.bulkeditor.dynamicNewMenu">
90
               <visibleWhen
91
                     checkEnabled="false">
92
                  <reference
93
                        definitionId="isCdmStoreConnected">
94
                  </reference>
95
               </visibleWhen>
72 96
            </dynamic>
97
            <visibleWhen
98
                  checkEnabled="true">
99
               <reference
100
                     definitionId="isCdmStoreConnected">
101
               </reference>
102
            </visibleWhen>
73 103
         </menu>
74 104
         <separator
75 105
               name="taxeditor-bulkeditor.separator1"
......
127 157
                  class="eu.etaxonomy.taxeditor.bulkeditor.command.DynamicMarkerTypeEditingMenu"
128 158
                  id="eu.etaxonomy.taxeditor.bulkeditor.dynamicMarkerTypeEditingMenu">
129 159
            </dynamic>
160
            <visibleWhen
161
                  checkEnabled="true">
162
               <reference
163
                     definitionId="isCdmStoreConnected">
164
               </reference>
165
            </visibleWhen>
130 166
         </menu>
131 167
         <separator
132 168
               name="taxeditor-bulkeditor.separator3"
......
136 172
               commandId="org.eclipse.ui.edit.delete"
137 173
               label="Delete"
138 174
               style="push">
175
            <visibleWhen
176
                  checkEnabled="true">
177
               <reference
178
                     definitionId="isCdmStoreConnected">
179
               </reference>
180
            </visibleWhen>
139 181
         </command>
140 182
      </menuContribution>
141 183
   </extension>
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/DeleteTaxonBaseHandler.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
*/
......
16 16
import org.eclipse.jface.dialogs.MessageDialog;
17 17
import org.eclipse.swt.widgets.Display;
18 18
import org.eclipse.ui.IWorkbenchPage;
19
import org.eclipse.ui.PartInitException;
20 19
import org.eclipse.ui.handlers.HandlerUtil;
21 20

  
21
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
22 22
import eu.etaxonomy.cdm.model.common.CdmBase;
23 23
import eu.etaxonomy.cdm.model.taxon.Synonym;
24 24
import eu.etaxonomy.cdm.model.taxon.Taxon;
25 25
import eu.etaxonomy.taxeditor.editor.EditorUtil;
26
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
27 26
import eu.etaxonomy.taxeditor.editor.Page;
28 27
import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
29 28
import eu.etaxonomy.taxeditor.editor.name.operation.DeleteMisapplicationOperation;
30 29
import eu.etaxonomy.taxeditor.editor.name.operation.DeleteSynonymOperation;
31 30
import eu.etaxonomy.taxeditor.editor.name.operation.DeleteTaxonOperation;
31
import eu.etaxonomy.taxeditor.model.AbstractUtility;
32 32
import eu.etaxonomy.taxeditor.model.MessagingUtils;
33 33
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
34 34
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
......
47 47
	 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
48 48
	 */
49 49
	/** {@inheritDoc} */
50
	public Object execute(ExecutionEvent event) throws ExecutionException {
50
	@Override
51
    public Object execute(ExecutionEvent event) throws ExecutionException {
51 52
		editor = (TaxonNameEditor) EditorUtil.getActiveEditorPage(Page.NAME);
52
				
53

  
53 54
		Object selectedElement = EditorUtil.getSelection(event).getFirstElement();
54
		
55

  
55 56
		doExecute(event, editor, selectedElement);
56
		
57

  
57 58
		return null;
58 59
	}
59
	
60

  
60 61
	/**
61 62
	 * @param editor
62 63
	 * @param selectedElement
......
65 66
	 */
66 67
	protected void doExecute(ExecutionEvent event, TaxonNameEditor editor, Object selectedElement) {
67 68
		AbstractPostOperation operation = null;
68
		String commandName = null;		
69
		String commandName = null;
69 70

  
70 71
		try {
71 72
			commandName = event.getCommand().getName();
72 73
		} catch (NotDefinedException e) {
73 74
			MessagingUtils.error(getClass(), e);
74 75
		}
75
		
76

  
76 77
		// synonym
77 78
		if(selectedElement instanceof Synonym){
78 79
			operation = new DeleteSynonymOperation(commandName, editor.getUndoContext(), editor.getTaxon(), (Synonym) selectedElement, editor);
......
87 88
			if(! MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Confirm Deletion", "Are you sure you want to delete the selected taxon?")){
88 89
				return ;
89 90
			}
91

  
90 92
			IWorkbenchPage activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
91
			
92
			operation = new DeleteTaxonOperation(commandName, editor.getUndoContext(),(Taxon) selectedElement, null, activePage, this, editor);
93

  
94
			operation = new DeleteTaxonOperation(commandName, editor.getUndoContext(),(Taxon) selectedElement, new TaxonDeletionConfigurator(), null, activePage, this, editor);
93 95
			//editor.dispose();
94
			
96

  
95 97
		}
96 98
		else {
97 99
			throw new IllegalArgumentException("Element has to be Synonym, Misapplication or Concept");
98 100
		}
99
				
100
		EditorUtil.executeOperation(operation);
101
		
102
		
103
		
104
		
101

  
102
		AbstractUtility.executeOperation(operation);
105 103
	}
106 104

  
107 105
	@Override
108 106
	public boolean postOperation(CdmBase objectAffectedByOperation) {
109 107
		Display.getDefault().asyncExec(new Runnable(){
110 108

  
111
			public void run() {
112
				EditorUtil.close(editor.getMultiPageTaxonEditor());
113
					
109
			@Override
110
            public void run() {
111
				AbstractUtility.close(editor.getMultiPageTaxonEditor());
114 112
			}
115
			
116 113
		});
117
		
118
		
119 114
		return true;
120 115
	}
121 116

  
......
124 119
		// TODO Auto-generated method stub
125 120
		return false;
126 121
	}
127
	
128
	
122

  
129 123
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteTaxonBaseOperation.java
5 5
import org.eclipse.core.runtime.IAdaptable;
6 6
import org.eclipse.core.runtime.IProgressMonitor;
7 7
import org.eclipse.core.runtime.IStatus;
8
import org.eclipse.ui.IEditorInput;
9
import org.eclipse.ui.IEditorReference;
10
import org.eclipse.ui.IPerspectiveDescriptor;
11
import org.eclipse.ui.IViewPart;
12 8
import org.eclipse.ui.IWorkbenchPage;
13
import org.eclipse.ui.PartInitException;
14 9

  
15 10
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
16
import eu.etaxonomy.cdm.model.taxon.Taxon;
17
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
18
import eu.etaxonomy.taxeditor.editor.EditorUtil;
19
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
11
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
20 12
import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation;
21 13
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
22 14

  
23 15
public class DeleteTaxonBaseOperation extends AbstractPersistentPostOperation {
24
	
25
	private IWorkbenchPage activePage;
26
	
16

  
17
	protected TaxonDeletionConfigurator configurator;
18

  
27 19
	public DeleteTaxonBaseOperation(String label, IUndoContext undoContext,
28
			Taxon taxon, IWorkbenchPage activePage, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) {
20
	        TaxonDeletionConfigurator configurator, IWorkbenchPage activePage, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) {
29 21
		super(label, undoContext, postOperationEnabled,
30 22
				 conversationEnabled);
31
		this.activePage = activePage;
32
		
23
		this.configurator = configurator;
24

  
33 25
	}
34 26

  
35 27
	@Override
......
52 44
		// TODO Auto-generated method stub
53 45
		return null;
54 46
	}
55
	
56
	protected void closeObsoleteEditor(Taxon taxon){
57
		for (IEditorReference ref : activePage.getEditorReferences()) {
58
			
59
			IViewPart view =  activePage.findView("eu.etaxonomy.taxeditor.navigation.navigator");
60
		
61
			try {
62
				IEditorInput input = ref.getEditorInput(); 
63
				if (input instanceof TaxonEditorInput) {
64
					TaxonNode node = ((TaxonEditorInput) input).getTaxonNode();
65
					if (taxonNode.equals(node)) {
66
						activePage.closeEditor(ref.getEditor(false), false);
67
					}
68
				}
69
			} catch (PartInitException e) {
70
				continue;
71
			}
72
		}
73
	}
74 47
}
75

  
76

  
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteTaxonOperation.java
23 23
import eu.etaxonomy.taxeditor.store.CdmStore;
24 24

  
25 25
public class DeleteTaxonOperation extends DeleteTaxonBaseOperation{
26
	//private Taxon taxon;
27
	private final Classification classification;
28

  
29

  
30 26

  
27
    private final Classification classification;
31 28

  
32 29
	public DeleteTaxonOperation(String label, IUndoContext undoContext,
33
			Taxon taxon, Classification classification, IWorkbenchPage activePage, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) {
34
		super(label, undoContext, taxon, activePage, postOperationEnabled, conversationEnabled);
30
			Taxon taxon, TaxonDeletionConfigurator configurator, Classification classification, IWorkbenchPage activePage, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) {
31
		super(label, undoContext, configurator, activePage, postOperationEnabled, conversationEnabled);
35 32
		this.element = taxon;
36 33

  
37 34
		Set<TaxonNode> nodes = taxon.getTaxonNodes();
......
52 49

  
53 50
	}
54 51

  
55

  
56

  
57 52
	@Override
58 53
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
59 54
			throws ExecutionException {
......
64 59

  
65 60
				ICdmApplicationConfiguration controller;
66 61

  
67
				controller = (ICdmApplicationConfiguration) CdmStore.getCurrentApplicationConfiguration();
62
				controller = CdmStore.getCurrentApplicationConfiguration();
68 63

  
69 64
				ITaxonService service = controller.getTaxonService();
70
				
71 65

  
72
				DeleteResult result =	service.deleteTaxon(element, new TaxonDeletionConfigurator(), classification);
66

  
67
				DeleteResult result =	service.deleteTaxon(element, configurator, classification);
73 68
				if (result.isError()){
74 69
					MessageDialog.openError(null, "Delete failed", result.getExceptions().get(0).getMessage());
75 70
				}
76 71

  
77
				//closeObsoleteEditor(taxon);
78 72
				monitor.worked(40);
79 73

  
80 74

  
......
95 89
		return null;
96 90
	}
97 91

  
98

  
99
}
92
}
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/MoveFactualDataHandler.java
100 100
                        CdmStore.getService(IDescriptionService.class).saveOrUpdate(description);
101 101
                        navigator.getConversationHolder().bind();
102 102
                        navigator.getConversationHolder().commit();
103
                    }
103 104

  
104
                        Display.getDefault().asyncExec(new Runnable(){
105
                    Display.getDefault().asyncExec(new Runnable(){
105 106

  
106
                            @Override
107
                            public void run() {
108
                                try {
109
                                    //close and re-open to refresh factual data view
110
                                    MultiPageTaxonEditor sourceEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(sourceTaxonNode.getUuid());
111
                                    MultiPageTaxonEditor targetEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(targetTaxonNode.getUuid());
112
                                    if(targetEditor != null){
113
                                        AbstractUtility.close(sourceEditor);
114
                                        AbstractUtility.close(targetEditor);
115
                                    }
116
                                    EditorUtil.openTaxonNode(sourceTaxonNode.getUuid());
117
                                    EditorUtil.openTaxonNode(targetTaxonNode.getUuid());
118
                                } catch (PartInitException e) {
119
                                    MessagingUtils.error(this.getClass(), e);
120
                                    throw new RuntimeException(e);
121
                                } catch (Exception e) {
122
                                    MessagingUtils.warningDialog("Could not create Taxon", this, e.getMessage());
107
                        @Override
108
                        public void run() {
109
                            try {
110
                                //close and re-open to refresh factual data view
111
                                MultiPageTaxonEditor sourceEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(sourceTaxonNode.getUuid());
112
                                MultiPageTaxonEditor targetEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(targetTaxonNode.getUuid());
113
                                if(targetEditor != null){
114
                                    AbstractUtility.close(sourceEditor);
115
                                    AbstractUtility.close(targetEditor);
123 116
                                }
117
                                EditorUtil.openTaxonNode(sourceTaxonNode.getUuid());
118
                                EditorUtil.openTaxonNode(targetTaxonNode.getUuid());
119
                            } catch (PartInitException e) {
120
                                MessagingUtils.error(this.getClass(), e);
121
                                throw new RuntimeException(e);
122
                            } catch (Exception e) {
123
                                MessagingUtils.warningDialog("Could not create Taxon", this, e.getMessage());
124 124
                            }
125
                        }
125 126

  
126
                        });
127
                    }
127
                    });
128 128
                }
129 129
            }
130 130
        }

Also available in: Unified diff