Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 141690 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/internal/dialogs/FilteredPreferenceDialog.java (-6 / +2 lines)
Lines 134-143 Link Here
134
		 * @see org.eclipse.ui.dialogs.FilteredTree#updateToolbar(boolean)
134
		 * @see org.eclipse.ui.dialogs.FilteredTree#updateToolbar(boolean)
135
		 */
135
		 */
136
		protected void updateToolbar(boolean visible) {
136
		protected void updateToolbar(boolean visible) {
137
			if (filterToolBar != null) {
137
			super.updateToolbar(viewerFilter != null || visible);
138
				filterToolBar.getControl().setVisible(
139
						viewerFilter != null || visible);
140
			}
141
		}
138
		}
142
139
143
		/*
140
		/*
Lines 320-327 Link Here
320
		leftLayout.numColumns = 1;
317
		leftLayout.numColumns = 1;
321
		leftLayout.marginHeight = 0;
318
		leftLayout.marginHeight = 0;
322
		leftLayout.marginTop = IDialogConstants.VERTICAL_MARGIN;
319
		leftLayout.marginTop = IDialogConstants.VERTICAL_MARGIN;
323
		leftLayout.marginWidth = 0;
320
		leftLayout.marginWidth = IDialogConstants.HORIZONTAL_MARGIN;
324
		leftLayout.marginLeft = IDialogConstants.HORIZONTAL_MARGIN;
325
		leftLayout.horizontalSpacing = 0;
321
		leftLayout.horizontalSpacing = 0;
326
		leftLayout.verticalSpacing = 0;
322
		leftLayout.verticalSpacing = 0;
327
		leftArea.setLayout(leftLayout);
323
		leftArea.setLayout(leftLayout);
(-)Eclipse UI/org/eclipse/ui/dialogs/FilteredTree.java (-32 / +101 lines)
Lines 15-22 Link Here
15
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.core.runtime.IStatus;
16
import org.eclipse.core.runtime.Status;
16
import org.eclipse.core.runtime.Status;
17
import org.eclipse.core.runtime.jobs.Job;
17
import org.eclipse.core.runtime.jobs.Job;
18
import org.eclipse.jface.action.Action;
19
import org.eclipse.jface.action.IAction;
20
import org.eclipse.jface.action.ToolBarManager;
18
import org.eclipse.jface.action.ToolBarManager;
21
import org.eclipse.jface.resource.ImageDescriptor;
19
import org.eclipse.jface.resource.ImageDescriptor;
22
import org.eclipse.jface.resource.JFaceResources;
20
import org.eclipse.jface.resource.JFaceResources;
Lines 25-31 Link Here
25
import org.eclipse.jface.viewers.TreeViewer;
23
import org.eclipse.jface.viewers.TreeViewer;
26
import org.eclipse.osgi.util.NLS;
24
import org.eclipse.osgi.util.NLS;
27
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.SWT;
26
import org.eclipse.swt.accessibility.ACC;
28
import org.eclipse.swt.accessibility.AccessibleAdapter;
27
import org.eclipse.swt.accessibility.AccessibleAdapter;
28
import org.eclipse.swt.accessibility.AccessibleControlAdapter;
29
import org.eclipse.swt.accessibility.AccessibleControlEvent;
29
import org.eclipse.swt.accessibility.AccessibleEvent;
30
import org.eclipse.swt.accessibility.AccessibleEvent;
30
import org.eclipse.swt.events.DisposeEvent;
31
import org.eclipse.swt.events.DisposeEvent;
31
import org.eclipse.swt.events.DisposeListener;
32
import org.eclipse.swt.events.DisposeListener;
Lines 35-51 Link Here
35
import org.eclipse.swt.events.KeyEvent;
36
import org.eclipse.swt.events.KeyEvent;
36
import org.eclipse.swt.events.ModifyEvent;
37
import org.eclipse.swt.events.ModifyEvent;
37
import org.eclipse.swt.events.ModifyListener;
38
import org.eclipse.swt.events.ModifyListener;
39
import org.eclipse.swt.events.MouseEvent;
40
import org.eclipse.swt.events.MouseListener;
41
import org.eclipse.swt.events.MouseTrackListener;
38
import org.eclipse.swt.events.SelectionAdapter;
42
import org.eclipse.swt.events.SelectionAdapter;
39
import org.eclipse.swt.events.SelectionEvent;
43
import org.eclipse.swt.events.SelectionEvent;
40
import org.eclipse.swt.events.TraverseEvent;
44
import org.eclipse.swt.events.TraverseEvent;
41
import org.eclipse.swt.events.TraverseListener;
45
import org.eclipse.swt.events.TraverseListener;
42
import org.eclipse.swt.graphics.Color;
46
import org.eclipse.swt.graphics.Color;
43
import org.eclipse.swt.graphics.Font;
47
import org.eclipse.swt.graphics.Font;
48
import org.eclipse.swt.graphics.Image;
44
import org.eclipse.swt.layout.GridData;
49
import org.eclipse.swt.layout.GridData;
45
import org.eclipse.swt.layout.GridLayout;
50
import org.eclipse.swt.layout.GridLayout;
46
import org.eclipse.swt.widgets.Composite;
51
import org.eclipse.swt.widgets.Composite;
47
import org.eclipse.swt.widgets.Control;
52
import org.eclipse.swt.widgets.Control;
48
import org.eclipse.swt.widgets.Display;
53
import org.eclipse.swt.widgets.Display;
54
import org.eclipse.swt.widgets.Label;
49
import org.eclipse.swt.widgets.Text;
55
import org.eclipse.swt.widgets.Text;
50
import org.eclipse.swt.widgets.TreeItem;
56
import org.eclipse.swt.widgets.TreeItem;
51
import org.eclipse.ui.IWorkbenchPreferenceConstants;
57
import org.eclipse.ui.IWorkbenchPreferenceConstants;
Lines 74-83 Link Here
74
	 * The control representing the clear button for the filter text entry. This
80
	 * The control representing the clear button for the filter text entry. This
75
	 * value may be <code>null</code> if no such button exists, or if the
81
	 * value may be <code>null</code> if no such button exists, or if the
76
	 * controls have not yet been created.
82
	 * controls have not yet been created.
83
	 * @deprecated Not used anymore. Use {@link #clearButtonControl} instead.
77
	 */
