View | Details | Raw Unified | Return to bug 195455
Collapse All | Expand All

(-)src/org/eclipse/ui/texteditor/AbstractTextEditor.java (-57 / +103 lines)
Lines 11-16 Link Here
11
 *     Michel Ishizuka (cqw10305@nifty.com) - http://bugs.eclipse.org/bugs/show_bug.cgi?id=68963
11
 *     Michel Ishizuka (cqw10305@nifty.com) - http://bugs.eclipse.org/bugs/show_bug.cgi?id=68963
12
 *     Genady Beryozkin, me@genady.org - https://bugs.eclipse.org/bugs/show_bug.cgi?id=11668
12
 *     Genady Beryozkin, me@genady.org - https://bugs.eclipse.org/bugs/show_bug.cgi?id=11668
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
 *     Cagatay Calli - https://bugs.eclipse.org/bugs/show_bug.cgi?id=195455
14
 *******************************************************************************/
15
 *******************************************************************************/
15
package org.eclipse.ui.texteditor;
16
package org.eclipse.ui.texteditor;
16
17
Lines 23-71 Link Here
23
import java.util.Map;
24
import java.util.Map;
24
import java.util.ResourceBundle;
25
import java.util.ResourceBundle;
25
26
26
import org.osgi.framework.Bundle;
27
28
import org.eclipse.swt.SWT;
29
import org.eclipse.swt.custom.BusyIndicator;
30
import org.eclipse.swt.custom.ST;
31
import org.eclipse.swt.custom.StyledText;
32
import org.eclipse.swt.custom.VerifyKeyListener;
33
import org.eclipse.swt.dnd.DND;
34
import org.eclipse.swt.dnd.DragSource;
35
import org.eclipse.swt.dnd.DragSourceAdapter;
36
import org.eclipse.swt.dnd.DragSourceEvent;
37
import org.eclipse.swt.dnd.DropTargetAdapter;
38
import org.eclipse.swt.dnd.DropTargetEvent;
39
import org.eclipse.swt.dnd.DropTargetListener;
40
import org.eclipse.swt.dnd.TextTransfer;
41
import org.eclipse.swt.dnd.Transfer;
42
import org.eclipse.swt.events.KeyEvent;
43
import org.eclipse.swt.events.KeyListener;
44
import org.eclipse.swt.events.MouseEvent;
45
import org.eclipse.swt.events.MouseListener;
46
import org.eclipse.swt.events.VerifyEvent;
47
import org.eclipse.swt.events.VerifyListener;
48
import org.eclipse.swt.graphics.Color;
49
import org.eclipse.swt.graphics.Font;
50
import org.eclipse.swt.graphics.FontData;
51
import org.eclipse.swt.graphics.GC;
52
import org.eclipse.swt.graphics.Image;
53
import org.eclipse.swt.graphics.ImageData;
54
import org.eclipse.swt.graphics.PaletteData;
55
import org.eclipse.swt.graphics.Point;
56
import org.eclipse.swt.graphics.RGB;
57
import org.eclipse.swt.widgets.Caret;
58
import org.eclipse.swt.widgets.Composite;
59
import org.eclipse.swt.widgets.Control;
60
import org.eclipse.swt.widgets.Display;
61
import org.eclipse.swt.widgets.Menu;
62
import org.eclipse.swt.widgets.Shell;
63
64
import org.eclipse.core.commands.operations.IOperationApprover;
27
import org.eclipse.core.commands.operations.IOperationApprover;
65
import org.eclipse.core.commands.operations.IOperationHistory;
28
import org.eclipse.core.commands.operations.IOperationHistory;
66
import org.eclipse.core.commands.operations.IUndoContext;
29
import org.eclipse.core.commands.operations.IUndoContext;
67
import org.eclipse.core.commands.operations.OperationHistoryFactory;
30
import org.eclipse.core.commands.operations.OperationHistoryFactory;
68
69
import org.eclipse.core.runtime.Assert;
31
import org.eclipse.core.runtime.Assert;
70
import org.eclipse.core.runtime.CoreException;
32
import org.eclipse.core.runtime.CoreException;
71
import org.eclipse.core.runtime.IConfigurationElement;
33
import org.eclipse.core.runtime.IConfigurationElement;
Lines 76-85 Link Here
76
import org.eclipse.core.runtime.Platform;
38
import org.eclipse.core.runtime.Platform;
77
import org.eclipse.core.runtime.SafeRunner;
39
import org.eclipse.core.runtime.SafeRunner;
78
import org.eclipse.core.runtime.Status;
40
import org.eclipse.core.runtime.Status;
79
80
import org.eclipse.text.undo.DocumentUndoManagerRegistry;
81
import org.eclipse.text.undo.IDocumentUndoManager;
82
83
import org.eclipse.jface.action.Action;
41
import org.eclipse.jface.action.Action;
84
import org.eclipse.jface.action.GroupMarker;
42
import org.eclipse.jface.action.GroupMarker;
85
import org.eclipse.jface.action.IAction;
43
import org.eclipse.jface.action.IAction;
Lines 96-112 Link Here
96
import org.eclipse.jface.preference.PreferenceConverter;
54
import org.eclipse.jface.preference.PreferenceConverter;
97
import org.eclipse.jface.resource.ImageDescriptor;
55
import org.eclipse.jface.resource.ImageDescriptor;
98
import org.eclipse.jface.resource.JFaceResources;
56
import org.eclipse.jface.resource.JFaceResources;
99
import org.eclipse.jface.util.IPropertyChangeListener;
100
import org.eclipse.jface.util.PropertyChangeEvent;
101
import org.eclipse.jface.util.SafeRunnable;
102
import org.eclipse.jface.viewers.IPostSelectionProvider;
103
import org.eclipse.jface.viewers.ISelection;
104
import org.eclipse.jface.viewers.ISelectionChangedListener;
105
import org.eclipse.jface.viewers.ISelectionProvider;
106
import org.eclipse.jface.viewers.SelectionChangedEvent;
107
import org.eclipse.jface.viewers.StructuredSelection;
108
import org.eclipse.jface.window.IShellProvider;
109
110
import org.eclipse.jface.text.AbstractInformationControlManager;
57
import org.eclipse.jface.text.AbstractInformationControlManager;
111
import org.eclipse.jface.text.BadLocationException;
58
import org.eclipse.jface.text.BadLocationException;
112
import org.eclipse.jface.text.DefaultInformationControl;
59
import org.eclipse.jface.text.DefaultInformationControl;
Lines 165-171 Link Here
165
import org.eclipse.jface.text.source.SourceViewer;
112
import org.eclipse.jface.text.source.SourceViewer;
166
import org.eclipse.jface.text.source.SourceViewerConfiguration;
113
import org.eclipse.jface.text.source.SourceViewerConfiguration;
167
import org.eclipse.jface.text.source.VerticalRuler;
114
import org.eclipse.jface.text.source.VerticalRuler;
168
115
import org.eclipse.jface.util.IPropertyChangeListener;
116
import org.eclipse.jface.util.PropertyChangeEvent;
117
import org.eclipse.jface.util.SafeRunnable;
118
import org.eclipse.jface.viewers.IPostSelectionProvider;
119
import org.eclipse.jface.viewers.ISelection;
120
import org.eclipse.jface.viewers.ISelectionChangedListener;
121
import org.eclipse.jface.viewers.ISelectionProvider;
122
import org.eclipse.jface.viewers.SelectionChangedEvent;
123
import org.eclipse.jface.viewers.StructuredSelection;
124
import org.eclipse.jface.window.IShellProvider;
125
import org.eclipse.swt.SWT;
126
import org.eclipse.swt.custom.BusyIndicator;
127
import org.eclipse.swt.custom.ST;
128
import org.eclipse.swt.custom.StyledText;
129
import org.eclipse.swt.custom.VerifyKeyListener;
130
import org.eclipse.swt.dnd.DND;
131
import org.eclipse.swt.dnd.DragSource;
132
import org.eclipse.swt.dnd.DragSourceAdapter;
133
import org.eclipse.swt.dnd.DragSourceEvent;
134
import org.eclipse.swt.dnd.DropTargetAdapter;
135
import org.eclipse.swt.dnd.DropTargetEvent;
136
import org.eclipse.swt.dnd.DropTargetListener;
137
import org.eclipse.swt.dnd.TextTransfer;
138
import org.eclipse.swt.dnd.Transfer;
139
import org.eclipse.swt.events.KeyEvent;
140
import org.eclipse.swt.events.KeyListener;
141
import org.eclipse.swt.events.MouseEvent;
142
import org.eclipse.swt.events.MouseListener;
143
import org.eclipse.swt.events.VerifyEvent;
144
import org.eclipse.swt.events.VerifyListener;
145
import org.eclipse.swt.graphics.Color;
146
import org.eclipse.swt.graphics.Font;
147
import org.eclipse.swt.graphics.FontData;
148
import org.eclipse.swt.graphics.GC;
149
import org.eclipse.swt.graphics.Image;
150
import org.eclipse.swt.graphics.ImageData;
151
import org.eclipse.swt.graphics.PaletteData;
152
import org.eclipse.swt.graphics.Point;
153
import org.eclipse.swt.graphics.RGB;
154
import org.eclipse.swt.layout.FillLayout;
155
import org.eclipse.swt.layout.GridData;
156
import org.eclipse.swt.layout.GridLayout;
157
import org.eclipse.swt.widgets.Caret;
158
import org.eclipse.swt.widgets.Composite;
159
import org.eclipse.swt.widgets.Control;
160
import org.eclipse.swt.widgets.Display;
161
import org.eclipse.swt.widgets.Menu;
162
import org.eclipse.swt.widgets.Shell;
163
import org.eclipse.text.undo.DocumentUndoManagerRegistry;
164
import org.eclipse.text.undo.IDocumentUndoManager;
169
import org.eclipse.ui.IActionBars;
165
import org.eclipse.ui.IActionBars;
170
import org.eclipse.ui.IEditorDescriptor;
166
import org.eclipse.ui.IEditorDescriptor;
171
import org.eclipse.ui.IEditorInput;
167
import org.eclipse.ui.IEditorInput;
Lines 209-214 Link Here
209
import org.eclipse.ui.texteditor.rulers.RulerColumnDescriptor;
205
import org.eclipse.ui.texteditor.rulers.RulerColumnDescriptor;
210
import org.eclipse.ui.texteditor.rulers.RulerColumnPreferenceAdapter;
206
import org.eclipse.ui.texteditor.rulers.RulerColumnPreferenceAdapter;
211
import org.eclipse.ui.texteditor.rulers.RulerColumnRegistry;
207
import org.eclipse.ui.texteditor.rulers.RulerColumnRegistry;
208
import org.osgi.framework.Bundle;
212
209
213
210
214
/**
211
/**
Lines 2498-2503 Link Here
2498
	 * @since 3.3
2495
	 * @since 3.3
2499
	 */
