|
Lines 13-22
Link Here
|
| 13 |
|
13 |
|
| 14 |
import org.eclipse.core.runtime.IProgressMonitor; |
14 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 15 |
import org.eclipse.core.runtime.IStatus; |
15 |
import org.eclipse.core.runtime.IStatus; |
|
|
16 |
import org.eclipse.core.runtime.Platform; |
| 16 |
import org.eclipse.core.runtime.Status; |
17 |
import org.eclipse.core.runtime.Status; |
| 17 |
import org.eclipse.core.runtime.jobs.Job; |
18 |
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; |
19 |
import org.eclipse.jface.action.ToolBarManager; |
| 21 |
import org.eclipse.jface.resource.ImageDescriptor; |
20 |
import org.eclipse.jface.resource.ImageDescriptor; |
| 22 |
import org.eclipse.jface.resource.JFaceResources; |
21 |
import org.eclipse.jface.resource.JFaceResources; |
|
Lines 25-31
Link Here
|
| 25 |
import org.eclipse.jface.viewers.TreeViewer; |
24 |
import org.eclipse.jface.viewers.TreeViewer; |
| 26 |
import org.eclipse.osgi.util.NLS; |
25 |
import org.eclipse.osgi.util.NLS; |
| 27 |
import org.eclipse.swt.SWT; |
26 |
import org.eclipse.swt.SWT; |
|
|
27 |
import org.eclipse.swt.accessibility.ACC; |
| 28 |
import org.eclipse.swt.accessibility.AccessibleAdapter; |
28 |
import org.eclipse.swt.accessibility.AccessibleAdapter; |
|
|
29 |
import org.eclipse.swt.accessibility.AccessibleControlAdapter; |
| 30 |
import org.eclipse.swt.accessibility.AccessibleControlEvent; |
| 29 |
import org.eclipse.swt.accessibility.AccessibleEvent; |
31 |
import org.eclipse.swt.accessibility.AccessibleEvent; |
| 30 |
import org.eclipse.swt.events.DisposeEvent; |
32 |
import org.eclipse.swt.events.DisposeEvent; |
| 31 |
import org.eclipse.swt.events.DisposeListener; |
33 |
import org.eclipse.swt.events.DisposeListener; |
|
Lines 35-51
Link Here
|
| 35 |
import org.eclipse.swt.events.KeyEvent; |
37 |
import org.eclipse.swt.events.KeyEvent; |
| 36 |
import org.eclipse.swt.events.ModifyEvent; |
38 |
import org.eclipse.swt.events.ModifyEvent; |
| 37 |
import org.eclipse.swt.events.ModifyListener; |
39 |
import org.eclipse.swt.events.ModifyListener; |
|
|
40 |
import org.eclipse.swt.events.MouseEvent; |
| 41 |
import org.eclipse.swt.events.MouseListener; |
| 42 |
import org.eclipse.swt.events.MouseTrackListener; |
| 38 |
import org.eclipse.swt.events.SelectionAdapter; |
43 |
import org.eclipse.swt.events.SelectionAdapter; |
| 39 |
import org.eclipse.swt.events.SelectionEvent; |
44 |
import org.eclipse.swt.events.SelectionEvent; |
| 40 |
import org.eclipse.swt.events.TraverseEvent; |
45 |
import org.eclipse.swt.events.TraverseEvent; |
| 41 |
import org.eclipse.swt.events.TraverseListener; |
46 |
import org.eclipse.swt.events.TraverseListener; |
| 42 |
import org.eclipse.swt.graphics.Color; |
47 |
import org.eclipse.swt.graphics.Color; |
| 43 |
import org.eclipse.swt.graphics.Font; |
48 |
import org.eclipse.swt.graphics.Font; |
|
|
49 |
import org.eclipse.swt.graphics.Image; |
| 44 |
import org.eclipse.swt.layout.GridData; |
50 |
import org.eclipse.swt.layout.GridData; |
| 45 |
import org.eclipse.swt.layout.GridLayout; |
51 |
import org.eclipse.swt.layout.GridLayout; |
| 46 |
import org.eclipse.swt.widgets.Composite; |
52 |
import org.eclipse.swt.widgets.Composite; |
| 47 |
import org.eclipse.swt.widgets.Control; |
53 |
import org.eclipse.swt.widgets.Control; |
| 48 |
import org.eclipse.swt.widgets.Display; |
54 |
import org.eclipse.swt.widgets.Display; |
|
|
55 |
import org.eclipse.swt.widgets.Label; |
| 49 |
import org.eclipse.swt.widgets.Text; |
56 |
import org.eclipse.swt.widgets.Text; |
| 50 |
import org.eclipse.swt.widgets.TreeItem; |
57 |
import org.eclipse.swt.widgets.TreeItem; |
| 51 |
import org.eclipse.ui.IWorkbenchPreferenceConstants; |
58 |
import org.eclipse.ui.IWorkbenchPreferenceConstants; |
|
Lines 74-83
Link Here
|
| 74 |
* The control representing the clear button for the filter text entry. This |
81 |
* 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 |
82 |
* value may be <code>null</code> if no such button exists, or if the |
| 76 |
* controls have not yet been created. |
83 |
* controls have not yet been created. |
|
|
84 |
* @deprecated Not used anymore. Use {@link #clearButtonControl} instead. |
| 77 |
*/ |
85 |
*/ |
| 78 |
protected ToolBarManager filterToolBar; |
86 |
protected ToolBarManager filterToolBar; |
| 79 |
|
87 |
|
| 80 |
/** |
88 |
/** |
|
|
89 |
* The control representing the clear button for the filter text entry. This |
| 90 |
* value may be <code>null</code> if no such button exists, or if the |
| 91 |
* controls have not yet been created. |
| 92 |
* |
| 93 |
* @since 3.5 |
| 94 |
*/ |
| 95 |
protected Control clearButtonControl; |
| 96 |
|
| 97 |
|
| 98 |
/** |
| 81 |
* The viewer for the filtered tree. This value should never be |
99 |
* The viewer for the filtered tree. This value should never be |
| 82 |
* <code>null</code> after the widget creation methods are complete. |
100 |
* <code>null</code> after the widget creation methods are complete. |
| 83 |
*/ |
101 |
*/ |
|
Lines 228-234
Link Here
|
| 228 |
setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
246 |
setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
| 229 |
|
247 |
|
| 230 |
if (showFilterControls) { |
248 |
if (showFilterControls) { |
| 231 |
filterComposite = new Composite(this, SWT.NONE); |
249 |
if (useNativeSearchField()) { |
|
|
250 |
filterComposite = new Composite(this, SWT.NONE); |
| 251 |
} else { |
| 252 |
filterComposite= new Composite(this, SWT.BORDER); |
| 253 |
filterComposite.setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); |
| 254 |
} |
| 232 |
GridLayout filterLayout = new GridLayout(2, false); |
255 |
GridLayout filterLayout = new GridLayout(2, false); |
| 233 |
filterLayout.marginHeight = 0; |
256 |
filterLayout.marginHeight = 0; |
| 234 |
filterLayout.marginWidth = 0; |
257 |
filterLayout.marginWidth = 0; |
|
Lines 249-254
Link Here
|
| 249 |
treeComposite.setLayoutData(data); |
272 |
treeComposite.setLayoutData(data); |
| 250 |
createTreeControl(treeComposite, treeStyle); |
273 |
createTreeControl(treeComposite, treeStyle); |
| 251 |
} |
274 |
} |
|
|
275 |
|
| 276 |
private static boolean useNativeSearchField() { |
| 277 |
return Platform.OS_MACOSX.equals(Platform.getOS()); |
| 278 |
} |
| 279 |
|
| 252 |
|
280 |
|
| 253 |
/** |
281 |
/** |
| 254 |
* Create the filter controls. By default, a text and corresponding tool bar |
282 |
* Create the filter controls. By default, a text and corresponding tool bar |
|
Lines 262-271
Link Here
|
| 262 |
protected Composite createFilterControls(Composite parent) { |
290 |
protected Composite createFilterControls(Composite parent) { |
| 263 |
createFilterText(parent); |
291 |
createFilterText(parent); |
| 264 |
createClearText(parent); |
292 |
createClearText(parent); |
| 265 |
if (filterToolBar != null) { |
293 |
if (clearButtonControl != null) { |
| 266 |
filterToolBar.update(false); |
|
|
| 267 |
// initially there is no text to clear |
294 |
// initially there is no text to clear |
| 268 |
filterToolBar.getControl().setVisible(false); |
295 |
clearButtonControl.setVisible(false); |
| 269 |
} |
296 |
} |
| 270 |
return parent; |
297 |
return parent; |
| 271 |
} |
298 |
} |
|
Lines 481-488
Link Here
|
| 481 |
} |
508 |
} |
| 482 |
|
509 |
|
| 483 |
protected void updateToolbar(boolean visible) { |
510 |
protected void updateToolbar(boolean visible) { |
| 484 |
if (filterToolBar != null) { |
511 |
if (clearButtonControl != null) { |
| 485 |
filterToolBar.getControl().setVisible(visible); |
512 |
clearButtonControl.setVisible(visible); |
| 486 |
} |
513 |
} |
| 487 |
} |
514 |
} |
| 488 |
|
515 |
|
|
Lines 649-655
Link Here
|
| 649 |
}); |
676 |
}); |
| 650 |
} |
677 |
} |
| 651 |
|
678 |
|
| 652 |
GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false); |
679 |
GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false); |
| 653 |
// if the text widget supported cancel then it will have it's own |
680 |
// if the text widget supported cancel then it will have it's own |
| 654 |
// integrated button. We can take all of the space. |
681 |
// integrated button. We can take all of the space. |
| 655 |
if ((filterText.getStyle() & SWT.CANCEL) != 0) |
682 |
if ((filterText.getStyle() & SWT.CANCEL) != 0) |
|
Lines 668-675
Link Here
|
| 668 |
* @since 3.3 |
695 |
* @since 3.3 |
| 669 |
*/ |
696 |
*/ |
| 670 |
protected Text doCreateFilterText(Composite parent) { |
697 |
protected Text doCreateFilterText(Composite parent) { |
| 671 |
return new Text(parent, SWT.SINGLE | SWT.BORDER | SWT.SEARCH |
698 |
if (useNativeSearchField()) { |
| 672 |
| SWT.CANCEL); |
699 |
return new Text(parent, SWT.SINGLE | SWT.BORDER | SWT.SEARCH |
|
|
700 |
| SWT.CANCEL); |
| 701 |
} |
| 702 |
return new Text(parent, SWT.SINGLE); |
| 673 |
} |
703 |
} |
| 674 |
|
704 |
|
| 675 |
private String previousFilterText; |
705 |
private String previousFilterText; |
|
Lines 696-707
Link Here
|
| 696 |
*/ |
726 |
*/ |
| 697 |
public void setBackground(Color background) { |
727 |
public void setBackground(Color background) { |
| 698 |
super.setBackground(background); |
728 |
super.setBackground(background); |
| 699 |
if (filterComposite != null) { |
729 |
if (filterComposite != null && useNativeSearchField()) { |
| 700 |
filterComposite.setBackground(background); |
730 |
filterComposite.setBackground(background); |
| 701 |
} |
731 |
} |
| 702 |
if (filterToolBar != null && filterToolBar.getControl() != null) { |
|
|
| 703 |
filterToolBar.getControl().setBackground(background); |
| 704 |
} |
| 705 |
} |
732 |
} |
| 706 |
|
733 |
|
| 707 |
/** |
734 |
/** |
|
Lines 714-741
Link Here
|
| 714 |
// only create the button if the text widget doesn't support one |
741 |
// only create the button if the text widget doesn't support one |
| 715 |
// natively |
742 |
// natively |
| 716 |
if ((filterText.getStyle() & SWT.CANCEL) == 0) { |
743 |
if ((filterText.getStyle() & SWT.CANCEL) == 0) { |
| 717 |
filterToolBar = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL); |
744 |
final Image inactiveImage= JFaceResources.getImageRegistry().getDescriptor(DCLEAR_ICON).createImage(); |
| 718 |
filterToolBar.createControl(parent); |
745 |
final Image activeImage= JFaceResources.getImageRegistry().getDescriptor(CLEAR_ICON).createImage(); |
|
|
746 |
|
| 747 |
final Label clearButton= new Label(parent, SWT.NONE); |
| 748 |
clearButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); |
| 749 |
clearButton.setImage(inactiveImage); |
| 750 |
clearButton.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); |
| 751 |
clearButton.setToolTipText(WorkbenchMessages.FilteredTree_ClearToolTip); |
| 752 |
clearButton.addMouseListener(new MouseListener() { |
| 753 |
public void mouseDoubleClick(MouseEvent e) { |
| 754 |
} |
| 719 |
|
755 |
|
| 720 |
IAction clearTextAction = new Action("", IAction.AS_PUSH_BUTTON) {//$NON-NLS-1$ |
756 |
public void mouseDown(MouseEvent e) { |
| 721 |
/* |
|
|
| 722 |
* (non-Javadoc) |
| 723 |
* |
| 724 |
* @see org.eclipse.jface.action.Action#run() |
| 725 |
*/ |
| 726 |
public void run() { |
| 727 |
clearText(); |
757 |
clearText(); |
| 728 |
} |
758 |
} |
| 729 |
}; |
|
|
| 730 |
|
759 |
|
| 731 |
clearTextAction |
760 |
public void mouseUp(MouseEvent e) { |
| 732 |
.setToolTipText(WorkbenchMessages.FilteredTree_ClearToolTip); |
761 |
} |
| 733 |
clearTextAction.setImageDescriptor(JFaceResources |
762 |
}); |
| 734 |
.getImageRegistry().getDescriptor(CLEAR_ICON)); |
763 |
clearButton.addMouseTrackListener(new MouseTrackListener() { |
| 735 |
clearTextAction.setDisabledImageDescriptor(JFaceResources |
764 |
public void mouseEnter(MouseEvent e) { |
| 736 |
.getImageRegistry().getDescriptor(DCLEAR_ICON)); |
765 |
clearButton.setImage(activeImage); |
|
|
766 |
} |
| 767 |
|
| 768 |
public void mouseExit(MouseEvent e) { |
| 769 |
clearButton.setImage(inactiveImage); |
| 770 |
} |
| 737 |
|
771 |
|
| 738 |
filterToolBar.add(clearTextAction); |
772 |
public void mouseHover(MouseEvent e) { |
|
|
773 |
} |
| 774 |
}); |
| 775 |
clearButton.addDisposeListener(new DisposeListener() { |
| 776 |
public void widgetDisposed(DisposeEvent e) { |
| 777 |
inactiveImage.dispose(); |
| 778 |
activeImage.dispose(); |
| 779 |
} |
| 780 |
}); |
| 781 |
clearButton.getAccessible().addAccessibleListener( |
| 782 |
new AccessibleAdapter() { |
| 783 |
public void getName(AccessibleEvent e) { |
| 784 |
e.result= WorkbenchMessages.FilteredTree_AccessibleListenerClearButton; |
| 785 |
} |
| 786 |
}); |
| 787 |
clearButton.getAccessible().addAccessibleControlListener( |
| 788 |
new AccessibleControlAdapter() { |
| 789 |
public void getRole(AccessibleControlEvent e) { |
| 790 |
e.detail= ACC.ROLE_PUSHBUTTON; |
| 791 |
} |
| 792 |
}); |
| 793 |
this.clearButtonControl= clearButton; |
| 739 |
} |
794 |
} |
| 740 |
} |
795 |
} |
| 741 |
|
796 |
|