use of com.android.sdklib.repository.IdDisplay in project android by JetBrains.
the class AvdComboBox method doUpdateAvds.
private void doUpdateAvds() {
final Module module = getModule();
if (module == null || module.isDisposed()) {
return;
}
final AndroidFacet facet = AndroidFacet.getInstance(module);
final IdDisplay[] newAvds;
if (facet != null) {
final Set<String> filteringSet = new HashSet<String>();
if (myShowNotLaunchedOnly) {
final AndroidDebugBridge debugBridge = AndroidSdkUtils.getDebugBridge(facet.getModule().getProject());
if (debugBridge != null) {
for (IDevice device : debugBridge.getDevices()) {
final String avdName = device.getAvdName();
if (avdName != null && avdName.length() > 0) {
filteringSet.add(avdName);
}
}
}
}
final List<IdDisplay> newAvdList = new ArrayList<IdDisplay>();
if (myAddEmptyElement) {
newAvdList.add(IdDisplay.create("", ""));
}
for (AvdInfo avd : facet.getAllAvds()) {
String displayName = avd.getProperties().get(AvdManager.AVD_INI_DISPLAY_NAME);
final String avdName = displayName == null || displayName.isEmpty() ? avd.getName() : displayName;
if (!filteringSet.contains(avdName)) {
newAvdList.add(IdDisplay.create(avd.getName(), avdName));
}
}
newAvds = ArrayUtil.toObjectArray(newAvdList, IdDisplay.class);
} else {
newAvds = new IdDisplay[0];
}
if (!Arrays.equals(myOldAvds, newAvds)) {
myOldAvds = newAvds;
final Object selected = getComboBox().getSelectedItem();
getComboBox().setModel(new DefaultComboBoxModel(newAvds));
getComboBox().setSelectedItem(selected);
}
}
use of com.android.sdklib.repository.IdDisplay in project android by JetBrains.
the class EmulatorTargetConfigurable method createUIComponents.
private void createUIComponents() {
myAvdCombo = new AvdComboBox(myProject, true, false) {
@Override
public Module getModule() {
return myContext.getModule();
}
};
myAvdCombo.startUpdatingAvds(ModalityState.current());
JComboBox avdComboBox = myAvdCombo.getComboBox();
avdComboBox.setRenderer(new ListCellRendererWrapper() {
@Override
public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
if (value instanceof IdDisplay) {
setText(((IdDisplay) value).getDisplay());
} else {
setText(String.format("<html><font color='red'>Unknown AVD %1$s</font></html>", value == null ? "" : value.toString()));
}
}
});
avdComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
resetAvdCompatibilityWarningLabel();
}
});
myAvdComboWithButton = new ComboboxWithBrowseButton(avdComboBox);
Disposer.register(myParentDisposable, myAvdCombo);
}
use of com.android.sdklib.repository.IdDisplay in project android by JetBrains.
the class ConfigureDeviceModel method buildDevice.
/**
* Once we finish editing the device, we set it to its final configuration
*/
@NotNull
private Device buildDevice() {
String deviceName = myDeviceData.name().get();
myBuilder.setName(deviceName);
myBuilder.setId(deviceName);
myBuilder.addSoftware(myDeviceData.software().getValue());
myBuilder.setManufacturer(myDeviceData.manufacturer().get());
IdDisplay tag = myDeviceData.deviceType().getValueOrNull();
myBuilder.setTagId((SystemImage.DEFAULT_TAG.equals(tag) || tag == null) ? null : tag.getId());
List<State> states = generateStates(new AvdHardwareData(myDeviceData).buildHardware());
myBuilder.addAllState(states);
return myBuilder.build();
}
use of com.android.sdklib.repository.IdDisplay in project android by JetBrains.
the class ConfigureDeviceOptionsStep method attachBindingsAndValidators.
private void attachBindingsAndValidators() {
final AvdDeviceData deviceModel = getModel().getDeviceData();
myBindings.bindTwoWay(new TextProperty(myDeviceName), deviceModel.name());
myBindings.bind(deviceModel.diagonalScreenSize(), myDiagScreenSizeAdapter);
myBindings.bind(deviceModel.screenResolutionWidth(), myScreenResWidthAdapter);
myBindings.bind(deviceModel.screenResolutionHeight(), myScreenResHeightAdapter);
myBindings.bindTwoWay(myRamField.storage(), deviceModel.ramStorage());
myBindings.bindTwoWay(new SelectedProperty(myHasHardwareButtons), deviceModel.hasHardwareButtons());
myBindings.bindTwoWay(new SelectedProperty(myHasHardwareKeyboard), deviceModel.hasHardwareKeyboard());
myBindings.bindTwoWay(new SelectedItemProperty<>(myNavigationControlsCombo), deviceModel.navigation());
myBindings.bindTwoWay(new SelectedProperty(myIsScreenRound), deviceModel.isScreenRound());
myBindings.bindTwoWay(new SelectedProperty(mySupportsLandscape), deviceModel.supportsLandscape());
myBindings.bindTwoWay(new SelectedProperty(mySupportsPortrait), deviceModel.supportsPortrait());
myBindings.bindTwoWay(new SelectedProperty(myHasBackFacingCamera), deviceModel.hasBackCamera());
myBindings.bindTwoWay(new SelectedProperty(myHasFrontFacingCamera), deviceModel.hasFrontCamera());
myBindings.bindTwoWay(new SelectedProperty(myHasAccelerometer), deviceModel.hasAccelerometer());
myBindings.bindTwoWay(new SelectedProperty(myHasGyroscope), deviceModel.hasGyroscope());
myBindings.bindTwoWay(new SelectedProperty(myHasGps), deviceModel.hasGps());
myBindings.bindTwoWay(new SelectedProperty(myHasProximitySensor), deviceModel.hasProximitySensor());
myBindings.bindTwoWay(new SelectedItemProperty<>(myCustomSkinPath.getComboBox()), deviceModel.customSkinFile());
SelectedItemProperty<IdDisplay> selectedDeviceType = new SelectedItemProperty<>(myDeviceTypeComboBox);
myBindings.bindTwoWay(selectedDeviceType, deviceModel.deviceType());
myListeners.receive(selectedDeviceType, idDisplayOptional -> {
if (idDisplayOptional.isPresent()) {
IdDisplay selectedType = idDisplayOptional.get();
getModel().getDeviceData().isWear().set(selectedType.equals(SystemImage.WEAR_TAG));
getModel().getDeviceData().isTv().set(selectedType.equals(SystemImage.TV_TAG));
myIsScreenRound.setEnabled(selectedType.equals(SystemImage.WEAR_TAG));
myIsScreenRound.setSelected(getModel().getDeviceData().isScreenRound().get());
}
});
myValidatorPanel.registerValidator(deviceModel.name().isEmpty().not(), "Please write a name for the new device.");
myValidatorPanel.registerValidator(myDiagScreenSizeAdapter.inSync().and(deviceModel.diagonalScreenSize().isEqualTo(myDiagScreenSizeAdapter)), "Please enter a non-zero positive floating point value for the screen size.");
myValidatorPanel.registerValidator(myScreenResWidthAdapter.inSync().and(deviceModel.screenResolutionWidth().isEqualTo(myScreenResWidthAdapter)), "Please enter a valid value for the screen width.");
myValidatorPanel.registerValidator(myScreenResHeightAdapter.inSync().and(deviceModel.screenResolutionHeight().isEqualTo(myScreenResHeightAdapter)), "Please enter a valid value for the screen height.");
myValidatorPanel.registerValidator(deviceModel.ramStorage(), value -> (value.getSize() > 0) ? Result.OK : new Result(Validator.Severity.ERROR, "Please specify a non-zero amount of RAM."));
myValidatorPanel.registerValidator(deviceModel.screenDpi().isGreaterThan(0), "The given resolution and screen size specified have a DPI that is too low.");
myValidatorPanel.registerValidator(deviceModel.supportsLandscape().or(deviceModel.supportsPortrait()), "A device must support at least one orientation (Portrait or Landscape).");
myValidatorPanel.registerValidator(deviceModel.customSkinFile(), value -> {
File skinPath = value.orElse(null);
if (skinPath != null && !FileUtil.filesEqual(skinPath, AvdWizardUtils.NO_SKIN) && !skinPath.getPath().equals(skinPath.getName())) {
File layoutFile = new File(skinPath, SdkConstants.FN_SKIN_LAYOUT);
if (!layoutFile.isFile()) {
return new Result(Validator.Severity.ERROR, "The skin directory does not point to a valid skin.");
}
}
return Result.OK;
});
myValidatorPanel.registerValidator(getModel().getDeviceData().compatibleSkinSize(), Validator.Severity.WARNING, "The selected skin is not large enough to view the entire screen.");
}
use of com.android.sdklib.repository.IdDisplay in project android by JetBrains.
the class ConfigureDeviceOptionsStep method onWizardStarting.
@Override
protected void onWizardStarting(@NotNull ModelWizard.Facade wizard) {
myDeviceTypeComboBox.setModel(new CollectionComboBoxModel<>(AvdWizardUtils.ALL_DEVICE_TAGS));
myDeviceTypeComboBox.setRenderer(new ListCellRendererWrapper<IdDisplay>() {
@Override
public void customize(JList list, IdDisplay value, int index, boolean selected, boolean hasFocus) {
if (value == null || SystemImage.DEFAULT_TAG.equals(value)) {
setText(DEFAULT_DEVICE_TYPE_LABEL);
} else {
setText(value.getDisplay());
}
}
});
myScrollPane.getVerticalScrollBar().setUnitIncrement(10);
myHelpAndErrorLabel.setBackground(JBColor.background());
myHelpAndErrorLabel.setForeground(JBColor.foreground());
myHelpAndErrorLabel.setBorder(BorderFactory.createEmptyBorder(15, 15, 10, 10));
myDiagScreenSizeAdapter = new StringToDoubleAdapterProperty(new TextProperty(myDiagonalScreenSize), 1, 2);
myScreenResWidthAdapter = new StringToIntAdapterProperty(new TextProperty(myScreenResolutionWidth));
myScreenResHeightAdapter = new StringToIntAdapterProperty(new TextProperty(myScreenResolutionHeight));
attachBindingsAndValidators();
}
Aggregations