Project

General

Profile

Revision a1d4e9e9

IDa1d4e9e94f591dad5227c16eae0b9484ecfce685
Parent fadf903a
Child 586de129

Added by Patrick Plitzner about 1 year ago

ref #6913 Remove e3 context menu items and name viewer extensions

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyListItem.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.key.polytomous;
11

  
12
import org.eclipse.swt.SWT;
13
import org.eclipse.swt.events.SelectionAdapter;
14
import org.eclipse.swt.events.SelectionEvent;
15
import org.eclipse.swt.events.SelectionListener;
16
import org.eclipse.swt.widgets.Composite;
17
import org.eclipse.swt.widgets.Label;
18
import org.eclipse.swt.widgets.Link;
19
import org.eclipse.ui.PlatformUI;
20
import org.eclipse.ui.forms.IFormPart;
21
import org.eclipse.ui.forms.IManagedForm;
22

  
23
import eu.etaxonomy.cdm.common.CdmUtils;
24
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
25
import eu.etaxonomy.cdm.model.description.KeyStatement;
26
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
27
import eu.etaxonomy.cdm.model.taxon.Taxon;
28
import eu.etaxonomy.taxeditor.editor.EditorUtil;
29
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
30
import eu.etaxonomy.taxeditor.store.CdmStore;
31
import eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement;
32
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
33
import eu.etaxonomy.taxeditor.ui.element.ISelectable;
34
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
35

  
36
/**
37
 * @author n.hoffmann
38
 * @created Apr 13, 2011
39
 * @version 1.0
40
 */
