Project

General

Profile

Revision 595bbde7

ID595bbde7996001971d867805fc62df29911503e1
Parent 8c9c3c81
Child 5ec2e7d4

Added by Patrick Plitzner almost 2 years ago

ref #6913 Remove descriptive and uses view

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveViewPart.java
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
*/
9

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

  
12
import java.util.HashMap;
13
import java.util.Map;
14

  
15
import org.eclipse.jface.action.Action;
16
import org.eclipse.jface.action.GroupMarker;
17
import org.eclipse.jface.action.IAction;
18
import org.eclipse.jface.action.IToolBarManager;
19
import org.eclipse.jface.action.MenuManager;
20
import org.eclipse.jface.resource.ImageDescriptor;
21
import org.eclipse.jface.viewers.ISelection;
22
import org.eclipse.jface.viewers.IStructuredSelection;
23
import org.eclipse.jface.viewers.ITreeContentProvider;
24
import org.eclipse.jface.viewers.StructuredSelection;
25
import org.eclipse.jface.viewers.TreeNode;
26
import org.eclipse.jface.viewers.TreeViewer;
27
import org.eclipse.jface.viewers.Viewer;
28
import org.eclipse.swt.SWT;
29
import org.eclipse.swt.dnd.DND;
30
import org.eclipse.swt.dnd.Transfer;
31
import org.eclipse.swt.graphics.ImageData;
32
import org.eclipse.swt.widgets.Composite;
33
import org.eclipse.swt.widgets.Control;
34
import org.eclipse.swt.widgets.Menu;
35
import org.eclipse.swt.widgets.Tree;
36
import org.eclipse.ui.IWorkbenchActionConstants;
37
import org.eclipse.ui.IWorkbenchPart;
38
import org.eclipse.ui.internal.E4PartWrapper;
39

  
40
import eu.etaxonomy.cdm.model.common.CdmBase;
41
import eu.etaxonomy.cdm.model.description.DescriptionBase;
42
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
43
import eu.etaxonomy.cdm.model.description.IDescribable;
44
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
45
import eu.etaxonomy.cdm.model.taxon.Taxon;
46
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
47
import eu.etaxonomy.taxeditor.editor.EditorUtil;
48
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
49
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
50
import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditor;
51
import eu.etaxonomy.taxeditor.editor.view.media.e4.MediaViewPartE4;
52
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
53
import eu.etaxonomy.taxeditor.model.FeatureNodeContainerTree;
54
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
55
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
56
import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
57
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
58
import eu.etaxonomy.taxeditor.model.ImageResources;
59
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
60
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
61

  
62
/**
63
 * @author n.hoffmann
64
 * @created Jun 9, 2010
65
 * @version 1.0
66
 */
67
public class DescriptiveViewPart extends AbstractCdmEditorViewPart implements IPartContentHasDetails, IPartContentHasSupplementalData {
68

  
69
	/** Constant <code>ID="eu.etaxonomy.taxeditor.editor.view.desc"{trunked}</code> */
70
	public static final String ID = "eu.etaxonomy.taxeditor.editor.view.descriptive"; //$NON-NLS-1$
71

  
72
	protected TreeViewer viewer;
73

  
74
	/**
75
	 * Maps {@link FeatureNodeContainerTree} to their corresponding {@link TaxonDescritpion}.<br>
76
	 * This serves as input for the {@link ITreeContentProvider} of the {@link TreeViewer}
77
	 */
78
	protected Map<DescriptionBase<?>, FeatureNodeContainerTree> featureNodeContainerCache = new HashMap<DescriptionBase<?>, FeatureNodeContainerTree>();
79

  
80
	protected ToggleDescriptionAction showAllElementsAction;
81

  
82
	protected ToggleDescriptionAction hideAllElementsAction;
83

  
84
	protected int dndOperations = DND.DROP_COPY | DND.DROP_MOVE;
85

  
86
    private DescriptiveContentProvider provider;
87

  
88
	/** {@inheritDoc} */
89
	@Override
90
	public void createViewer(Composite parent) {
91
		viewer = new TreeViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL
92
				| SWT.V_SCROLL | SWT.FULL_SELECTION));
