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 |
} |