41
public class PolytomousKeyListItem extends AbstractCdmFormElement implements
42
		IFormPart, ISelectable {
43

  
44
	private boolean dirty;
45
	private final PolytomousKeyNode entity;
46

  
47
	private SelectionListener linkSelectionListener;
48

  
49
	/**
50
	 * @param formFactory
51
	 * @param layoutComposite
52
	 */
53
	protected PolytomousKeyListItem(CdmFormFactory formFactory,
54
			Composite layoutComposite, PolytomousKeyNode entity) {
55
		super(formFactory, layoutComposite);
56

  
57
		// layoutComposite.setBackground(Display.getDefault().getSystemColor(
58
		// SWT.COLOR_CYAN));
59

  
60
		this.entity = HibernateProxyHelper.deproxy(entity);
61

  
62
		Label label_nodeNumber = new Label(getLayoutComposite(), SWT.NULL);
63
		label_nodeNumber.setText(getItemNumber());
64

  
65
		Label label_question = new Label(getLayoutComposite(), SWT.NULL);
66
		label_question.setText(getItemQuestion());
67

  
68
		Label label_statement = new Label(getLayoutComposite(), SWT.NULL);
69
		label_statement.setText(getItemStatement());
70
		label_statement.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
71

  
72
		Link link = new Link(getLayoutComposite(), SWT.NONE);
73
		link.setText("<a>" + getItemLink() + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$
74
		link.setData(getItemLinkData());
75
		link.addSelectionListener(getLinkSelectionListener());
76

  
77
		// Label label_link = new Label(getLayoutComposite(), SWT.NULL);
78
		// label_link.setText(link);
79

  
80
	}
81

  
82
	/**
83
	 * @return
84
	 */
85
	private SelectionListener getLinkSelectionListener() {
86
		if (linkSelectionListener == null) {
87
			linkSelectionListener = new SelectionAdapter() {
88
				/*
89
				 * (non-Javadoc)
90
				 *
91
				 * @see
92
				 * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org
93
				 * .eclipse.swt.events.SelectionEvent)
94
				 */
95
				@Override
96
				public void widgetSelected(SelectionEvent e) {
97
					Object data = e.widget.getData();
98

  
99
					if (data instanceof Taxon) {
100
						EditorUtil.openTaxonBaseE4(((Taxon) data).getUuid());
101
					}
102
				}
103
			};
104
		}
105
		return linkSelectionListener;
106
	}
107

  
108
	private String getItemNumber() {
109
		if (isParentRoot()) {
110
			return "root"; //$NON-NLS-1$
111
		} else {
112
			PolytomousKeyNode parent = getParent();
113
			String itemNumber = parent.getNodeNumber() != null ? parent
114
					.getNodeNumber().toString() : "NaN"; //$NON-NLS-1$
115

  
116
			int index = parent.getChildren().indexOf(entity);
117

  
118
			for (int i = 0; i < index; i++) {
119
				itemNumber += "'"; //$NON-NLS-1$
120
			}
121

  
122
			return itemNumber;
123
		}
124
	}
125

  
126
	private String getItemQuestion() {
127
		if (isParentRoot()) {
128
			return ""; //$NON-NLS-1$
129
		} else {
130
			KeyStatement question = getParent().getQuestion();
131
			return question != null ? question.getLabelText(CdmStore
132
					.getDefaultLanguage()) : ""; //$NON-NLS-1$
133
		}
134

  
135
	}
136

  
137
	private String getItemStatement() {
138
		KeyStatement statement = entity.getStatement();
139
		return statement != null ? CdmUtils.Nz(statement.getLabelText(CdmStore
140
				.getDefaultLanguage())) : Messages.PolytomousKeyListItem_NO_STATEMENT;
141
	}
142

  
143
	private String getItemLink() {
144
		String taxonString = entity.getTaxon() != null ? entity.getTaxon()
145
				.getName().getTitleCache() : Messages.PolytomousKeyListItem_TAXON_EMPTY;
146

  
147
		return entity.getChildren().isEmpty() ? taxonString : entity
148
				.getNodeNumber().toString();
149
	}
150

  
151
	/**
152
	 * @return
153
	 */
154
	private Object getItemLinkData() {
155
		return entity.getChildren().isEmpty() ? entity.getTaxon() : entity
156
				.getChildAt(0);
157
	}
158

  
159
	private PolytomousKeyNode getParent() {
160
		return entity.getParent();
161
	}
162

  
163
	private boolean isParentRoot() {
164
		return getParent() == null;
165
	}
166

  
167
	/*
168
	 * (non-Javadoc)
169
	 *
170
	 * @see
171
	 * org.eclipse.ui.forms.IFormPart#initialize(org.eclipse.ui.forms.IManagedForm
172
	 * )
173
	 */
174
	@Override
175
	public void initialize(IManagedForm form) {
176
		// TODO Auto-generated method stub
177

  
178
	}
179

  
180
	/*
181
	 * (non-Javadoc)
182
	 *
183
	 * @see org.eclipse.ui.forms.IFormPart#isDirty()
184
	 */
185
	@Override
186
	public boolean isDirty() {
187
		return dirty;
188
	}
189

  
190
	/*
191
	 * (non-Javadoc)
192
	 *
193
	 * @see org.eclipse.ui.forms.IFormPart#commit(boolean)
194
	 */
195
	@Override
196
	public void commit(boolean onSave) {
197
		// TODO Auto-generated method stub
198

  
199
	}
200

  
201
	/*
202
	 * (non-Javadoc)
203
	 *
204
	 * @see org.eclipse.ui.forms.IFormPart#setFormInput(java.lang.Object)
205
	 */
206
	@Override
207
	public boolean setFormInput(Object input) {
208
		// TODO Auto-generated method stub
209
		return false;
210
	}
211

  
212
	/*
213
	 * (non-Javadoc)
214
	 *
215
	 * @see org.eclipse.ui.forms.IFormPart#setFocus()
216
	 */
217
	@Override
218
	public void setFocus() {
219
		// TODO Auto-generated method stub
220
		PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().setFocus();
221
	}
222

  
223
	/*
224
	 * (non-Javadoc)
225
	 *
226
	 * @see org.eclipse.ui.forms.IFormPart#isStale()
227
	 */
228
	@Override
229
	public boolean isStale() {
230
		// TODO Auto-generated method stub
231
		return false;
232
	}
233

  
234
	/*
235
	 * (non-Javadoc)
236
	 *
237
	 * @see org.eclipse.ui.forms.IFormPart#refresh()
238
	 */
239
	@Override
240
	public void refresh() {
241
		// TODO Auto-generated method stub
242

  
243
	}
244

  
245
	/*
246
	 * (non-Javadoc)
247
	 *
248
	 * @see org.eclipse.ui.forms.IFormPart#dispose()
249
	 */
250
	@Override
251
	public void dispose() {
252
		// TODO Auto-generated method stub
253

  
254
	}
255

  
256
	/**
257
	 * @return the entity
258
	 */
259
	public PolytomousKeyNode getEntity() {
260
		return entity;
261
	}
262

  
263
	@Override
264
	public void setSelected(boolean selected) {
265
		setBackground(selected ? SELECTED : getPersistentBackground());
266
	}
267

  
268
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/container/NameViewer.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.name.container;
11

  
12
import java.util.Iterator;
13

  
14
import org.eclipse.core.commands.operations.IUndoContext;
15
import org.eclipse.core.runtime.Assert;
16
import org.eclipse.jface.text.Document;
17
import org.eclipse.jface.text.IUndoManager;
18
import org.eclipse.jface.text.IUndoManagerExtension;
19
import org.eclipse.jface.text.Position;
20
import org.eclipse.jface.text.TextViewerUndoManager;
21
import org.eclipse.jface.text.source.Annotation;
22
import org.eclipse.jface.text.source.AnnotationModel;
23
import org.eclipse.jface.text.source.AnnotationPainter;
24
import org.eclipse.jface.text.source.IAnnotationAccess;
25
import org.eclipse.jface.text.source.IVerticalRuler;
26
import org.eclipse.jface.text.source.SourceViewer;
27
import org.eclipse.swt.SWT;
28
import org.eclipse.swt.graphics.Color;
29
import org.eclipse.swt.graphics.Image;
30
import org.eclipse.swt.widgets.Canvas;
31
import org.eclipse.swt.widgets.Composite;
32
import org.eclipse.swt.widgets.Control;
33
import org.eclipse.swt.widgets.Display;
34
import org.eclipse.swt.widgets.Layout;
35
import org.eclipse.swt.widgets.Menu;
36
import org.eclipse.ui.IActionBars;
37
import org.eclipse.ui.IEditorSite;
38
import org.eclipse.ui.actions.ActionFactory;
39
import org.eclipse.ui.forms.widgets.TableWrapData;
40
import org.eclipse.ui.forms.widgets.TableWrapLayout;
41
import org.eclipse.ui.operations.OperationHistoryActionHandler;
42
import org.eclipse.ui.operations.RedoActionHandler;
43
import org.eclipse.ui.operations.UndoActionHandler;
44
import org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess;
45
import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
46

  
47
import eu.etaxonomy.taxeditor.editor.EditorUtil;
48
import eu.etaxonomy.taxeditor.editor.ViewerConfiguration;
49
import eu.etaxonomy.taxeditor.editor.name.container.EditorAnnotation.EditorAnnotationType;
50
import eu.etaxonomy.taxeditor.preference.Resources;
51

  
52
/**
53
 * SourceViewer implementation called by NameComposite.
54
 *
55
 * @author p.ciardelli
56
 * @created 27.05.2008
57
 * @version 1.0
58
 */
59
public class NameViewer extends SourceViewer {
60

  
61
	/** Constant <code>RULER_WIDTH=16</code> */
62
	public static final int RULER_WIDTH = 16;
63

  
64
	private final IVerticalRuler ruler;
65
	private final AnnotationModel annotationModel;
66

  
67
	/**
68
	 * <p>Constructor for NameViewer.</p>
69
	 *
70
	 * @param parent a {@link org.eclipse.swt.widgets.Composite} object.
71
	 */
72
	public NameViewer(Composite parent) {
73
		super(parent, new RulerWithIcon(RULER_WIDTH), SWT.WRAP | SWT.MULTI | SWT.RESIZE);
74

  
75
		this.ruler = getVerticalRuler();
76

  
77
		setBackground(EditorUtil.getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
78

  
79
		Canvas canvas = (Canvas) getControl();
80
		TableWrapLayout layout = (TableWrapLayout) canvas.getLayout();
81
		layout.topMargin = 0;
82
		layout.rightMargin = 0;
83
		layout.bottomMargin = 0;
84
		layout.leftMargin = 0;
85
		layout.verticalSpacing = 10;
86
		layout.horizontalSpacing = 0;
87

  
88
		canvas.setLayout(layout);
89

  
90
		// Lay out the viewer's widgets
91
		TableWrapData twdata = new TableWrapData(TableWrapData.FILL_GRAB);
92
		getControl().setLayoutData(twdata);
93

  
94
		twdata = new TableWrapData(TableWrapData.FILL_GRAB);
95
		getTextWidget().setLayoutData(twdata);
96
		getTextWidget().setLineSpacing(5);
97

  
98
		// Default implementation adds ruler after the text widget, then
99
		//	uses a custom layout to display it before the text widget
100
		ruler.getControl().moveAbove(getTextWidget());
101

  
102
		annotationModel = new AnnotationModel();
103
		this.setDocument(new Document(""), annotationModel); //$NON-NLS-1$
104

  
105
		createAnnotationPainter();
106

  
107
		this.configure(new ViewerConfiguration());
108

  
109
//		setDecorationSupport();
110
//		DocumentUndoManagerRegistry.connect(this.getDocument());
111
//		IDocumentUndoManager docUndoManager = DocumentUndoManagerRegistry.getDocumentUndoManager(this.getDocument());
112

  
113
		/**
114
		getEditorSite().getActionBars().setGlobalActionHandler(ActionFactory.UNDO.getId(), new UndoActionHandler(getSite(), undoContext));
115
		getEditorSite().getActionBars().setGlobalActionHandler(ActionFactory.REDO.getId(), new RedoActionHandler(getSite(), undoContext));
116
		**/
117
	}
118

  
119
	/**
120
	 * <p>setBackground</p>
121
	 *
122
	 * @param color a {@link org.eclipse.swt.graphics.Color} object.
123
	 */
124
	public void setBackground(Color color) {
125

  
126
		// Set background color of ruler
127
		ruler.getControl().setBackground(color);
128

  
129
		// Set background color of text widget
130
		getTextWidget().setBackground(color);
131

  
132
		// Set background color of strip between ruler and textWidget
133
		getTextWidget().getParent().setBackground(color);
134
	}
135

  
136
	/**
137
	 * <p>getRulerControl</p>
138
	 *
139
	 * @return a {@link org.eclipse.swt.widgets.Control} object.
140
	 */
141
	public Control getRulerControl() {
142
		return ruler.getControl();
143
	}
144

  
145
	/**
146
	 * <p>setIcon</p>
147
	 *
148
	 * @param icon a {@link org.eclipse.swt.graphics.Image} object.
149
	 */
150
	public void setIcon(Image icon) {
151
		if (ruler instanceof RulerWithIcon) {
152
			((RulerWithIcon) ruler).setIcon(icon);
153
		} else {
154
			throw new IllegalStateException("Viewer's IVerticalRuler is not an instance of RulerWithIcon."); //$NON-NLS-1$
155
		}
156
	}
157

  
158
	/* (non-Javadoc)
159
	 * @see org.eclipse.jface.text.source.SourceViewer#createLayout()
160
	 */
161
	/**
162
	 * <p>createLayout</p>
163
	 *
164
	 * @return a {@link org.eclipse.swt.widgets.Layout} object.
165
	 */
166
	@Override
167
	protected Layout createLayout() {
168
		TableWrapLayout layout = new TableWrapLayout();
169
		layout.numColumns = 2;
170
		layout.verticalSpacing = 0;
171
		return layout;
172
	}
173

  
174
	private void createAnnotationPainter(){
175
		// Annotations section
176
		IAnnotationAccess fAnnotationAccess = new DefaultMarkerAnnotationAccess();
177

  
178
		// To paint the annotations
179
		AnnotationPainter annotationPainter = new AnnotationPainter(this, fAnnotationAccess);
180

  
181
		// Default SquigglesStrategy doesn't recognize line wraps
182
		annotationPainter.addDrawingStrategy(LineWrapSquigglesStrategy.ID, new LineWrapSquigglesStrategy());
183

  
184
		// Add ability to paint red squigglies
185
		annotationPainter.addAnnotationType(EditorAnnotationType.ERROR.name(), LineWrapSquigglesStrategy.ID);
186
		annotationPainter.setAnnotationTypeColor(EditorAnnotationType.ERROR.image,
187
				new Color(Display.getDefault(), EditorAnnotationType.ERROR.color));
188

  
189
		// Add ability to paint yellow squigglies
190
		annotationPainter.addAnnotationType(EditorAnnotationType.WARNING.name(), LineWrapSquigglesStrategy.ID);
191
		annotationPainter.setAnnotationTypeColor(EditorAnnotationType.WARNING.image,
192
				new Color(Display.getDefault(), EditorAnnotationType.WARNING.color));
193

  
194
		this.addPainter(annotationPainter);
195
	}
196

  
197

  
198
	/**
199
	 * <p>clearAnnotations</p>
200
	 */
201
	public void clearAnnotations() {
202
		Iterator<Annotation> annotations = this.getAnnotationModel().getAnnotationIterator();
203
		while (annotations.hasNext()) {
204
			Annotation annotation = annotations.next();
205
			this.getAnnotationModel().removeAnnotation(annotation);
206
		}
207
	}
208

  
209
	/**
210
	 * If <code>name.hasProblem()</code> is <code>true</code>, underlines section
211
	 * of text bounded by <code>name.getProblemStarts()</code> and
212
	 * <code>name.getProblemEnds()</code>.
213
	 *
214
	 * @param name a {@link eu.etaxonomy.cdm.model.name.TaxonNameBase} object.
215
	 */
216
//	public void setShowParsingErrors(TaxonNameBase<?, ?> name) {
217
//
218
//		String text = this.getTextWidget().getText();
219
//
220
//		if (name.hasProblem() && text.length() > 0) {
221
//			int start = name.getProblemStarts();
222
//			int length = name.getProblemEnds() - start;
223
//
224
//			if (start == -1 || name.getProblemEnds() == -1) {
225
//				return;
226
//			}
227
//
228
//			// Don't let squigglies try to draw beyond the end of the text
229
//			if (text.length() < start + length) {
230
//				length = text.length() - start;
231
//			}
232
//
233
//			for (ParserProblem problem : name.getParsingProblems()) {
234
//
235
//				String type = null;
236
//				if (problem.isWarning()) {
237
//					type = EditorAnnotation.WARNING_TYPE;
238
//				}
239
//				if (problem.isError()) {
240
//					type = EditorAnnotation.ERROR_TYPE;
241
//				}
242
//				if (type == null) {
243
//					continue;
244
//				}
245
//				this.getAnnotationModel().addAnnotation(
246
//						new EditorAnnotation(type, 0, problem.getMessage()),
247
//						new Position(start, length));
248
//			}
249
//
250
//		}
251
//	}
252

  
253
	public void addAnnotation(EditorAnnotation annotation){
254
		addAnnotation(annotation, null);
255
	}
256

  
257
	public void addAnnotation(EditorAnnotation annotation, Position position){
258
		if(position == null){
259
			position = new Position(0, 0);
260
		}
261

  
262
		this.getAnnotationModel().addAnnotation(annotation, position);
263
	}
264

  
265
	/**
266
	 * <p>setText</p>
267
	 *
268
	 * @param text a {@link java.lang.String} object.
269
	 */
270
	public void setText(String text) {
271
		if (text == null) {
272
			text = ""; //$NON-NLS-1$
273
		}
274
		try {
275
			Assert.isNotNull(text);
276
			// TODO figure out why getTextWidget() returns null!
277
			if (this.getTextWidget() == null) {
278
				return;
279
			}
280
			Assert.isNotNull(this.getTextWidget());
281
			this.getTextWidget().setText(text);
282
		} catch (RuntimeException e) {
283
			throw e;
284
		}
285
	}
286

  
287
	/**
288
	 * <p>setMenu</p>
289
	 *
290
	 * @param menu a {@link org.eclipse.swt.widgets.Menu} object.
291
	 */
292
	public void setMenu(Menu menu) {
293
		getRulerControl().setMenu(menu);
294
		getTextWidget().setMenu(menu);
295
	}
296

  
297
	/**
298
	 * <p>setCursorToEOL</p>
299
	 */
300
	public void setCursorToEOL() {
301
		getTextWidget().setCaretOffset(getTextWidget().getText().length());
302
	}
303

  
304

  
305
	/**
306
	 * <p>getCursorPosition</p>
307
	 *
308
	 * @return a int.
309
	 */
310
	public int getCursorPosition(){
311
		return getTextWidget().getCaretOffset();
312
	}
313

  
314
	/**
315
	 * <p>setCursorPosition</p>
316
	 *
317
	 * @param offset a int.
318
	 */
319
	public void setCursorPosition(int offset){
320
		try{
321
			getTextWidget().setCaretOffset(offset);
322
		}catch(IllegalArgumentException e){
323
			// do nothing
324
		}
325
	}
326

  
327
	/**
328
	 * <p>createUndoSupport</p>
329
	 *
330
	 * @param editorSite a {@link org.eclipse.ui.IEditorSite} object.
331
	 */
332
	public void createUndoSupport(IEditorSite editorSite) {
333

  
334
		IUndoManager undoManager = new TextViewerUndoManager(25);
335
		this.setUndoManager(undoManager);
336
		undoManager.connect(this);
337

  
338
//		IUndoContext workbenchUndoContext = UiUtil.getWorkbenchUndoContext();
339

  
340
		IUndoContext workbenchUndoContext = ((IUndoManagerExtension)undoManager).getUndoContext();
341

  
342
		OperationHistoryActionHandler undoAction = new UndoActionHandler(editorSite, workbenchUndoContext);
343
//		undoAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.UNDO);
344
		undoAction.setActionDefinitionId(ActionFactory.UNDO.getId());
345

  
346
		// Create the redo action.
347
		OperationHistoryActionHandler redoAction = new RedoActionHandler(editorSite, workbenchUndoContext);
348
//		redoAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.REDO);
349
		undoAction.setActionDefinitionId(ActionFactory.REDO.getId());
350

  
351
		IActionBars actionBars = editorSite.getActionBars();
352
		if (actionBars != null) {
353
//				actionBars.setGlobalActionHandler(IWorkbenchActionDefinitionIds.UNDO, undoAction);
354
//				actionBars.setGlobalActionHandler(IWorkbenchActionDefinitionIds.REDO, redoAction);
355
			actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), undoAction);
356
			actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), redoAction);
357

  
358
		}
359

  
360
//		actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), undoAction);
361
//		actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), redoAction);
362
	}
