View | Details | Raw Unified | Return to bug 256699 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/tasks/ui/editors/RichTextAttributeEditor.java (+6 lines)
Lines 172-175 Link Here
172
		}
172
		}
173
	}
173
	}
174
174
175
	/**
176
	 * Tries to enable auto toggling of preview (editable on click)
177
	 */
178
	public void enableAutoTogglePreview() {
179
		editor.enableAutoTogglePreview();
180
	}
175
}
181
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/editors/RichTextEditor.java (-1 / +37 lines)
Lines 43-48 Link Here
43
import org.eclipse.swt.events.FocusAdapter;
43
import org.eclipse.swt.events.FocusAdapter;
44
import org.eclipse.swt.events.FocusEvent;
44
import org.eclipse.swt.events.FocusEvent;
45
import org.eclipse.swt.events.FocusListener;
45
import org.eclipse.swt.events.FocusListener;
46
import org.eclipse.swt.events.MouseAdapter;
47
import org.eclipse.swt.events.MouseEvent;
46
import org.eclipse.swt.graphics.Font;
48
import org.eclipse.swt.graphics.Font;
47
import org.eclipse.swt.graphics.Point;
49
import org.eclipse.swt.graphics.Point;
48
import org.eclipse.swt.widgets.Composite;
50
import org.eclipse.swt.widgets.Composite;
Lines 138-143 Link Here
138
	 */
140
	 */
139
	private int textVersion;
141
	private int textVersion;
140
142
143
	private boolean stickyPreview = false;
144
141
	public RichTextEditor(TaskRepository repository, int style) {
145
	public RichTextEditor(TaskRepository repository, int style) {
142
		this(repository, style, null, null);
146
		this(repository, style, null, null);
143
	}
147
	}
Lines 352-357 Link Here
352
			// adapt maximize action
356
			// adapt maximize action
353
			previewViewer.getControl().setData(EditorUtil.KEY_TOGGLE_TO_MAXIMIZE_ACTION,
357
			previewViewer.getControl().setData(EditorUtil.KEY_TOGGLE_TO_MAXIMIZE_ACTION,
354
					editorViewer.getControl().getData(EditorUtil.KEY_TOGGLE_TO_MAXIMIZE_ACTION));
358
					editorViewer.getControl().getData(EditorUtil.KEY_TOGGLE_TO_MAXIMIZE_ACTION));
359
			installMenu(previewViewer.getControl(), editorViewer.getControl().getMenu());
355
		}
360
		}
356
		return previewViewer;
361
		return previewViewer;
357
	}
362
	}
Lines 550-566 Link Here
550
	public void showEditor() {
555
	public void showEditor() {
551
		if (getEditorViewer() != null) {
556
		if (getEditorViewer() != null) {
552
			show(getEditorViewer());
557
			show(getEditorViewer());
558
			stickyPreview = false;
553
		} else {
559
		} else {
554
			show(getDefaultViewer());
560
			show(getDefaultViewer());
555
		}
561
		}
556
	}
562
	}
557
563
558
	public void showPreview() {
564
	private void showPreview(boolean sticky) {
559
		if (!isReadOnly()) {
565
		if (!isReadOnly()) {
560
			show(getPreviewViewer());
566
			show(getPreviewViewer());
567
			stickyPreview = sticky;
561
		}
568
		}
562
	}
569
	}
563
570
571
	public void showPreview() {
572
		showPreview(true);
573
	}
