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

Collapse All | Expand All

(-)src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties (+6 lines)
Lines 39-44 Link Here
39
TextEditorDefaultsPreferencePage_smartHomeEnd= &Smart caret positioning at line start and end
39
TextEditorDefaultsPreferencePage_smartHomeEnd= &Smart caret positioning at line start and end
40
TextEditorDefaultsPreferencePage_showWhitespaceCharacters= Sh&ow whitespace characters
40
TextEditorDefaultsPreferencePage_showWhitespaceCharacters= Sh&ow whitespace characters
41
TextEditorDefaultsPreferencePage_textDragAndDrop= Enable drag and dro&p of text
41
TextEditorDefaultsPreferencePage_textDragAndDrop= Enable drag and dro&p of text
42
43
TextEditorDefaultsPreferencePage_rightMouseMode= Right-click moves c&aret when:
44
TextEditorDefaultsPreferencePage_rightMouseMode_never=Never
45
TextEditorDefaultsPreferencePage_rightMouseMode_noSelection=No Selection
46
TextEditorDefaultsPreferencePage_rightMouseMode_always=Always
47
42
TextEditorPreferencePage_colorsAndFonts_link= More colors can be configured on the <a>Colors and Fonts</a> preference page.
48
TextEditorPreferencePage_colorsAndFonts_link= More colors can be configured on the <a>Colors and Fonts</a> preference page.
43
TextEditorPreferencePage_colorsAndFonts_link_tooltip= Show the Colors and Fonts preferences
49
TextEditorPreferencePage_colorsAndFonts_link_tooltip= Show the Colors and Fonts preferences
44
50
(-)src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java (+9 lines)
Lines 449-454 Link Here
449
		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WARN_IF_INPUT_DERIVED));
449
		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WARN_IF_INPUT_DERIVED));
450
		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SMART_HOME_END));
450
		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SMART_HOME_END));
451
		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TEXT_DRAG_AND_DROP_ENABLED));
451
		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TEXT_DRAG_AND_DROP_ENABLED));
452
		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, AbstractTextEditor.PREFERENCE_MOUSE_RIGHT_CLICK_CARET_MODE));
452
		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE));
453
		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE));
453
		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HOVER_ENRICH_MODE));
454
		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HOVER_ENRICH_MODE));
454
455
Lines 570-575 Link Here
570
		Preference textDragAndDrop= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TEXT_DRAG_AND_DROP_ENABLED, label, null);
571
		Preference textDragAndDrop= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TEXT_DRAG_AND_DROP_ENABLED, label, null);
571
		addCheckBox(appearanceComposite, textDragAndDrop, new BooleanDomain(), 0);
572
		addCheckBox(appearanceComposite, textDragAndDrop, new BooleanDomain(), 0);
572
573
574
		label=TextEditorMessages.TextEditorDefaultsPreferencePage_rightMouseMode;
575
		Preference rightMouse= new Preference(AbstractTextEditor.PREFERENCE_MOUSE_RIGHT_CLICK_CARET_MODE, label, null);
576
		EnumeratedDomain rightMouseDomain= new EnumeratedDomain();
577
		rightMouseDomain.addValue(new EnumValue(0, TextEditorMessages.TextEditorDefaultsPreferencePage_rightMouseMode_never));
578
		rightMouseDomain.addValue(new EnumValue(1, TextEditorMessages.TextEditorDefaultsPreferencePage_rightMouseMode_noSelection));
579
		rightMouseDomain.addValue(new EnumValue(2, TextEditorMessages.TextEditorDefaultsPreferencePage_rightMouseMode_always));
580
		addCombo(appearanceComposite, rightMouse, rightMouseDomain, 0);
581
573
		label= TextEditorMessages.TextEditorDefaultsPreferencePage_warn_if_derived;
582
		label= TextEditorMessages.TextEditorDefaultsPreferencePage_warn_if_derived;
574
		Preference warnIfDerived= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WARN_IF_INPUT_DERIVED, label, null);
583
		Preference warnIfDerived= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WARN_IF_INPUT_DERIVED, label, null);
575
		addCheckBox(appearanceComposite, warnIfDerived, new BooleanDomain(), 0);
584
		addCheckBox(appearanceComposite, warnIfDerived, new BooleanDomain(), 0);
(-)src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java (+4 lines)
Lines 131-136 Link Here
131
	public static String TextEditorDefaultsPreferencePage_warn_if_derived;
131
	public static String TextEditorDefaultsPreferencePage_warn_if_derived;
