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/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
(-)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
(-)plugin.xml (+8 lines)
Lines 389-394 Link Here
389
            contentProvider="org.eclipse.mylyn.internal.sandbox.ui.GroupedTaskListContentProvider:Sheduled"/>
389
            contentProvider="org.eclipse.mylyn.internal.sandbox.ui.GroupedTaskListContentProvider:Sheduled"/>
390
   </extension>
390
   </extension>
391
   -->
391
   -->
392
  
393
     <extension
394
         point="org.eclipse.mylyn.tasks.ui.editors">
395
      <pageFactory
396
            class="org.eclipse.mylyn.internal.sandbox.ui.editors.BuzillaTaskEditorPageFactory2"
397
            id="org.eclipse.mylyn.internal.sandbox.ui.bugzillaPageFactory2">
398
      </pageFactory>            
399
   </extension>
392
   
400
   
393
</plugin>
401
</plugin>
394
402
(-)src/org/eclipse/mylyn/internal/sandbox/ui/editors/ExtensionAttributeEditorFactory.java (+54 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;
10
11
import org.eclipse.mylyn.tasks.core.TaskRepository;
12
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
13
import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
14
import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor;
15
import org.eclipse.mylyn.tasks.ui.editors.AttributeEditorFactory;
16
import org.eclipse.swt.SWT;
17
import org.eclipse.ui.IEditorSite;
18
import org.eclipse.ui.contexts.IContextService;
19
20
public class ExtensionAttributeEditorFactory extends AttributeEditorFactory {
21
22
	private final AbstractTaskEditorExtension extension;
23
24
	private final TaskDataModel model;
25
26
	private final TaskRepository taskRepository;
27
28
	private final IEditorSite editorSite;
29
30
	public ExtensionAttributeEditorFactory(IEditorSite editorSite, TaskDataModel model, TaskRepository taskRepository) {
31
		super(model, taskRepository);
32
		this.model = model;
33
		this.taskRepository = taskRepository;
34
		this.editorSite = editorSite;
35
		extension = TaskEditorExtensions.getTaskEditorExtension(taskRepository);
36
	}
37
38
	@Override
39
	public AbstractAttributeEditor createEditor(String type, TaskAttribute taskAttribute) {
40
		if (extension != null) {
41
			if (TaskAttribute.TYPE_SHORT_RICH_TEXT.equals(type)) {
42
				return new ExtensionRichTextAttributeEditor(
43
						(IContextService) editorSite.getService(IContextService.class), model, taskRepository,
44
						extension, taskAttribute, SWT.SINGLE);
45
			} else if (TaskAttribute.TYPE_LONG_RICH_TEXT.equals(type)) {
46
				return new ExtensionRichTextAttributeEditor(
47
						(IContextService) editorSite.getService(IContextService.class), model, taskRepository,
48
						extension, taskAttribute, SWT.MULTI);
49
			}
50
		}
51
		return super.createEditor(type, taskAttribute);
52
	}
53
54
}
(-)src/org/eclipse/mylyn/internal/sandbox/ui/editors/ExtensionRichTextAttributeEditor.java (+157 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;
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.mylyn.internal.provisional.commons.ui.CommonThemes;
16
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
17
import org.eclipse.mylyn.tasks.core.TaskRepository;
18
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
19
import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
20
import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor;
21
import org.eclipse.mylyn.tasks.ui.editors.LayoutHint;
22
import org.eclipse.mylyn.tasks.ui.editors.LayoutHint.ColumnSpan;
23
import org.eclipse.mylyn.tasks.ui.editors.LayoutHint.RowSpan;
24
import org.eclipse.swt.SWT;
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.graphics.Font;
30
import org.eclipse.swt.widgets.Composite;
31
import org.eclipse.ui.PlatformUI;
32
import org.eclipse.ui.contexts.IContextActivation;
33
import org.eclipse.ui.contexts.IContextService;
34
import org.eclipse.ui.forms.widgets.FormToolkit;
35
import org.eclipse.ui.themes.IThemeManager;
36
37
public class ExtensionRichTextAttributeEditor extends AbstractAttributeEditor {
38
39
	private final AbstractTaskEditorExtension extension;
40
41
	private final TaskRepository taskRepository;
42
43
	private final int style;
44
45
	private SourceViewer viewer;
46
47
	private final IContextService contextService;
48
49
	private FocusListener focusListener;
50
51
	private IContextActivation contextActivation;
52
53
	private DisposeListener disposeListener;
54
55
	public ExtensionRichTextAttributeEditor(IContextService contextService, TaskDataModel manager,
56
			TaskRepository taskRepository, AbstractTaskEditorExtension extension, TaskAttribute taskAttribute, int style) {
57
		super(manager, taskAttribute);
58
		this.contextService = contextService;
59
		this.taskRepository = taskRepository;
60
		this.extension = extension;
61
		this.style = style;
62
		if ((style & SWT.MULTI) != 0) {
63
			setLayoutHint(new LayoutHint(RowSpan.MULTIPLE, ColumnSpan.MULTIPLE));
64
		} else {
65
			setLayoutHint(new LayoutHint(RowSpan.SINGLE, ColumnSpan.MULTIPLE));
66
		}
67
	}
68
69
	@Override
70
	public void createControl(Composite parent, FormToolkit toolkit) {
71
		int style = this.style;
72
		if (!isReadOnly() && (style & TasksUiInternal.SWT_NO_SCROLL) == 0) {
73
			style |= SWT.V_SCROLL;
74
		}
75
		style = SWT.FLAT | SWT.WRAP | style;
76
77
		if (isReadOnly()) {
78
			viewer = extension.createViewer(taskRepository, parent, style);
79
		} else {
80
			viewer = extension.createEditor(taskRepository, parent, style);
81
		}
82
		Document document = new Document(getValue());
83
84
		IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager();
85
		Font font = themeManager.getCurrentTheme().getFontRegistry().get(CommonThemes.FONT_EDITOR_COMMENT);
86
		viewer.getTextWidget().setFont(font);
87
88
		if (isReadOnly()) {
89
			viewer.setEditable(false);
90
			viewer.setDocument(document);
91
		} else {
92
			viewer.setEditable(true);
93
			viewer.setDocument(document);
94
95
			viewer.addTextListener(new ITextListener() {
96
				public void textChanged(TextEvent event) {
97
					// filter out events caused by text presentation changes, e.g. annotation drawing
98
					String value = viewer.getTextWidget().getText();
99
					if (!getValue().equals(value)) {
100
						setValue(value);
101
					}
102
				}
103
			});
104
			viewer.getControl().setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
105
		}
106
107
		toolkit.adapt(viewer.getTextWidget(), true, false);
108
109
		setControl(viewer.getTextWidget());
110
111
		focusListener = new FocusListener() {
112
113
			public void focusGained(FocusEvent e) {
114
				setContext();
115
			}
116
117
			public void focusLost(FocusEvent e) {
118
				unsetContext();
119
			}
120
		};
121
122
		viewer.getTextWidget().addFocusListener(focusListener);
123
		disposeListener = new DisposeListener() {
124
			public void widgetDisposed(DisposeEvent e) {
125
				unsetContext();
126
			}
127
		};
128
129
		viewer.getTextWidget().addDisposeListener(disposeListener);
130
	}
131
132
	protected void unsetContext() {
133
		if (contextActivation != null) {
134
			contextService.deactivateContext(contextActivation);
135
			contextActivation = null;
136
		}
137
	}
138
139
	protected void setContext() {
140
		if (contextActivation != null) {
141
			contextService.deactivateContext(contextActivation);
142
			contextActivation = null;
143
		}
144
		if (contextService != null && extension.getEditorContextId() != null) {
145
			contextActivation = contextService.activateContext(extension.getEditorContextId());
146
		}
147
	}
148
149
	public String getValue() {
150
		return getAttributeMapper().getValue(getTaskAttribute());
151
	}
152
153
	public void setValue(String value) {
154
		getAttributeMapper().setValue(getTaskAttribute(), value);
155
		attributeChanged();
156
	}
157
}
(-)src/org/eclipse/mylyn/internal/sandbox/ui/editors/BuzillaTaskEditorPageFactory2.java (+61 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;
10
11
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
12
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
13
import org.eclipse.mylyn.tasks.ui.ITasksUiConstants;
14
import org.eclipse.mylyn.tasks.ui.TasksUiImages;
15
import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
16
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPageFactory;
17
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
18
import org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput;
19
import org.eclipse.swt.graphics.Image;
20
import org.eclipse.ui.forms.editor.FormPage;
21
22
public class BuzillaTaskEditorPageFactory2 extends AbstractTaskEditorPageFactory {
23
24
	@Override
25
	public boolean canCreatePageFor(TaskEditorInput input) {
26
		if (input.getTask().getConnectorKind().equals(BugzillaCorePlugin.CONNECTOR_KIND)
27
				|| TasksUiUtil.isOutgoingNewTask(input.getTask(), BugzillaCorePlugin.CONNECTOR_KIND)) {
28
			return true;
29
		}
30
		return false;
31
	}
32
33
	@Override
34
	public FormPage createPage(TaskEditor parentEditor) {
35
		return new BugzillaTaskEditorPage2(parentEditor);
36
	}
37
38
	@Override
39
	public String[] getConflictingIds(TaskEditorInput input) {
40
		if (!input.getTask().getConnectorKind().equals(BugzillaCorePlugin.CONNECTOR_KIND)) {
41
			return new String[] { ITasksUiConstants.ID_PAGE_PLANNING };
42
		}
43
		return null;
44
	}
45
46
	@Override
47
	public int getPriority() {
48
		return PRIORITY_TASK;
49
	}
50
51
	@Override
52
	public Image getPageImage() {
53
		return CommonImages.getImage(TasksUiImages.REPOSITORY);
54
	}
55
56
	@Override
57
	public String getPageText() {
58
		return "Bugzilla 2";
59
	}
60
61
}
(-)src/org/eclipse/mylyn/internal/sandbox/ui/editors/BugzillaTaskEditorPage2.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;
10
11
import org.eclipse.mylyn.internal.bugzilla.ui.editor.BugzillaTaskEditorPage;
12
import org.eclipse.mylyn.tasks.ui.editors.AttributeEditorFactory;
13
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
14
15
public class BugzillaTaskEditorPage2 extends BugzillaTaskEditorPage {
16
17
	public BugzillaTaskEditorPage2(TaskEditor editor) {
18
		super(editor);
19
	}
20
21
	@Override
22
	protected AttributeEditorFactory createAttributeEditorFactory() {
23
		return new ExtensionAttributeEditorFactory(getEditor().getEditorSite(), getModel(), getTaskRepository());
24
	}
25
26
}

Return to bug 235222