574
564
	private void unsetContext() {
575
	private void unsetContext() {
565
		if (contextService == null) {
576
		if (contextService == null) {
566
			return;
577
			return;
Lines 574-577 Link Here
574
	protected void valueChanged(String value) {
585
	protected void valueChanged(String value) {
575
	}
586
	}
576
587
588
	public void enableAutoTogglePreview() {
589
		if (getPreviewViewer() != null) {
590
			show(getPreviewViewer());
591
			previewViewer.getTextWidget().addMouseListener(new MouseAdapter() {
592
				@Override
593
				public void mouseUp(MouseEvent e) {
594
					if (!stickyPreview) {
595
						int offset = previewViewer.getTextWidget().getCaretOffset();
596
						showEditor();
597
						editorViewer.getTextWidget().setCaretOffset(offset);
598
					}
599
				}
600
			});
601
			editorViewer.getTextWidget().addFocusListener(new FocusAdapter() {
602
				@Override
603
				public void focusLost(FocusEvent e) {
604
					super.focusLost(e);
605
					if (!stickyPreview) {
606
						showPreview(false);
607
					}
608
				}
609
			});
610
		}
611
	}
612
577
}
613
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/editors/EditorUtil.java (-1 / +8 lines)
Lines 428-433 Link Here
428
	}
428
	}
429
429
430
	public static GridData getTextControlLayoutData(TaskFormPage page, Control control, boolean expandVertically) {
430
	public static GridData getTextControlLayoutData(TaskFormPage page, Control control, boolean expandVertically) {
431
		return getTextControlLayoutData(page, control, expandVertically, false);
432
	}
433
434
	public static GridData getTextControlLayoutData(TaskFormPage page, Control control, boolean expandVertically,
435
			boolean hasPreviewToggle) {
431
		final GridData gd = new GridData();
436
		final GridData gd = new GridData();
432
		// wrap text at this margin, see comment below
437
		// wrap text at this margin, see comment below
433
		int width = getEditorWidth(page);
438
		int width = getEditorWidth(page);
Lines 441-447 Link Here
441
		// limit height to be avoid dynamic resizing of the text widget: 
446
		// limit height to be avoid dynamic resizing of the text widget: 
442
		// MAXIMUM_HEIGHT < height < MAXIMUM_HEIGHT * 3
447
		// MAXIMUM_HEIGHT < height < MAXIMUM_HEIGHT * 3
443
		//gd.minimumHeight = AbstractAttributeEditor.MAXIMUM_HEIGHT;
448
		//gd.minimumHeight = AbstractAttributeEditor.MAXIMUM_HEIGHT;
444
		gd.heightHint = Math.min(Math.max(EditorUtil.MAXIMUM_HEIGHT, size.y), EditorUtil.MAXIMUM_HEIGHT * 3);
449
		if (!hasPreviewToggle) {
450
			gd.heightHint = Math.min(Math.max(EditorUtil.MAXIMUM_HEIGHT, size.y), EditorUtil.MAXIMUM_HEIGHT * 3);
451
		}
445
		if (expandVertically) {
452
		if (expandVertically) {
446
			gd.verticalAlignment = SWT.FILL;
453
			gd.verticalAlignment = SWT.FILL;
447
			gd.grabExcessVerticalSpace = true;
454
			gd.grabExcessVerticalSpace = true;
(-)src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorDescriptionPart.java (+5 lines)
Lines 122-127 Link Here
122
122
123
		super.createControl(parent, toolkit);
123
		super.createControl(parent, toolkit);
124
		addDuplicateDetection(getComposite(), toolkit);
124
		addDuplicateDetection(getComposite(), toolkit);
125
		getEditor().enableAutoTogglePreview();
125
	}
126
	}
126
127
127
	@Override
128
	@Override
Lines 188-191 Link Here
188
		}
189
		}
189
	}
190
	}
190
191
192
	@Override
193
	protected boolean isAutoTogglePreview() {
194
		return !getEditor().isReadOnly() && getEditor().hasPreview();
195
	}
191
}
196
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorRichTextPart.java (-2 / +6 lines)
Lines 120-126 Link Here
120
		} else {
120
		} else {
121
			StyledText textWidget = editor.getViewer().getTextWidget();
121
			StyledText textWidget = editor.getViewer().getTextWidget();
122
			editor.getControl().setLayoutData(
122
			editor.getControl().setLayoutData(
123
					EditorUtil.getTextControlLayoutData(getTaskEditorPage(), textWidget, getExpandVertically()));
123
					EditorUtil.getTextControlLayoutData(getTaskEditorPage(), textWidget, getExpandVertically(),
124
							isAutoTogglePreview()));
124
			editor.getControl().setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
125
			editor.getControl().setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
125
		}
126
		}
126
127
Lines 193-199 Link Here
193
194
194
			GridData gd = (GridData) getEditor().getControl().getLayoutData();
195
			GridData gd = (GridData) getEditor().getControl().getLayoutData();
195
196
196
			if (originalHeight == -1) {
197
			if (originalHeight == -1 && !isAutoTogglePreview()) { //for auto toggle editors, SWT.DEFAULT is a valid hint
197
				originalHeight = gd.heightHint;
198
				originalHeight = gd.heightHint;
198
			}
199
			}
199
200
Lines 270-273 Link Here
270
		super.fillToolBar(manager);
271
		super.fillToolBar(manager);
271
	}
272
	}
272
273
274
	protected boolean isAutoTogglePreview() {
275
		return false;
276
	}
273
}
277
}

Return to bug 256699