aboutsummaryrefslogtreecommitdiffstats
path: root/ddms
diff options
context:
space:
mode:
authorSiva Velusamy <vsiva@google.com>2012-06-08 10:57:17 -0700
committerSiva Velusamy <vsiva@google.com>2012-06-08 10:57:17 -0700
commit46e46005df47d0fbb8cf32d33e55064ae557a874 (patch)
treea4b16a62260d2161e8ba764109d011412c36b159 /ddms
parentd0fdcfdfac4b2ec4898df933aa90541d79420519 (diff)
downloadsdk-46e46005df47d0fbb8cf32d33e55064ae557a874.zip
sdk-46e46005df47d0fbb8cf32d33e55064ae557a874.tar.gz
sdk-46e46005df47d0fbb8cf32d33e55064ae557a874.tar.bz2
Find Dialog: allow control over the default action.
This CL allows the default action to be either of the "Find Next" or the "Find Previous" buttons in the find dialog. Typically, in logcat you want to find previous, while in gltrace view you want to find next. Change-Id: Ie11cbd8a7987b8011ec2ee3664034e9ecfc4e24b
Diffstat (limited to 'ddms')
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/FindDialog.java26
1 files changed, 22 insertions, 4 deletions
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/FindDialog.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/FindDialog.java
index 6370be4..fe3f438 100644
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/FindDialog.java
+++ b/ddms/libs/ddmuilib/src/com/android/ddmuilib/FindDialog.java
@@ -44,14 +44,29 @@ public class FindDialog extends Dialog {
private final IFindTarget mTarget;
private Text mSearchText;
private String mPreviousSearchText;
+ private final int mDefaultButtonId;
- private final static int FIND_NEXT_ID = IDialogConstants.CLIENT_ID;
- private final static int FIND_PREVIOUS_ID = IDialogConstants.CLIENT_ID + 1;
+ /** Id of the "Find Next" button */
+ public static final int FIND_NEXT_ID = IDialogConstants.CLIENT_ID;
+
+ /** Id of the "Find Previous button */
+ public static final int FIND_PREVIOUS_ID = IDialogConstants.CLIENT_ID + 1;
public FindDialog(Shell shell, IFindTarget target) {
+ this(shell, target, FIND_PREVIOUS_ID);
+ }
+
+ /**
+ * Construct a find dialog.
+ * @param shell shell to use
+ * @param target delegate to be invoked on user action
+ * @param defaultButtonId one of {@code #FIND_NEXT_ID} or {@code #FIND_PREVIOUS_ID}.
+ */
+ public FindDialog(Shell shell, IFindTarget target, int defaultButtonId) {
super(shell);
mTarget = target;
+ mDefaultButtonId = defaultButtonId;
setShellStyle((getShellStyle() & ~SWT.APPLICATION_MODAL) | SWT.MODELESS);
setBlockOnOpen(true);
@@ -91,8 +106,11 @@ public class FindDialog extends Dialog {
@Override
protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, false);
- mFindNext = createButton(parent, FIND_NEXT_ID, "Find Next", false);
- mFindPrevious = createButton(parent, FIND_PREVIOUS_ID, "Find Previous", /* default */ true);
+
+ mFindNext = createButton(parent, FIND_NEXT_ID, "Find Next",
+ mDefaultButtonId == FIND_NEXT_ID);
+ mFindPrevious = createButton(parent, FIND_PREVIOUS_ID, "Find Previous",
+ mDefaultButtonId != FIND_NEXT_ID);
mFindNext.setEnabled(false);
mFindPrevious.setEnabled(false);
}