### Eclipse Workspace Patch 1.0 #P org.eclipse.mylyn.tasks.ui Index: src/org/eclipse/mylyn/internal/tasks/ui/editors/PreviewAttributeEditor.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/PreviewAttributeEditor.java,v retrieving revision 1.10 diff -u -r1.10 PreviewAttributeEditor.java --- src/org/eclipse/mylyn/internal/tasks/ui/editors/PreviewAttributeEditor.java 13 Jun 2008 10:27:01 -0000 1.10 +++ src/org/eclipse/mylyn/internal/tasks/ui/editors/PreviewAttributeEditor.java 18 Jun 2008 15:51:46 -0000 @@ -98,7 +98,7 @@ Composite editorComposite = toolkit.createComposite(composite); editorComposite.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); GridData gd = new GridData(GridData.FILL_BOTH); - gd.widthHint = EditorUtil.MAXIMUM_WIDTH; +// gd.widthHint = EditorUtil.MAXIMUM_WIDTH; gd.minimumHeight = EditorUtil.MAXIMUM_HEIGHT; gd.grabExcessHorizontalSpace = true; editorComposite.setLayoutData(gd); Index: src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorRichTextPart.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorRichTextPart.java,v retrieving revision 1.17 diff -u -r1.17 TaskEditorRichTextPart.java --- src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorRichTextPart.java 7 Jun 2008 08:13:41 -0000 1.17 +++ src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorRichTextPart.java 18 Jun 2008 15:51:46 -0000 @@ -112,8 +112,7 @@ } else { editor.createControl(composite, toolkit); if (editor.isReadOnly()) { - GridDataFactory.fillDefaults().minSize(EditorUtil.MAXIMUM_WIDTH, 0).hint(EditorUtil.MAXIMUM_WIDTH, - SWT.DEFAULT).applyTo(editor.getControl()); + composite.setLayout(new ShowAllLayout()); } else { final GridData gd = new GridData(); // wrap text at this margin, see comment below Index: src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorCommentPart.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorCommentPart.java,v retrieving revision 1.33 diff -u -r1.33 TaskEditorCommentPart.java --- src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorCommentPart.java 13 Jun 2008 03:20:32 -0000 1.33 +++ src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorCommentPart.java 18 Jun 2008 15:51:46 -0000 @@ -80,9 +80,6 @@ }); composite.setData(KEY_EDITOR, editor); - GridDataFactory.fillDefaults().minSize(EditorUtil.MAXIMUM_WIDTH, 0).hint(EditorUtil.MAXIMUM_WIDTH, - SWT.DEFAULT).applyTo(editor.getControl()); - getTaskEditorPage().getAttributeEditorToolkit().adapt(editor); getTaskEditorPage().reflow(); } @@ -191,11 +188,7 @@ final Composite commentTextComposite = toolkit.createComposite(commentComposite); commentComposite.setClient(commentTextComposite); - GridLayout ecLayout = new GridLayout(); - ecLayout.marginHeight = 0; - ecLayout.marginBottom = 3; - ecLayout.marginLeft = 15; - commentTextComposite.setLayout(ecLayout); + commentTextComposite.setLayout(new ShowAllLayout()); commentTextComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); commentComposite.addExpansionListener(new ExpansionAdapter() { @Override Index: src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java,v retrieving revision 1.68 diff -u -r1.68 AbstractTaskEditorPage.java --- src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java 16 Jun 2008 22:01:05 -0000 1.68 +++ src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java 18 Jun 2008 15:51:46 -0000 @@ -103,6 +103,8 @@ import org.eclipse.swt.events.FocusAdapter; import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.FocusListener; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.RowLayout; @@ -111,7 +113,9 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Link; +import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.Spinner; import org.eclipse.swt.widgets.TabFolder; @@ -448,6 +452,13 @@ @Override protected void createFormContent(final IManagedForm managedForm) { form = managedForm.getForm(); + + form.getParent().addListener(SWT.Resize, new Listener() { + public void handleEvent(Event event) { + reflow(); + } + }); + toolkit = managedForm.getToolkit(); registerDefaultDropListener(form); EditorUtil.disableScrollingOnFocus(form); @@ -1028,7 +1039,23 @@ */ public void reflow() { if (reflow) { - form.layout(true, true); + Rectangle parentClientArea = form.getParent().getClientArea(); + Point formSize = form.getSize(); + if (formSize.x != parentClientArea.width) { + form.setSize(parentClientArea.width, formSize.y); + } + Rectangle clientArea = form.getClientArea(); + + Composite body = form.getBody(); + Control[] children = body.getChildren(); + for (Control child : children) { + Object layoutData = child.getLayoutData(); + if (layoutData != null) { + ((GridData) layoutData).widthHint = clientArea.width; + } + } + + form.layout(true, false); form.reflow(true); } } Index: src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorExtension.java =================================================================== RCS file: src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorExtension.java diff -N src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorExtension.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorExtension.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Mylyn project committers and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.eclipse.mylyn.tasks.ui.editors; + +import org.eclipse.jface.text.source.SourceViewer; +import org.eclipse.mylyn.tasks.core.TaskRepository; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.contexts.IContextService; + +/** + * An extension that provides task editor capabilities beyond the default, oriented towards providing markup-aware + * editing and viewing + * + * @author David Green + */ +public abstract class AbstractTaskEditorExtension { + + /** + * Create a source viewer that can be used to view content in the task editor. The source viewer should be + * configured with a source viewer configuration prior to returning. + * + * @param taskRepository + * the task repository for which the viewer is created + * @param parent + * the control parent of the source viewer + * @param style + * the styles to use + */ + public abstract SourceViewer createViewer(TaskRepository taskRepository, Composite parent, int style); + + /** + * Create a source viewer that can be used to edit content in the task editor. The source viewer should be + * configured with a source viewer configuration prior to returning. + * + * @param taskRepository + * the task repository for which the viewer is created + * @param parent + * the control parent of the source viewer + * @param style + * the styles to use + */ + public abstract SourceViewer createEditor(TaskRepository taskRepository, Composite parent, int style); + + /** + * Get the editor context id, to be passed to the {@link IContextService} when the editor is in focus. + */ + public abstract String getEditorContextId(); +} Index: src/org/eclipse/mylyn/internal/tasks/ui/editors/ShowAllLayout.java =================================================================== RCS file: src/org/eclipse/mylyn/internal/tasks/ui/editors/ShowAllLayout.java diff -N src/org/eclipse/mylyn/internal/tasks/ui/editors/ShowAllLayout.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/mylyn/internal/tasks/ui/editors/ShowAllLayout.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Mylyn project committers and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.eclipse.mylyn.internal.tasks.ui.editors; + +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Layout; + +/** + * A layout that uses the width hint or width of a composite to recommend the width of its children, allowing children + * to occupy the preferred height for a given width. + * + * Intended for use with a composite that contains a single child that should fill available horizontal space. + * + * @author David Green + */ +public class ShowAllLayout extends Layout { + + @Override + protected Point computeSize(Composite composite, int widthHint, int heightHint, boolean flushCache) { + int resultX = 1; + int resultY = 1; + + Control[] children = composite.getChildren(); + + if (widthHint == -1) { + widthHint = composite.getClientArea().width; + if (widthHint < 300) { + widthHint = 300; + } + } + + for (Control control : children) { + Point sz = control.computeSize(widthHint, -1, flushCache); + + resultX = Math.max(resultX, sz.x); + resultY = Math.max(resultY, sz.y); + } + + return new Point(resultX, resultY); + } + + @Override + protected void layout(Composite composite, boolean flushCache) { + + Rectangle area = composite.getClientArea(); + Control[] children = composite.getChildren(); + + for (Control control : children) { + control.setBounds(area); + } + } + +}