84
	 */
78
	protected ToolBarManager filterToolBar;
85
	protected ToolBarManager filterToolBar;
79
86
80
	/**
87
	/**
88
	 * The control representing the clear button for the filter text entry. This
89
	 * value may be <code>null</code> if no such button exists, or if the
90
	 * controls have not yet been created.
91
	 * 
92
	 * @since 3.5
93
	 */
94
	protected Control clearButtonControl;
95
	
96
	
97
	/**
81
	 * The viewer for the filtered tree. This value should never be
98
	 * The viewer for the filtered tree. This value should never be
82
	 * <code>null</code> after the widget creation methods are complete.
99
	 * <code>null</code> after the widget creation methods are complete.
83
	 */
100
	 */
Lines 228-234 Link Here
228
		setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
245
		setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
229
246
230
		if (showFilterControls) {
247
		if (showFilterControls) {
231
			filterComposite = new Composite(this, SWT.NONE);
248
			if (useNativeSearchField(parent)) {
249
				filterComposite = new Composite(this, SWT.NONE);
250
			} else {
251
				filterComposite= new Composite(this, SWT.BORDER);
252
				filterComposite.setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
253
			}
232
			GridLayout filterLayout = new GridLayout(2, false);
254
			GridLayout filterLayout = new GridLayout(2, false);
233
			filterLayout.marginHeight = 0;
255
			filterLayout.marginHeight = 0;
234
			filterLayout.marginWidth = 0;
256
			filterLayout.marginWidth = 0;
Lines 249-254 Link Here
249
		treeComposite.setLayoutData(data);
271
		treeComposite.setLayoutData(data);
250
		createTreeControl(treeComposite, treeStyle);
272
		createTreeControl(treeComposite, treeStyle);
251
	}
273
	}
274
	
275
	private static Boolean useNativeSearchField;
276
	
277
	private static boolean useNativeSearchField(Composite composite) {
278
		if (useNativeSearchField == null) {
279
			useNativeSearchField = Boolean.FALSE;
280
			Text testText = null;
281
			try {
282
				testText = new Text(composite, SWT.SEARCH | SWT.CANCEL);
283
				useNativeSearchField = new Boolean((testText.getStyle() & SWT.CANCEL) != 0);
284
			} finally {
285
				if (testText != null) {
286
					testText.dispose();
287
				}
288
			}
289
				
290
		}
291
		return useNativeSearchField.booleanValue();
292
	}
