public void setSingleSelectionMode() { myTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); }
public MyDeviceChooser( boolean multipleSelection, @NotNull final Action okAction, @NotNull AndroidFacet facet, @NotNull IAndroidTarget projectTarget, @Nullable Condition<IDevice> filter) { myFacet = facet; myFilter = filter; myMinSdkVersion = AndroidModuleInfo.get(facet).getRuntimeMinSdkVersion(); myProjectTarget = projectTarget; if (new IsWatchFeatureRequiredCompat(facet).get()) { myRequiredHardwareFeatures = EnumSet.of(IDevice.HardwareFeature.WATCH); } else { myRequiredHardwareFeatures = EnumSet.noneOf(IDevice.HardwareFeature.class); } myDeviceTable = new JBTable(); myPanel = ScrollPaneFactory.createScrollPane(myDeviceTable); myPanel.setPreferredSize(new Dimension(450, 220)); myDeviceTable.setModel(new MyDeviceTableModel(EMPTY_DEVICE_ARRAY)); myDeviceTable.setSelectionMode( multipleSelection ? ListSelectionModel.MULTIPLE_INTERVAL_SELECTION : ListSelectionModel.SINGLE_SELECTION); myDeviceTable .getSelectionModel() .addListSelectionListener( new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (myProcessSelectionFlag) { hadUserInteraction = true; fireSelectedDevicesChanged(); } } }); new DoubleClickListener() { @Override protected boolean onDoubleClick(MouseEvent e) { if (myDeviceTable.isEnabled() && okAction.isEnabled()) { okAction.actionPerformed(null); return true; } return false; } }.installOn(myDeviceTable); myDeviceTable.setDefaultRenderer(LaunchCompatibility.class, new LaunchCompatibilityRenderer()); myDeviceTable.setDefaultRenderer( IDevice.class, new DeviceRenderer.DeviceNameRenderer(facet.getAvdManagerSilently())); myDeviceTable.addKeyListener( new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER && okAction.isEnabled()) { okAction.actionPerformed(null); } } }); setColumnWidth( myDeviceTable, DEVICE_NAME_COLUMN_INDEX, "Samsung Galaxy Nexus Android 4.1 (API 17)"); setColumnWidth(myDeviceTable, SERIAL_COLUMN_INDEX, "0000-0000-00000"); setColumnWidth(myDeviceTable, DEVICE_STATE_COLUMN_INDEX, "offline"); setColumnWidth(myDeviceTable, COMPATIBILITY_COLUMN_INDEX, "yes"); // Do not recreate columns on every model update - this should help maintain the column sizes // set above myDeviceTable.setAutoCreateColumnsFromModel(false); // Allow sorting by columns (in lexicographic order) myDeviceTable.setAutoCreateRowSorter(true); myRefreshingAlarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, this); myBridge = AndroidSdkUtils.getDebugBridge(myFacet.getModule().getProject()); }