diff options
author | Siva Velusamy <vsiva@google.com> | 2012-06-12 09:25:30 -0700 |
---|---|---|
committer | android code review <noreply-gerritcodereview@google.com> | 2012-06-12 09:25:30 -0700 |
commit | ef4c41f342af19f9199f6e46168401f3398c23f7 (patch) | |
tree | 52747bad48250dfd56a9b15561d60716facdbd11 /eclipse/plugins/com.android.ide.eclipse.gldebugger | |
parent | 2c407fd37c0dac821de7015a43a6f39f30ec4315 (diff) | |
parent | 0f48e99ef075a45d655cff2a6a2113fd75d76b41 (diff) | |
download | sdk-ef4c41f342af19f9199f6e46168401f3398c23f7.zip sdk-ef4c41f342af19f9199f6e46168401f3398c23f7.tar.gz sdk-ef4c41f342af19f9199f6e46168401f3398c23f7.tar.bz2 |
Merge "Minor UI cleanup to trace options dialog"
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.gldebugger')
-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() { |