2496
	 */
2500
	private InformationPresenter fInformationPresenter;
2497
	private InformationPresenter fInformationPresenter;
2498
	
2499
	/** Composite under the editor that holds QuickFindBar */
2500
	private Composite fFindComposite;
2501
	
2502
	/** QuickFind bar */
2503
	private QuickFindBar fQuickFind;
2504
	
2505
	private Composite fMainComposite; 
2501
2506
2502
2507
2503
	/**
2508
	/**
Lines 3188-3197 Link Here
3188
	 */
3193
	 */
3189
	public void createPartControl(Composite parent) {
3194
	public void createPartControl(Composite parent) {
3190
3195
3196
		fMainComposite = new Composite(parent,SWT.NONE);
3197
		GridLayout layout = new GridLayout();
3198
		layout.marginWidth = 0;
3199
		layout.marginHeight = 0;
3200
		fMainComposite.setLayout(layout);
3201
		GridData gd = new GridData(SWT.FILL,SWT.FILL,true,true,1,2);
3202
		fMainComposite.setLayoutData(gd);
3203
		
3191
		fVerticalRuler= createVerticalRuler();
3204
		fVerticalRuler= createVerticalRuler();
3205
		
3206
		Composite sourceComposite = new Composite(fMainComposite,SWT.NONE);
3207
		sourceComposite.setLayout(new FillLayout());
3208
		gd = new GridData(SWT.FILL,SWT.FILL,true,true);
3209
		sourceComposite.setLayoutData(gd);
3192
3210
3193
		int styles= SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION;
3211
		int styles= SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION;
3194
		fSourceViewer= createSourceViewer(parent, fVerticalRuler, styles);
3212
		fSourceViewer= createSourceViewer(sourceComposite, fVerticalRuler, styles);
3213
		
3214
		// add a composite to hold lightweight Find/Replace bar
3215
		fFindComposite = new Composite(fMainComposite,SWT.BORDER);
3216
		fFindComposite.setLayout(new FillLayout());
3217
		gd = new GridData(SWT.FILL,SWT.FILL,true,false);
3218
		gd.exclude = true;
3219
		fFindComposite.setLayoutData(gd);
3220
		
3221
		// add a Text widget into the composite for testing
3222
		// replace this with a QuickFindBar class
3223
		fQuickFind = new QuickFindBar(fFindComposite,SWT.NONE);
3195
3224
3196
		if (fConfiguration == null)
3225
		if (fConfiguration == null)
3197
			fConfiguration= new SourceViewerConfiguration();
3226
			fConfiguration= new SourceViewerConfiguration();
Lines 5425-5431 Link Here
5425
		action.setActionDefinitionId(IWorkbenchActionDefinitionIds.FIND_PREVIOUS);
5454
		action.setActionDefinitionId(IWorkbenchActionDefinitionIds.FIND_PREVIOUS);
5426
		setAction(ITextEditorActionConstants.FIND_PREVIOUS, action);
5455
		setAction(ITextEditorActionConstants.FIND_PREVIOUS, action);
5427
5456
5428
		action= new IncrementalFindAction(EditorMessages.getBundleForConstructedKeys(), "Editor.FindIncremental.", this, true); //$NON-NLS-1$
5457
		//action= new IncrementalFindAction(EditorMessages.getBundleForConstructedKeys(), "Editor.FindIncremental.", this, true); //$NON-NLS-1$
5458
		action= new QuickFindAction(EditorMessages.getBundleForConstructedKeys(), "Editor.QuickFind.", this); //$NON-NLS-1$
5429
		action.setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_INCREMENTAL_ACTION);
5459
		action.setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_INCREMENTAL_ACTION);