132
	public static String TextEditorDefaultsPreferencePage_showWhitespaceCharacters;
132
	public static String TextEditorDefaultsPreferencePage_showWhitespaceCharacters;
133
	public static String TextEditorDefaultsPreferencePage_textDragAndDrop;
133
	public static String TextEditorDefaultsPreferencePage_textDragAndDrop;
134
	public static String TextEditorDefaultsPreferencePage_rightMouseMode;
135
	public static String TextEditorDefaultsPreferencePage_rightMouseMode_never;
136
	public static String TextEditorDefaultsPreferencePage_rightMouseMode_noSelection;
137
	public static String TextEditorDefaultsPreferencePage_rightMouseMode_always;
134
	public static String LinkedModeConfigurationBlock_annotationPresentationOptions;
138
	public static String LinkedModeConfigurationBlock_annotationPresentationOptions;
135
	public static String LinkedModeConfigurationBlock_SQUIGGLES;
139
	public static String LinkedModeConfigurationBlock_SQUIGGLES;
136
	public static String LinkedModeConfigurationBlock_UNDERLINE;
140
	public static String LinkedModeConfigurationBlock_UNDERLINE;
(-)src/org/eclipse/ui/texteditor/AbstractTextEditor.java (-1 / +100 lines)
Lines 13-18 Link Here
13
 *     Benjamin Muskalla <b.muskalla@gmx.net> - https://bugs.eclipse.org/bugs/show_bug.cgi?id=41573
13
 *     Benjamin Muskalla <b.muskalla@gmx.net> - https://bugs.eclipse.org/bugs/show_bug.cgi?id=41573
14
 *     Stephan Wahlbrink <stephan.wahlbrink@walware.de> - Wrong operations mode/feedback for text drag over/drop in text editors - https://bugs.eclipse.org/bugs/show_bug.cgi?id=206043
14
 *     Stephan Wahlbrink <stephan.wahlbrink@walware.de> - Wrong operations mode/feedback for text drag over/drop in text editors - https://bugs.eclipse.org/bugs/show_bug.cgi?id=206043
15
 *     Tom Eicher (Avaloq Evolution AG) - block selection mode
15
 *     Tom Eicher (Avaloq Evolution AG) - block selection mode
16
 *     Luke Gumbley <luke.gumbley@gmail.com> - https://bugs.eclipse.org/bugs/show_bug.cgi?id=19825
16
 *******************************************************************************/
17
 *******************************************************************************/
17
package org.eclipse.ui.texteditor;
18
package org.eclipse.ui.texteditor;
18
19
Lines 2196-2201 Link Here
2196
	 */
2197
	 */
2197
	public static final String PREFERENCE_HOVER_ENRICH_MODE= "hoverReplaceMode"; //$NON-NLS-1$
2198
	public static final String PREFERENCE_HOVER_ENRICH_MODE= "hoverReplaceMode"; //$NON-NLS-1$
2198
2199
2200
	/**
2201
	 * A named preference that controls the behaviour of the caret when the right mouse button
2202
	 * is clicked.
2203
	 * <p>
2204
	 * Value is of type <code>Integer</code> and is interpreted as follows:
2205
	 * </p>
2206
	 * <ul>
2207
	 * <li>0: "Never" - No effect (default).</li>
2208
	 * <li>1: "No Selection" - If there is a selection, no effect.  If there is no selection,
2209
	 * move the caret to the current mouse position.<li>
2210
	 * <li>2: "Always" - If there is a selection but it was not clicked, or if there is no
2211
	 * selection, clear the selection and move the caret to the current mouse position.
2212
	 * If there is a selection and it was clicked, no effect.</li>
2213
	 * </ul>
2214
	 *
2215
	 * @since 3.5
2216
	 */
2217
	public static final String PREFERENCE_MOUSE_RIGHT_CLICK_CARET_MODE="mouseRightClickCaretMode"; //$NON-NLS-1$
2218
	
2199
	/** Menu id for the editor context menu. */
2219
	/** Menu id for the editor context menu. */
2200
	public static final String DEFAULT_EDITOR_CONTEXT_MENU_ID= "#EditorContext"; //$NON-NLS-1$
2220
	public static final String DEFAULT_EDITOR_CONTEXT_MENU_ID= "#EditorContext"; //$NON-NLS-1$
2201
	/** Menu id for the ruler context menu. */
2221
	/** Menu id for the ruler context menu. */
Lines 2576-2582 Link Here
2576
	 */