363

  
364
	/**
365
	 * <p>createUndoSupport_</p>
366
	 *
367
	 * @param editorSite a {@link org.eclipse.ui.IEditorSite} object.
368
	 */
369
	public void createUndoSupport_(IEditorSite editorSite) {
370
		IUndoManager undoManager = new TextViewerUndoManager(25);
371
		this.setUndoManager(undoManager);
372
		undoManager.connect(this);
373
		IUndoContext undoContext;
374
		if (undoManager instanceof IUndoManagerExtension) {
375
			undoContext = ((IUndoManagerExtension)undoManager).getUndoContext();
376

  
377
			OperationHistoryActionHandler undoAction = new UndoActionHandler(editorSite, undoContext);
378
//			PlatformUI.getWorkbench().getHelpSystem().setHelp(undoAction, IAbstractTextEditorHelpContextIds.UNDO_ACTION);
379
			undoAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.UNDO);
380

  
381
			// Create the redo action.
382
			OperationHistoryActionHandler redoAction = new RedoActionHandler(editorSite, undoContext);
383
//			PlatformUI.getWorkbench().getHelpSystem().setHelp(redoAction, IAbstractTextEditorHelpContextIds.REDO_ACTION);
384
			redoAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.REDO);
385

  
386

  
387
			IActionBars actionBars = editorSite.getActionBars();
