diff options
| -rw-r--r-- | altosui/AltosEepromDelete.java | 2 | ||||
| -rw-r--r-- | altosui/AltosEepromDownload.java | 2 | ||||
| -rw-r--r-- | altosui/AltosEepromLog.java | 8 | ||||
| -rw-r--r-- | altosui/AltosEepromManage.java | 72 | ||||
| -rw-r--r-- | altosui/AltosEepromSelect.java | 45 | 
5 files changed, 52 insertions, 77 deletions
| diff --git a/altosui/AltosEepromDelete.java b/altosui/AltosEepromDelete.java index a9d77788..fcce8155 100644 --- a/altosui/AltosEepromDelete.java +++ b/altosui/AltosEepromDelete.java @@ -90,7 +90,7 @@ public class AltosEepromDelete implements Runnable {  				serial_line.start_remote();  			for (AltosEepromLog log : flights) { -				if (log.delete) { +				if (log.selected) {  					DeleteLog(log);  				}  			} diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index e7e52466..40c98bfd 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -351,7 +351,7 @@ public class AltosEepromDownload implements Runnable {  			for (AltosEepromLog log : flights) {  				parse_exception = null; -				if (log.download) { +				if (log.selected) {  					monitor.reset();  					CaptureLog(log);  				} diff --git a/altosui/AltosEepromLog.java b/altosui/AltosEepromLog.java index ee77e5c8..475d7f12 100644 --- a/altosui/AltosEepromLog.java +++ b/altosui/AltosEepromLog.java @@ -43,8 +43,7 @@ public class AltosEepromLog {  	int		year, month, day; -	boolean		download; -	boolean		delete; +	boolean		selected;  	public AltosEepromLog(AltosConfigData config_data,  			      AltosSerial serial_line, @@ -63,10 +62,9 @@ public class AltosEepromLog {  		serial = config_data.serial;  		/* -		 * By default, request that every log be downloaded but not deleted +		 * Select all flights for download  		 */ -		download = true; -		delete = false; +		selected = true;  		/*  		 * Look in TeleMetrum log data for date diff --git a/altosui/AltosEepromManage.java b/altosui/AltosEepromManage.java index 083c7372..1e06f4ca 100644 --- a/altosui/AltosEepromManage.java +++ b/altosui/AltosEepromManage.java @@ -39,8 +39,6 @@ public class AltosEepromManage implements ActionListener {  	AltosEepromList		flights;  	AltosEepromDownload	download;  	AltosEepromDelete	delete; -	boolean			any_download; -	boolean			any_delete;  	public void finish() {  		if (serial_line != null) { @@ -57,7 +55,7 @@ public class AltosEepromManage implements ActionListener {  		String	result = "";  		for (AltosEepromLog flight : flights) { -			if (flight.delete) { +			if (flight.selected) {  				if (result.equals(""))  					result = String.format("%d", flight.flight);  				else @@ -67,18 +65,38 @@ public class AltosEepromManage implements ActionListener {  		return result;  	} +	public boolean download_done() { +		AltosEepromSelect	select = new AltosEepromSelect(frame, flights, "Delete"); + +		if (select.run()) { +			boolean any_selected = false; +			for (AltosEepromLog flight : flights) +				any_selected = any_selected || flight.selected; +			if (any_selected) { +				delete = new AltosEepromDelete(frame, +							       serial_line, +							       remote, +							       flights); +				delete.addActionListener(this); +				/* +				 * Start flight log delete +				 */ + +				delete.start(); +				return true; +			} +		} +		return false; +	} +  	public void actionPerformed(ActionEvent e) {  		String	cmd = e.getActionCommand();  		boolean	success = e.getID() != 0;  		boolean running = false;  		if (cmd.equals("download")) { -			if (success) { -				if (any_delete) { -					delete.start(); -					running = true; -				} -			} +			if (success) +				running = download_done();  		} else if (cmd.equals("delete")) {  			if (success) {  				JOptionPane.showMessageDialog(frame, @@ -104,40 +122,26 @@ public class AltosEepromManage implements ActionListener {  							      serial_line.device.toShortString(),  							      JOptionPane.INFORMATION_MESSAGE);  			} else { -				AltosEepromSelect	select = new AltosEepromSelect(frame, flights); +				AltosEepromSelect	select = new AltosEepromSelect(frame, flights, "Download");  				if (select.run()) { -					for (AltosEepromLog flight : flights) { -						any_download = any_download || flight.download; -						any_delete = any_delete || flight.delete; -					} -					if (any_download) { +					boolean any_selected = false; +					for (AltosEepromLog flight : flights) +						any_selected = any_selected || flight.selected; +					if (any_selected) {  						download = new AltosEepromDownload(frame,  										   serial_line,  										   remote,  										   flights);  						download.addActionListener(this); -					} - -					if (any_delete) { -						delete = new AltosEepromDelete(frame, -									       serial_line, -									       remote, -									       flights); -						delete.addActionListener(this); -					} +						/* +						 * Start flight log download +						 */ -					/* -					 * Start flight log download -					 */ - -					if (any_download) {  						download.start();  						running = true; -					} -					else if (any_delete) { -						delete.start(); -						running = true; +					} else { +						running = download_done();  					}  				}  			} @@ -203,8 +207,6 @@ public class AltosEepromManage implements ActionListener {  		device = AltosDeviceDialog.show(frame, Altos.product_any);  		remote = false; -		any_download = false; -		any_delete = false;  		if (device != null) {  			try { diff --git a/altosui/AltosEepromSelect.java b/altosui/AltosEepromSelect.java index ebafc4c8..e0fbeead 100644 --- a/altosui/AltosEepromSelect.java +++ b/altosui/AltosEepromSelect.java @@ -31,15 +31,11 @@ import libaltosJNI.SWIGTYPE_p_altos_list;  class AltosEepromItem implements ActionListener {  	AltosEepromLog	log;  	JLabel		label; -	JCheckBox	download; +	JCheckBox	action;  	JCheckBox	delete;  	public void actionPerformed(ActionEvent e) { -		if (e.getSource() == download) { -			log.download = download.isSelected(); -		} else if (e.getSource() == delete) { -			log.delete = delete.isSelected(); -		} +		log.selected = action.isSelected();  	}  	public AltosEepromItem(AltosEepromLog in_log) { @@ -54,11 +50,8 @@ class AltosEepromItem implements ActionListener {  		label = new JLabel(text); -		download = new JCheckBox("", log.download); -		download.addActionListener(this); - -		delete = new JCheckBox("", log.delete); -		delete.addActionListener(this); +		action = new JCheckBox("", log.selected); +		action.addActionListener(this);  	}  } @@ -86,7 +79,8 @@ public class AltosEepromSelect extends AltosDialog implements ActionListener {  	}  	public AltosEepromSelect (JFrame in_frame, -				  AltosEepromList flights) { +				  AltosEepromList flights, +				  String action) {  		super(in_frame, String.format("Flight list for serial %d", flights.config_data.serial), true);  		frame = in_frame; @@ -95,7 +89,7 @@ public class AltosEepromSelect extends AltosDialog implements ActionListener {  		Container contentPane = getContentPane();  		/* First, we create a pane containing the dialog's header/title */ -		JLabel	selectLabel = new JLabel("Select flights to download and/or delete", SwingConstants.CENTER); +		JLabel	selectLabel = new JLabel(String.format ("Select flights to %s", action), SwingConstants.CENTER);  		JPanel	labelPane = new JPanel();  		labelPane.setLayout(new BoxLayout(labelPane, BoxLayout.X_AXIS)); @@ -132,19 +126,9 @@ public class AltosEepromSelect extends AltosDialog implements ActionListener {  		c.weightx = 0.5;  		c.anchor = GridBagConstraints.CENTER;  		c.insets = i; -		JLabel downloadHeaderLabel = new JLabel("Download"); +		JLabel downloadHeaderLabel = new JLabel(action);  		flightPane.add(downloadHeaderLabel, c); -		/* Delete Header */ -		c = new GridBagConstraints(); -		c.gridx = 2; c.gridy = 0; -		c.fill = GridBagConstraints.NONE; -		c.weightx = 0.5; -		c.anchor = GridBagConstraints.CENTER; -		c.insets = i; -		JLabel deleteHeaderLabel = new JLabel("Delete"); -		flightPane.add(deleteHeaderLabel, c); -  		/* Add the flights to the GridBag */  		AltosEepromItem item;  		int itemNumber = 1; @@ -163,23 +147,14 @@ public class AltosEepromSelect extends AltosDialog implements ActionListener {  			c.insets = i;  			flightPane.add(item.label, c); -			/* Add a download checkbox for the flight */ +			/* Add action checkbox for the flight */  			c = new GridBagConstraints();  			c.gridx = 1; c.gridy = itemNumber;  			c.fill = GridBagConstraints.NONE;  			c.weightx = 0.5;  			c.anchor = GridBagConstraints.CENTER;  			c.insets = i; -			flightPane.add(item.download, c); - -			/* Add a delete checkbox for the flight */ -			c = new GridBagConstraints(); -			c.gridx = 2; c.gridy = itemNumber; -			c.fill = GridBagConstraints.NONE; -			c.weightx = 0.5; -			c.anchor = GridBagConstraints.CENTER; -			c.insets = i; -			flightPane.add(item.delete, c); +			flightPane.add(item.action, c);  			itemNumber++;  		} | 