293
	
252
294
253
	/**
295
	/**
254
	 * Create the filter controls. By default, a text and corresponding tool bar
296
	 * Create the filter controls. By default, a text and corresponding tool bar
Lines 262-271 Link Here
262
	protected Composite createFilterControls(Composite parent) {
304
	protected Composite createFilterControls(Composite parent) {
263
		createFilterText(parent);
305
		createFilterText(parent);
264
		createClearText(parent);
306
		createClearText(parent);
265
		if (filterToolBar != null) {
307
		if (clearButtonControl != null) {
266
			filterToolBar.update(false);
267
			// initially there is no text to clear
308
			// initially there is no text to clear
268
			filterToolBar.getControl().setVisible(false);
309
			clearButtonControl.setVisible(false);
269
		}
310
		}
270
		return parent;
311
		return parent;
271
	}
312
	}
Lines 481-488 Link Here
481
	}
522
	}
482
523
483
	protected void updateToolbar(boolean visible) {
524
	protected void updateToolbar(boolean visible) {
484
		if (filterToolBar != null) {
525
		if (clearButtonControl != null) {
485
			filterToolBar.getControl().setVisible(visible);
526
			clearButtonControl.setVisible(visible);
486
		}
527
		}
487
	}
528
	}
488
529
Lines 649-655 Link Here
649
			});
690
			});
650
		}
691
		}
651
692
652
		GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
693
		GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
653
		// if the text widget supported cancel then it will have it's own
694
		// if the text widget supported cancel then it will have it's own
654
		// integrated button. We can take all of the space.
695
		// integrated button. We can take all of the space.
655
		if ((filterText.getStyle() & SWT.CANCEL) != 0)
696
		if ((filterText.getStyle() & SWT.CANCEL) != 0)
Lines 668-675 Link Here
668
	 * @since 3.3
709
	 * @since 3.3
669
	 */
710
	 */
670
	protected Text doCreateFilterText(Composite parent) {
711
	protected Text doCreateFilterText(Composite parent) {
671
		return new Text(parent, SWT.SINGLE | SWT.BORDER | SWT.SEARCH
712
		if (useNativeSearchField(parent)) {
672
				| SWT.CANCEL);
713
			return new Text(parent, SWT.SINGLE | SWT.BORDER | SWT.SEARCH
714
					| SWT.CANCEL);
715
		}
716
		return new Text(parent, SWT.SINGLE);
673
	}
717
	}
674
718
675
	private String previousFilterText;
719
	private String previousFilterText;
Lines 708-719 Link Here
708
	 */
752
	 */
709
	public void setBackground(Color background) {
753
	public void setBackground(Color background) {
710
		super.setBackground(background);
754
		super.setBackground(background);
711
		if (filterComposite != null) {
755
		if (filterComposite != null && useNativeSearchField(filterComposite)) {
712
			filterComposite.setBackground(background);
756
			filterComposite.setBackground(background);
713
		}
757
		}
714
		if (filterToolBar != null && filterToolBar.getControl() != null) {
715
			filterToolBar.getControl().setBackground(background);
716
		}
717
	}
758
	}
718
759
719
	/**
760
	/**
Lines 726-753 Link Here
726
		// only create the button if the text widget doesn't support one
767
		// only create the button if the text widget doesn't support one
727
		// natively
768
		// natively
728
		if ((filterText.getStyle() & SWT.CANCEL) == 0) {
769
		if ((filterText.getStyle() & SWT.CANCEL) == 0) {
729
			filterToolBar = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL);
770
			final Image inactiveImage= JFaceResources.getImageRegistry().getDescriptor(DCLEAR_ICON).createImage();
730
			filterToolBar.createControl(parent);
771
			final Image activeImage= JFaceResources.getImageRegistry().getDescriptor(CLEAR_ICON).createImage();
772
			
773
			final Label clearButton= new Label(parent, SWT.NONE);
774
			clearButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
775
			clearButton.setImage(inactiveImage);
776
			clearButton.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
777
			clearButton.setToolTipText(WorkbenchMessages.FilteredTree_ClearToolTip);
778
			clearButton.addMouseListener(new MouseListener() {
779
				public void mouseDoubleClick(MouseEvent e) {
780
				}
731
781
732
			IAction clearTextAction = new Action("", IAction.AS_PUSH_BUTTON) {//$NON-NLS-1$
782
				public void mouseDown(MouseEvent e) {
733
				/*
734
				 * (non-Javadoc)
735
				 * 
736
				 * @see org.eclipse.jface.action.Action#run()
737
				 */
