Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 235222 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/sandbox/ui/editors/TaskEditorExtensions.java (+1 lines)
Lines 34-39 Link Here
34
	private static boolean initialized;
34
	private static boolean initialized;
35
35
36
	public static SortedSet<RegisteredTaskEditorExtension> getTaskEditorExtensions() {
36
	public static SortedSet<RegisteredTaskEditorExtension> getTaskEditorExtensions() {
37
		init();
37
		return new TreeSet<RegisteredTaskEditorExtension>(extensionsById.values());
38
		return new TreeSet<RegisteredTaskEditorExtension>(extensionsById.values());
38
	}
39
	}
39
40
(-)src/org/eclipse/mylyn/internal/sandbox/ui/editors/TaskEditorExtensionReader.java (-1 / +1 lines)
Lines 28-34 Link Here
28
28
29
	public static final String ATTR_NAME = "name";
29
	public static final String ATTR_NAME = "name";
30
30
31
	public static final String EXTENSION_TASK_EDITOR_EXTENSIONS = "org.eclipse.mylyn.tasks.ui.taskEditorExtensions";
31
	public static final String EXTENSION_TASK_EDITOR_EXTENSIONS = "org.eclipse.mylyn.sandbox.ui.taskEditorExtensions";
32
32
33
	private static final String REPOSITORY_ASSOCIATION = "repositoryAssociation";
33
	private static final String REPOSITORY_ASSOCIATION = "repositoryAssociation";
34
34
(-)plugin.xml (+8 lines)
Lines 357-362 Link Here
357
             state="true">
357
             state="true">
358
       </decorator>
358
       </decorator>
359
    </extension>
359
    </extension>
360
   <extension
361
         point="org.eclipse.mylyn.tasks.ui.editors">
362
      <pageFactory
363
            class="org.eclipse.mylyn.internal.sandbox.ui.editors.bugzilla.BugzillaTaskEditorPageFactory2"
364
            id="org.eclipse.mylyn.bugzilla.ui.pageFactory">
365
      </pageFactory>     
366
      </extension>
360
   
367
   
361
   
368
   
362
   
369
   
Lines 389-394 Link Here
389
            contentProvider="org.eclipse.mylyn.internal.sandbox.ui.GroupedTaskListContentProvider:Sheduled"/>
396
            contentProvider="org.eclipse.mylyn.internal.sandbox.ui.GroupedTaskListContentProvider:Sheduled"/>
390
   </extension>
397
   </extension>
391
   -->
398
   -->
399
  
392
   
400
   
