diff options
author | Siva Velusamy <vsiva@google.com> | 2012-06-12 09:04:27 -0700 |
---|---|---|
committer | Siva Velusamy <vsiva@google.com> | 2012-06-12 09:22:07 -0700 |
commit | 0f48e99ef075a45d655cff2a6a2113fd75d76b41 (patch) | |
tree | 91c757ed9ccef7f0eccaa43d328bd7b3477acf9d | |
parent | d0fdcfdfac4b2ec4898df933aa90541d79420519 (diff) | |
download | sdk-0f48e99ef075a45d655cff2a6a2113fd75d76b41.zip sdk-0f48e99ef075a45d655cff2a6a2113fd75d76b41.tar.gz sdk-0f48e99ef075a45d655cff2a6a2113fd75d76b41.tar.bz2 |
Minor UI cleanup to trace options dialog
- Fix default message shown for activity
- Make trace file path text editable
- Save/Restore last used device
Change-Id: I762a054e16c8ac5418375a5ac2086add7f631e45
-rw-r--r-- | eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/GLTraceOptionsDialog.java | 48 |
1 files changed, 39 insertions, 9 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/GLTraceOptionsDialog.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/GLTraceOptionsDialog.java index ac752e7..4023061 100644 --- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/GLTraceOptionsDialog.java +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/GLTraceOptionsDialog.java @@ -43,6 +43,7 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.osgi.service.prefs.BackingStoreException; +import java.io.File; import java.util.ArrayList; import java.util.List; @@ -51,10 +52,12 @@ public class GLTraceOptionsDialog extends TitleAreaDialog { private static final String TITLE = "OpenGL ES Trace Options"; private static final String DEFAULT_MESSAGE = "Provide the application and activity to be traced."; - private static final String PREF_APPNAME = "gl.trace.appname"; - private static final String PREF_TRACEFILE = "gl.trace.destfile"; + private static final String PREF_APPNAME = "gl.trace.appname"; //$NON-NLS-1$ + private static final String PREF_TRACEFILE = "gl.trace.destfile"; //$NON-NLS-1$ + private static final String PREF_DEVICE = "gl.trace.device"; //$NON-NLS-1$ + private String mLastUsedDevice; - private static String sSaveToFolder = System.getProperty("user.home");; + private static String sSaveToFolder = System.getProperty("user.home"); //$NON-NLS-1$ private Button mOkButton; @@ -69,6 +72,7 @@ public class GLTraceOptionsDialog extends TitleAreaDialog { private boolean mCollectFbOnEglSwap = true; private boolean mCollectFbOnGlDraw = false; private boolean mCollectTextureData = false; + private IDevice[] mDevices; public GLTraceOptionsDialog(Shell parentShell) { super(parentShell); @@ -86,10 +90,11 @@ public class GLTraceOptionsDialog extends TitleAreaDialog { c.setLayoutData(new GridData(GridData.FILL_BOTH)); createLabel(c, "Device:"); - createDeviceDropdown(c, AndroidDebugBridge.getBridge().getDevices()); + mDevices = AndroidDebugBridge.getBridge().getDevices(); + createDeviceDropdown(c, mDevices); createLabel(c, "Activity:"); - createAppToTraceText(c, "e.g. com.example.android.apis"); + createAppToTraceText(c, "e.g. com.example.package/.ActivityName"); createLabel(c, "Capture Image:"); createCaptureImageOptions(c); @@ -126,9 +131,14 @@ public class GLTraceOptionsDialog extends TitleAreaDialog { c.setLayoutData(new GridData(GridData.FILL_BOTH)); mTraceFilePathText = new Text(c, SWT.BORDER); - mTraceFilePathText.setEditable(false); mTraceFilePathText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); mTraceFilePathText.setText(mTraceFilePath); + mTraceFilePathText.addModifyListener(new ModifyListener() { + @Override + public void modifyText(ModifyEvent e) { + validateAndSetMessage(); + } + }); Button browse = new Button(c, SWT.PUSH); browse.setText("Browse..."); @@ -230,8 +240,15 @@ public class GLTraceOptionsDialog extends TitleAreaDialog { } items.add(name); } - mDeviceCombo.setItems(items.toArray(new String[0])); - mDeviceCombo.select(0); + mDeviceCombo.setItems(items.toArray(new String[items.size()])); + + int index = 0; + if (mLastUsedDevice != null) { + index = items.indexOf(mLastUsedDevice); + } + if (index >= 0 && index < items.size()) { + mDeviceCombo.select(index); + } return mDeviceCombo; } @@ -260,14 +277,25 @@ public class GLTraceOptionsDialog extends TitleAreaDialog { } private DialogStatus validateDialog() { + if (mDevices.length == 0) { + return new DialogStatus(false, "No connected devices."); + } + if (mActivityToTraceText.getText().trim().length() == 0) { return new DialogStatus(false, "Provide an application name"); } - if (mTraceFilePathText.getText().trim().length() == 0) { + String traceFile = mTraceFilePathText.getText().trim(); + if (traceFile.isEmpty()) { return new DialogStatus(false, "Specify the location where the trace will be saved."); } + File f = new File(traceFile).getParentFile(); + if (f != null && !f.exists()) { + return new DialogStatus(false, + String.format("Folder %s does not exist", f.getAbsolutePath())); + } + return new DialogStatus(true, null); } @@ -286,6 +314,7 @@ public class GLTraceOptionsDialog extends TitleAreaDialog { IEclipsePreferences prefs = new InstanceScope().getNode(GlTracePlugin.PLUGIN_ID); prefs.put(PREF_APPNAME, mActivityToTrace); prefs.put(PREF_TRACEFILE, mTraceFilePath); + prefs.put(PREF_DEVICE, mSelectedDevice); try { prefs.flush(); } catch (BackingStoreException e) { @@ -297,6 +326,7 @@ public class GLTraceOptionsDialog extends TitleAreaDialog { IEclipsePreferences prefs = new InstanceScope().getNode(GlTracePlugin.PLUGIN_ID); mActivityToTrace = prefs.get(PREF_APPNAME, ""); mTraceFilePath = prefs.get(PREF_TRACEFILE, ""); + mLastUsedDevice = prefs.get(PREF_DEVICE, ""); } public TraceOptions getTraceOptions() { |