93
		provider = new DescriptiveContentProvider(featureNodeContainerCache);
94
        viewer.setContentProvider(provider);
95
		viewer.setLabelProvider(new DescriptiveLabelProvider());
96
		viewer.setSorter(new DescriptiveViewerSorter());
97
		viewer.setAutoExpandLevel(2);
98
		Transfer[] transfers = new Transfer[] { DescriptionElementTransfer.getInstance() };
99
//		viewer.addDragSupport(dndOperations, transfers, new DescriptionElementDragListener(
100
//				this));
101
//		viewer.addDropSupport(dndOperations, transfers,
102
//				new DescriptionElementDropAdapter(viewer));
103

  
104
		// Propagate selection from viewer
105
		getSite().setSelectionProvider(viewer);
106

  
107
		showAllElementsAction = new ToggleDescriptionAction(false);
108
		hideAllElementsAction = new ToggleDescriptionAction(true);
109

  
110
		// Add context menu to tree
111
		createMenu();
112

  
113
		createToolbar();
114

  
115
	}
116

  
117
	/** {@inheritDoc} */
118
	@Override
119
	protected ISelection getInitialSelection() {
120
//		if(getEditor() != null){
121
//			return new StructuredSelection(getEditor().getEditorInput());
122
//		}
123

  
124
		return super.getInitialSelection();
125
	}
126

  
127
	protected void createToolbar() {
128
		IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager();
129
		toolBarManager.add(showAllElementsAction);
130
		toolBarManager.add(hideAllElementsAction);
131
	}
132

  
133
	/*
134
	 * TODO add to the views menu
135
	 */
136
	protected void createMenu(){
137
		MenuManager menuManager = new MenuManager();
138
		menuManager.setRemoveAllWhenShown(true);
139
		menuManager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
140

  
141
		getSite().registerContextMenu(menuManager, viewer);
142

  
143
		// FIXME for some reason this is not working
144
		menuManager.add(showAllElementsAction);
145
		menuManager.add(hideAllElementsAction);
146

  
147
		Control control = viewer.getControl();
148
		Menu menu = menuManager.createContextMenu(control);
149

  
150
		control.setMenu(menu);
151
	}
152

  
153
	/** {@inheritDoc} */
154
	@Override
155
    protected void selectionChanged_internal(IWorkbenchPart workbenchPart, ISelection selection) {
156
	    Object partObject = workbenchPart;
157
//		if(AbstractUtility.getActiveE4Editor() == null){
158
//			showEmptyPage();
159
//			return;
160
//		}
161

  
162

  
163
		if(partObject == this){
164
		    return;
165
		}
166

  
167
        Object wrappedPart = WorkbenchUtility.getE4WrappedPart(partObject);
168

  
169
        if(wrappedPart!=null){
170
            partObject = wrappedPart;
171
        }
172
        if(part == this){
173
		    return;
174
		}
175

  
176
        if (partObject instanceof MediaViewPartE4) {
177
            // do not show empty page as these views are also used to edit the
178
            // description selected in this view
179
            return;
180
        }
181
        else if(partObject instanceof ChecklistEditor){
182
            if(selection instanceof StructuredSelection  && ((IStructuredSelection) selection).getFirstElement() instanceof Taxon){
183
                Taxon taxon = (Taxon)((IStructuredSelection) selection).getFirstElement();
184
                selection = new StructuredSelection(taxon);
185
            }
186
        }
187
        //check if it is a tree node selection
188
        TreeNode treeNodeOfSelection = EditorUtil.getTreeNodeOfSelection(selection);
189
        if(treeNodeOfSelection!=null){
190
            selection = new StructuredSelection(treeNodeOfSelection.getValue());
191
        }
192
        if(selection instanceof IStructuredSelection){
193
            Object firstElement = ((IStructuredSelection) selection).getFirstElement();
194
            if (partObject instanceof TaxonNameEditorE4){
195
            	if (firstElement != ((TaxonNameEditorE4)partObject).getTaxon()){
196
            		showEmptyPage();
197
            		return;
198
            	}
199
            }
200

  
201
            if(firstElement instanceof IDescribable<?>
202
            	&& partObject instanceof IPartContentHasFactualData
203
            		&& !(firstElement instanceof SpecimenOrObservationBase && partObject instanceof BulkEditor)){
204

  
205
                featureNodeContainerCache.clear();
206
                showViewer(partObject, (IStructuredSelection) selection);
207
                return;
208
            }
209
        }
210
        showEmptyPage();
211
	}