738
				public void run() {
739
					clearText();
783
					clearText();
740
				}
784
				}
741
			};
742
785
743
			clearTextAction
786
				public void mouseUp(MouseEvent e) {
744
					.setToolTipText(WorkbenchMessages.FilteredTree_ClearToolTip);
787
				}			
745
			clearTextAction.setImageDescriptor(JFaceResources
788
			});
746
					.getImageRegistry().getDescriptor(CLEAR_ICON));
789
			clearButton.addMouseTrackListener(new MouseTrackListener() {
747
			clearTextAction.setDisabledImageDescriptor(JFaceResources
790
				public void mouseEnter(MouseEvent e) {
748
					.getImageRegistry().getDescriptor(DCLEAR_ICON));
791
					clearButton.setImage(activeImage);
792
				}
749
793
750
			filterToolBar.add(clearTextAction);
794
				public void mouseExit(MouseEvent e) {
795
					clearButton.setImage(inactiveImage);
796
				}
797
798
				public void mouseHover(MouseEvent e) {
799
				}
800
			});
801
			clearButton.addDisposeListener(new DisposeListener() {
802
				public void widgetDisposed(DisposeEvent e) {
803
					inactiveImage.dispose();
804
					activeImage.dispose();
805
				}
806
			});
807
			clearButton.getAccessible().addAccessibleListener(
808
				new AccessibleAdapter() {
809
					public void getName(AccessibleEvent e) {
810
						e.result= WorkbenchMessages.FilteredTree_AccessibleListenerClearButton;
811
					}
812
			});
813
			clearButton.getAccessible().addAccessibleControlListener(
814
				new AccessibleControlAdapter() {
815
					public void getRole(AccessibleControlEvent e) {
816
						e.detail= ACC.ROLE_PUSHBUTTON;
817
					}
818
			});
819
			this.clearButtonControl= clearButton;
751
		}
820
		}
752
	}
821
	}
753
822
(-)Eclipse UI/org/eclipse/ui/internal/messages.properties (+1 lines)
Lines 883-888 Link Here
883
FilteredTree_ClearToolTip=Clear
883
FilteredTree_ClearToolTip=Clear
884
FilteredTree_FilterMessage=type filter text
884
FilteredTree_FilterMessage=type filter text
885
FilteredTree_FilteredDialogTitle={0} (Filtered)
885
FilteredTree_FilteredDialogTitle={0} (Filtered)
886
FilteredTree_AccessibleListenerClearButton=Clear filter field
886
FilteredTree_AccessibleListenerFiltered={0} {1} matches.
887
FilteredTree_AccessibleListenerFiltered={0} {1} matches.
887
Workbench_restoreDisabled=This application does not save and restore previously saved state.
888
Workbench_restoreDisabled=This application does not save and restore previously saved state.
888
Workbench_noStateToRestore=No previously saved state to restore.
889
Workbench_noStateToRestore=No previously saved state to restore.
(-)Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java (+1 lines)
Lines 902-907 Link Here
902
	public static String FilteredTree_ClearToolTip;
902
	public static String FilteredTree_ClearToolTip;
903
	public static String FilteredTree_FilterMessage;
903
	public static String FilteredTree_FilterMessage;
904
	public static String FilteredTree_FilteredDialogTitle;
904
	public static String FilteredTree_FilteredDialogTitle;
905
	public static String FilteredTree_AccessibleListenerClearButton;
905
	public static String FilteredTree_AccessibleListenerFiltered;
906
	public static String FilteredTree_AccessibleListenerFiltered;
906
	public static String Workbench_restoreDisabled;
907
	public static String Workbench_restoreDisabled;
907
	public static String Workbench_noStateToRestore;
908
	public static String Workbench_noStateToRestore;

Return to bug 141690