diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/callhierarchy/CallHierarchyCore.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/callhierarchy/CallHierarchyCore.java index 1c24a09ac11..a14960bec26 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/callhierarchy/CallHierarchyCore.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/callhierarchy/CallHierarchyCore.java @@ -46,10 +46,13 @@ public class CallHierarchyCore { - private static final String PREF_USE_IMPLEMENTORS= "PREF_USE_IMPLEMENTORS"; //$NON-NLS-1$ - private static final String PREF_USE_FILTERS= "PREF_USE_FILTERS"; //$NON-NLS-1$ - private static final String PREF_FILTERS_LIST= "PREF_FILTERS_LIST"; //$NON-NLS-1$ - private static final String PREF_FILTER_TESTCODE= "PREF_FILTER_TESTCODE"; //$NON-NLS-1$ + public static final String PREF_SHOW_ALL_CODE = "PREF_SHOW_ALL_CODE"; //$NON-NLS-1$ + public static final String PREF_HIDE_TEST_CODE = "PREF_HIDE_TEST_CODE"; //$NON-NLS-1$ + public static final String PREF_SHOW_TEST_CODE_ONLY = "PREF_SHOW_TEST_CODE_ONLY"; //$NON-NLS-1$ + + private static final String PREF_USE_IMPLEMENTORS= "PREF_USE_IMPLEMENTORS"; //$NON-NLS-1$ + private static final String PREF_USE_FILTERS= "PREF_USE_FILTERS"; //$NON-NLS-1$ + private static final String PREF_FILTERS_LIST= "PREF_FILTERS_LIST"; //$NON-NLS-1$ private String defaultIgnoreFilters= "java.*,javax.*"; //$NON-NLS-1$ @@ -69,10 +72,18 @@ public boolean isSearchUsingImplementorsEnabled() { return Boolean.parseBoolean(JavaManipulation.getPreference(PREF_USE_IMPLEMENTORS, null)); } - public boolean isFilterTestCode() { - return Boolean.parseBoolean(JavaManipulation.getPreference(PREF_FILTER_TESTCODE, null)); + public boolean isShowTestCode() { + return Boolean.parseBoolean(JavaManipulation.getPreference(PREF_SHOW_TEST_CODE_ONLY, null)); + } + + public boolean isShowAll() { + return Boolean.parseBoolean(JavaManipulation.getPreference(PREF_SHOW_ALL_CODE, null)); } + public boolean isHideTestCode() { + return Boolean.parseBoolean(JavaManipulation.getPreference(PREF_HIDE_TEST_CODE, null)); + } + public Collection getImplementingMethods(IMethod method) { if (isSearchUsingImplementorsEnabled()) { IJavaElement[] result= Implementors.getInstance().searchForImplementors(new IJavaElement[] { @@ -196,10 +207,8 @@ public boolean isIgnored(String fullyQualifiedName) { } } } - return false; } - public boolean isFilterEnabled() { return Boolean.parseBoolean(JavaManipulation.getPreference(PREF_USE_FILTERS, null)); } diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/callhierarchy/CallSearchResultCollector.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/callhierarchy/CallSearchResultCollector.java index 9bc574ee5a6..db266001e72 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/callhierarchy/CallSearchResultCollector.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/callhierarchy/CallSearchResultCollector.java @@ -72,19 +72,21 @@ protected Map createCalledMethodsData() { * Method isIgnored. * @return boolean */ - private boolean isIgnored(IMember enclosingElement) { - String fullyQualifiedName = getTypeOfElement(enclosingElement) - .getFullyQualifiedName(); - - if (CallHierarchyCore.getDefault().isFilterTestCode()) { - IClasspathEntry classpathEntry= determineClassPathEntry(enclosingElement); - if (classpathEntry != null && classpathEntry.isTest()) { - return true; - } + private boolean isIgnored(IMember enclosingElement) { + String fullyQualifiedName= getTypeOfElement(enclosingElement).getFullyQualifiedName(); + + if (CallHierarchyCore.getDefault().isShowAll()) { + return false; } + IClasspathEntry classpathEntry= determineClassPathEntry(enclosingElement); - return CallHierarchyCore.getDefault().isIgnored(fullyQualifiedName); - } + if (classpathEntry != null) { + boolean isTest= classpathEntry.isTest(); + return CallHierarchyCore.getDefault().isHideTestCode() && isTest + || CallHierarchyCore.getDefault().isShowTestCode() && !isTest; + } + return CallHierarchyCore.getDefault().isIgnored(fullyQualifiedName); + } private static IClasspathEntry determineClassPathEntry(Object element) { if (element instanceof IJavaElement) { diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/callhierarchy/CallHierarchy.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/callhierarchy/CallHierarchy.java index 8a8cd726bd8..e0ce5f450f8 100644 --- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/callhierarchy/CallHierarchy.java +++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/callhierarchy/CallHierarchy.java @@ -37,10 +37,14 @@ import org.eclipse.jdt.internal.ui.util.StringMatcher; public class CallHierarchy { - private static final String PREF_USE_IMPLEMENTORS= "PREF_USE_IMPLEMENTORS"; //$NON-NLS-1$ + +// private static final String PREF_SHOW_ALL_CODE = "PREF_SHOW_ALL_CODE"; //$NON-NLS-1$ +// private static final String PREF_HIDE_TEST_CODE = "PREF_HIDE_TEST_CODE"; //$NON-NLS-1$ +// private static final String PREF_SHOW_TEST_CODE_ONLY = "PREF_SHOW_TEST_CODE_ONLY"; //$NON-NLS-1$ +// + private static final String PREF_USE_IMPLEMENTORS= "PREF_USE_IMPLEMENTORS"; //$NON-NLS-1$ private static final String PREF_USE_FILTERS = "PREF_USE_FILTERS"; //$NON-NLS-1$ private static final String PREF_FILTERS_LIST = "PREF_FILTERS_LIST"; //$NON-NLS-1$ - private static final String PREF_FILTER_TESTCODE= "PREF_FILTER_TESTCODE"; //$NON-NLS-1$ private static CallHierarchy fgInstance; private CallHierarchyCore fgCallHierarchyCore; @@ -53,35 +57,35 @@ public static CallHierarchy getDefault() { if (fgInstance == null) { fgInstance = new CallHierarchy(); } - return fgInstance; } - public boolean isSearchUsingImplementorsEnabled() { + public void setShowAll(boolean value) { IPreferenceStore settings = JavaPlugin.getDefault().getPreferenceStore(); - - return settings.getBoolean(PREF_USE_IMPLEMENTORS); + settings.setValue(CallHierarchyCore.PREF_SHOW_ALL_CODE, value); } - public static void setSearchUsingImplementorsEnabled(boolean enabled) { + public void setHideTestCode(boolean value) { IPreferenceStore settings = JavaPlugin.getDefault().getPreferenceStore(); - - settings.setValue(PREF_USE_IMPLEMENTORS, enabled); + settings.setValue(CallHierarchyCore.PREF_HIDE_TEST_CODE, value); } - public boolean isFilterTestCode() { + public void setShowTestCode(boolean value) { IPreferenceStore settings = JavaPlugin.getDefault().getPreferenceStore(); + settings.setValue(CallHierarchyCore.PREF_SHOW_TEST_CODE_ONLY, value); + } - return settings.getBoolean(PREF_FILTER_TESTCODE); + public boolean isSearchUsingImplementorsEnabled() { + IPreferenceStore settings = JavaPlugin.getDefault().getPreferenceStore(); + return settings.getBoolean(PREF_USE_IMPLEMENTORS); } - public void setFilterTestCode(boolean enabled) { + public static void setSearchUsingImplementorsEnabled(boolean enabled) { IPreferenceStore settings = JavaPlugin.getDefault().getPreferenceStore(); - settings.setValue(PREF_FILTER_TESTCODE, enabled); + settings.setValue(PREF_USE_IMPLEMENTORS, enabled); } - public Collection getImplementingMethods(IMethod method) { return fgCallHierarchyCore.getImplementingMethods(method); } @@ -135,6 +139,22 @@ public boolean isFilterEnabled() { return settings.getBoolean(PREF_USE_FILTERS); } + public boolean isShowAll() { + IPreferenceStore settings = JavaPlugin.getDefault().getPreferenceStore(); + return settings.getBoolean(CallHierarchyCore.PREF_SHOW_ALL_CODE); + } + + public boolean isHideTestCode() { + IPreferenceStore settings = JavaPlugin.getDefault().getPreferenceStore(); + return settings.getBoolean(CallHierarchyCore.PREF_HIDE_TEST_CODE); + } + + public boolean isShowTestCode() { + IPreferenceStore settings = JavaPlugin.getDefault().getPreferenceStore(); + return settings.getBoolean(CallHierarchyCore.PREF_SHOW_TEST_CODE_ONLY); + } + + public void setFilterEnabled(boolean filterEnabled) { IPreferenceStore settings = JavaPlugin.getDefault().getPreferenceStore(); settings.setValue(PREF_USE_FILTERS, filterEnabled); diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyMessages.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyMessages.java index f8a1d365c64..882aec6efda 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyMessages.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyMessages.java @@ -66,6 +66,11 @@ private CallHierarchyMessages() { public static String ShowExpandWithConstructorsDialogAction_text; public static String ShowFilterDialogAction_text; public static String FiltersDialog_filter; + + public static String FiltersDialog_ShowAllCode; + public static String FiltersDialog_HideTestCode; + public static String FiltersDialog_TestCodeOnly; + public static String FiltersDialog_filterOnNames; public static String FiltersDialog_filterOnNamesSubCaption; public static String FiltersDialog_maxCallDepth; diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyMessages.properties b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyMessages.properties index 41fcfa09393..d17c5a4adb0 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyMessages.properties +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyMessages.properties @@ -62,6 +62,11 @@ ShowSearchInDialogAction_text= Search &In... SearchInDialog_title= Search In ShowExpandWithConstructorsDialogAction_text=E&xpand with Constructors... ShowFilterDialogAction_text= &Filters... + +FiltersDialog_HideTestCode = Hide Test Code +FiltersDialog_ShowAllCode = Show All Code +FiltersDialog_TestCodeOnly = Test Code only + FiltersDialog_filter= Filter Calls FiltersDialog_filterOnNames= &Name filter patterns (matching names will be hidden): FiltersDialog_filterOnNamesSubCaption= Patterns are separated by commas (* = any string, ? = any character) diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/FiltersDialog.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/FiltersDialog.java index 35b995aba76..1fc44129115 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/FiltersDialog.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/FiltersDialog.java @@ -36,108 +36,138 @@ import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; class FiltersDialog extends StatusDialog { - private Label fNamesHelpText; - private Button fFilterOnNames; - private Text fNames; - private Text fMaxCallDepth; - private Button fFilterTestCode; + private Label fNamesHelpText; - protected FiltersDialog(Shell parentShell) { - super(parentShell); - } + private Button fFilterOnNames; - @Override + private Text fNames; + + private Text fMaxCallDepth; + + private Button fShowAll; + + private Button fHideTest; + + private Button fShowTest; + + + protected FiltersDialog(Shell parentShell) { + super(parentShell); + } + + @Override protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText(CallHierarchyMessages.FiltersDialog_filter); - PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.CALL_HIERARCHY_FILTERS_DIALOG); - } + super.configureShell(newShell); + newShell.setText(CallHierarchyMessages.FiltersDialog_filter); + PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.CALL_HIERARCHY_FILTERS_DIALOG); + } - @Override + @Override protected boolean isResizable() { - return true; - } + return true; + } - @Override + @Override protected Control createDialogArea(Composite parent) { - Composite composite= (Composite) super.createDialogArea(parent); + Composite composite= (Composite) super.createDialogArea(parent); - createTestCodeArea(composite); - createNamesArea(composite); - new Label(composite, SWT.NONE); // Filler - createMaxCallDepthArea(composite); + createTestCodeArea(composite); + createNamesArea(composite); + new Label(composite, SWT.NONE); // Filler + createMaxCallDepthArea(composite); - updateUIFromFilter(); + updateUIFromFilter(); - return composite; - } + return composite; + } - private void createMaxCallDepthArea(Composite parent) { - Composite composite= new Composite(parent, SWT.NONE); - composite.setFont(parent.getFont()); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - composite.setLayout(layout); + private void createMaxCallDepthArea(Composite parent) { + Composite composite= new Composite(parent, SWT.NONE); + composite.setFont(parent.getFont()); + GridLayout layout= new GridLayout(); + layout.numColumns= 2; + composite.setLayout(layout); - Label label= new Label(composite, SWT.NONE); - label.setFont(composite.getFont()); + Label label= new Label(composite, SWT.NONE); + label.setFont(composite.getFont()); label.setText(CallHierarchyMessages.FiltersDialog_maxCallDepth); - fMaxCallDepth = new Text(composite, SWT.SINGLE | SWT.BORDER); - fMaxCallDepth.setFont(composite.getFont()); - fMaxCallDepth.setTextLimit(6); - fMaxCallDepth.addModifyListener(e -> validateInput()); - - GridData gridData = new GridData(); - gridData.widthHint = convertWidthInCharsToPixels(10); - fMaxCallDepth.setLayoutData(gridData); - } - - private void createNamesArea(Composite parent) { - fFilterOnNames = createCheckbox(parent, - CallHierarchyMessages.FiltersDialog_filterOnNames, true); - - fNames= new Text(parent, SWT.SINGLE | SWT.BORDER); - fNames.setFont(parent.getFont()); - fNames.addModifyListener(e -> validateInput()); - - GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL); - gridData.widthHint = convertWidthInCharsToPixels(60); - fNames.setLayoutData(gridData); - - fNamesHelpText= new Label(parent, SWT.LEFT); - fNamesHelpText.setFont(parent.getFont()); - fNamesHelpText.setText(CallHierarchyMessages.FiltersDialog_filterOnNamesSubCaption); - } - - private void createTestCodeArea(Composite parent) { - fFilterTestCode = createCheckbox(parent, - CallHierarchyMessages.FiltersDialog_filterTestCode, true); - } - - - /** - * Creates a check box button with the given parent and text. - * - * @param parent the parent composite - * @param text the text for the check box - * @param grabRow trueto grab the remaining horizontal space, - * false otherwise - * - * @return the check box button - */ - private Button createCheckbox(Composite parent, String text, boolean grabRow) { - Button button = new Button(parent, SWT.CHECK); - button.setFont(parent.getFont()); - - if (grabRow) { - GridData gridData = new GridData(GridData.FILL_HORIZONTAL); - button.setLayoutData(gridData); - } - - button.setText(text); - button.addSelectionListener(new SelectionAdapter() { + fMaxCallDepth= new Text(composite, SWT.SINGLE | SWT.BORDER); + fMaxCallDepth.setFont(composite.getFont()); + fMaxCallDepth.setTextLimit(6); + fMaxCallDepth.addModifyListener(e -> validateInput()); + + GridData gridData= new GridData(); + gridData.widthHint= convertWidthInCharsToPixels(10); + fMaxCallDepth.setLayoutData(gridData); + } + + private void createNamesArea(Composite parent) { + fFilterOnNames= createCheckbox(parent, + CallHierarchyMessages.FiltersDialog_filterOnNames, true); + + fNames= new Text(parent, SWT.SINGLE | SWT.BORDER); + fNames.setFont(parent.getFont()); + fNames.addModifyListener(e -> validateInput()); + + GridData gridData= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL); + gridData.widthHint= convertWidthInCharsToPixels(60); + fNames.setLayoutData(gridData); + + fNamesHelpText= new Label(parent, SWT.LEFT); + fNamesHelpText.setFont(parent.getFont()); + fNamesHelpText.setText(CallHierarchyMessages.FiltersDialog_filterOnNamesSubCaption); + } + + private void createTestCodeArea(Composite parent) { + + Composite radioGroup= new Composite(parent, SWT.NONE); + GridLayout layout= new GridLayout(); + layout.numColumns= 1; + radioGroup.setLayout(layout); + + fShowAll= new Button(radioGroup, SWT.RADIO); + fShowAll.setText(CallHierarchyMessages.FiltersDialog_ShowAllCode); + fShowAll.setSelection(CallHierarchy.getDefault().isShowAll()); + + fHideTest= new Button(radioGroup, SWT.RADIO); + fHideTest.setText(CallHierarchyMessages.FiltersDialog_HideTestCode); + fHideTest.setSelection(CallHierarchy.getDefault().isHideTestCode()); + + fShowTest= new Button(radioGroup, SWT.RADIO); + fShowTest.setText(CallHierarchyMessages.FiltersDialog_TestCodeOnly); + fShowTest.setSelection(CallHierarchy.getDefault().isShowTestCode()); + + GridData gridData= new GridData(); + gridData.horizontalIndent= 0; + fShowAll.setLayoutData(gridData); + fHideTest.setLayoutData(gridData); + fShowTest.setLayoutData(gridData); + } + + + /** + * Creates a check box button with the given parent and text. + * + * @param parent the parent composite + * @param text the text for the check box + * @param grabRow trueto grab the remaining horizontal space, false + * otherwise + * + * @return the check box button + */ + private Button createCheckbox(Composite parent, String text, boolean grabRow) { + Button button= new Button(parent, SWT.CHECK); + button.setFont(parent.getFont()); + + if (grabRow) { + GridData gridData= new GridData(GridData.FILL_HORIZONTAL); + button.setLayoutData(gridData); + } + + button.setText(text); + button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { validateInput(); @@ -145,78 +175,99 @@ public void widgetSelected(SelectionEvent e) { } }); - return button; - } - - /** - * Updates the enabled state of the widgetry. - */ - private void updateEnabledState() { - fNames.setEnabled(fFilterOnNames.getSelection()); - fNamesHelpText.setEnabled(fFilterOnNames.getSelection()); - } - - /** - * Updates the given filter from the UI state. - */ - private void updateFilterFromUI() { - int maxCallDepth = Integer.parseInt(this.fMaxCallDepth.getText()); - - CallHierarchyUI.getDefault().setMaxCallDepth(maxCallDepth); - CallHierarchy.getDefault().setFilters(fNames.getText()); - CallHierarchy.getDefault().setFilterEnabled(fFilterOnNames.getSelection()); - CallHierarchy.getDefault().setFilterTestCode(fFilterTestCode.getSelection()); - } - - /** - * Updates the UI state from the given filter. - */ - private void updateUIFromFilter() { - fMaxCallDepth.setText(String.valueOf(CallHierarchyUI.getDefault().getMaxCallDepth())); - fNames.setText(CallHierarchy.getDefault().getFilters()); - fFilterOnNames.setSelection(CallHierarchy.getDefault().isFilterEnabled()); - fFilterTestCode.setSelection(CallHierarchy.getDefault().isFilterTestCode()); - updateEnabledState(); - } + return button; + } /** - * Updates the filter from the UI state. - * Must be done here rather than by extending open() - * because after super.open() is called, the widgetry is disposed. + * Updates the enabled state of the widgetry. + */ + private void updateEnabledState() { + fNames.setEnabled(fFilterOnNames.getSelection()); + fNamesHelpText.setEnabled(fFilterOnNames.getSelection()); + } + + /** + * Updates the given filter from the UI state. + */ + private void updateFilterFromUI() { + int maxCallDepth= Integer.parseInt(this.fMaxCallDepth.getText()); + + CallHierarchyUI.getDefault().setMaxCallDepth(maxCallDepth); + CallHierarchy.getDefault().setFilters(fNames.getText()); + CallHierarchy.getDefault().setFilterEnabled(fFilterOnNames.getSelection()); + + //try which one is selected and set the filters + if (fShowAll.getSelection()) { + CallHierarchy.getDefault().setShowAll(true); + CallHierarchy.getDefault().setHideTestCode(false); + CallHierarchy.getDefault().setShowTestCode(false); + } else if (fHideTest.getSelection()) { + CallHierarchy.getDefault().setShowAll(false); + CallHierarchy.getDefault().setHideTestCode(true); + CallHierarchy.getDefault().setShowTestCode(false); + } else if (fShowTest.getSelection()) { + CallHierarchy.getDefault().setShowAll(false); + CallHierarchy.getDefault().setHideTestCode(false); + CallHierarchy.getDefault().setShowTestCode(true); + } + } + + /** + * Updates the UI state from the given filter. + */ + private void updateUIFromFilter() { + fMaxCallDepth.setText(String.valueOf(CallHierarchyUI.getDefault().getMaxCallDepth())); + fNames.setText(CallHierarchy.getDefault().getFilters()); + fFilterOnNames.setSelection(CallHierarchy.getDefault().isFilterEnabled()); + + if (CallHierarchy.getDefault().isShowTestCode()) { + fShowTest.setSelection(true); + } else if (CallHierarchy.getDefault().isHideTestCode()) { + fHideTest.setSelection(true); + } else { + fShowAll.setSelection(true); + } + updateEnabledState(); + } + + /** + * Updates the filter from the UI state. Must be done here rather than by extending open() + * because after super.open() is called, the widgetry is disposed. + * * @see org.eclipse.jface.dialogs.Dialog#okPressed() - */ - @Override + */ + @Override protected void okPressed() { - if (!isMaxCallDepthValid()) { - if (fMaxCallDepth.forceFocus()) { - fMaxCallDepth.setSelection(0, fMaxCallDepth.getCharCount()); - fMaxCallDepth.showSelection(); - } - } - - updateFilterFromUI(); - super.okPressed(); - } - - private boolean isMaxCallDepthValid() { - String text= fMaxCallDepth.getText(); - if (text.length() == 0) - return false; - - try { - int maxCallDepth= Integer.parseInt(text); - - return (maxCallDepth >= 1 && maxCallDepth <= 99); - } catch (NumberFormatException e) { - return false; - } - } - - private void validateInput() { - StatusInfo status= new StatusInfo(); - if (!isMaxCallDepthValid()) { - status.setError(CallHierarchyMessages.FiltersDialog_messageMaxCallDepthInvalid); - } - updateStatus(status); - } + if (!isMaxCallDepthValid()) { + if (fMaxCallDepth.forceFocus()) { + fMaxCallDepth.setSelection(0, fMaxCallDepth.getCharCount()); + fMaxCallDepth.showSelection(); + } + } + + updateFilterFromUI(); + super.okPressed(); + } + + private boolean isMaxCallDepthValid() { + String text= fMaxCallDepth.getText(); + if (text.length() == 0) + return false; + + try { + int maxCallDepth= Integer.parseInt(text); + + return (maxCallDepth >= 1 && maxCallDepth <= 99); + } catch (NumberFormatException e) { + return false; + } + } + + private void validateInput() { + StatusInfo status= new StatusInfo(); + if (!isMaxCallDepthValid()) { + status.setError(CallHierarchyMessages.FiltersDialog_messageMaxCallDepthInvalid); + } + updateStatus(status); + } }