388
			if (actionBars != null) {
389
				actionBars.setGlobalActionHandler(IWorkbenchActionDefinitionIds.UNDO, undoAction);
390
				actionBars.setGlobalActionHandler(IWorkbenchActionDefinitionIds.REDO, redoAction);
391

  
392
			}
393
		}
394
	}
395

  
396
}
397

  
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/container/AbstractGroupedContainerE4.java
19 19
import org.eclipse.jface.dialogs.Dialog;
20 20
import org.eclipse.jface.text.IDocument;
21 21
import org.eclipse.jface.text.Position;
22
import org.eclipse.jface.viewers.ISelectionChangedListener;
23 22
import org.eclipse.jface.window.DefaultToolTip;
24 23
import org.eclipse.swt.custom.StyledText;
25 24
import org.eclipse.swt.dnd.DND;
......
59 58
import eu.etaxonomy.taxeditor.editor.name.container.IContainerConstants;
60 59
import eu.etaxonomy.taxeditor.editor.name.container.LineBreakListener;
61 60
import eu.etaxonomy.taxeditor.editor.name.container.LineWrapSupport;
62
import eu.etaxonomy.taxeditor.editor.name.container.NameViewer;
63 61
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
64 62
import eu.etaxonomy.taxeditor.editor.name.e4.dnd.NameEditorDragListenerE4;
65 63
import eu.etaxonomy.taxeditor.editor.name.e4.dnd.NameEditorDragSourceEffect;
......
102 100
	private FocusListener nameCompositeFocusListener;
