use of javax.swing.event.ListSelectionEvent in project intellij-community by JetBrains.
the class MavenRepositoriesConfigurable method configControls.
private void configControls() {
myServiceList.setModel(myModel);
myServiceList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
myAddButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final String value = (String) myServiceList.getSelectedValue();
final String text = Messages.showInputDialog("Artifactory or Nexus Service URL", "Add Service URL", Messages.getQuestionIcon(), value == null ? "http://" : value, new URLInputVaslidator());
if (StringUtil.isNotEmpty(text)) {
myModel.add(text);
myServiceList.setSelectedValue(text, true);
}
}
});
myEditButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final int index = myServiceList.getSelectedIndex();
final String text = Messages.showInputDialog("Artifactory or Nexus Service URL", "Edit Service URL", Messages.getQuestionIcon(), myModel.getElementAt(index), new URLInputVaslidator());
if (StringUtil.isNotEmpty(text)) {
myModel.setElementAt(text, index);
}
}
});
ListUtil.addRemoveListener(myRemoveButton, myServiceList);
ListUtil.disableWhenNoSelection(myTestButton, myServiceList);
ListUtil.disableWhenNoSelection(myEditButton, myServiceList);
myTestButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final String value = (String) myServiceList.getSelectedValue();
if (value != null) {
testServiceConnection(value);
}
}
});
myUpdateButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
doUpdateIndex();
}
});
myIndicesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
updateButtonsState();
}
});
myIndicesTable.addMouseMotionListener(new MouseMotionListener() {
public void mouseDragged(MouseEvent e) {
}
public void mouseMoved(MouseEvent e) {
int row = myIndicesTable.rowAtPoint(e.getPoint());
if (row == -1)
return;
updateIndexHint(row);
}
});
myIndicesTable.setDefaultRenderer(Object.class, new MyCellRenderer());
myIndicesTable.setDefaultRenderer(MavenIndicesManager.IndexUpdatingState.class, new MyIconCellRenderer());
myServiceList.getEmptyText().setText("No services");
myIndicesTable.getEmptyText().setText("No remote repositories");
updateButtonsState();
}
use of javax.swing.event.ListSelectionEvent in project kotlin by JetBrains.
the class KotlinOverridingDialog method createCenterPanel.
@Override
protected JComponent createCenterPanel() {
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEmptyBorder(8, 0, 4, 0));
final MyTableModel tableModel = new MyTableModel();
myTable = new JBTable(tableModel);
myTable.setShowGrid(false);
TableColumnModel columnModel = myTable.getColumnModel();
int checkBoxWidth = new JCheckBox().getPreferredSize().width;
columnModel.getColumn(CHECK_COLUMN).setCellRenderer(new BooleanTableCellRenderer());
columnModel.getColumn(CHECK_COLUMN).setMaxWidth(checkBoxWidth);
columnModel.getColumn(CHECK_COLUMN).setMinWidth(checkBoxWidth);
// make SPACE check/uncheck selected rows
InputMap inputMap = myTable.getInputMap();
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "enable_disable");
ActionMap actionMap = myTable.getActionMap();
actionMap.put("enable_disable", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
if (myTable.isEditing())
return;
int[] rows = myTable.getSelectedRows();
if (rows.length > 0) {
boolean valueToBeSet = false;
for (int row : rows) {
if (!myChecked[row]) {
valueToBeSet = true;
break;
}
}
for (int row : rows) {
myChecked[row] = valueToBeSet;
}
tableModel.updateData();
}
}
});
panel.setLayout(new BorderLayout());
JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTable);
panel.add(scrollPane, BorderLayout.CENTER);
ListSelectionListener selectionListener = new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
int index = myTable.getSelectionModel().getLeadSelectionIndex();
if (index != -1) {
UsageInfo usageInfo = myOverridingMethods.get(index);
myUsagePreviewPanel.updateLayout(Collections.singletonList(usageInfo));
} else {
myUsagePreviewPanel.updateLayout(null);
}
}
};
myTable.getSelectionModel().addListSelectionListener(selectionListener);
final Splitter splitter = new Splitter(true, 0.3f);
splitter.setFirstComponent(panel);
splitter.setSecondComponent(myUsagePreviewPanel);
myUsagePreviewPanel.updateLayout(null);
Disposer.register(myDisposable, new Disposable() {
@Override
public void dispose() {
splitter.dispose();
}
});
if (tableModel.getRowCount() != 0) {
myTable.getSelectionModel().addSelectionInterval(0, 0);
}
return splitter;
}
use of javax.swing.event.ListSelectionEvent in project android by JetBrains.
the class ConfigureAvdOptionsStep method bindComponents.
private void bindComponents() {
myBindings.bindTwoWay(new TextProperty(myAvdDisplayName), getModel().avdDisplayName());
myBindings.bind(new TextProperty(myAvdId), new StringExpression(getModel().avdDisplayName()) {
@NotNull
@Override
public String get() {
String displayName = getModel().avdDisplayName().get();
getModel().avdId().set(StringUtil.isNotEmpty(displayName) ? AvdWizardUtils.cleanAvdName(connection, displayName, !displayName.equals(myOriginalName)) : "");
return getModel().avdId().get();
}
});
myBindings.bindTwoWay(new TextProperty(mySystemImageName), getModel().systemImageName());
myBindings.bindTwoWay(new TextProperty(mySystemImageDetails), getModel().systemImageDetails());
myBindings.bindTwoWay(new SelectedProperty(myQemu2CheckBox), getModel().useQemu2());
myBindings.bindTwoWay(new SelectedItemProperty<Integer>(myCoreCount), getModel().cpuCoreCount());
myBindings.bindTwoWay(myRamStorage.storage(), getModel().getAvdDeviceData().ramStorage());
myBindings.bindTwoWay(myVmHeapStorage.storage(), getModel().vmHeapStorage());
myBindings.bindTwoWay(myInternalStorage.storage(), getModel().internalStorage());
myBindings.bindTwoWay(myBuiltInSdCardStorage.storage(), new OptionalToValuePropertyAdapter<Storage>(getModel().sdCardStorage()));
myBindings.bindTwoWay(new SelectedItemProperty<GpuMode>(myHostGraphics), getModel().hostGpuMode());
myBindings.bindTwoWay(new SelectedProperty(myDeviceFrameCheckbox), getModel().hasDeviceFrame());
myBindings.bindTwoWay(new SelectedItemProperty<File>(mySkinComboBox.getComboBox()), getModel().getAvdDeviceData().customSkinFile());
myOrientationToggle.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
ScreenOrientation orientation = myOrientationToggle.getSelectedElement();
if (orientation == null) {
getModel().selectedAvdOrientation().set(ScreenOrientation.PORTRAIT);
} else {
getModel().selectedAvdOrientation().set(orientation);
}
}
});
FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false) {
@Override
public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
return super.isFileVisible(file, true);
}
};
fileChooserDescriptor.setHideIgnored(false);
myExternalSdCard.addBrowseFolderListener("Select SD Card", "Select an existing SD card image", myProject, fileChooserDescriptor);
myBindings.bindTwoWay(new TextProperty(myExternalSdCard.getTextField()), getModel().externalSdCardLocation());
myBindings.bindTwoWay(new OptionalToValuePropertyAdapter<AvdCamera>(new SelectedItemProperty<AvdCamera>(myFrontCameraCombo)), getModel().selectedFrontCamera());
myBindings.bindTwoWay(new OptionalToValuePropertyAdapter<AvdCamera>(new SelectedItemProperty<AvdCamera>(myBackCameraCombo)), getModel().selectedBackCamera());
myBindings.bindTwoWay(new OptionalToValuePropertyAdapter<AvdNetworkSpeed>(new SelectedItemProperty<AvdNetworkSpeed>(mySpeedCombo)), getModel().selectedNetworkSpeed());
myBindings.bindTwoWay(new OptionalToValuePropertyAdapter<AvdNetworkLatency>(new SelectedItemProperty<AvdNetworkLatency>(myLatencyCombo)), getModel().selectedNetworkLatency());
myBindings.bindTwoWay(new SelectedProperty(myEnableComputerKeyboard), getModel().enableHardwareKeyboard());
myBindings.bindTwoWay(new SelectedProperty(myExternalRadioButton), getModel().useExternalSdCard());
myBindings.bindTwoWay(new SelectedProperty(myBuiltInRadioButton), getModel().useBuiltInSdCard());
myCheckSdForChanges = true;
}
use of javax.swing.event.ListSelectionEvent in project intellij-plugins by JetBrains.
the class CPUSnapshotView method createHotSpotsTreeTable.
private void createHotSpotsTreeTable() {
myHotSpotsTreeTable = new CallTreeTable(getProject());
myHotSpotsTreeTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
final Object node = myHotSpotsTreeTable.getSelectedValue();
if (!(node instanceof MergedCallNode))
return;
myAlarm.cancelAllRequests();
final MergedCallNode mergedCallNode = (MergedCallNode) node;
myAlarm.addRequest(() -> {
FrameInfo[] frames = new FrameInfo[] { mergedCallNode.getFrameInfo() };
final Pair<Map<FrameInfo, Long>, Map<FrameInfo, Long>> countMaps = mergedCallNode.getCallTree().getCalleesTimeMaps(frames);
final Map<FrameInfo, Long> countMap = countMaps.getFirst();
final Map<FrameInfo, Long> selfCountMap = countMaps.getSecond();
DefaultMutableTreeNode tracesRoot = (DefaultMutableTreeNode) myTracesTreeTable.getSortableTreeTableModel().getRoot();
JTreeUtil.removeChildren(tracesRoot, myTracesTreeTable.getSortableTreeTableModel());
fillTreeModelRoot(tracesRoot, mergedCallNode.getCallTree(), countMap, selfCountMap, false, frames);
myTracesTreeTable.reload();
TreeUtil.expand(myTracesTreeTable.getTree(), 1);
}, 500);
}
});
}
use of javax.swing.event.ListSelectionEvent in project JMRI by JMRI.
the class RowComboBoxPanel method getTableCellEditorComponent.
/**
* Create the editor component for the cell and add a listener for changes in the table.
*
* @param table parent JTable of NamedBean
* @param value current value for cell to be rendered.
* @param isSelected tells if this row is selected in the table.
* @param row the row in table.
* @param col the column in table, in this case Value (Aspect or Appearance).
* @return A JPanel containing a JComboBox with valid options as the CellEditor for the Value.
*/
@Override
public final Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int col) {
//add a listener to the table
if (!this.tableListenerAdded) {
this.tableListenerAdded = true;
this.table = table;
this.table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public final void valueChanged(ListSelectionEvent evt) {
eventTableSelectionChanged();
}
});
}
this.currentRow = row;
updateData(row, true, table);
return getEditorComponent(table, value, isSelected, row, col);
}
Aggregations