save command history with configs
This commit is contained in:
parent
207fddddf0
commit
3a02e43e09
|
@ -25,8 +25,6 @@
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
|
||||||
* $Id: SerialUI.java,v 1.7 2010/10/07 13:09:28 joxe Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.dialogs;
|
package se.sics.cooja.dialogs;
|
||||||
|
@ -39,11 +37,12 @@ import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.KeyAdapter;
|
import java.awt.event.KeyAdapter;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Observable;
|
import java.util.Observable;
|
||||||
import java.util.Observer;
|
import java.util.Observer;
|
||||||
|
|
||||||
import org.jdom.Element;
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
@ -52,7 +51,9 @@ import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTextArea;
|
import javax.swing.JTextArea;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.jdom.Element;
|
||||||
|
|
||||||
import se.sics.cooja.Mote;
|
import se.sics.cooja.Mote;
|
||||||
import se.sics.cooja.interfaces.Log;
|
import se.sics.cooja.interfaces.Log;
|
||||||
|
@ -214,7 +215,14 @@ public abstract class SerialUI extends Log implements SerialPort {
|
||||||
// Receive RS232 data visualizer
|
// Receive RS232 data visualizer
|
||||||
logTextPane.setOpaque(false);
|
logTextPane.setOpaque(false);
|
||||||
logTextPane.setEditable(false);
|
logTextPane.setEditable(false);
|
||||||
|
logTextPane.addKeyListener(new KeyAdapter() {
|
||||||
|
public void keyPressed(KeyEvent e) {
|
||||||
|
if ((e.getModifiers() & (MouseEvent.SHIFT_MASK|MouseEvent.CTRL_MASK)) != 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
commandField.requestFocusInWindow();
|
||||||
|
}
|
||||||
|
});
|
||||||
if (getLastLogMessage() == null) {
|
if (getLastLogMessage() == null) {
|
||||||
logTextPane.setText("");
|
logTextPane.setText("");
|
||||||
} else {
|
} else {
|
||||||
|
@ -272,10 +280,34 @@ public abstract class SerialUI extends Log implements SerialPort {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<Element> getConfigXML() {
|
public Collection<Element> getConfigXML() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (String s: history) {
|
||||||
|
if (s == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
sb.append(s + "~;");
|
||||||
|
}
|
||||||
|
if (sb.length() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ArrayList<Element> config = new ArrayList<Element>();
|
||||||
|
Element element = new Element("history");
|
||||||
|
element.setText(sb.toString());
|
||||||
|
config.add(element);
|
||||||
|
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
public void setConfigXML(Collection<Element> configXML, boolean visAvailable) {
|
public void setConfigXML(Collection<Element> configXML, boolean visAvailable) {
|
||||||
|
for (Element element : configXML) {
|
||||||
|
if (element.getName().equals("history")) {
|
||||||
|
String[] history = element.getText().split("~;");
|
||||||
|
System.arraycopy(history, 0, this.history, 0, history.length);
|
||||||
|
historyCount = history.length;
|
||||||
|
historyPos = historyCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int tosChars = 0;
|
private int tosChars = 0;
|
||||||
|
|
Loading…
Reference in New Issue