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
(-)plugin.xml (-1 / +23 lines)
Lines 358-364 Link Here
358
       </decorator>
358
       </decorator>
359
    </extension>
359
    </extension>
360
   
360
   
361
   
361
   <extension
362
         point="org.eclipse.mylyn.tasks.ui.editors">
363
      <pageFactory
364
            class="org.eclipse.mylyn.internal.sandbox.ui.editors.bugzilla.BugzillaTaskEditorPageFactory"
365
            id="org.eclipse.mylyn.bugzilla.ui.pageFactory">
366
      </pageFactory>            
367
   </extension>
368
   <extension
369
         point="org.eclipse.mylyn.sandbox.ui.taskEditorExtensions">
370
      <taskEditorExtension
371
            class="org.eclipse.mylyn.internal.sandbox.ui.editors.DefalutTaskEditorExtension"
372
            id="org.eclipse.mylyn.sandbox.ui.defaultTaskEditorExtension"
373
            name="Textile">
374
      </taskEditorExtension>
375
      <repositoryAssociation
376
            repository="bugzilla"
377
            taskEditorExtension="org.eclipse.mylyn.sandbox.ui.defaultTaskEditorExtension">
378
      </repositoryAssociation>
379
      <repositoryAssociation
380
            repository="local"
381
            taskEditorExtension="org.eclipse.mylyn.sandbox.ui.defaultTaskEditorExtension">
382
      </repositoryAssociation>
383
   </extension>
362
   
384
   
363
   <!--
385
   <!--
364
   <extension point="org.eclipse.mylyn.tasks.ui.presentations">
386
   <extension point="org.eclipse.mylyn.tasks.ui.presentations">
(-)META-INF/MANIFEST.MF (-1 / +4 lines)
Lines 27-33 Link Here
27
 org.eclipse.mylyn.monitor.core;bundle-version="[3.0.0,4.0.0)",
27
 org.eclipse.mylyn.monitor.core;bundle-version="[3.0.0,4.0.0)",
28
 org.eclipse.mylyn.resources.ui;bundle-version="[3.0.0,4.0.0)",
28
 org.eclipse.mylyn.resources.ui;bundle-version="[3.0.0,4.0.0)",
29
 org.eclipse.mylyn.ide.ant;bundle-version="[3.0.0,4.0.0)",
29
 org.eclipse.mylyn.ide.ant;bundle-version="[3.0.0,4.0.0)",
30
 org.eclipse.mylyn.pde.ui;bundle-version="[3.0.0,4.0.0)"
30
 org.eclipse.mylyn.pde.ui;bundle-version="[3.0.0,4.0.0)",
31
 org.eclipse.mylyn.wikitext.textile.core;bundle-version="1.0.0"
31
Bundle-ActivationPolicy: lazy
32
Bundle-ActivationPolicy: lazy
32
Bundle-Vendor: Eclipse.org
33
Bundle-Vendor: Eclipse.org
33
Export-Package: org.eclipse.mylyn.internal.sandbox.bridge.bugs;x-internal:=true,
34
Export-Package: org.eclipse.mylyn.internal.sandbox.bridge.bugs;x-internal:=true,
Lines 40-42 Link Here
40
 org.eclipse.mylyn.internal.sandbox.ui.views;x-internal:=true
41
 org.eclipse.mylyn.internal.sandbox.ui.views;x-internal:=true
41
Bundle-RequiredExecutionEnvironment: J2SE-1.5
42
Bundle-RequiredExecutionEnvironment: J2SE-1.5
42
Bundle-ClassPath: .
43
Bundle-ClassPath: .
44
Import-Package: org.eclipse.mylyn.wikitext.core.parser.markup,
45
 org.eclipse.mylyn.wikitext.ui.viewer