393
</plugin>
401
</plugin>
394
402
(-)src/org/eclipse/mylyn/internal/sandbox/ui/editors/bugzilla/BugzillaTaskEditorPageFactory2.java (+26 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2007 Mylyn project committers and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *******************************************************************************/
8
9
package org.eclipse.mylyn.internal.sandbox.ui.editors.bugzilla;
10
11
import org.eclipse.mylyn.internal.bugzilla.ui.editor.BugzillaTaskEditorPageFactory;
12
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
13
import org.eclipse.ui.forms.editor.FormPage;
14
15
/**
16
 * A bugzilla task editor page factory that invokes a task editor page that has wiki facilities
17
 * 
18
 * @author Jingwen Ou
19
 */
20
public class BugzillaTaskEditorPageFactory2 extends BugzillaTaskEditorPageFactory {
21
22
	@Override
23
	public FormPage createPage(TaskEditor parentEditor) {
24
		return new BugzillaTaskEditorPage2(parentEditor);
25
	}
26
}
(-)src/org/eclipse/mylyn/internal/sandbox/ui/editors/bugzilla/RichTextAttributeEditor2.java (+191 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2007 Mylyn project committers and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *******************************************************************************/
8
9
package org.eclipse.mylyn.internal.sandbox.ui.editors.bugzilla;
10
11
import org.eclipse.jface.text.Document;
12
import org.eclipse.jface.text.ITextListener;
13
import org.eclipse.jface.text.TextEvent;
14
import org.eclipse.jface.text.source.SourceViewer;
15
import org.eclipse.jface.viewers.Viewer;
16
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonThemes;
17
import org.eclipse.mylyn.internal.sandbox.ui.editors.AbstractTaskEditorExtension;
18
import org.eclipse.mylyn.internal.tasks.ui.editors.RichTextAttributeEditor;
19
import org.eclipse.mylyn.tasks.core.TaskRepository;
20
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
21
import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
22
import org.eclipse.swt.SWT;
23
import org.eclipse.swt.custom.CTabFolder;
24
import org.eclipse.swt.custom.CTabItem;
25
import org.eclipse.swt.events.DisposeEvent;
26
import org.eclipse.swt.events.DisposeListener;
27
import org.eclipse.swt.events.FocusEvent;
28
import org.eclipse.swt.events.FocusListener;
29
import org.eclipse.swt.events.SelectionEvent;
30
import org.eclipse.swt.events.SelectionListener;
31
import org.eclipse.swt.graphics.Font;
32
import org.eclipse.swt.widgets.Composite;
33
import org.eclipse.ui.PlatformUI;
34
import org.eclipse.ui.contexts.IContextActivation;
35
import org.eclipse.ui.contexts.IContextService;
36
import org.eclipse.ui.forms.widgets.FormToolkit;
37
import org.eclipse.ui.themes.IThemeManager;
38
39
/**
40
 * A multitab source viewer that can edit and preview Textile wikitext markup
41
 * 
42
 * FIXME: it will be cool that RichTextAttributeEditor has a protected method to create the SourceViewer
43
 * (RepositoryTextViewer), then subclasses can then create its own SourceViewer without overriding createControl and
44
 * copying the code in it
45
 * 
46
 * @author Jingwen Ou
47
 */
48
public class RichTextAttributeEditor2 extends RichTextAttributeEditor {
49
50
	private SourceViewer source;
51
52
	private final TaskRepository taskRepository;
53
54
	private final int styles;
55
56
	private final IContextService contextService;
57
58
	private IContextActivation contextActivation;
59
60
	private final AbstractTaskEditorExtension extension;
61
62
	public RichTextAttributeEditor2(IContextService contextService, TaskDataModel manager,
63
			TaskRepository taskRepository, AbstractTaskEditorExtension extension, TaskAttribute taskAttribute,
64
			int styles) {
65
		super(manager, taskRepository, taskAttribute, styles);
66
		this.contextService = contextService;
67
		this.taskRepository = taskRepository;
68
		this.extension = extension;
69
		this.styles = styles;
70
	}
71
72
	@Override
73
	public SourceViewer getViewer() {
74
		return source;
75
	}
76
77
	@Override
78
	public void createControl(Composite parent, FormToolkit toolkit) {
79
		if (isReadOnly()) {
80
			source = extension.createViewer(taskRepository, parent, styles);
81
			source.setDocument(new Document(getValue()));
82
83
			setControl(source instanceof Viewer ? ((Viewer) source).getControl() : source.getTextWidget());
84
		} else {
85
			CTabFolder folder = new CTabFolder(parent, SWT.FLAT | SWT.BOTTOM);
86
87
			/** wikitext markup editor **/
88
89
			CTabItem viewerItem = new CTabItem(folder, SWT.NONE);
90
			viewerItem.setText("Source");
91
			viewerItem.setToolTipText("Edit Source");
92
93
			source = extension.createEditor(taskRepository, folder, styles | SWT.V_SCROLL);
94
			if (source.getDocument() == null) {
95
				source.setDocument(new Document(getValue()));
96
			}
97
			source.addTextListener(new ITextListener() {
98
				public void textChanged(TextEvent event) {
99
					// filter out events caused by text presentation changes, e.g. annotation drawing
100
					String value = source.getTextWidget().getText();
101
					if (!getValue().equals(value)) {
102
						setValue(value);
103
					}
104
				}
105
			});
106
			source.getControl().setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
107
108
			//setting up focus stuff, copied from Daivd's solution
109
			FocusListener focusListener = new FocusListener() {
110
111
				public void focusGained(FocusEvent e) {
112
					setContext();
113
				}
114
115
				public void focusLost(FocusEvent e) {
116
					unsetContext();
117
				}
118
			};
119
			source.getTextWidget().addFocusListener(focusListener);
120
			DisposeListener disposeListener = new DisposeListener() {
121
				public void widgetDisposed(DisposeEvent e) {
122
					unsetContext();
123
				}
124
			};
125
			source.getTextWidget().addDisposeListener(disposeListener);
126
127
			viewerItem.setControl(source instanceof Viewer ? ((Viewer) source).getControl() : source.getTextWidget());
128
			folder.setSelection(viewerItem);
129
130
			/** wikitext markup viewer **/
131
132
			CTabItem previewItem = new CTabItem(folder, SWT.NONE);
133
			previewItem.setText("Preview");
134
			previewItem.setToolTipText("Preview Source");
135
136
			final SourceViewer preview = extension.createViewer(taskRepository, folder, styles);
137
138
			previewItem.setControl(preview instanceof Viewer ? ((Viewer) preview).getControl()
139
					: preview.getTextWidget());
140
141
			folder.addSelectionListener(new SelectionListener() {
142
				public void widgetDefaultSelected(SelectionEvent selectionevent) {
143
					widgetSelected(selectionevent);
144
				}
145
146
				public void widgetSelected(SelectionEvent selectionevent) {
147
					Document document = new Document(source.getDocument().get());
148
					preview.setDocument(document);
149
				}
150
			});
151
152
			setControl(folder);
153
		}
154
155
		IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager();
156
		Font font = themeManager.getCurrentTheme().getFontRegistry().get(CommonThemes.FONT_EDITOR_COMMENT);
157
		source.getTextWidget().setFont(font);
158
		toolkit.adapt(source.getControl(), true, false);
159
160
	}
161
162
	protected void unsetContext() {
163
		if (contextActivation != null) {
164
			contextService.deactivateContext(contextActivation);
165
			contextActivation = null;
166
		}
167
	}
168
169
	protected void setContext() {
170
		if (contextActivation != null) {
171
			contextService.deactivateContext(contextActivation);
172
			contextActivation = null;
173
		}
174
		if (contextService != null && extension.getEditorContextId() != null) {
175
			contextActivation = contextService.activateContext(extension.getEditorContextId());
176
		}
177
	}
178
}
179
180
/**
181
 * left for future extensions
182
 */
183
//	private boolean enabled = true;
184
//
185
//	public boolean isEnabled() {
186
//		return enabled;
187
//	}
188
//
189
//	public void setEnabled(boolean enabled) {
190
//		this.enabled = enabled;
191
//	}
(-)src/org/eclipse/mylyn/internal/sandbox/ui/editors/bugzilla/BugzillaTaskEditorPage2.java (+72 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2007 Mylyn project committers and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *******************************************************************************/
8
9
package org.eclipse.mylyn.internal.sandbox.ui.editors.bugzilla;
10
11
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
12
import org.eclipse.mylyn.internal.bugzilla.ui.editor.BugzillaCcAttributeEditor;
13
import org.eclipse.mylyn.internal.bugzilla.ui.editor.BugzillaKeywordAttributeEditor;
14
import org.eclipse.mylyn.internal.bugzilla.ui.editor.BugzillaTaskEditorPage;
15
import org.eclipse.mylyn.internal.sandbox.ui.editors.AbstractTaskEditorExtension;
16
import org.eclipse.mylyn.internal.sandbox.ui.editors.TaskEditorExtensions;
17
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
18
import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor;
19
import org.eclipse.mylyn.tasks.ui.editors.AttributeEditorFactory;
20
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
21
import org.eclipse.swt.SWT;
22
import org.eclipse.ui.contexts.IContextService;
23
24
/**
25
 * A bugzilla task editor page that has wiki facilities
26
 * 
27
 * @author Jingwen Ou
28
 */
29
public class BugzillaTaskEditorPage2 extends BugzillaTaskEditorPage {
30
31
	public BugzillaTaskEditorPage2(TaskEditor editor) {
32
		super(editor);
33
	}
34
35
	@Override
36
	protected AttributeEditorFactory createAttributeEditorFactory() {
37
		AttributeEditorFactory factory = new AttributeEditorFactory(getModel(), getTaskRepository()) {
38
			@Override
39
			public AbstractAttributeEditor createEditor(String type, TaskAttribute taskAttribute) {
40
41
				//replace all long rich text & short rich text, including description part and the comment part, others copied from super class
42
				AbstractTaskEditorExtension extension = TaskEditorExtensions.getTaskEditorExtension(getTaskRepository());
43
				if (extension != null) {
44
					if (TaskAttribute.TYPE_LONG_RICH_TEXT.equals(type)) {
45
						return new RichTextAttributeEditor2((IContextService) getEditor().getEditorSite().getService(
46
								IContextService.class), getModel(), getTaskRepository(), extension, taskAttribute,
47
								SWT.MULTI);
48
					} else if (TaskAttribute.TYPE_SHORT_RICH_TEXT.equals(type)) {
49
						return new RichTextAttributeEditor2((IContextService) getEditor().getEditorSite().getService(
50
								IContextService.class), getModel(), getTaskRepository(), extension, taskAttribute,
51
								SWT.SINGLE);
52
					}
53
				}
54
55
				// copied from BugzillaTaskEditorPage#createAttributeEditorFactory(), create other editors
56
				AbstractAttributeEditor editor;
57
				if (IBugzillaConstants.EDITOR_TYPE_KEYWORDS.equals(type)) {
58
					editor = new BugzillaKeywordAttributeEditor(getModel(), taskAttribute);
59
				} else if (IBugzillaConstants.EDITOR_TYPE_REMOVECC.equals(type)) {
60
					editor = new BugzillaCcAttributeEditor(getModel(), taskAttribute);
61
				} else {
62
					editor = super.createEditor(type, taskAttribute);
63
					if (TaskAttribute.TYPE_BOOLEAN.equals(type)) {
64
						editor.setDecorationEnabled(false);
65
					}
66
				}
67
				return editor;
68
			}
69
		};
70
		return factory;
71
	}
72
}
(-)plugin.xml (-7 / +1 lines)
Lines 58-69 Link Here
58
      </language> 
58
      </language> 
59
   </extension>    
59
   </extension>    
60
  
60
  
61
     <extension
61
     
62
         point="org.eclipse.mylyn.tasks.ui.editors">
63
      <pageFactory
64
            class="org.eclipse.mylyn.internal.bugzilla.ui.editor.BugzillaTaskEditorPageFactory"
65
            id="org.eclipse.mylyn.bugzilla.ui.pageFactory">
66
      </pageFactory>            
67
   </extension>
68
   
62
   
69
</plugin>
63
</plugin>

Return to bug 235222