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 25584 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 to fix problem 3, 5 and 7 in comment 4
0802_102081AfterReuse.txt (text/plain), 15.94 KB, created by
shujie liao
on 2005-08-02 16:24:40 EDT
(
hide
)
Description:
A patch to fix problem 3, 5 and 7 in comment 4
Filename:
MIME Type:
Creator:
shujie liao
Created:
2005-08-02 16:24:40 EDT
Size:
15.94 KB
patch
obsolete
>Index: Eclipse UI/org/eclipse/ui/internal/dialogs/FilteredPreferenceDialog.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/FilteredPreferenceDialog.java,v >retrieving revision 1.66 >diff -u -r1.66 FilteredPreferenceDialog.java >--- Eclipse UI/org/eclipse/ui/internal/dialogs/FilteredPreferenceDialog.java 6 Jul 2005 18:12:09 -0000 1.66 >+++ Eclipse UI/org/eclipse/ui/internal/dialogs/FilteredPreferenceDialog.java 2 Aug 2005 20:22:27 -0000 >@@ -45,6 +45,7 @@ > import org.eclipse.ui.internal.WorkbenchMessages; > import org.eclipse.ui.internal.WorkbenchPlugin; > import org.eclipse.ui.internal.preferences.WorkingCopyManager; >+import org.eclipse.ui.internal.wizards.preferences.PreferencesMessages; > import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; > import org.eclipse.ui.preferences.IWorkingCopyManager; > import org.osgi.service.prefs.BackingStoreException; >@@ -65,8 +66,8 @@ > > private Collection updateJobs = new ArrayList(); > >- //Composite toolBarComposite; >- >+ //A key which is paired with a search history string as part of dialog settings >+ private static final String SEARCHHISTORY = PreferencesMessages.SearchKey; //$NON-NLS-1$ > > /** > * The preference page history. >@@ -110,7 +111,7 @@ > protected TreeViewer createTreeViewer(Composite parent) { > PatternItemFilter filter = new PatternItemFilter(true); > int styleBits = SWT.SINGLE | SWT.H_SCROLL; >- filteredTree = new FilteredTextTree(parent, styleBits, filter); >+ filteredTree = new FilteredTextTree(parent, styleBits, filter,SEARCHHISTORY); > GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); > gd.horizontalIndent = IDialogConstants.HORIZONTAL_MARGIN; > filteredTree.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); >@@ -354,13 +355,23 @@ > null)); > } > return success; >- } >+ } > > /* (non-Javadoc) >+ * @see org.eclipse.jface.window.Window#open() >+ */ >+ public int open() { >+ int code = super.open(); >+ filteredTree.setPreferenceSearchHistory(filteredTree.getDialogSettings(),SEARCHHISTORY); >+ return code; >+ } >+ >+ /* (non-Javadoc) > * @see org.eclipse.jface.window.Window#close() > */ > public boolean close() { > history.dispose(); >+ filteredTree.saveDialogSettings(filteredTree.getDialogSettings(),SEARCHHISTORY); > return super.close(); > } > >Index: Eclipse UI/org/eclipse/ui/internal/dialogs/FilteredTextTree.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/FilteredTextTree.java,v >retrieving revision 1.3 >diff -u -r1.3 FilteredTextTree.java >--- Eclipse UI/org/eclipse/ui/internal/dialogs/FilteredTextTree.java 2 Aug 2005 17:40:39 -0000 1.3 >+++ Eclipse UI/org/eclipse/ui/internal/dialogs/FilteredTextTree.java 2 Aug 2005 20:22:27 -0000 >@@ -17,8 +17,6 @@ > import org.eclipse.swt.SWT; > import org.eclipse.swt.events.ControlAdapter; > 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; >@@ -52,12 +50,15 @@ > //A popup shell to hold the currentSeachTable > private Shell popupShell; > >- //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 > private Table currentSeachTable; >- >+ >+ //Set a minimum width for popupShell to make sure to show all >+ //text in the horizonal space >+ private int minPopupShellWidth; >+ >+ //Identify wether the text area was resized. >+ private boolean resizedFlag; > /** > * Create a new instance of the receiver. > * >@@ -74,11 +75,14 @@ > * @param parent > * @param treeStyle > * @param filter >+ * @param searchKey > */ > public FilteredTextTree(Composite parent, int treeStyle, >- PatternItemFilter filter) { >+ PatternItemFilter filter, String searchKey) { > super(parent, treeStyle, filter); >- treeViewer.getControl().addFocusListener(new FocusAdapter(){ >+ searchHistory = getPreferenceSearchHistory(searchKey); >+ resizedFlag = false; >+ 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) > */ >@@ -105,10 +109,9 @@ > * @see org.eclipse.ui.internal.dialogs.FilteredTree#createFilterControl(org.eclipse.swt.widgets.Composite) > */ > protected void createFilterControl(final Composite parent) { >- filterText = new Text(parent, SWT.DROP_DOWN | SWT.BORDER); >- filterText.setFont(parent.getFont()); >- searchHistory = getPreferenceSearchHistory(); >- >+ filterText = new Text(parent, SWT.BORDER | SWT.MULTI); >+ filterText.setFont(parent.getFont()); >+ > popupShell = new Shell(parent.getShell(), SWT.NO_TRIM); > popupShell > .setBackground(parent.getDisplay().getSystemColor( >@@ -123,9 +126,9 @@ > currentSeachTable = new Table(popupShell, 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 >+ Font font = parent.getFont(); > currentSeachTable.setFont(new Font > (parent.getDisplay(),font.getFontData()[0].getName(), > font.getFontData()[0].getHeight()-1,font.getFontData()[0].getStyle())); >@@ -144,7 +147,40 @@ > } > } > }); >+ >+ >+ filterText.addFocusListener(new FocusAdapter(){ >+ public void focusGained(FocusEvent e) { >+ //filterText.setText("Focus gained!!"); //$NON-NLS-1$ >+ filterText.selectAll(); >+ } >+ >+ public void focusLost(FocusEvent e) { >+ filterText.setSelection(0,0); >+ } >+ }); >+ >+ >+ popupShell.addTraverseListener(new TraverseListener() { >+ public void keyTraversed(TraverseEvent e) { >+ if ((e.detail == SWT.TRAVERSE_RETURN)||(e.detail == SWT.TRAVERSE_ESCAPE)) { >+ e.doit = false; >+ if(e.detail == SWT.TRAVERSE_RETURN){ >+ setFilterText(currentSeachTable.getSelection()[0].getText()); >+ textChanged(); >+ } >+ popupShell.setVisible(false); >+ getViewer().getTree().setFocus(); >+ } >+ } >+ }); > >+ currentSeachTable.addSelectionListener(new SelectionAdapter(){ >+ public void widgetSelected(SelectionEvent e) { >+ setFilterText(currentSeachTable.getSelection()[0].getText()); //$NON-NLS-1$ >+ textChanged(); >+ } >+ }); > filterText.addKeyListener(new KeyAdapter() { > /* > * (non-Javadoc) >@@ -156,20 +192,16 @@ > if (e.keyCode == SWT.ARROW_DOWN) { > if (currentSeachTable.isVisible()) { > // Make selection at popup table >- if (currentSeachTable.getSelectionCount() < 1) >+ if (currentSeachTable.getSelectionCount() < 1){ > currentSeachTable.setSelection(0); >+ setFilterText(currentSeachTable.getSelection()[0].getText()); //$NON-NLS-1$ >+ textChanged(); >+ } > currentSeachTable.setFocus(); >- } else >- // Make selection be on the left tree >- treeViewer.getTree().setFocus(); >+ } else if(getViewer().getTree().getItemCount() > 0) >+ //Make selection be on the left tree >+ treeViewer.getTree().setFocus(); > } else { >- if (e.character == SWT.CR){ >- int index =currentSeachTable.getSelectionIndex(); >- setFilterText(currentSeachTable.getItem(index).getText()); >- textChanged(); >- popupShell.setVisible(false); >- return; >- } > textChanged(); > List result = new ArrayList(); > result = reduceSearch(searchHistory, filterText.getText()); >@@ -217,35 +249,22 @@ > popupShell.setVisible(false); > } > }); >- >- currentSeachTable.addSelectionListener(new SelectionAdapter() { >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) >- */ >- public void widgetSelected(SelectionEvent e) { >- >- setFilterText(currentSeachTable.getSelection()[0].getText()); >- textChanged(); >- } >- >- public void widgetDefaultSelected(SelectionEvent e) { >- popupShell.setVisible(false); >- } >- }); >- >- filterText.addDisposeListener(new DisposeListener() { >+ >+ filterText.addControlListener(new ControlAdapter() { > /* > * (non-Javadoc) > * >- * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent) >+ * @see org.eclipse.swt.events.ControlListener#controlMoved(org.eclipse.swt.events.ControlEvent) > */ >- public void widgetDisposed(DisposeEvent e) { >- saveDialogSettings(); >+ public void controlResized(ControlEvent e) { >+ int initialTextWidth = filterText.getBounds().width; >+ if((initialTextWidth >0)&& (resizedFlag ==false)){ >+ minPopupShellWidth=initialTextWidth; >+ resizedFlag = true; >+ } > } > }); >- >+ > filterText.getAccessible().addAccessibleListener( > getAccessibleListener()); > >@@ -288,8 +307,13 @@ > int tableHeight = currentSeachTable > .getItemHeight()* currentSeachTable.getItemCount() + space; > int tableWidth = textBounds.width; >- popupShell.setSize(tableWidth,tableHeight); > >+ //Make sure the width of popupShell be at least minPopupShellWidth >+ if(tableWidth <= minPopupShellWidth) >+ popupShell.setSize(minPopupShellWidth,tableHeight); >+ else >+ popupShell.setSize(tableWidth,tableHeight); >+ > //Caculate x,y coordinator of the popup shell > Point point = getDisplay().map(parent, null, > textBounds.x, textBounds.y); >@@ -301,12 +325,13 @@ > //Try to show whole popup shell through relocating its x and y coordinator > final Display display = popupShell.getDisplay(); > final Rectangle displayBounds = display.getClientArea(); >+ Rectangle popupShellBounds = popupShell.getBounds(); > final int displayRightEdge = displayBounds.x + displayBounds.width; > > if (location.x <0) > location.x = 0; >- if ((location.x + tableWidth) > displayRightEdge) >- location.x = displayRightEdge - tableWidth; >+ if ((location.x + popupShellBounds.width) > displayRightEdge) >+ location.x = displayRightEdge - popupShellBounds.width; > > final int displayBottomEdge = displayBounds.y + displayBounds.height; > if ((location.y + tableHeight) > displayBottomEdge) >@@ -340,7 +365,7 @@ > * > * @return IDialogSettings > */ >- private IDialogSettings getDialogSettings(){ >+ public IDialogSettings getDialogSettings(){ > IDialogSettings settings = WorkbenchPlugin.getDefault() > .getDialogSettings(); > IDialogSettings thisSettings = settings >@@ -357,11 +382,11 @@ > * > * @return a list > */ >- private List getPreferenceSearchHistory() { >+ private List getPreferenceSearchHistory(String key) { > > List searchList = new ArrayList(); > IDialogSettings settings = getDialogSettings(); >- String[] search = settings.getArray(SEARCHHISTORY); >+ String[] search = settings.getArray(key); > > if (search != null) { > for (int i = 0; i < search.length; i++) >@@ -370,18 +395,31 @@ > return searchList; > > } >+ >+ /**Set the preference value matching searchkey >+ * @param settings >+ * @param searchKey >+ */ >+ public void setPreferenceSearchHistory(IDialogSettings settings, String searchKey) { >+ String[] search = settings.getArray(searchKey); //$NON-NLS-1$ >+ if (search != null) { >+ for (int i = 0; i < search.length; i++) >+ searchHistory.add(search[i]); >+ } >+ } > > /** > * Saves the search history. >+ * @param settings >+ * @param key > */ >- private void saveDialogSettings(){ >- IDialogSettings settings = getDialogSettings(); >- >+ public void saveDialogSettings(IDialogSettings settings,String key){ >+ > // If the settings contains the same key, the previous value will be > // replaced by new one > String[] result = new String[searchHistory.size()]; > listToArray(searchHistory, result); >- settings.put(SEARCHHISTORY, result); >+ settings.put(key, result); > > } > >Index: Eclipse UI/org/eclipse/ui/internal/dialogs/FilteredTree.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/FilteredTree.java,v >retrieving revision 1.30 >diff -u -r1.30 FilteredTree.java >--- Eclipse UI/org/eclipse/ui/internal/dialogs/FilteredTree.java 26 Jul 2005 14:34:57 -0000 1.30 >+++ Eclipse UI/org/eclipse/ui/internal/dialogs/FilteredTree.java 2 Aug 2005 20:22:27 -0000 >@@ -26,7 +26,6 @@ > import org.eclipse.swt.accessibility.AccessibleEvent; > import org.eclipse.swt.events.DisposeEvent; > import org.eclipse.swt.events.DisposeListener; >-import org.eclipse.swt.events.FocusEvent; > import org.eclipse.swt.events.FocusListener; > import org.eclipse.swt.events.KeyAdapter; > import org.eclipse.swt.events.KeyEvent; >@@ -358,20 +357,6 @@ > setFilterText(initialText); > > textChanged(); >- listener = new FocusListener() { >- public void focusGained(FocusEvent event) { >- filterFocusGained(); >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent) >- */ >- public void focusLost(FocusEvent e) { >- } >- }; >- getFilterControl().addFocusListener(listener); > } > > >@@ -409,22 +394,4 @@ > cachedTitle)); > > } >- >- /** >- * Focus has been gained on the filter control. >- * >- */ >- protected void filterFocusGained() { >- selectAll(); >- getFilterControl().removeFocusListener(listener); >- } >- >- /** >- * Focus has been lost on the filter control. >- * >- */ >- protected void filterFocusLost() { >- >- } >- > } >Index: Eclipse UI/org/eclipse/ui/internal/wizards/preferences/PreferencesMessages.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/wizards/preferences/PreferencesMessages.java,v >retrieving revision 1.4 >diff -u -r1.4 PreferencesMessages.java >--- Eclipse UI/org/eclipse/ui/internal/wizards/preferences/PreferencesMessages.java 8 Jun 2005 22:07:12 -0000 1.4 >+++ Eclipse UI/org/eclipse/ui/internal/wizards/preferences/PreferencesMessages.java 2 Aug 2005 20:22:28 -0000 >@@ -24,6 +24,7 @@ > public static String WizardPreferences_description; > public static String WizardPreferencesPage_noOptionsSelected; > public static String WizardPreferences_noSpecificPreferenceDescription; >+ public static String SearchKey; > > public static String PreferencesExportWizard_export; > public static String WizardPreferencesExportPage1_exportTitle; >Index: Eclipse UI/org/eclipse/ui/internal/wizards/preferences/messages.properties >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/wizards/preferences/messages.properties,v >retrieving revision 1.6 >diff -u -r1.6 messages.properties >--- Eclipse UI/org/eclipse/ui/internal/wizards/preferences/messages.properties 8 Jun 2005 22:45:22 -0000 1.6 >+++ Eclipse UI/org/eclipse/ui/internal/wizards/preferences/messages.properties 2 Aug 2005 20:22:28 -0000 >@@ -15,6 +15,7 @@ > PreferencesExportWizard_export=Export Preferences > WizardPreferencesExportPage1_exportTitle=Export Preferences > WizardPreferencesExportPage1_exportDescription=Export preferences to the local file system. >+SearchKey = SearchHistory > > WizardPreferencesExportPage1_preferences=Preferences > WizardPreferencesExportPage1_noPrefFile=Preference file not set, or is not a normal file.
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