MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / ExportTool

Class ExportTool

src/org/opensourcephysics/tools/ExportTool.java:46–329  ·  view source on GitHub ↗

An export tool which launches a Save dialog @author Kipton Barros @version 1.0

Source from the content-addressed store, hash-verified

44 * @version 1.0
45 */
46public class ExportTool implements Tool, PropertyChangeListener {
47 /*
48 * TOOL is the single instance of ExportTool registered with the OSP Toolbox.
49 */
50 static ExportTool TOOL;
51 AsyncFileChooser fc;
52 static String exportExtension = "txt"; //$NON-NLS-1$
53 static Hashtable<String, ExportFormat> formats;
54 JCheckBox[] checkBoxes;
55 String exportName = "default"; //$NON-NLS-1$
56
57 /**
58 * Creates a new export tool. Doesn't get activated until setXML() is called.
59 */
60 public ExportTool() {
61 createFileChooser();
62 fc.addPropertyChangeListener(this);
63 }
64
65 void createFileChooser() {
66 formats = new Hashtable<String, ExportFormat>();
67 registerFormat(new ExportGnuplotFormat());
68 registerFormat(new ExportXMLFormat());
69 // Set the "filesOfTypeLabelText" to "File Format:"
70 Object oldFilesOfTypeLabelText = UIManager.put("FileChooser.filesOfTypeLabelText", //$NON-NLS-1$
71 ToolsRes.getString("ExportTool.FileChooser.Label.FileFormat")); //$NON-NLS-1$
72 // Create a new FileChooser
73 // fc = new JFileChooser(OSPRuntime.chooserDir);
74 fc = OSPRuntime.getChooser();
75
76 // Reset the "filesOfTypeLabelText" to previous value
77 UIManager.put("FileChooser.filesOfTypeLabelText", oldFilesOfTypeLabelText); //$NON-NLS-1$
78 fc.setDialogType(JFileChooser.SAVE_DIALOG);
79 fc.setDialogTitle(ToolsRes.getString("ExportTool.FileChooser.Title")); //$NON-NLS-1$
80 fc.setApproveButtonText(ToolsRes.getString("ExportTool.FileChooser.Button.Export")); // Set export //$NON-NLS-1$
81 // formats
82 setChooserFormats();
83 }
84
85 /*
86 * void createFileChooser() { formats = new Hashtable<String, ExportFormat>();
87 * registerFormat(new ExportGnuplotFormat()); registerFormat(new
88 * ExportXMLFormat()); // Set the "filesOfTypeLabelText" to "File Format:"
89 * Object oldFilesOfTypeLabelText =
90 * UIManager.put("FileChooser.filesOfTypeLabelText", //$NON-NLS-1$
91 * ToolsRes.getString("ExportTool.FileChooser.Label.FileFormat")); //$NON-NLS-1$
92 * // Create a new FileChooser //fc = new JFileChooser(OSPRuntime.chooserDir) fc
93 * = OSPRuntime.getChooser(); if(fc==null) { return; } String oldTitle =
94 * fc.getDialogTitle(); fc.setDialogTitle("Export Data");
95 * fc.showOpenDialog(null, new Runnable() { // OK
96 *
97 * @Override public void run() {
98 * org.opensourcephysics.display.OSPRuntime.chooserDir =
99 * fc.getCurrentDirectory().toString(); // It is critical to pass the actual
100 * file along, as it has the bytes already. // XMLControlElement xml = new
101 * XMLControlElement(fc.getSelectedFile()); //xml.loadObject(GROrbitsApp.this);
102 * // load the data fc.setDialogTitle(oldTitle); }
103 *

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected