diff options
author | Josiah Gaskin <josiahgaskin@google.com> | 2014-09-18 14:59:39 -0700 |
---|---|---|
committer | Josiah Gaskin <josiahgaskin@google.com> | 2014-09-22 16:23:37 -0700 |
commit | 8a994ff05399d337ca30662d6c5a142caefdc014 (patch) | |
tree | 3f1e91ce92c801c7d6f3a8bf33f96d7b7510de09 | |
parent | 0f28a57a3f72f5983ec54c20cb3396c6e8b10e57 (diff) | |
download | idea-8a994ff05399d337ca30662d6c5a142caefdc014.tar.gz |
Add device selection UI
This change adds selection UI for choosing from installed devices
Change-Id: I6e9a86daf3acaf4216b83fea224ad87934f9e736
-rw-r--r-- | android/src/com/android/tools/idea/avdmanager/ChooseDeviceDefinitionStep.form | 29 | ||||
-rw-r--r-- | android/src/com/android/tools/idea/avdmanager/ChooseDeviceDefinitionStep.java | 75 |
2 files changed, 104 insertions, 0 deletions
diff --git a/android/src/com/android/tools/idea/avdmanager/ChooseDeviceDefinitionStep.form b/android/src/com/android/tools/idea/avdmanager/ChooseDeviceDefinitionStep.form new file mode 100644 index 00000000000..4fe37666c14 --- /dev/null +++ b/android/src/com/android/tools/idea/avdmanager/ChooseDeviceDefinitionStep.form @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.android.tools.idea.avdmanager.ChooseDeviceDefinitionStep"> + <grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> + <margin top="0" left="0" bottom="0" right="0"/> + <constraints> + <xy x="20" y="20" width="626" height="400"/> + </constraints> + <properties/> + <border type="none"/> + <children> + <component id="8bc86" class="com.android.tools.idea.avdmanager.DeviceDefinitionList" binding="myDeviceDefinitionList"> + <constraints> + <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"> + <preferred-size width="-1" height="1"/> + </grid> + </constraints> + </component> + <component id="64669" class="com.android.tools.idea.avdmanager.DeviceDefinitionPreview" binding="myDeviceDefinitionPreview"> + <constraints> + <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="0" anchor="4" fill="2" indent="0" use-parent-layout="false"> + <preferred-size width="360" height="-1"/> + <maximum-size width="360" height="-1"/> + </grid> + </constraints> + <properties/> + </component> + </children> + </grid> +</form> diff --git a/android/src/com/android/tools/idea/avdmanager/ChooseDeviceDefinitionStep.java b/android/src/com/android/tools/idea/avdmanager/ChooseDeviceDefinitionStep.java new file mode 100644 index 00000000000..bfcf19b93cb --- /dev/null +++ b/android/src/com/android/tools/idea/avdmanager/ChooseDeviceDefinitionStep.java @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.tools.idea.avdmanager; + +import com.android.sdklib.devices.Device; +import com.android.tools.idea.wizard.DynamicWizardStepWithHeaderAndDescription; +import com.intellij.openapi.Disposable; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.swing.*; + +import static com.android.tools.idea.avdmanager.AvdWizardConstants.DEVICE_DEFINITION_KEY; + +/** + * Wizard step for selecting a device definition from the devices declared in the SDK and + * defined by the user. + */ +public class ChooseDeviceDefinitionStep extends DynamicWizardStepWithHeaderAndDescription { + private JPanel myPanel; + private DeviceDefinitionList myDeviceDefinitionList; + private DeviceDefinitionPreview myDeviceDefinitionPreview; + + public ChooseDeviceDefinitionStep(@Nullable Disposable parentDisposable) { + super("Select Hardware", "Choose a device definition", null, parentDisposable); + setBodyComponent(myPanel); + myDeviceDefinitionList.addSelectionListener(new DeviceDefinitionList.DeviceDefinitionSelectionListener() { + @Override + public void onDeviceSelectionChanged(@Nullable Device selectedDevice) { + myDeviceDefinitionPreview.setDevice(selectedDevice); + myState.put(DEVICE_DEFINITION_KEY, selectedDevice); + } + }); + } + + @Override + public void onEnterStep() { + super.onEnterStep(); + myDeviceDefinitionList.setSelectedDevice(myState.get(DEVICE_DEFINITION_KEY)); + } + + @Override + public boolean validate() { + return myState.get(DEVICE_DEFINITION_KEY) != null; + } + + @Override + public boolean isStepVisible() { + return myState.get(DEVICE_DEFINITION_KEY) == null; + } + + @Override + public JComponent getPreferredFocusedComponent() { + return null; + } + + @NotNull + @Override + public String getStepName() { + return AvdWizardConstants.CHOOSE_DEVICE_DEFINITION_STEP; + } +} |