Add right-click select to simulation panel
This commit is contained in:
		
							parent
							
								
									749047a791
								
							
						
					
					
						commit
						fd4c647b36
					
				| @ -464,9 +464,6 @@ public class SimulationPanel extends JPanel { | |||||||
| 			@Override | 			@Override | ||||||
| 			public void mouseClicked(MouseEvent e) { | 			public void mouseClicked(MouseEvent e) { | ||||||
| 				int selectedRow = simulationTable.getSelectedRow(); | 				int selectedRow = simulationTable.getSelectedRow(); | ||||||
| 				if (selectedRow < 0) { |  | ||||||
| 					return; |  | ||||||
| 				} |  | ||||||
| 
 | 
 | ||||||
| 				if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) { | 				if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) { | ||||||
| 					int selected = simulationTable.convertRowIndexToModel(selectedRow); | 					int selected = simulationTable.convertRowIndexToModel(selectedRow); | ||||||
| @ -475,13 +472,24 @@ public class SimulationPanel extends JPanel { | |||||||
| 					if (column == 0) { | 					if (column == 0) { | ||||||
| 						SimulationWarningDialog.showWarningDialog(SimulationPanel.this, document.getSimulations().get(selected)); | 						SimulationWarningDialog.showWarningDialog(SimulationPanel.this, document.getSimulations().get(selected)); | ||||||
| 					} else { | 					} else { | ||||||
| 
 |  | ||||||
| 						simulationTable.clearSelection(); | 						simulationTable.clearSelection(); | ||||||
| 						simulationTable.addRowSelectionInterval(selectedRow, selectedRow); | 						simulationTable.addRowSelectionInterval(selectedRow, selectedRow); | ||||||
| 
 | 
 | ||||||
| 						openDialog(document.getSimulations().get(selected)); | 						openDialog(document.getSimulations().get(selected)); | ||||||
| 					} | 					} | ||||||
| 				} else if (e.getButton() == MouseEvent.BUTTON3 && e.getClickCount() == 1) { | 				} else if (e.getButton() == MouseEvent.BUTTON3 && e.getClickCount() == 1) { | ||||||
|  | 					// Get the row that the right-click action happened on | ||||||
|  | 					int r = simulationTable.rowAtPoint(e.getPoint()); | ||||||
|  | 
 | ||||||
|  | 					// Select new row | ||||||
|  | 					if (!simulationTable.isRowSelected(r)) { | ||||||
|  | 						if (r >= 0 && r < simulationTable.getRowCount()) { | ||||||
|  | 							simulationTable.setRowSelectionInterval(r, r); | ||||||
|  | 						} else { | ||||||
|  | 							return; | ||||||
|  | 						} | ||||||
|  | 					} | ||||||
|  | 
 | ||||||
|                     doPopup(e); |                     doPopup(e); | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user