Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 73494 Details for
Bug 195455
A lightweight "Find/Replace" - using the bottom of the screen
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Initial work as a patch
findreplace-editorbar.diff (text/plain), 16.56 KB, created by
Cagatay Calli
on 2007-07-10 19:19:22 EDT
(
hide
)
Description:
Initial work as a patch
Filename:
MIME Type:
Creator:
Cagatay Calli
Created:
2007-07-10 19:19:22 EDT
Size:
16.56 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.workbench.texteditor >Index: src/org/eclipse/ui/texteditor/AbstractTextEditor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java,v >retrieving revision 1.249 >diff -u -r1.249 AbstractTextEditor.java >--- src/org/eclipse/ui/texteditor/AbstractTextEditor.java 20 Jun 2007 11:04:34 -0000 1.249 >+++ src/org/eclipse/ui/texteditor/AbstractTextEditor.java 10 Jul 2007 23:18:43 -0000 >@@ -11,6 +11,7 @@ > * Michel Ishizuka (cqw10305@nifty.com) - http://bugs.eclipse.org/bugs/show_bug.cgi?id=68963 > * Genady Beryozkin, me@genady.org - https://bugs.eclipse.org/bugs/show_bug.cgi?id=11668 > * Benjamin Muskalla <b.muskalla@gmx.net> - https://bugs.eclipse.org/bugs/show_bug.cgi?id=41573 >+ * Cagatay Calli - https://bugs.eclipse.org/bugs/show_bug.cgi?id=195455 > *******************************************************************************/ > package org.eclipse.ui.texteditor; > >@@ -23,49 +24,10 @@ > import java.util.Map; > import java.util.ResourceBundle; > >-import org.osgi.framework.Bundle; >- >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.custom.BusyIndicator; >-import org.eclipse.swt.custom.ST; >-import org.eclipse.swt.custom.StyledText; >-import org.eclipse.swt.custom.VerifyKeyListener; >-import org.eclipse.swt.dnd.DND; >-import org.eclipse.swt.dnd.DragSource; >-import org.eclipse.swt.dnd.DragSourceAdapter; >-import org.eclipse.swt.dnd.DragSourceEvent; >-import org.eclipse.swt.dnd.DropTargetAdapter; >-import org.eclipse.swt.dnd.DropTargetEvent; >-import org.eclipse.swt.dnd.DropTargetListener; >-import org.eclipse.swt.dnd.TextTransfer; >-import org.eclipse.swt.dnd.Transfer; >-import org.eclipse.swt.events.KeyEvent; >-import org.eclipse.swt.events.KeyListener; >-import org.eclipse.swt.events.MouseEvent; >-import org.eclipse.swt.events.MouseListener; >-import org.eclipse.swt.events.VerifyEvent; >-import org.eclipse.swt.events.VerifyListener; >-import org.eclipse.swt.graphics.Color; >-import org.eclipse.swt.graphics.Font; >-import org.eclipse.swt.graphics.FontData; >-import org.eclipse.swt.graphics.GC; >-import org.eclipse.swt.graphics.Image; >-import org.eclipse.swt.graphics.ImageData; >-import org.eclipse.swt.graphics.PaletteData; >-import org.eclipse.swt.graphics.Point; >-import org.eclipse.swt.graphics.RGB; >-import org.eclipse.swt.widgets.Caret; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.Control; >-import org.eclipse.swt.widgets.Display; >-import org.eclipse.swt.widgets.Menu; >-import org.eclipse.swt.widgets.Shell; >- > import org.eclipse.core.commands.operations.IOperationApprover; > import org.eclipse.core.commands.operations.IOperationHistory; > import org.eclipse.core.commands.operations.IUndoContext; > import org.eclipse.core.commands.operations.OperationHistoryFactory; >- > import org.eclipse.core.runtime.Assert; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IConfigurationElement; >@@ -76,10 +38,6 @@ > import org.eclipse.core.runtime.Platform; > import org.eclipse.core.runtime.SafeRunner; > import org.eclipse.core.runtime.Status; >- >-import org.eclipse.text.undo.DocumentUndoManagerRegistry; >-import org.eclipse.text.undo.IDocumentUndoManager; >- > import org.eclipse.jface.action.Action; > import org.eclipse.jface.action.GroupMarker; > import org.eclipse.jface.action.IAction; >@@ -96,17 +54,6 @@ > import org.eclipse.jface.preference.PreferenceConverter; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.resource.JFaceResources; >-import org.eclipse.jface.util.IPropertyChangeListener; >-import org.eclipse.jface.util.PropertyChangeEvent; >-import org.eclipse.jface.util.SafeRunnable; >-import org.eclipse.jface.viewers.IPostSelectionProvider; >-import org.eclipse.jface.viewers.ISelection; >-import org.eclipse.jface.viewers.ISelectionChangedListener; >-import org.eclipse.jface.viewers.ISelectionProvider; >-import org.eclipse.jface.viewers.SelectionChangedEvent; >-import org.eclipse.jface.viewers.StructuredSelection; >-import org.eclipse.jface.window.IShellProvider; >- > import org.eclipse.jface.text.AbstractInformationControlManager; > import org.eclipse.jface.text.BadLocationException; > import org.eclipse.jface.text.DefaultInformationControl; >@@ -165,7 +112,56 @@ > import org.eclipse.jface.text.source.SourceViewer; > import org.eclipse.jface.text.source.SourceViewerConfiguration; > import org.eclipse.jface.text.source.VerticalRuler; >- >+import org.eclipse.jface.util.IPropertyChangeListener; >+import org.eclipse.jface.util.PropertyChangeEvent; >+import org.eclipse.jface.util.SafeRunnable; >+import org.eclipse.jface.viewers.IPostSelectionProvider; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.ISelectionChangedListener; >+import org.eclipse.jface.viewers.ISelectionProvider; >+import org.eclipse.jface.viewers.SelectionChangedEvent; >+import org.eclipse.jface.viewers.StructuredSelection; >+import org.eclipse.jface.window.IShellProvider; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.BusyIndicator; >+import org.eclipse.swt.custom.ST; >+import org.eclipse.swt.custom.StyledText; >+import org.eclipse.swt.custom.VerifyKeyListener; >+import org.eclipse.swt.dnd.DND; >+import org.eclipse.swt.dnd.DragSource; >+import org.eclipse.swt.dnd.DragSourceAdapter; >+import org.eclipse.swt.dnd.DragSourceEvent; >+import org.eclipse.swt.dnd.DropTargetAdapter; >+import org.eclipse.swt.dnd.DropTargetEvent; >+import org.eclipse.swt.dnd.DropTargetListener; >+import org.eclipse.swt.dnd.TextTransfer; >+import org.eclipse.swt.dnd.Transfer; >+import org.eclipse.swt.events.KeyEvent; >+import org.eclipse.swt.events.KeyListener; >+import org.eclipse.swt.events.MouseEvent; >+import org.eclipse.swt.events.MouseListener; >+import org.eclipse.swt.events.VerifyEvent; >+import org.eclipse.swt.events.VerifyListener; >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.Font; >+import org.eclipse.swt.graphics.FontData; >+import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.ImageData; >+import org.eclipse.swt.graphics.PaletteData; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.RGB; >+import org.eclipse.swt.layout.FillLayout; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Caret; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.Menu; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.text.undo.DocumentUndoManagerRegistry; >+import org.eclipse.text.undo.IDocumentUndoManager; > import org.eclipse.ui.IActionBars; > import org.eclipse.ui.IEditorDescriptor; > import org.eclipse.ui.IEditorInput; >@@ -209,6 +205,7 @@ > import org.eclipse.ui.texteditor.rulers.RulerColumnDescriptor; > import org.eclipse.ui.texteditor.rulers.RulerColumnPreferenceAdapter; > import org.eclipse.ui.texteditor.rulers.RulerColumnRegistry; >+import org.osgi.framework.Bundle; > > > /** >@@ -2498,6 +2495,14 @@ > * @since 3.3 > */ > private InformationPresenter fInformationPresenter; >+ >+ /** Composite under the editor that holds QuickFindBar */ >+ private Composite fFindComposite; >+ >+ /** QuickFind bar */ >+ private QuickFindBar fQuickFind; >+ >+ private Composite fMainComposite; > > > /** >@@ -3188,10 +3193,34 @@ > */ > public void createPartControl(Composite parent) { > >+ fMainComposite = new Composite(parent,SWT.NONE); >+ GridLayout layout = new GridLayout(); >+ layout.marginWidth = 0; >+ layout.marginHeight = 0; >+ fMainComposite.setLayout(layout); >+ GridData gd = new GridData(SWT.FILL,SWT.FILL,true,true,1,2); >+ fMainComposite.setLayoutData(gd); >+ > fVerticalRuler= createVerticalRuler(); >+ >+ Composite sourceComposite = new Composite(fMainComposite,SWT.NONE); >+ sourceComposite.setLayout(new FillLayout()); >+ gd = new GridData(SWT.FILL,SWT.FILL,true,true); >+ sourceComposite.setLayoutData(gd); > > int styles= SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION; >- fSourceViewer= createSourceViewer(parent, fVerticalRuler, styles); >+ fSourceViewer= createSourceViewer(sourceComposite, fVerticalRuler, styles); >+ >+ // add a composite to hold lightweight Find/Replace bar >+ fFindComposite = new Composite(fMainComposite,SWT.BORDER); >+ fFindComposite.setLayout(new FillLayout()); >+ gd = new GridData(SWT.FILL,SWT.FILL,true,false); >+ gd.exclude = true; >+ fFindComposite.setLayoutData(gd); >+ >+ // add a Text widget into the composite for testing >+ // replace this with a QuickFindBar class >+ fQuickFind = new QuickFindBar(fFindComposite,SWT.NONE); > > if (fConfiguration == null) > fConfiguration= new SourceViewerConfiguration(); >@@ -5425,7 +5454,8 @@ > action.setActionDefinitionId(IWorkbenchActionDefinitionIds.FIND_PREVIOUS); > setAction(ITextEditorActionConstants.FIND_PREVIOUS, action); > >- action= new IncrementalFindAction(EditorMessages.getBundleForConstructedKeys(), "Editor.FindIncremental.", this, true); //$NON-NLS-1$ >+ //action= new IncrementalFindAction(EditorMessages.getBundleForConstructedKeys(), "Editor.FindIncremental.", this, true); //$NON-NLS-1$ >+ action= new QuickFindAction(EditorMessages.getBundleForConstructedKeys(), "Editor.QuickFind.", this); //$NON-NLS-1$ > action.setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_INCREMENTAL_ACTION); > action.setActionDefinitionId(IWorkbenchActionDefinitionIds.FIND_INCREMENTAL); > setAction(ITextEditorActionConstants.FIND_INCREMENTAL, action); >@@ -6899,5 +6929,21 @@ > fSourceViewer.setIndentPrefixes(prefixes, types[i]); > } > } >+ >+ /** >+ * Returns the composite that holds QuickFindBar >+ * @return a Composite >+ */ >+ public Composite getFindComposite(){ >+ return fFindComposite; >+ } >+ >+ public QuickFindBar getQuickFindBar(){ >+ return fQuickFind; >+ } >+ >+ public Composite getMainComposite(){ >+ return fMainComposite; >+ } > > } >Index: src/org/eclipse/ui/texteditor/QuickFindBar.java >=================================================================== >RCS file: src/org/eclipse/ui/texteditor/QuickFindBar.java >diff -N src/org/eclipse/ui/texteditor/QuickFindBar.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/texteditor/QuickFindBar.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,89 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation 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 >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Cagatay Calli - https://bugs.eclipse.org/bugs/show_bug.cgi?id=195455 >+ *******************************************************************************/ >+ >+package org.eclipse.ui.texteditor; >+ >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.CLabel; >+import org.eclipse.swt.custom.StackLayout; >+import org.eclipse.swt.events.DisposeEvent; >+import org.eclipse.swt.events.DisposeListener; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Combo; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.swt.IFocusService; >+ >+public class QuickFindBar extends Composite { >+ >+// /** The text viewer to operate on */ >+// private final ITextViewer fTextViewer; >+// >+// /** The find replace target to delegate find requests */ >+// private final IFindReplaceTarget fTarget; >+ >+ /** stack layout to hold basic and advanced bars */ >+ private StackLayout layout; >+ >+ /** basic QuickFindBar composite */ >+ private Composite basicBar; >+ >+ /** <i>"Find:"</i> label */ >+ private CLabel fFindLabel; >+ >+ /** Find query input */ >+ private Combo fFindField; >+ >+ public QuickFindBar(Composite parent, int style) { >+ super(parent, style); >+ >+ layout = new StackLayout(); >+ this.setLayout(layout); >+ >+ basicBar = new Composite(this,SWT.NONE); >+ basicBar.setLayout(new GridLayout(2,false)); >+ >+ createBasicBar(); >+ >+ layout.topControl = basicBar; >+ } >+ >+ private void createBasicBar(){ >+ fFindLabel = new CLabel(basicBar,SWT.NONE); >+ fFindLabel.setText(EditorMessages.FindReplace_Find_label); //$NON-NLS-1$ >+ fFindField = new Combo(basicBar,SWT.SINGLE | SWT.BORDER | SWT.SEARCH); >+ fFindField.setText("Enter query"); //$NON-NLS-1$ >+ fFindField.add("1"); >+ fFindField.add("2"); >+ fFindField.add("3"); >+ fFindField.add("4"); >+ GridData gd = new GridData(SWT.FILL,SWT.NONE,true,false); >+ fFindField.setLayoutData(gd); >+ >+ final IFocusService service = (IFocusService) PlatformUI.getWorkbench().getService(IFocusService.class); >+ service.addFocusTracker(fFindField, "QuickFindBarFindTextId"); //$NON-NLS-1$ >+ >+ >+ fFindField.addDisposeListener(new DisposeListener() { >+ public void widgetDisposed(DisposeEvent e) { >+ service.removeFocusTracker(fFindField); >+ >+ } >+ }); >+ } >+ >+ public Combo getFindField(){ >+ return fFindField; >+ } >+ >+} >Index: src/org/eclipse/ui/texteditor/QuickFindAction.java >=================================================================== >RCS file: src/org/eclipse/ui/texteditor/QuickFindAction.java >diff -N src/org/eclipse/ui/texteditor/QuickFindAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/texteditor/QuickFindAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,109 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation 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 >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Cagatay Calli - https://bugs.eclipse.org/bugs/show_bug.cgi?id=195455 >+ *******************************************************************************/ >+ >+package org.eclipse.ui.texteditor; >+ >+ >+import java.util.ResourceBundle; >+ >+import org.eclipse.jface.text.IFindReplaceTarget; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.ui.IWorkbenchPart; >+import org.eclipse.ui.IWorkbenchWindow; >+ >+ >+/** >+ * An action which adds a lightweight Find/Replace composite >+ * under the editor. >+ * <p> >+ * This class may be instantiated; it is not intended to be subclassed. >+ * </p> >+ * >+ * @see IFindReplaceTarget >+ */ >+public class QuickFindAction extends ResourceAction implements IUpdate { >+ >+ /** The action's target */ >+ private IFindReplaceTarget fTarget; >+ /** The part the action is bound to */ >+ private IWorkbenchPart fWorkbenchPart; >+ /** The workbench window */ >+ private IWorkbenchWindow fWorkbenchWindow; >+ /** The text editor */ >+ private AbstractTextEditor fEditor; >+ /** QuickFind bar displayed under the editor */ >+ private QuickFindBar quickFind; >+ >+ /** >+ * Creates a new find/replace action for the given target and shell. >+ * <p> >+ * This can be used without having an IWorkbenchPart e.g. for >+ * dialogs or wizards.</p> >+ * <p> >+ * The action configures its visual representation from the given >+ * resource bundle.</p> >+ * >+ * @param bundle the resource bundle >+ * @param prefix a prefix to be prepended to the various resource keys >+ * (described in <code>ResourceAction</code> constructor), or >+ * <code>null</code> if none >+ * @param editor the AbstractTextEditor to use >+ * @see ResourceAction#ResourceAction(ResourceBundle, String) >+ * >+ * @since 3.3 >+ */ >+ public QuickFindAction(ResourceBundle bundle, String prefix, AbstractTextEditor editor) { >+ super(bundle, prefix); >+ fEditor = editor; >+ fWorkbenchPart= editor; >+ } >+ >+ /* >+ * @see IAction#run() >+ */ >+ public void run() { >+ if (fTarget == null) >+ return; >+ >+ final boolean isEditable; >+ >+ System.out.println(fTarget.getClass()); >+ >+ // display lightweight Find/Replace bar >+ Composite fFindComposite = fEditor.getFindComposite(); >+ GridData gd = (GridData) fFindComposite.getLayoutData(); >+ gd.exclude = false; >+ fFindComposite.setLayoutData(gd); >+ fFindComposite.getParent().layout(); >+ >+ isEditable= fTarget.isEditable(); >+ >+ } >+ >+ /* >+ * @see IUpdate#update() >+ */ >+ public void update() { >+ >+ if (fWorkbenchPart == null && fWorkbenchWindow != null) >+ fWorkbenchPart= fWorkbenchWindow.getPartService().getActivePart(); >+ >+ if (fWorkbenchPart != null) >+ fTarget= (IFindReplaceTarget) fWorkbenchPart.getAdapter(IFindReplaceTarget.class); >+ else >+ fTarget= null; >+ >+ setEnabled(fTarget != null && fTarget.canPerformFind()); >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 195455
:
73077
|
73493
| 73494