(-)src/org/eclipse/mylyn/internal/sandbox/ui/editors/bugzilla/WikiTextAttributeEditor.java (+103 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.mylyn.internal.provisional.commons.ui.CommonThemes;
16
import org.eclipse.mylyn.internal.sandbox.ui.editors.AbstractTaskEditorExtension;
17
import org.eclipse.mylyn.internal.sandbox.ui.editors.TaskEditorExtensionHelper;
18
import org.eclipse.mylyn.internal.sandbox.ui.editors.TaskEditorExtensions;
19
import org.eclipse.mylyn.internal.tasks.ui.editors.RichTextAttributeEditor;
20
import org.eclipse.mylyn.tasks.core.TaskRepository;
21
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
22
import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
23
import org.eclipse.swt.SWT;
24
import org.eclipse.swt.graphics.Font;
25
import org.eclipse.swt.widgets.Composite;
26
import org.eclipse.ui.PlatformUI;
27
import org.eclipse.ui.forms.widgets.FormToolkit;
28
import org.eclipse.ui.themes.IThemeManager;
29
30
public class WikiTextAttributeEditor extends RichTextAttributeEditor {
31
32
	private final int style;
33
34
	private final TaskRepository taskRepository;
35
36
	private SourceViewer viewer;
37
38
	public WikiTextAttributeEditor(TaskDataModel manager, TaskRepository taskRepository, TaskAttribute taskAttribute,
39
			int style) {
40
		super(manager, taskRepository, taskAttribute, style);
41
		this.style = style;
42
		this.taskRepository = taskRepository;
43
44
		TaskEditorExtensionHelper.initEditorExtensions();
45
	}
46
47
	@Override
48
	public void createControl(Composite parent, FormToolkit toolkit) {
49
		int style = this.style;
50
		if (!isReadOnly()) {
51
			style |= SWT.V_SCROLL;
52
		}
53
		style = SWT.FLAT | SWT.WRAP | style;
54
55
		AbstractTaskEditorExtension extension = TaskEditorExtensions.getTaskEditorExtension(taskRepository);
56
		if (extension != null) {
57
			if (isReadOnly()) {
58
				viewer = extension.createViewer(taskRepository, parent, style);
59
			} else {
60
				viewer = extension.createEditor(taskRepository, parent, style);
61
			}
62
		}
63
		Document document = new Document(getValue());
64
65
		if (viewer == null) {
66
			super.createControl(parent, toolkit);
67
			return;
68
		}
69
70
		if (isReadOnly()) {
71
			viewer.setEditable(false);
72
			viewer.setDocument(document);
73
		} else {
74
			viewer.setEditable(true);
75
			if (viewer.getDocument() == null) {
76
				viewer.setDocument(document);
77
			}
78
			viewer.addTextListener(new ITextListener() {
79
				public void textChanged(TextEvent event) {
80
					// filter out events caused by text presentation changes, e.g. annotation drawing
81
					String value = viewer.getTextWidget().getText();
82
					if (!getValue().equals(value)) {
83
						setValue(value);
84
					}
85
				}
86
			});
87
			//viewer.getControl().setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
88
		}
89
90
		IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager();
91
		Font font = themeManager.getCurrentTheme().getFontRegistry().get(CommonThemes.FONT_EDITOR_COMMENT);
92
		viewer.getTextWidget().setFont(font);
93
		toolkit.adapt(viewer.getTextWidget(), true, false);
94
95
		setControl(viewer.getTextWidget());
96
	}
97
98
	@Override
99
	public SourceViewer getViewer() {
100
		return viewer;
101
	}
102
103
}
(-)src/org/eclipse/mylyn/internal/sandbox/ui/editors/bugzilla/TaskEditorWikiNewCommentPart.java (+27 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.tasks.core.data.TaskAttribute;
12
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage;
13
import org.eclipse.ui.forms.widgets.ExpandableComposite;
14
15
public class TaskEditorWikiNewCommentPart extends TaskEditorWikiTextPart {
16
	public TaskEditorWikiNewCommentPart() {
17
		setPartName("New Comment");
18
		setSectionStyle(ExpandableComposite.TITLE_BAR | ExpandableComposite.EXPANDED);
19
		setExpandVertically(true);
20
	}
21
22
	@Override
23
	public void initialize(AbstractTaskEditorPage taskEditorPage) {
24
		super.initialize(taskEditorPage);
25
		setAttribute(getModel().getTaskData().getRoot().getMappedAttribute(TaskAttribute.COMMENT_NEW));
26
	}
27
}
(-)src/org/eclipse/mylyn/internal/sandbox/ui/editors/bugzilla/BugzillaTaskEditorPage.java (+144 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 java.util.Set;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute;
15
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
16
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
17
import org.eclipse.mylyn.internal.bugzilla.ui.editor.BugzillaCcAttributeEditor;
18
import org.eclipse.mylyn.internal.bugzilla.ui.editor.BugzillaKeywordAttributeEditor;
19
import org.eclipse.mylyn.internal.bugzilla.ui.editor.BugzillaPeoplePart;
20
import org.eclipse.mylyn.internal.bugzilla.ui.editor.BugzillaPlanningEditorPart;
21
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
22
import org.eclipse.mylyn.tasks.core.data.TaskData;
23
import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
24
import org.eclipse.mylyn.tasks.ui.TasksUi;
25
import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor;
26
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage;
27
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPart;
28
import org.eclipse.mylyn.tasks.ui.editors.AttributeEditorFactory;
29
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
30
import org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput;
31
import org.eclipse.mylyn.tasks.ui.editors.TaskEditorPartDescriptor;
32
33
/**
34
 * @author Rob Elves
35
 * @since 3.0
36
 */
37
public class BugzillaTaskEditorPage extends AbstractTaskEditorPage {
38
39
	public static final String ID_PART_BUGZILLA_PLANNING = "org.eclipse.mylyn.bugzilla.ui.editors.part.planning";
40
41
	public BugzillaTaskEditorPage(TaskEditor editor) {
42
		super(editor, BugzillaCorePlugin.CONNECTOR_KIND);
43
	}
44
45
	@Override
46
	protected Set<TaskEditorPartDescriptor> createPartDescriptors() {
47
		Set<TaskEditorPartDescriptor> descriptors = super.createPartDescriptors();
48
49
		// remove unnecessary default editor parts
50
		for (TaskEditorPartDescriptor taskEditorPartDescriptor : descriptors) {
51
			if (taskEditorPartDescriptor.getId().equals(ID_PART_PEOPLE)) {
52
				descriptors.remove(taskEditorPartDescriptor);
53
				break;
54
			}
55
		}
56
57
		for (TaskEditorPartDescriptor taskEditorPartDescriptor : descriptors) {
58
			if (taskEditorPartDescriptor.getId().equals(ID_PART_NEW_COMMENT)) {
59
				descriptors.remove(taskEditorPartDescriptor);
60
				break;
61
			}
62
		}
63
64
		// Add Bugzilla Planning part
65
		try {
66
			TaskData data = TasksUi.getTaskDataManager().getTaskData(getTask());
67
			if (data != null) {
68
				TaskAttribute attrEstimatedTime = data.getRoot().getMappedAttribute(
69
						BugzillaAttribute.ESTIMATED_TIME.getKey());
70
				if (attrEstimatedTime != null) {
71
					descriptors.add(new TaskEditorPartDescriptor(ID_PART_BUGZILLA_PLANNING) {
72
						@Override
73
						public AbstractTaskEditorPart createPart() {
74
							return new BugzillaPlanningEditorPart();
75
						}
76
					}.setPath(PATH_ATTRIBUTES));
77
				}
78
			}
79
		} catch (CoreException e) {
80
			// ignore
81
		}
82
83
		// Add the updated Bugzilla people part
84
		descriptors.add(new TaskEditorPartDescriptor(ID_PART_PEOPLE) {
85
			@Override
86
			public AbstractTaskEditorPart createPart() {
87
				return new BugzillaPeoplePart();
88
			}
89
		}.setPath(PATH_PEOPLE));
90
91
		// Add the new comment part with wiki integration
92
		descriptors.add(new TaskEditorPartDescriptor(ID_PART_NEW_COMMENT) {
93
			@Override
94
			public AbstractTaskEditorPart createPart() {
95
				return new TaskEditorWikiNewCommentPart();
96
			}
97
		}.setPath(PATH_COMMENTS));
98
99
		return descriptors;
100
	}
101
102
	@Override
103
	protected AttributeEditorFactory createAttributeEditorFactory() {
104
		AttributeEditorFactory factory = new AttributeEditorFactory(getModel(), getTaskRepository()) {
105
			@Override
106
			public AbstractAttributeEditor createEditor(String type, TaskAttribute taskAttribute) {
107
				AbstractAttributeEditor editor;
108
				if (IBugzillaConstants.EDITOR_TYPE_KEYWORDS.equals(type)) {
109
					editor = new BugzillaKeywordAttributeEditor(getModel(), taskAttribute);
110
				} else if (IBugzillaConstants.EDITOR_TYPE_REMOVECC.equals(type)) {
111
					editor = new BugzillaCcAttributeEditor(getModel(), taskAttribute);
112
				} else {
113
					editor = super.createEditor(type, taskAttribute);
114
					if (TaskAttribute.TYPE_BOOLEAN.equals(type)) {
115
						editor.setDecorationEnabled(false);
116
					}
117
				}
118
119
				return editor;
120
			}
121
		};
122
		return factory;
123
	}
124
125
	@Override
126
	protected TaskDataModel createModel(TaskEditorInput input) throws CoreException {
127
		TaskDataModel model = super.createModel(input);
128
		if (model.getTaskData().isNew()) {
129
			TaskAttribute attrDescription = model.getTaskData().getRoot().getMappedAttribute(TaskAttribute.DESCRIPTION);
130
			if (attrDescription != null) {
131
				attrDescription.getMetaData().setReadOnly(false);
132
			}
133
			TaskAttribute attrOwner = model.getTaskData().getRoot().getMappedAttribute(TaskAttribute.USER_ASSIGNED);
134
			if (attrOwner != null) {
135
				attrOwner.getMetaData().setReadOnly(false);
136
			}
137
			TaskAttribute attrAddSelfToCc = model.getTaskData().getRoot().getMappedAttribute(TaskAttribute.ADD_SELF_CC);
138
			if (attrAddSelfToCc != null) {
139
				attrAddSelfToCc.getMetaData().setKind(null);
140
			}
141
		}
142
		return model;
143
	}
144
}
(-).refactorings/2008/6/23/refactorings.index (+3 lines)
Added Link Here
1
1212827078015	Move compilation unit
2
1212828531765	Move compilation units
3
1212830996265	Extract method 'checkMarkupLanguage'
(-)src/org/eclipse/mylyn/internal/sandbox/ui/editors/MarkupTaskEditorExtension.java (+156 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.source.IVerticalRuler;
12
import org.eclipse.jface.text.source.SourceViewer;
13
import org.eclipse.jface.viewers.Viewer;
14
import org.eclipse.mylyn.tasks.core.TaskRepository;
15
import org.eclipse.mylyn.wikitext.core.parser.markup.MarkupLanguage;
16
import org.eclipse.mylyn.wikitext.ui.viewer.MarkupViewer;
17
import org.eclipse.mylyn.wikitext.ui.viewer.MarkupViewerConfiguration;
18
import org.eclipse.swt.SWT;
19
import org.eclipse.swt.custom.CTabFolder;
20
import org.eclipse.swt.custom.CTabItem;
21
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.swt.widgets.Control;
23
24
/**
25
 * @author Jingwen Ou
26
 */
27
public abstract class MarkupTaskEditorExtension extends AbstractTaskEditorExtension {
28
29
	private boolean enable;
30
31
	public abstract class MultiSourceViewer extends SourceViewer {
32
33
		private CTabFolder folder;
34
35
		public MultiSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
36
			super(parent, ruler, styles);
37
		}
38
39
		// FIXME so wired can't access FastMarkupPartitioner
40
//		private void configurePartitioning(IDocument document) {
41
//			FastMarkupPartitioner partitioner = new FastMarkupPartitioner();
42
//			partitioner.setMarkupLanguage(markupLanguage.clone());
43
//			partitioner.connect(document);
44
//			document.setDocumentPartitioner(partitioner);
45
//		}
46
47
		//surround the source viewer with CTabFolder if enable is true
48
		@Override
49
		public void createControl(Composite parent, int styles) {
50
			if (!enable) {
51
				super.createControl(parent, styles);
52
				return;
53
			}
54
55
			folder = new CTabFolder(parent, SWT.BOTTOM);
56
			{
57
				CTabItem viewerItem = new CTabItem(folder, SWT.NONE);
58
				viewerItem.setText("Source");
59
				viewerItem.setToolTipText("Edit Source");
60
61
				super.createControl(folder, styles);
62
63
				viewerItem.setControl(this.getTextWidget());
64
				folder.setSelection(viewerItem);
65
			}
66
67
			{
68
				CTabItem previewItem = new CTabItem(folder, SWT.NONE);
69
				previewItem.setText("Preview");
70
				previewItem.setToolTipText("Preview Source");
71
72
				SourceViewer previewViewer = createPreviewViewer(folder, styles);
73
74
				previewItem.setControl(previewViewer instanceof Viewer ? ((Viewer) previewViewer).getControl()
75
						: previewViewer.getTextWidget());
76
			}
77
		}
78
79
		protected abstract SourceViewer createPreviewViewer(Composite parent, int style);
80
81
		public Control getParentControl() {
82
			return folder != null ? folder : this.getTextWidget().getParent();
83
		}
84
85
		public boolean isEnable() {
86
			return enable;
87
		}
88
89
//		@Override
90
//		public void setDocument(IDocument document, IAnnotationModel annotationModel, int modelRangeOffset,
91
//				int modelRangeLength) {
92
//			configurePartitioning(document);
93
//			super.setDocument(document, annotationModel, modelRangeOffset, modelRangeLength);
94
//		}
95
	}
96
97
	private MarkupLanguage markupLanguage;;
98
99
	public MarkupTaskEditorExtension() {
100
		initializeMarkupLanguage();
101
	}
102
103
	private void checkMarkupLanguage() {
104
		if (markupLanguage == null) {
105
			throw new IllegalStateException();
106
		}
107
	}
108
109
	protected SourceViewer createMultiSourceViewer(TaskRepository taskRepository, Composite parent, int style) {
110
		return createMultiSourceViewer(taskRepository, parent, style, true);
111
	}
112
113
	protected SourceViewer createMultiSourceViewer(final TaskRepository taskRepository, Composite parent, int style,
114
			boolean enable) {
115
		checkMarkupLanguage();
116
117
		this.enable = enable;
118
119
		// FIXME words don't really wrap, also "enter" does not work 
120
		SourceViewer multiSourceViewer = new MultiSourceViewer(parent, null, style | SWT.FLAT | SWT.WRAP) {
121
122
			@Override
123
			protected SourceViewer createPreviewViewer(Composite parent, int style) {
124
				return createReadOnlyViewer(taskRepository, parent, style);
125
			}
126
127
		};
128
129
		multiSourceViewer.getTextWidget().setEditable(true);
130
131
		return multiSourceViewer;
132
133
	}
134
135
	protected SourceViewer createReadOnlyViewer(TaskRepository taskRepository, Composite parent, int style) {
136
		checkMarkupLanguage();
137
		MarkupViewer markupViewer = new MarkupViewer(parent, null, style | SWT.FLAT | SWT.WRAP);
138
		markupViewer.setMarkupLanguage(markupLanguage.clone());
139
		MarkupViewerConfiguration configuration = new MarkupViewerConfiguration(markupViewer);
140
		markupViewer.configure(configuration);
141
142
		markupViewer.getTextWidget().setEditable(false);
143
144
		return markupViewer;
145
	}
146
147
	public MarkupLanguage getMarkupLanguage() {
148
		return markupLanguage;
149
	}
150
151
	public abstract void initializeMarkupLanguage();
152
153
	public void setMarkupLanguage(MarkupLanguage markupLanguage) {
154
		this.markupLanguage = markupLanguage;
155
	}
156
}
(-)src/org/eclipse/mylyn/internal/sandbox/ui/editors/bugzilla/TaskEditorWikiTextPart.java (+131 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.layout.GridDataFactory;
12
import org.eclipse.mylyn.internal.sandbox.ui.editors.MarkupTaskEditorExtension.MultiSourceViewer;
13
import org.eclipse.mylyn.internal.tasks.ui.editors.EditorUtil;
14
import org.eclipse.mylyn.internal.tasks.ui.editors.RichTextAttributeEditor;
15
import org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorRichTextPart;
16
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.graphics.Point;
18
import org.eclipse.swt.layout.GridData;
19
import org.eclipse.swt.layout.GridLayout;
20
import org.eclipse.swt.widgets.Composite;
21
import org.eclipse.swt.widgets.Control;
22
import org.eclipse.ui.forms.widgets.ExpandableComposite;
23
import org.eclipse.ui.forms.widgets.FormToolkit;
24
import org.eclipse.ui.forms.widgets.Section;
25
import org.eclipse.ui.internal.EditorAreaHelper;
26
import org.eclipse.ui.internal.WorkbenchPage;
27
28
public class TaskEditorWikiTextPart extends TaskEditorRichTextPart {
29
30
	private WikiTextAttributeEditor editor;
31
32
	private Composite composite;
33
34
	public TaskEditorWikiTextPart() {
35
		setSectionStyle(ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
36
	}
37
38
	@Override
39
	public void createControl(Composite parent, FormToolkit toolkit) {
40
		if (getAttribute() == null) {
41
			return;
42
		}
43
44
		editor = new WikiTextAttributeEditor(this.getTaskEditorPage().getModel(), this.getTaskEditorPage()
45
				.getTaskRepository(), getAttribute(), SWT.SINGLE);
46
47
		Section section = createSection(parent, toolkit, getSectionStyle());
48
49
		composite = toolkit.createComposite(section);
50
		GridLayout layout = new GridLayout();
51
		layout.numColumns = 1;
52
		composite.setLayout(layout);
53
54
		editor.createControl(composite, toolkit);
55
		if (editor.isReadOnly()) {
56
			GridDataFactory.fillDefaults().hint(EditorUtil.MAXIMUM_WIDTH, SWT.DEFAULT).applyTo(editor.getControl());
57
		} else {
58
			final GridData gd = new GridData();
59
			// wrap text at this margin, see comment below
60
			int width = getEditorWidth();
61
			// the goal is to make the text viewer as big as the text so it does not require scrolling when first drawn 
62
			// on screen
63
64
			//resizing CTabFolder if enable
65
			Control control = editor.getViewer().getTextWidget();
66
67
			if (editor.getViewer() instanceof MultiSourceViewer) {
68
				control = ((MultiSourceViewer) editor.getViewer()).getParentControl();
69
			}
70
71
			Point size = control.computeSize(width, SWT.DEFAULT, true);
72
			gd.widthHint = EditorUtil.MAXIMUM_WIDTH;
73
			gd.horizontalAlignment = SWT.FILL;
74
			gd.grabExcessHorizontalSpace = true;
75
			// limit height to be avoid dynamic resizing of the text widget: 
76
			// MAXIMUM_HEIGHT < height < MAXIMUM_HEIGHT * 4  
77
			//gd.minimumHeight = AbstractAttributeEditor.MAXIMUM_HEIGHT;
78
			gd.heightHint = Math.min(Math.max(EditorUtil.MAXIMUM_HEIGHT, size.y), EditorUtil.MAXIMUM_HEIGHT * 4);
79
			if (getExpandVertically()) {
80
				gd.verticalAlignment = SWT.FILL;
81
				gd.grabExcessVerticalSpace = true;
82
			}
83
84
			control.setLayoutData(gd);
85
			control.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
86
		}
87
88
		getTaskEditorPage().getAttributeEditorToolkit().adapt(editor);
89
90
		toolkit.paintBordersFor(composite);
91
		section.setClient(composite);
92
		setSection(toolkit, section);
93
94
	}
95
96
	@Override
97
	protected Composite getComposite() {
98
		return composite;
99
	}
100
101
	private int getEditorWidth() {
102
		int widthHint = 0;
103
		if (getManagedForm() != null && getManagedForm().getForm() != null) {
104
			widthHint = getManagedForm().getForm().getClientArea().width - 90;
105
		}
106
		if (widthHint <= 0 && getTaskEditorPage().getEditor().getEditorSite() != null
107
				&& getTaskEditorPage().getEditor().getEditorSite().getPage() != null) {
108
			EditorAreaHelper editorManager = ((WorkbenchPage) getTaskEditorPage().getEditor().getEditorSite().getPage()).getEditorPresentation();
109
			if (editorManager != null && editorManager.getLayoutPart() != null) {
110
				widthHint = editorManager.getLayoutPart().getControl().getBounds().width - 90;
111
			}
112
		}
113
		if (widthHint <= 0) {
114
			widthHint = EditorUtil.MAXIMUM_WIDTH;
115
		}
116
		return widthHint;
117
	}
118
119
	@Override
120
	protected RichTextAttributeEditor getEditor() {
121
		return editor;
122
	}
123
124
	@Override
125
	public void setFocus() {
126
		if (editor != null) {
127
			editor.getControl().setFocus();
128
		}
129
	}
130
131
}
(-)src/org/eclipse/mylyn/internal/sandbox/ui/editors/DefalutTaskEditorExtension.java (+41 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.source.SourceViewer;
12
import org.eclipse.mylyn.tasks.core.TaskRepository;
13
import org.eclipse.mylyn.wikitext.textile.core.TextileLanguage;
14
import org.eclipse.swt.widgets.Composite;
15
16
/**
17
 * @author Jingwen Ou
18
 */
19
public class DefalutTaskEditorExtension extends MarkupTaskEditorExtension {
20
21
	@Override
22
	public SourceViewer createEditor(TaskRepository taskRepository, Composite parent, int style) {
23
		return createMultiSourceViewer(taskRepository, parent, style);
24
	}
25
26
	@Override
27
	public SourceViewer createViewer(TaskRepository taskRepository, Composite parent, int style) {
28
		return createReadOnlyViewer(taskRepository, parent, style);
29
	}
30
31
	@Override
32
	public String getEditorContextId() {
33
		// ignore
34
		return null;
35
	}
36
37
	@Override
38
	public void initializeMarkupLanguage() {
39
		setMarkupLanguage(new TextileLanguage());
40
	}
41
}
(-)src/org/eclipse/mylyn/internal/sandbox/ui/editors/bugzilla/BugzillaTaskEditorPageFactory.java (+64 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.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
/**
23
 * @author Rob Elves
24
 */
25
public class BugzillaTaskEditorPageFactory extends AbstractTaskEditorPageFactory {
26
27
	@Override
28
	public boolean canCreatePageFor(TaskEditorInput input) {
29
		if (input.getTask().getConnectorKind().equals(BugzillaCorePlugin.CONNECTOR_KIND)
30
				|| TasksUiUtil.isOutgoingNewTask(input.getTask(), BugzillaCorePlugin.CONNECTOR_KIND)) {
31
			return true;
32
		}
33
		return false;
34
	}
35
36
	@Override
37
	public FormPage createPage(TaskEditor parentEditor) {
38
		return new BugzillaTaskEditorPage(parentEditor);
39
	}
40
41
	@Override
42
	public String[] getConflictingIds(TaskEditorInput input) {
43
		if (!input.getTask().getConnectorKind().equals(BugzillaCorePlugin.CONNECTOR_KIND)) {
44
			return new String[] { ITasksUiConstants.ID_PAGE_PLANNING };
45
		}
46
		return null;
47
	}
48
49
	@Override
50
	public int getPriority() {
51
		return PRIORITY_TASK;
52
	}
53
54
	@Override
55
	public Image getPageImage() {
56
		return CommonImages.getImage(TasksUiImages.REPOSITORY);
57
	}
58
59
	@Override
60
	public String getPageText() {
61
		return "Bugzilla";
62
	}
63
64
}
(-)src/org/eclipse/mylyn/internal/sandbox/ui/editors/TaskEditorExtensionHelper.java (+73 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.core.runtime.CoreException;
12
import org.eclipse.core.runtime.IConfigurationElement;
13
import org.eclipse.core.runtime.IExtension;
14
import org.eclipse.core.runtime.IExtensionPoint;
15
import org.eclipse.core.runtime.IExtensionRegistry;
16
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.core.runtime.Platform;
18
import org.eclipse.core.runtime.Status;
19
import org.eclipse.mylyn.commons.core.StatusHandler;
20
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
21
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiExtensionReader;
22
23
public class TaskEditorExtensionHelper {
24
25
	public static final String EXTENSION_TASK_EDITOR_EXTENSIONS = "org.eclipse.mylyn.sandbox.ui.taskEditorExtensions";
26
27
	private static final String REPOSITORY_ASSOCIATION = "repositoryAssociation";
28
29
	private static final String TASK_EDITOR_EXTENSION = "taskEditorExtension";
30
31
	public static void initEditorExtensions() {
32
		IExtensionRegistry registry = Platform.getExtensionRegistry();
33
34
		IExtensionPoint editorExtensionPoint = registry.getExtensionPoint(EXTENSION_TASK_EDITOR_EXTENSIONS);
35
		IExtension[] editorExtensions = editorExtensionPoint.getExtensions();
36
		for (IExtension extension : editorExtensions) {
37
			IConfigurationElement[] elements = extension.getConfigurationElements();
38
			for (IConfigurationElement element : elements) {
39
				if (element.getName().equals(TASK_EDITOR_EXTENSION)) {
40
					readEditorExtension(element);
41
				} else if (element.getName().equals(REPOSITORY_ASSOCIATION)) {
42
					readEditorExtensionAssociation(element);
43
				}
44
			}
45
		}
46
	}
47
48
	private static void readEditorExtensionAssociation(IConfigurationElement element) {
49
		try {
50
			String repository = element.getAttribute("repository");
51
			String taskEditorExtension = element.getAttribute("taskEditorExtension");
52
			TaskEditorExtensions.addRepositoryAssociation(repository, taskEditorExtension);
53
		} catch (Exception e) {
54
			StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Could not load taskEditorExtension",
55
					e));
56
		}
57
	}
58
59
	private static void readEditorExtension(IConfigurationElement element) {
60
		try {
61
			String id = element.getAttribute(TasksUiExtensionReader.ATTR_ID);
62
			String name = element.getAttribute(TasksUiExtensionReader.ATTR_NAME);
63
			AbstractTaskEditorExtension extension = (AbstractTaskEditorExtension) element.createExecutableExtension("class");
64
			TaskEditorExtensions.addTaskEditorExtension(id, name, extension);
65
		} catch (CoreException e) {
66
			StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Could not load taskEditorExtension",
67
					e));
68
		} catch (Exception e) {
69
			StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Could not load taskEditorExtension",
70
					e));
71
		}
72
	}
73
}
(-).refactorings/2008/6/23/refactorings.history (+3 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<session version="1.0">&#x0A;<refactoring comment="Move 1 elements(s) to &apos;org.eclipse.mylyn.tasks.ui/src/org.eclipse.mylyn.internal.tasks.ui.editors&apos;&#x0D;&#x0A;- Original project: &apos;org.eclipse.mylyn.sandbox.ui&apos;&#x0D;&#x0A;- Destination element: &apos;org.eclipse.mylyn.tasks.ui/src/org.eclipse.mylyn.internal.tasks.ui.editors&apos;&#x0D;&#x0A;- Original element: &apos;org.eclipse.mylyn.internal.sandbox.ui.editors.TaskEditorWikiTextPart.java&apos;&#x0D;&#x0A;- Update references to refactored element" description="Move compilation unit" destination="=org.eclipse.mylyn.tasks.ui/src&lt;org.eclipse.mylyn.internal.tasks.ui.editors" element1="/src&lt;org.eclipse.mylyn.internal.sandbox.ui.editors{TaskEditorWikiTextPart.java" files="0" flags="589830" folders="0" id="org.eclipse.jdt.ui.move" patterns="*" policy="org.eclipse.jdt.ui.moveResources" qualified="false" references="true" stamp="1212827078015" units="1" version="1.0"/>&#x0A;&#x0A;<refactoring comment="Move 3 elements(s) to &apos;org.eclipse.mylyn.sandbox.ui/src/org.eclipse.mylyn.internal.sandbox.ui.editors.bugzilla&apos;&#x0D;&#x0A;- Original project: &apos;org.eclipse.mylyn.sandbox.ui&apos;&#x0D;&#x0A;- Destination element: &apos;org.eclipse.mylyn.sandbox.ui/src/org.eclipse.mylyn.internal.sandbox.ui.editors.bugzilla&apos;&#x0D;&#x0A;- Original elements:&#x0D;&#x0A;     org.eclipse.mylyn.internal.sandbox.ui.editors.WikiTextAttributeEditor.java&#x0D;&#x0A;     org.eclipse.mylyn.internal.sandbox.ui.editors.BugzillaTaskEditorPage.java&#x0D;&#x0A;     org.eclipse.mylyn.internal.sandbox.ui.editors.TaskEditorWikiTextPart.java&#x0D;&#x0A;- Update references to refactored element" description="Move compilation units" destination="/src&lt;org.eclipse.mylyn.internal.sandbox.ui.editors.bugzilla" element1="/src&lt;org.eclipse.mylyn.internal.sandbox.ui.editors{WikiTextAttributeEditor.java" element2="/src&lt;org.eclipse.mylyn.internal.sandbox.ui.editors{BugzillaTaskEditorPage.java" element3="/src&lt;org.eclipse.mylyn.internal.sandbox.ui.editors{TaskEditorWikiTextPart.java" files="0" flags="589830" folders="0" id="org.eclipse.jdt.ui.move" patterns="*" policy="org.eclipse.jdt.ui.moveResources" qualified="false" references="true" stamp="1212828531765" units="3" version="1.0"/>&#x0A;<refactoring comment="Extract method &apos;private void checkMarkupLanguage()&apos; from &apos;org.eclipse.mylyn.internal.sandbox.ui.editors.MarkupTaskEditorExtension.createReadOnlyViewer()&apos; to &apos;org.eclipse.mylyn.internal.sandbox.ui.editors.MarkupTaskEditorExtension&apos;&#x0D;&#x0A;- Original project: &apos;org.eclipse.mylyn.sandbox.ui&apos;&#x0D;&#x0A;- Method name: &apos;checkMarkupLanguage&apos;&#x0D;&#x0A;- Destination type: &apos;org.eclipse.mylyn.internal.sandbox.ui.editors.MarkupTaskEditorExtension&apos;&#x0D;&#x0A;- Declared visibility: &apos;private&apos;&#x0D;&#x0A;- Replace occurrences of statements with method" comments="false" description="Extract method &apos;checkMarkupLanguage&apos;" destination="0" exceptions="false" flags="786434" id="org.eclipse.jdt.ui.extract.method" input="/src&lt;org.eclipse.mylyn.internal.sandbox.ui.editors{MarkupTaskEditorExtension.java" name="checkMarkupLanguage" replace="true" selection="3921 73" stamp="1212830996265" version="1.0" visibility="2"/>
3
</session>

Return to bug 235222