2596
	 */
2577
	private KeyBindingSupportForAssistant fKeyBindingSupportForContentAssistant;
2597
	private KeyBindingSupportForAssistant fKeyBindingSupportForContentAssistant;
2578
2598
2579
2599
	/**
2600
	 * Current setting of the right mouse button mode.
2601
	 * 
2602
	 * @since 3.5
2603
	 */
2604
	private int rightMouseMode=-1;
2605
	
2580
	/**
2606
	/**
2581
	 * Creates a new text editor. If not explicitly set, this editor uses
2607
	 * Creates a new text editor. If not explicitly set, this editor uses
2582
	 * a <code>SourceViewerConfiguration</code> to configure its
2608
	 * a <code>SourceViewerConfiguration</code> to configure its
Lines 3044-3049 Link Here
3044
				}
3070
				}
3045
3071
3046
				public void mouseDown(MouseEvent e) {
3072
				public void mouseDown(MouseEvent e) {
3073
					handleMouseDown(e);
3047
				}
3074
				}
3048
3075
3049
				public void mouseUp(MouseEvent e) {
3076
				public void mouseUp(MouseEvent e) {
Lines 4541-4546 Link Here
4541
			return;
4568
			return;
4542
		}
4569
		}
4543
4570
4571
		if (PREFERENCE_MOUSE_RIGHT_CLICK_CARET_MODE.equals(property)) {
4572
			IPreferenceStore store = getPreferenceStore();
4573
			if(store != null) {
4574
				rightMouseMode = store.getInt(PREFERENCE_MOUSE_RIGHT_CLICK_CARET_MODE);
4575
			}
4576
		}
4577
			
4544
	}
4578
	}
4545
4579
4546
	/**
4580
	/**
Lines 6495-6500 Link Here
6495
	}
6529
	}
6496
6530
6497
	/**
6531
	/**
6532
	 * Handles a mouse event on the editor (currently only right-clicks) as per user
6533
	 * preferences.  See {@link #PREFERENCE_MOUSE_RIGHT_CLICK_CARET_MODE}.
6534
	 * 
6535
	 * @param e The MouseEvent to be handled.
6536
	 * 
6537
	 * @since 3.5
6538
	 */
6539
	protected void handleMouseDown(MouseEvent e) {
6540
		
6541
		if(e.button!=3)
6542
			return;
6543
		
6544
		// If the mode is -1 it has not yet been set
6545
		if(rightMouseMode == -1) {
6546
			IPreferenceStore store = getPreferenceStore();
6547
			if(store != null) {
6548
				rightMouseMode = store.getInt(PREFERENCE_MOUSE_RIGHT_CLICK_CARET_MODE);
6549
			}
6550
		}
6551
		
6552
		if(rightMouseMode == 0)
6553
			return;
6554
6555
		StyledText textWidget = null;
6556
		ISourceViewer viewer = fSourceViewer;
6557
		if (viewer != null)
6558
			textWidget = viewer.getTextWidget();
6559
6560
		if(textWidget == null)
6561
			return;
6562
6563
		int mouseOffset=-1;
6564
		try {
6565
			mouseOffset = textWidget.getOffsetAtLocation(new Point(e.x,e.y));
6566
		}
6567
		catch (IllegalArgumentException ex) {
6568
6569
		}
6570
6571
		if(mouseOffset == -1)
6572
		{
6573
			int lineIndex=textWidget.getLineIndex(e.y)+1;
6574
			
6575
			if(lineIndex >= textWidget.getLineCount())
6576
				mouseOffset = textWidget.getCharCount();
6577
			else
6578
				mouseOffset = textWidget.getOffsetAtLine(lineIndex)-1;
6579
		}
6580
		
6581
		if(textWidget.getSelectionCount() > 0)
6582
		{
6583
			if(rightMouseMode == 1)
6584
				return;
6585
			
6586
			Point textSelection = textWidget.getSelection();
6587
			boolean withinSelection = (mouseOffset >= textSelection.x) && (mouseOffset < textSelection.y);
6588
			
6589
			if(withinSelection)
6590
				return;
6591
		}
6592
		
6593
		textWidget.setCaretOffset(mouseOffset);
6594
	}
6595
	
6596
	/**
6498
	 * Handles a potential change of the cursor position.
6597
	 * Handles a potential change of the cursor position.
6499
	 * Subclasses may extend.
6598
	 * Subclasses may extend.
6500
	 *
6599
	 *

Return to bug 19825