mirror of
https://github.com/nasa/trick.git
synced 2024-12-18 20:57:55 +00:00
Switched to using jaxb.index instead of enumerating classes in the call to JAXBContent.newInstance.
Modified the makefile to copy jaxb.index files into the JAR. Removed now-unnecessary annotations from TVBean. Modified and exposed the save/open .tv file framework to subclasses so they can add additional information to .tv files. fixes #12
This commit is contained in:
parent
2fab93da66
commit
71b6b25278
@ -20,6 +20,7 @@ space := $(empty) $(empty)
|
||||
CLASS_PATH = $(subst $(space),:,$(wildcard ${LIB_DIR}/*.jar))
|
||||
|
||||
RESOURCES = $(subst src/,,$(shell find src/trick -name resources))
|
||||
RESOURCES += $(subst src/,,$(shell find src/trick -name jaxb.index))
|
||||
|
||||
all: ${DIST_DIR}/trick.jar resources
|
||||
@echo "[32mJava build successful[0m"
|
||||
|
@ -73,9 +73,12 @@ import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.TreePath;
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
|
||||
import joptsimple.OptionParser;
|
||||
import joptsimple.OptionSet;
|
||||
@ -411,10 +414,7 @@ public class TVApplication extends RunTimeTrickApplication implements VariableLi
|
||||
|
||||
// Initialize the JAXB elements.
|
||||
try {
|
||||
JAXBContext jaxbContext = JAXBContext.newInstance(TVBean.class,
|
||||
TVBoolean.class, TVByte.class, TVDouble.class, TVEnumeration.class,
|
||||
TVFloat.class, TVInteger.class, TVLong.class, TVShort.class,
|
||||
TVString.class);
|
||||
JAXBContext jaxbContext = JAXBContext.newInstance("trick.tv");
|
||||
marshaller = jaxbContext.createMarshaller();
|
||||
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
|
||||
unmarshaller = jaxbContext.createUnmarshaller();
|
||||
@ -1767,13 +1767,13 @@ public class TVApplication extends RunTimeTrickApplication implements VariableLi
|
||||
* @param display whether or not to replace the current variable table contents with those in the file
|
||||
* @param set whether or not to send the values in the file to the Variable Server
|
||||
*/
|
||||
void openFile(File file, boolean display, boolean set) {
|
||||
protected void openFile(File file, boolean display, boolean set) {
|
||||
try {
|
||||
openFileAsBinary(file, display, set);
|
||||
}
|
||||
catch (Exception binaryException) {
|
||||
try {
|
||||
restoreState((TVBean)unmarshaller.unmarshal(file), display, set);
|
||||
restoreState((TVBean)unmarshaller.unmarshal(new StreamSource(file), TVBean.class).getValue(), display, set);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
JOptionPane.showMessageDialog(getMainFrame(), exception,
|
||||
@ -1856,9 +1856,7 @@ public class TVApplication extends RunTimeTrickApplication implements VariableLi
|
||||
* @param display whether or not to display the data
|
||||
* @param set whether or not to set the data's values
|
||||
*/
|
||||
protected void restoreState(TVBean tvBean, boolean display, boolean set)
|
||||
throws IOException, ClassNotFoundException, InstantiationException,
|
||||
IllegalAccessException, JAXBException {
|
||||
protected void restoreState(TVBean tvBean, boolean display, boolean set) {
|
||||
if (display) {
|
||||
removeAllStripCharts();
|
||||
removeAllVariables();
|
||||
@ -1950,12 +1948,12 @@ public class TVApplication extends RunTimeTrickApplication implements VariableLi
|
||||
if (!file.exists() || (JOptionPane.showConfirmDialog(getMainFrame(),"Overwrite existing file?",
|
||||
"File Already Exists", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)) {
|
||||
try {
|
||||
marshaller.marshal(new TVBean(this), file);
|
||||
saveState(file);
|
||||
}
|
||||
catch (JAXBException jaxbException) {
|
||||
JOptionPane.showMessageDialog(getMainFrame(), jaxbException,
|
||||
catch (Exception exception) {
|
||||
JOptionPane.showMessageDialog(getMainFrame(), exception,
|
||||
"Failed to Save State", JOptionPane.ERROR_MESSAGE);
|
||||
jaxbException.printStackTrace(System.err);
|
||||
exception.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -1964,6 +1962,15 @@ public class TVApplication extends RunTimeTrickApplication implements VariableLi
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* saves the variable table and strip charts to <code>file</code>
|
||||
*
|
||||
* @param file the target
|
||||
*/
|
||||
protected void saveState(File file) throws JAXBException {
|
||||
marshaller.marshal(new JAXBElement<TVBean>(new QName("trickView"), TVBean.class, new TVBean(this)), file);
|
||||
}
|
||||
|
||||
/**
|
||||
* determines how the Variable Tree is being sorted
|
||||
*
|
||||
|
@ -8,7 +8,6 @@ import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import org.jdesktop.swingx.JXFrame;
|
||||
@ -23,8 +22,6 @@ import trick.common.utils.vs.Variable;
|
||||
import trick.sie.utils.SieEnumeration;
|
||||
import trick.stripchart.StripChart;
|
||||
|
||||
@XmlRootElement(name = "trickView")
|
||||
@XmlType(name = "trickView")
|
||||
public class TVBean {
|
||||
|
||||
public double cyclePeriod;
|
||||
|
10
trick_source/java/src/trick/tv/jaxb.index
Normal file
10
trick_source/java/src/trick/tv/jaxb.index
Normal file
@ -0,0 +1,10 @@
|
||||
TVBean
|
||||
TVBoolean
|
||||
TVByte
|
||||
TVDouble
|
||||
TVEnumeration
|
||||
TVFloat
|
||||
TVInteger
|
||||
TVLong
|
||||
TVShort
|
||||
TVString
|
Loading…
Reference in New Issue
Block a user