private JComponent getLibrariesTable() { myLibraryTableModel = new LibraryTableModel(); final JBTable librariesTable = new JBTable(myLibraryTableModel); librariesTable.setTableHeader(null); librariesTable.setDefaultRenderer(String.class, new MyPathRenderer()); librariesTable.setShowHorizontalLines(false); librariesTable.setShowVerticalLines(false); librariesTable.setAutoCreateRowSorter(false); librariesTable.setAutoscrolls(true); ToolbarDecorator decorator = ToolbarDecorator.createDecorator(librariesTable); decorator .setAddAction( new AnActionButtonRunnable() { @Override public void run(AnActionButton anActionButton) { List<ModelRootDescriptor> modelRoots = new ArrayList<ModelRootDescriptor>( myJavaModuleFacet .getModule() .getModuleDescriptor() .getModelRootDescriptors()); StubRootChooser stubRootChooser = new StubRootChooser( modelRoots, (myJavaModuleFacet.getModule() instanceof Language ? true : false)); myLibraryTableModel.addAll(stubRootChooser.compute()); } }) .setRemoveAction( new AnActionButtonRunnable() { @Override public void run(AnActionButton anActionButton) { TableUtil.removeSelectedItems(librariesTable); myLibraryTableModel.fireTableDataChanged(); } }); decorator.setToolbarBorder(IdeBorderFactory.createBorder()); decorator.setPreferredSize(new Dimension(500, 100)); JPanel table = decorator.createPanel(); table.setBorder( IdeBorderFactory.createTitledBorder( PropertiesBundle.message("mps.properties.configurable.module.javatab.librariesborder"), false)); return table; }
private JComponent getSourcePathsTable() { myPathsTableModel = new PathsTableModel(); final JBTable sourcePathTable = new JBTable(myPathsTableModel); sourcePathTable.setTableHeader(null); sourcePathTable.setDefaultRenderer(String.class, new MyPathRenderer()); sourcePathTable.setShowHorizontalLines(false); sourcePathTable.setShowVerticalLines(false); sourcePathTable.setAutoCreateRowSorter(false); sourcePathTable.setAutoscrolls(true); ToolbarDecorator decorator = ToolbarDecorator.createDecorator(sourcePathTable); decorator .setAddAction( new AnActionButtonRunnable() { @Override public void run(AnActionButton anActionButton) { myPathsTableModel.add((new PathChooser()).compute()); } }) .setRemoveAction( new AnActionButtonRunnable() { @Override public void run(AnActionButton anActionButton) { TableUtil.removeSelectedItems(sourcePathTable); myPathsTableModel.fireTableDataChanged(); } }); decorator.setToolbarBorder(IdeBorderFactory.createBorder()); decorator.setPreferredSize(new Dimension(500, 100)); JPanel table = decorator.createPanel(); table.setBorder( IdeBorderFactory.createTitledBorder( PropertiesBundle.message("mps.properties.configurable.module.javatab.sourcepathborder"), false)); return table; }
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()); }