212

  
213
	@Override
214
	protected String getViewName(){
215
	    return Messages.DescriptiveViewPart_FACTUAL_DATA;
216
	}
217

  
218
	/**
219
	 *
220
	 * @author n.hoffmann
221
	 * @created May 28, 2010
222
	 * @version 1.0
223
	 */
224
	protected class ToggleDescriptionAction extends Action{
225
		private final boolean expanded;
226

  
227
		public ToggleDescriptionAction(boolean expand){
228
			super(null, IAction.AS_PUSH_BUTTON);
229
			expanded = expand;
230
			setImageAndTooltip();
231
		}
232

  
233
		private void setImageAndTooltip(){
234
			setImageDescriptor(new ImageDescriptor() {
235
				@Override
236
				public ImageData getImageData() {
237
					setText(expanded ? Messages.DescriptiveViewPart_COLLAPSE_ALL : Messages.DescriptiveViewPart_EXPAND_ALL);
238
					String resource = expanded ? ImageResources.COLLAPSE_ALL : ImageResources.EXPAND_ALL;
239
					return ImageResources.getImage(resource).getImageData();
240
				}
241
			});
242

  
243
			String toolTipText = expanded ? Messages.DescriptiveViewPart_COLLAPSE_ALL : Messages.DescriptiveViewPart_SHOW_ALL_DATA;
244
			setToolTipText(toolTipText);
245
		}
246

  
247
		@Override
248
		public void run() {
249
			if(expanded){
250
				viewer.collapseAll();
251
			}else{
252
				viewer.expandAll();
253
			}
254
			setImageAndTooltip();
255
		}
256
	}
257

  
258
	/** {@inheritDoc} */
259
	@Override
260
	public boolean postOperation(CdmBase objectAffectedByOperation) {
261
		return super.postOperation(objectAffectedByOperation);
262
	}
263

  
264
	/** {@inheritDoc} */
265
	@Override
266
	public void changed(Object object) {
267
		for(FeatureNodeContainerTree containerTree : featureNodeContainerCache.values()){
268
			containerTree.buildTree();
269
		}
270
		viewer.expandToLevel(2);
271
		viewer.refresh();
272

  
273
		if(object instanceof DescriptionElementBase){
274
			DescriptionElementBase descriptionElement = (DescriptionElementBase) object;
275
			DescriptionBase description = descriptionElement.getInDescription();
276
			FeatureNodeContainerTree containerTree = featureNodeContainerCache.get(description);
277

  
278
			FeatureNodeContainer featureNodeContainer = containerTree.getFeatureNodeContainerForDescriptionElement(descriptionElement);
279
			viewer.expandToLevel(featureNodeContainer, 1);
280

  
281
		}
282

  
283
		if(object != null){
284
			StructuredSelection selection = new StructuredSelection(object);
285
			viewer.setSelection(selection, true);
286
		}
287
		if(part instanceof BulkEditor && !(object instanceof SpecimenOrObservationBase<?>)){
288
		    ((BulkEditor) part).forceDirty();
289
		    IStructuredSelection selection = (IStructuredSelection) ((BulkEditor) part).getSelectionProvider().getSelection();
290
		    ((BulkEditor) part).changed(selection.getFirstElement());
291

  
292
		}
293

  
294
		if (part instanceof E4PartWrapper){
295
	    	part = WorkbenchUtility.getE4WrappedPart(part);
296
	    	if (part instanceof IDirtyMarkable){
297
	    		 StructuredSelection selection = new StructuredSelection(object);
298
	    		((IDirtyMarkable)part).changed(selection.getFirstElement());
299
	    	}
300
	    }
301

  
302

  
303
		super.changed(object);
304
	}