103 101
	private ModifyListener nameCompositeModifyListener;
104 102

  
105
	protected NameViewer nameViewer;
103
	protected NameViewerE4 nameViewer;
106 104

  
107 105
	private AbstractGroupE4 group;
108 106

  
......
168 166
				// notify selection listener
169 167
				setDelayedSelection();
170 168
		};
171
		
169

  
172 170
		nameCompositeFocusListener = new FocusAdapter() {
173 171

  
174 172
			@Override
......
495 493
	}
496 494

  
497 495
	protected void createTextViewer() {
498
		nameViewer = new NameViewer(control);
496
		nameViewer = new NameViewerE4(control);
499 497

  
500 498
		focusListener = new FocusAdapter() {
501 499
			@Override
......
632 630
		getNameViewer().getTextWidget().setFont(font);
633 631
	}
634 632

  
635
	public NameViewer getNameViewer() {
633
	public NameViewerE4 getNameViewer() {
636 634
		if (nameViewer == null) {
637 635
			throw new RuntimeException(
638 636
					"The Name Viewer is corrupt for Name Container: " //$NON-NLS-1$
......
796 794
			// Set indent to viewer ruler's width
797 795
			if (getNameViewer().getRulerControl() != null) {
798 796
				// TODO right justify
799
				layoutData.indent = NameViewer.RULER_WIDTH;
797
				layoutData.indent = NameViewerE4.RULER_WIDTH;
800 798
			}
801 799
			nonEditableInfoLabel.setLayoutData(layoutData);
802 800

  
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteMisapplicationOperation.java
14 14
import org.eclipse.core.runtime.IAdaptable;
15 15
import org.eclipse.core.runtime.IProgressMonitor;
16 16
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.ui.IWorkbenchPage;
18 17

  
19 18
import eu.etaxonomy.cdm.api.application.ICdmRepository;
20 19
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/handler/AbstractDynamicConceptRelationMenu.java
1
/**
2
 *
3
 */
4
package eu.etaxonomy.taxeditor.editor.view.concept.handler;
5

  
6
import org.eclipse.jface.action.ContributionItem;
7
import org.eclipse.swt.events.SelectionEvent;
8
import org.eclipse.swt.events.SelectionListener;
9
import org.eclipse.swt.widgets.Event;
10
import org.eclipse.swt.widgets.Menu;
11
import org.eclipse.swt.widgets.MenuItem;
12
import org.eclipse.ui.handlers.IHandlerService;
13

  
14
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
15
import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
16
import eu.etaxonomy.taxeditor.model.MessagingUtils;
17
import eu.etaxonomy.taxeditor.store.CdmStore;
18

  
19
/**
20
 * <p>Abstract AbstractDynamicConceptRelationMenu class.</p>
21
 *
22
 * @author n.hoffmann
23
 * @created 17.04.2009
24
 * @version 1.0
25
 */
26
public abstract class AbstractDynamicConceptRelationMenu extends ContributionItem {
27

  
28
	/*
29
	 * (non-Javadoc)
30
	 * @see org.eclipse.jface.action.ContributionItem#fill(org.eclipse.swt.widgets.Menu, int)
31
	 */
32
	/** {@inheritDoc} */
33
	@Override
34
	public void fill(Menu menu, int index){
35
		final IHandlerService handlerService = (IHandlerService) TaxeditorEditorPlugin.getDefault().getWorkbench().getService(IHandlerService.class);
36
		/*
37
		for(final TaxonRelationshipTypeInverseContainer container : CdmStore.getTermManager().getPreferredTerms(TaxonRelationshipTypeInverseContainer.class)){
38
			MenuItem menuItem = new MenuItem(menu, -1);
39
			menuItem.setText(container.getTitleCache());
40
			menuItem.setData(container);
41
			menuItem.addSelectionListener(new SelectionListener(){
42

  
43
				public void widgetDefaultSelected(SelectionEvent e) {}
44

  
45
				public void widgetSelected(SelectionEvent ev) {
46
					Event event = new Event();
47
					event.data = container;
48
					try {
49
						handlerService.executeCommand(getCommandName(), event);
50
					} catch (Exception e) {
51
						EditorUtil.error(getClass(), "Error executing command", e);
52
					}
53
				}
54
			});
55
		*/
56
		for(final TaxonRelationshipType taxonRelationshipType: CdmStore.getTermManager().getPreferredTerms(TaxonRelationshipType.class)){
57
		    if (!taxonRelationshipType.equals(TaxonRelationshipType.TAXONOMICALLY_INCLUDED_IN())){
58
			MenuItem menuItem = new MenuItem(menu, -1);
59
			menuItem.setText(taxonRelationshipType.getTitleCache());
60
			menuItem.setData(taxonRelationshipType);
61
			menuItem.addSelectionListener(new SelectionListener(){
62

  
63
				@Override
64
                public void widgetDefaultSelected(SelectionEvent e) {}
65

  
66
				@Override
67
                public void widgetSelected(SelectionEvent ev) {
68
					Event event = new Event();
69
					event.data = taxonRelationshipType;
70
					try {
71
						handlerService.executeCommand(getCommandName(), event);
72
					} catch (Exception e) {
73
						MessagingUtils.error(getClass(), "Error executing command", e); //$NON-NLS-1$
74
					}
75
				}
76
			});
77
		    }
78
		}
79
	}
80

  
81
	/**
82
	 * <p>getCommandName</p>
83
	 *
84
	 * @return a {@link java.lang.String} object.
85
	 */
86
	public abstract String getCommandName();
87

  
88
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/handler/ChangeToConceptRelationMenu.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.concept.handler;
11

  
12

  
13

  
14
/**
15
 * <p>ChangeToConceptRelationMenu class.</p>
16
 *
17
 * @author n.hoffmann
18
 * @created 22.04.2009
19
 * @version 1.0
20
 */
21
public class ChangeToConceptRelationMenu extends
22
		AbstractDynamicConceptRelationMenu {
23
	
24
	public String commandName = "eu.etaxonomy.taxeditor.editor.name.changeToConceptRelation"; //$NON-NLS-1$
25

  
26
	/* (non-Javadoc)
27
	 * @see eu.etaxonomy.taxeditor.editor.handler.AbstractDynamicConceptRelationMenu#getCommandName()
28
	 */
29
	/** {@inheritDoc} */
30
	@Override
31
	public String getCommandName() {
32
		return commandName;
33
	}
34
	
35
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/handler/CreateConceptRelationMenu.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.concept.handler;
11

  
12

  
13

  
14
/**
15
 * <p>CreateConceptRelationMenu class.</p>
16
 *
17
 * @author n.hoffmann
18
 * @created 22.04.2009
19
 * @version 1.0
20
 */
21
public class CreateConceptRelationMenu extends
22
		AbstractDynamicConceptRelationMenu {
23
	
24
	public String commandName = "eu.etaxonomy.taxeditor.editor.name.createConceptRelation"; //$NON-NLS-1$
25

  
26
	/* (non-Javadoc)
27
	 * @see eu.etaxonomy.taxeditor.editor.handler.AbstractDynamicConceptRelationMenu#getCommandName()
28
	 */
29
	/** {@inheritDoc} */
30
	@Override
31
	public String getCommandName() {
32
		return commandName;
33
	}
34
	
35
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)