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 25296 Details for
Bug 102081
Abandon the combo box of preferenceDialog
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
A patch based on comment 4
0726_102081.txt (text/plain), 9.70 KB, created by
shujie liao
on 2005-07-26 09:44:35 EDT
(
hide
)
Description:
A patch based on comment 4
Filename:
MIME Type:
Creator:
shujie liao
Created:
2005-07-26 09:44:35 EDT
Size:
9.70 KB
patch
obsolete
>Index: FilteredTextTree.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/FilteredTextTree.java,v >retrieving revision 1.1 >diff -u -r1.1 FilteredTextTree.java >--- FilteredTextTree.java 6 Jul 2005 18:12:09 -0000 1.1 >+++ FilteredTextTree.java 26 Jul 2005 13:41:47 -0000 >@@ -19,12 +19,15 @@ > import org.eclipse.swt.events.ControlEvent; > import org.eclipse.swt.events.DisposeEvent; > import org.eclipse.swt.events.DisposeListener; >+import org.eclipse.swt.events.FocusAdapter; >+import org.eclipse.swt.events.FocusEvent; > import org.eclipse.swt.events.KeyAdapter; > import org.eclipse.swt.events.KeyEvent; > import org.eclipse.swt.events.SelectionAdapter; > import org.eclipse.swt.events.SelectionEvent; > import org.eclipse.swt.events.TraverseEvent; > import org.eclipse.swt.events.TraverseListener; >+import org.eclipse.swt.graphics.Font; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.swt.layout.GridData; >@@ -45,7 +48,11 @@ > public class FilteredTextTree extends FilteredTree { > // A list contains all strings in search history > private List searchHistory; >+ >+ //A popup shell to hold the currentSeachTable >+ private Shell shell; > >+ //A key which is paired with a search history string as part of dialog settings > private static final String SEARCHHISTORY = "search"; //$NON-NLS-1$ > > // A table which contains only strings begin with typed strings >@@ -71,6 +78,25 @@ > public FilteredTextTree(Composite parent, int treeStyle, > PatternItemFilter filter) { > super(parent, treeStyle, filter); >+ treeViewer.getControl().addFocusListener(new FocusAdapter(){ >+ /* Each time the tree gains focus, the current text in text area is saved as search history >+ * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent) >+ */ >+ public void focusGained(FocusEvent e) { >+ String newText = filterText.getText(); >+ Object[] textValues = searchHistory.toArray(); >+ >+ if((newText.equals(""))||(newText.equals(initialText)))//$NON-NLS-1$ >+ return; >+ >+ for (int i = 0; i < textValues.length; i++) { >+ if(((String)textValues[i]).equals(newText)) >+ return; >+ } >+ searchHistory.add(newText); >+ } >+ }); >+ > } > > /* >@@ -83,7 +109,7 @@ > filterText.setFont(parent.getFont()); > searchHistory = getPreferenceSearchHistory(); > >- final Shell shell = new Shell(parent.getShell(), SWT.NO_TRIM); >+ shell = new Shell(parent.getShell(), SWT.NO_TRIM); > shell > .setBackground(parent.getDisplay().getSystemColor( > SWT.COLOR_WHITE)); >@@ -97,7 +123,13 @@ > currentSeachTable = new Table(shell, SWT.SINGLE | SWT.BORDER); > currentSeachTable.setLayoutData(new GridData( > (GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL))); >- >+ Font font = parent.getFont(); >+ >+ //Make sure the popup shell show whole words without scrollable horizontally >+ currentSeachTable.setFont(new Font >+ (parent.getDisplay(),font.getFontData()[0].getName(), >+ font.getFontData()[0].getHeight()-1,font.getFontData()[0].getStyle())); >+ > filterText.addTraverseListener(new TraverseListener() { > public void keyTraversed(TraverseEvent e) { > if (e.detail == SWT.TRAVERSE_RETURN) { >@@ -131,24 +163,22 @@ > // Make selection be on the left tree > treeViewer.getTree().setFocus(); > } else { >- if (e.character == SWT.CR) >+ if (e.character == SWT.CR){ >+ int index =currentSeachTable.getSelectionIndex(); >+ setFilterText(currentSeachTable.getItem(index).getText()); >+ textChanged(); >+ shell.setVisible(false); > return; >- >+ } > textChanged(); > List result = new ArrayList(); > result = reduceSearch(searchHistory, filterText.getText()); >- upDateTable(currentSeachTable, result); >+ updateTable(currentSeachTable, result); > > if (currentSeachTable.getItemCount() > 0) { > Rectangle textBounds = filterText.getBounds(); >- Point point = getDisplay().map(parent, null, >- textBounds.x, textBounds.y); >- int space = currentSeachTable.getItemHeight(); >- shell.setBounds(point.x, point.y + textBounds.height, >- textBounds.width, currentSeachTable >- .getItemHeight() >- * currentSeachTable.getItemCount() >- + space); >+ >+ setShellLocationAndSize(parent,textBounds); > > if (shell.isDisposed()) > shell.open(); >@@ -231,18 +261,59 @@ > * String > * @return a list in which all strings start from the typed letter(s) > */ >- public List reduceSearch(List list, String wordsEntered) { >+ private List reduceSearch(List list, String wordsEntered) { > List result = new ArrayList(); > if (list == null) > return result; > for (int i = 0; i < list.size(); i++) { > if (filterText.getText() == "") //$NON-NLS-1$ >+ return result; >+ String historyString = (String) list.get(i); >+ String typedString = wordsEntered; >+ if (historyString.toLowerCase().startsWith(typedString.toLowerCase())) >+ result.add(historyString); >+ } >+ > return result; >- else if (((String) list.get(i)).startsWith(wordsEntered)) >- result.add(list.get(i)); >- } >- >- return result; >+ } >+ /** >+ * Caculate and set the position and size of the popup shell >+ * @param parent >+ * @param textBounds >+ */ >+ private void setShellLocationAndSize(Composite parent, Rectangle textBounds){ >+ >+ //Caculate size of the popup shell >+ int space = currentSeachTable.getItemHeight(); >+ int tableHeight = currentSeachTable >+ .getItemHeight()* currentSeachTable.getItemCount() + space; >+ int tableWidth = textBounds.width; >+ shell.setSize(tableWidth,tableHeight); >+ >+ //Caculate x,y coordinator of the popup shell >+ Point point = getDisplay().map(parent, null, >+ textBounds.x, textBounds.y); >+ final int xCoord = point.x; >+ final int yCoord = point.y + textBounds.height; >+ >+ final Point location = new Point(xCoord, yCoord); >+ >+ //Try to show whole popup shell through relocating its x and y coordinator >+ final Display display = shell.getDisplay(); >+ final Rectangle displayBounds = display.getClientArea(); >+ final int displayRightEdge = displayBounds.x + displayBounds.width; >+ >+ if (location.x <0) >+ location.x = 0; >+ if ((location.x + tableWidth) > displayRightEdge) >+ location.x = displayRightEdge - tableWidth; >+ >+ final int displayBottomEdge = displayBounds.y + displayBounds.height; >+ if ((location.y + tableHeight) > displayBottomEdge) >+ location.y = displayBottomEdge - tableHeight; >+ >+ // Set the location. >+ shell.setLocation(location); > } > > /** >@@ -251,7 +322,7 @@ > * @param table > * @param list > */ >- public void upDateTable(Table table, List list) { >+ private void updateTable(Table table, List list) { > table.removeAll(); > if (list.size() > 0) { > TableItem newItem; >@@ -269,7 +340,7 @@ > * > * @return IDialogSettings > */ >- private IDialogSettings getDialogSettings() { >+ private IDialogSettings getDialogSettings(){ > IDialogSettings settings = WorkbenchPlugin.getDefault() > .getDialogSettings(); > IDialogSettings thisSettings = settings >@@ -286,7 +357,7 @@ > * > * @return a list > */ >- public List getPreferenceSearchHistory() { >+ private List getPreferenceSearchHistory() { > > List searchList = new ArrayList(); > IDialogSettings settings = getDialogSettings(); >@@ -303,7 +374,7 @@ > /** > * Saves the search history. > */ >- private void saveDialogSettings() { >+ private void saveDialogSettings(){ > IDialogSettings settings = getDialogSettings(); > > // If the settings contains the same key, the previous value will be >@@ -320,23 +391,4 @@ > string[i] = (String) list.get(i); > } > >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.ui.internal.dialogs.FilteredTree#filterFocusLost() >- */ >- protected void filterFocusLost() { >- String newText = filterText.getText(); >- Object[] textValues = searchHistory.toArray(); >- >- if ((newText.equals("")) || (newText.equals(initialText)))//$NON-NLS-1$ >- return; >- >- for (int i = 0; i < textValues.length; i++) { >- if (((String) textValues[i]).equals(newText)) >- return; >- } >- searchHistory.add(newText); >- } >- > } >Index: FilteredTree.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/FilteredTree.java,v >retrieving revision 1.29 >diff -u -r1.29 FilteredTree.java >--- FilteredTree.java 14 Jul 2005 13:35:23 -0000 1.29 >+++ FilteredTree.java 26 Jul 2005 13:41:47 -0000 >@@ -241,7 +241,7 @@ > * @see org.eclipse.swt.accessibility.AccessibleListener#getName(org.eclipse.swt.accessibility.AccessibleEvent) > */ > public void getName(AccessibleEvent e) { >- String filterTextString = getFilterText(); >+ String filterTextString = getFilterControlText(); > if(filterTextString.length() == 0){ > e.result = initialText; > } >@@ -253,13 +253,6 @@ > } > > /** >- * Get the text from the filter widget. >- * @return String >- */ >- protected String getFilterText() { >- return filterText.getText(); >- } >- /** > * update the receiver after the text has changed > */ > protected void textChanged() { >@@ -376,7 +369,6 @@ > * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent) > */ > public void focusLost(FocusEvent e) { >- filterFocusLost(); > } > }; > getFilterControl().addFocusListener(listener);
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 102081
:
24326
|
24383
|
24783
|
25296
|
25430
|
25584
|
27648
|
27653
|
27838
|
27868
|
27957
|
27967
|
27979
|
28401
|
28603