305

  
306
	/** {@inheritDoc} */
307
	@Override
308
	public Viewer getViewer() {
309
		return viewer;
310
	}
311

  
312
	@Override
313
    public boolean onComplete() {
314
		return false;
315
	}
316

  
317
	public void toggleShowOnlyIndividualAssociations(){
318
	    provider.toggleShowOnlyIndividualAssociations();
319
	    viewer.refresh();
320
	}
321

  
322

  
323

  
324
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/CreateDescriptionElementHandler.java
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
 */
9

  
10
package eu.etaxonomy.taxeditor.editor.view.descriptive.handler;
11

  
12
import org.eclipse.core.commands.AbstractHandler;
13
import org.eclipse.core.commands.ExecutionEvent;
14
import org.eclipse.core.commands.ExecutionException;
15
import org.eclipse.core.commands.common.NotDefinedException;
16
import org.eclipse.jface.viewers.ISelection;
17
import org.eclipse.jface.viewers.IStructuredSelection;
18
import org.eclipse.jface.viewers.ITreeSelection;
19
import org.eclipse.jface.viewers.TreePath;
20
import org.eclipse.swt.widgets.Event;
21
import org.eclipse.ui.IWorkbenchPart;
22
import org.eclipse.ui.handlers.HandlerUtil;
23

  
24
import eu.etaxonomy.cdm.model.description.DescriptionBase;
25
import eu.etaxonomy.cdm.model.description.Feature;
26
import eu.etaxonomy.taxeditor.editor.EditorUtil;
27
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateDescriptionElementOperation;
28
import eu.etaxonomy.taxeditor.model.MessagingUtils;
29
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
30
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
31

  
32
/**
33
 * <p>CreateDescriptionElementHandler class.</p>
34
 *
35
 * @author n.hoffmann
36
 * @created 16.04.2009
37
 * @version 1.0
38
 */