5430
		action.setActionDefinitionId(IWorkbenchActionDefinitionIds.FIND_INCREMENTAL);
5460
		action.setActionDefinitionId(IWorkbenchActionDefinitionIds.FIND_INCREMENTAL);
5431
		setAction(ITextEditorActionConstants.FIND_INCREMENTAL, action);
5461
		setAction(ITextEditorActionConstants.FIND_INCREMENTAL, action);
Lines 6899-6903 Link Here
6899
				fSourceViewer.setIndentPrefixes(prefixes, types[i]);
6929
				fSourceViewer.setIndentPrefixes(prefixes, types[i]);
6900
		}
6930
		}
6901
	}
6931
	}
6932
	
6933
	/**
6934
	 * Returns the composite that holds QuickFindBar
6935
	 * @return a Composite
6936
	 */
6937
	public Composite getFindComposite(){
6938
		return fFindComposite;
6939
	}
6940
	
6941
	public QuickFindBar getQuickFindBar(){
6942
		return fQuickFind;
6943
	}
6944
	
6945
	public Composite getMainComposite(){
6946
		return fMainComposite;
6947
	}
6902
6948
6903
}
6949
}
(-)src/org/eclipse/ui/texteditor/QuickFindBar.java (+89 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation 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
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Cagatay Calli - https://bugs.eclipse.org/bugs/show_bug.cgi?id=195455
11
 *******************************************************************************/
12
13
package org.eclipse.ui.texteditor;
14
15
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.custom.CLabel;
17
import org.eclipse.swt.custom.StackLayout;
18
import org.eclipse.swt.events.DisposeEvent;
19
import org.eclipse.swt.events.DisposeListener;
20
import org.eclipse.swt.layout.GridData;
21
import org.eclipse.swt.layout.GridLayout;
22
import org.eclipse.swt.widgets.Combo;
23
import org.eclipse.swt.widgets.Composite;
24
import org.eclipse.ui.PlatformUI;
25
import org.eclipse.ui.swt.IFocusService;
26
27
public class QuickFindBar extends Composite {
28
29
//	/** The text viewer to operate on */
30
//	private final ITextViewer fTextViewer;
31
//	
32
//	/** The find replace target to delegate find requests */
33
//	private final IFindReplaceTarget fTarget;
34
	
35
	/** stack layout to hold basic and advanced bars */
36
	private StackLayout layout;
37
	
38
	/** basic QuickFindBar composite */
39
	private Composite basicBar;
40
	
41
	/** <i>"Find:"</i> label */
42
	private CLabel fFindLabel;
43
	
44
	/** Find query input */
45
	private Combo fFindField;
46
	
47
	public QuickFindBar(Composite parent, int style) {
48
		super(parent, style);
49
50
		layout = new StackLayout();
51
		this.setLayout(layout);
52
		
53
		basicBar = new Composite(this,SWT.NONE);
54
		basicBar.setLayout(new GridLayout(2,false));
55
56
		createBasicBar();
57
		
58
		layout.topControl = basicBar;
59
	}
60
	
61
	private void createBasicBar(){
62
		fFindLabel = new CLabel(basicBar,SWT.NONE);
63
		fFindLabel.setText(EditorMessages.FindReplace_Find_label); //$NON-NLS-1$
64
		fFindField = new Combo(basicBar,SWT.SINGLE | SWT.BORDER | SWT.SEARCH);
65
		fFindField.setText("Enter query"); //$NON-NLS-1$
66
		fFindField.add("1");
67
		fFindField.add("2");
68
		fFindField.add("3");
69
		fFindField.add("4");
70
		GridData gd = new GridData(SWT.FILL,SWT.NONE,true,false);
71
		fFindField.setLayoutData(gd);
72
		
73
		final IFocusService service = (IFocusService) PlatformUI.getWorkbench().getService(IFocusService.class);
74
		service.addFocusTracker(fFindField, "QuickFindBarFindTextId"); //$NON-NLS-1$
75
		
76
		
77
		fFindField.addDisposeListener(new DisposeListener() {
78
			public void widgetDisposed(DisposeEvent e) {
79
				service.removeFocusTracker(fFindField);					
80
81
			}
82
		});
83
	}
84
	
85
	public Combo getFindField(){
86
		return fFindField;
87
	}
88
89
}
(-)src/org/eclipse/ui/texteditor/QuickFindAction.java (+109 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation 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
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Cagatay Calli - https://bugs.eclipse.org/bugs/show_bug.cgi?id=195455
11
 *******************************************************************************/
12
13
package org.eclipse.ui.texteditor;
14
15
16
import java.util.ResourceBundle;
17
18
import org.eclipse.jface.text.IFindReplaceTarget;
19
import org.eclipse.swt.layout.GridData;
20
import org.eclipse.swt.widgets.Composite;
21
import org.eclipse.ui.IWorkbenchPart;
22
import org.eclipse.ui.IWorkbenchWindow;
23
24
25
/**
26
 * An action which adds a lightweight Find/Replace composite
27
 * under the editor.
28
 * <p>
29
 * This class may be instantiated; it is not intended to be subclassed.
30
 * </p>
31
 *
32
 * @see IFindReplaceTarget
33
 */
34
public class QuickFindAction extends ResourceAction implements IUpdate {
35
	
36
	/** The action's target */
37
	private IFindReplaceTarget fTarget;
38
	/** The part the action is bound to */
39
	private IWorkbenchPart fWorkbenchPart;
40
	/** The workbench window */
41
	private IWorkbenchWindow fWorkbenchWindow;
42
	/** The text editor */
43
	private AbstractTextEditor fEditor;
44
	/** QuickFind bar displayed under the editor */
45
	private QuickFindBar quickFind;
46
	
47
	/**
48
	 * Creates a new find/replace action for the given target and shell.
49
	 * <p>
50
	 * This can be used without having an IWorkbenchPart e.g. for
51
	 * dialogs or wizards.</p>
52
	 * <p>
53
	 * The action configures its visual representation from the given
54
	 * resource bundle.</p>
55
	 *
56
	 * @param bundle the resource bundle
57
	 * @param prefix a prefix to be prepended to the various resource keys
58
	 *   (described in <code>ResourceAction</code> constructor), or
59
	 *   <code>null</code> if none
60
	 * @param editor the AbstractTextEditor to use
61
	 * @see ResourceAction#ResourceAction(ResourceBundle, String)
62
	 * 
63
	 * @since 3.3
64
	 */
65
	public QuickFindAction(ResourceBundle bundle, String prefix, AbstractTextEditor editor) {
66
		super(bundle, prefix);
67
		fEditor = editor;
68
		fWorkbenchPart= editor;
69
	}
70
	
71
	/*
72
	 *	@see IAction#run()
73
	 */
74
	public void run() {
75
		if (fTarget == null)
76
			return;
77
		
78
		final boolean isEditable;
79
80
		System.out.println(fTarget.getClass());
81
		
82
		// display lightweight Find/Replace bar
83
		Composite fFindComposite = fEditor.getFindComposite();
84
		GridData gd = (GridData) fFindComposite.getLayoutData();
85
		gd.exclude = false;
86
		fFindComposite.setLayoutData(gd);
87
		fFindComposite.getParent().layout();
88
		
89
		isEditable= fTarget.isEditable();
90
		
91
	}
92
	
93
	/*
94
	 * @see IUpdate#update()
95
	 */
96
	public void update() {
97
98
		if (fWorkbenchPart == null && fWorkbenchWindow != null)
99
			fWorkbenchPart= fWorkbenchWindow.getPartService().getActivePart();
100
101
		if (fWorkbenchPart != null)
102
			fTarget= (IFindReplaceTarget) fWorkbenchPart.getAdapter(IFindReplaceTarget.class);
103
		else
104
			fTarget= null;
105
106
		setEnabled(fTarget != null && fTarget.canPerformFind());
107
	}
108
109
}

Return to bug 195455