39
public class CreateDescriptionElementHandler extends AbstractHandler {
40

  
41
	/*
42
	 * (non-Javadoc)
43
	 *
44
	 * @see
45
	 * org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.
46
	 * ExecutionEvent)
47
	 */
48
    /** {@inheritDoc} */
49
    @Override
50
    public Object execute(ExecutionEvent event) throws ExecutionException {
51
        IWorkbenchPart part = HandlerUtil.getActivePart(event);
52
        IPostOperationEnabled postOperationEnabled = (part instanceof IPostOperationEnabled) ? (IPostOperationEnabled) part
53
                : null;
54

  
55

  
56
        DescriptionBase<?> description = null;
57

  
58
        ISelection selection = HandlerUtil.getCurrentSelection(event);
59
        Object selectedElement = null;
60
        if (selection instanceof ITreeSelection) {
61
            TreePath[] paths = ((ITreeSelection) selection).getPaths();
62
            selectedElement = paths[0].getFirstSegment();
63
        }
64
        else if (selection instanceof IStructuredSelection) {
65
            selectedElement = ((IStructuredSelection) selection).getFirstElement();
66
        }
67
        if (selectedElement instanceof DescriptionBase<?>) {
68
            description = (DescriptionBase<?>) selectedElement;
69
        }
70

  
71
        if (description != null) {
72
            AbstractPostOperation operation = null;
73
            try {
74
                // TODO use undo context specific to editor
75
                operation = operationCreationInstance(event.getCommand().getName(), event, description, postOperationEnabled);
76
            } catch (NotDefinedException e) {
77
                MessagingUtils.warn(getClass(), "Command name not set"); //$NON-NLS-1$
78
            }
79
        } else {
80
            MessagingUtils.error(getClass(), new IllegalArgumentException("Could not determine the taxon description")); //$NON-NLS-1$
81
            return null;
82
        }
83
        return null;
84

  
85
    }
86

  
87
    /**
88
	 * Added to make the Class more generic and limit the amount of code changes required
89
	 * @param label
90
	 * @param event
91
	 * @param taxon
92
	 * @param description
93
	 * @param postOperationEnabled
94
	 * @return
95
	 */
96
	protected AbstractPostOperation operationCreationInstance(String label, ExecutionEvent event, DescriptionBase<?> description, IPostOperationEnabled postOperationEnabled) {
97
		Feature feature = (Feature) ((Event) event.getTrigger()).data;
98
		return new CreateDescriptionElementOperation(label, EditorUtil.getUndoContext(), description, feature, postOperationEnabled);
99
	}
100

  
101
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/CreateDescriptionHandler.java
1
/**
2
* Copyright (C) 2011 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
package eu.etaxonomy.taxeditor.editor.view.descriptive.handler;
10

  
11
import org.eclipse.core.commands.AbstractHandler;
12
import org.eclipse.core.commands.ExecutionEvent;
13
import org.eclipse.core.commands.ExecutionException;
14
import org.eclipse.core.commands.common.NotDefinedException;
15
import org.eclipse.ui.IWorkbenchPart;
16
import org.eclipse.ui.handlers.HandlerUtil;
17

  
18
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
19
import eu.etaxonomy.cdm.model.taxon.Taxon;
20
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
21
import eu.etaxonomy.taxeditor.editor.EditorUtil;
22
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart;
23
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateSpecimenDescriptionOperation;
24
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateTaxonDescriptionOperation;
25
import eu.etaxonomy.taxeditor.model.MessagingUtils;
26
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
27
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
28

  
29
/**
30
 * <p>AddDescriptionHandler class.</p>
31
 *
32
 * @author p.ciardelli
33
 * @created 11.08.2009
34
 * @version 1.0
35
 */
36
public class CreateDescriptionHandler extends AbstractHandler {
37

  
38
	/* (non-Javadoc)
39
	 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
40
	 */
41
	/** {@inheritDoc} */
42
	@Override
43
    public Object execute(ExecutionEvent event) throws ExecutionException {
44
		IWorkbenchPart part = HandlerUtil.getActivePart(event);
45
		IPostOperationEnabled postOperationEnabled = (part instanceof IPostOperationEnabled) ? (IPostOperationEnabled) part : null;
46

  
47
		AbstractPostOperation<?> operation;
48
		if(part instanceof DescriptiveViewPart){
49

  
50
		    Object viewerInput = ((DescriptiveViewPart)part).getViewer().getInput();
51
		    if(viewerInput instanceof SpecimenOrObservationBase<?>){
52
		        try {
53
		            operation = new CreateSpecimenDescriptionOperation(event.getCommand().getName(), EditorUtil.getUndoContext(), (SpecimenOrObservationBase<?>) viewerInput, postOperationEnabled);
54
		        } catch (NotDefinedException e) {
55
		            MessagingUtils.warn(getClass(), "Command name not set."); //$NON-NLS-1$
56
		        }
57
		    }
58
		    if(viewerInput instanceof TaxonBase){
59
		    	try{
60
		    		operation = createTaxonOperation(event.getCommand().getName(), (Taxon) viewerInput, postOperationEnabled);
61
		    	 } catch (NotDefinedException e) {
62
			            MessagingUtils.warn(getClass(), "Command name not set."); //$NON-NLS-1$
63
			     }
64

  
65
		    }
66
		}
67
		return null;
68
	}
69

  
70
	   /** {@inheritDoc} */
71
    protected CreateTaxonDescriptionOperation createTaxonOperation(String eventLabel, Taxon taxon, IPostOperationEnabled postOperationEnabled) {
72
        return new CreateTaxonDescriptionOperation(eventLabel, EditorUtil.getUndoContext(), taxon, postOperationEnabled);
73
    }
74

  
75
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/UsesViewPart.java
1
/**
2
 * Copyright (C) 2011 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
package eu.etaxonomy.taxeditor.editor.view.uses;
10

  
11
import org.eclipse.jface.viewers.TreeViewer;
12
import org.eclipse.swt.SWT;
13
import org.eclipse.swt.dnd.Transfer;
14
import org.eclipse.swt.widgets.Composite;
15
import org.eclipse.swt.widgets.Tree;
16

  
17
import eu.etaxonomy.cdm.model.common.CdmBase;
18
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
19
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementTransfer;
20
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart;
21

  
22

  
23
/**
24
 * The Class create a specific Use View to keep the taxonomic view clean
25
 * @author a.theys
26
 * @created mar 13, 2012
27
 * @version 1.0
28
 */
29
public class UsesViewPart extends DescriptiveViewPart {
30

  
31
	public UsesViewPart() {
32
		super();
33
	}
34

  
35
	/** Constant <code>ID="eu.etaxonomy.taxeditor.editor.view.uses"</code> */
36
	public static final String ID = "eu.etaxonomy.taxeditor.editor.view.uses"; //$NON-NLS-1$
37
	/** {@inheritDoc} */
38
	@Override
39
	public void createViewer(Composite parent) {
40

  
41
		viewer = new TreeViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL
42
				| SWT.V_SCROLL | SWT.FULL_SELECTION));
43
		viewer.setContentProvider(new UsesContentProvider(featureNodeContainerCache));
44
		viewer.setLabelProvider(new UsesLabelProvider());
45
		viewer.setAutoExpandLevel(2);
46

  
47

  
48

  
49
		Transfer[] transfers = new Transfer[] { DescriptionElementTransfer.getInstance() };
50
//		viewer.addDragSupport(dndOperations, transfers, new DescriptionElementDragListener(
51
//				this));
52
//		viewer.addDropSupport(dndOperations, transfers,
53
//				new DescriptionElementDropAdapter(viewer));
54

  
55
		// Propagate selection from viewer
56
		getSite().setSelectionProvider(viewer);
57

  
58
		showAllElementsAction = new ToggleDescriptionAction(false);
59
		hideAllElementsAction = new ToggleDescriptionAction(true);
60

  
61
		// Add context menu to tree
62
		createMenu();
63

  
64
		createToolbar();
65

  
66
	}
67

  
68
	@Override
69
    protected String getViewName(){
70
	    return Messages.UsesViewPart_VIEWER_NAME;
71
	}
72

  
73
	/** {@inheritDoc} */
74
	@Override
75
	public boolean postOperation(CdmBase objectAffectedByOperation) {
76
		viewer.refresh();
77
		return super.postOperation(objectAffectedByOperation);
78
	}
79

  
80

  
81

  
82
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/CreateUseHandler.java
1
/**
2
* Copyright (C) 2011 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
package eu.etaxonomy.taxeditor.editor.view.uses.handler;
10

  
11
import eu.etaxonomy.cdm.model.taxon.Taxon;
12
import eu.etaxonomy.taxeditor.editor.EditorUtil;
13
import eu.etaxonomy.taxeditor.editor.view.descriptive.handler.CreateDescriptionHandler;
14
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateTaxonDescriptionOperation;
15
import eu.etaxonomy.taxeditor.editor.view.uses.operation.CreateTaxonUseOperation;
16
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
17

  
18
/**
19
 * CreateUseHandler Class
20
 * @author a.theys
21
 * @created mar 13, 2012
22
 * @version 1.0
23
 */
24
public class CreateUseHandler extends CreateDescriptionHandler {
25

  
26

  
27
	/** {@inheritDoc} */
28
	@Override
29
    protected CreateTaxonDescriptionOperation createTaxonOperation(String eventLabel, Taxon taxon, IPostOperationEnabled postOperationEnabled) {
30
		return new CreateTaxonUseOperation(eventLabel, EditorUtil.getUndoContext(), taxon, postOperationEnabled);
31
	}
32
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/CreateUseRecordHandler.java
1
/**
2
 * Copyright (C) 2011 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

  
10
package eu.etaxonomy.taxeditor.editor.view.uses.handler;
11

  
12
import org.eclipse.core.commands.ExecutionEvent;
13

  
14
import eu.etaxonomy.cdm.api.service.ITermService;
15
import eu.etaxonomy.cdm.model.description.DescriptionBase;
16
import eu.etaxonomy.cdm.model.description.Feature;
17
import eu.etaxonomy.taxeditor.editor.EditorUtil;
18
import eu.etaxonomy.taxeditor.editor.view.descriptive.handler.CreateDescriptionElementHandler;
19
import eu.etaxonomy.taxeditor.editor.view.uses.operation.CreateUseRecordOperation;
20
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
21
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
22
import eu.etaxonomy.taxeditor.store.CdmStore;
23
import eu.etaxonomy.taxeditor.store.UsageTermCollection;
24
import eu.etaxonomy.taxeditor.store.UseObjectStore;
25

  
26
/**
27
 * CreateUseRecordHandler Class
28
 * @author a.theys
29
 * @created mar 13, 2012
30
 * @version 1.0
31
 */
32
public class CreateUseRecordHandler extends CreateDescriptionElementHandler {
33
	/** {@inheritDoc} */
34
	@Override
35
	protected AbstractPostOperation operationCreationInstance(String label, ExecutionEvent event, DescriptionBase<?> description, IPostOperationEnabled postOperationEnabled) {
36
		//Use Record Feature retrieval below
37
		Feature feature = UseObjectStore.getUseRecordFeature();
38
		feature.setSupportsCategoricalData(true);
39
		return new CreateUseRecordOperation(label,
40
					EditorUtil.getUndoContext(),
41
					description, feature, postOperationEnabled);
42
	}
43

  
44

  
45

  
46
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/CreateUseSummaryHandler.java
1
/**
2
* Copyright (C) 2011 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
package eu.etaxonomy.taxeditor.editor.view.uses.handler;
10

  
11

  
12
import org.eclipse.core.commands.ExecutionEvent;
13

  
14
import eu.etaxonomy.cdm.model.description.DescriptionBase;
15
import eu.etaxonomy.cdm.model.description.Feature;
16
import eu.etaxonomy.taxeditor.editor.EditorUtil;
17
import eu.etaxonomy.taxeditor.editor.view.descriptive.handler.CreateDescriptionElementHandler;
18
import eu.etaxonomy.taxeditor.editor.view.uses.operation.CreateUseSummaryOperation;
19
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
20
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
21
import eu.etaxonomy.taxeditor.store.UseObjectStore;
22

  
23
/**
24
 * CreateUseSummaryHandler Class
25
 * @author a.theys
26
 * @created mar 13, 2012
27
 * @version 1.0
28
 */
29
public class CreateUseSummaryHandler extends CreateDescriptionElementHandler {
30
	/** {@inheritDoc} */
31
	@Override
32
	protected AbstractPostOperation operationCreationInstance(String label, ExecutionEvent event, DescriptionBase<?> description, IPostOperationEnabled postOperationEnabled) {
33
		//Use Record Feature retrieval below
34
		Feature feature = UseObjectStore.getUseSummaryFeature();
35
		
36
		feature.setSupportsTextData(true);
37
		return new CreateUseSummaryOperation(label,	EditorUtil.getUndoContext(), description, feature, postOperationEnabled);
38
	}
39

  
40
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)