本文整理汇总了Java中org.opensourcephysics.controls.XMLControl.write方法的典型用法代码示例。如果您正苦于以下问题:Java XMLControl.write方法的具体用法?Java XMLControl.write怎么用?Java XMLControl.write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opensourcephysics.controls.XMLControl
的用法示例。
在下文中一共展示了XMLControl.write方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveXML
import org.opensourcephysics.controls.XMLControl; //导入方法依赖的package包/类
public void saveXML() {
JFileChooser chooser = OSPRuntime.getChooser();
int result = chooser.showSaveDialog(null);
if(result==JFileChooser.APPROVE_OPTION) {
OSPRuntime.chooserDir = chooser.getCurrentDirectory().toString();
File file = chooser.getSelectedFile();
// check to see if file already exists
if(file.exists()) {
int selected = JOptionPane.showConfirmDialog(null, DisplayRes.getString("DrawingFrame.ReplaceExisting_message")+file.getName() //$NON-NLS-1$
+DisplayRes.getString("DrawingFrame.QuestionMark"), //$NON-NLS-1$
DisplayRes.getString("DrawingFrame.ReplaceFile_option_title"), //$NON-NLS-1$
JOptionPane.YES_NO_CANCEL_OPTION);
if(selected!=JOptionPane.YES_OPTION) {
return;
}
}
String fileName = XML.getRelativePath(file.getAbsolutePath());
if((fileName==null)||fileName.trim().equals("")) { //$NON-NLS-1$
return;
}
int i = fileName.toLowerCase().lastIndexOf(".xml"); //$NON-NLS-1$
if(i!=fileName.length()-4) {
fileName += ".xml"; //$NON-NLS-1$
}
try {
// if drawingPanel provides an xml loader, save the drawingPanel
Method method = drawingPanel.getClass().getMethod("getLoader", (Class[]) null); //$NON-NLS-1$
if((method!=null)&&Modifier.isStatic(method.getModifiers())) {
XMLControl xml = new XMLControlElement(drawingPanel);
xml.write(fileName);
}
} catch(NoSuchMethodException ex) {
// this drawingPanel cannot be saved
return;
}
}
}
示例2: saveXML
import org.opensourcephysics.controls.XMLControl; //导入方法依赖的package包/类
public void saveXML() {
JFileChooser chooser = OSPRuntime.getChooser();
int result = chooser.showSaveDialog(null);
if(result==JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
// check to see if file already exists
if(file.exists()) {
int selected = JOptionPane.showConfirmDialog(null, DisplayRes.getString("DrawingFrame.ReplaceExisting_message")+file.getName() //$NON-NLS-1$
+DisplayRes.getString("DrawingFrame.QuestionMark"), //$NON-NLS-1$
DisplayRes.getString("DrawingFrame.ReplaceFile_option_title"), //$NON-NLS-1$
JOptionPane.YES_NO_CANCEL_OPTION);
if(selected!=JOptionPane.YES_OPTION) {
return;
}
}
String fileName = XML.getRelativePath(file.getAbsolutePath());
if((fileName==null)||fileName.trim().equals("")) { //$NON-NLS-1$
return;
}
int i = fileName.toLowerCase().lastIndexOf(".xml"); //$NON-NLS-1$
if(i!=fileName.length()-4) {
fileName += ".xml"; //$NON-NLS-1$
}
try {
// if drawingPanel provides an xml loader, save the drawingPanel
Method method = drawingPanel.getClass().getMethod("getLoader", (java.lang.Class[]) null); //$NON-NLS-1$
if((method!=null)&&Modifier.isStatic(method.getModifiers())) {
XMLControl xml = new XMLControlElement(drawingPanel);
xml.write(fileName);
}
} catch(NoSuchMethodException ex) {
// this drawingPanel cannot be saved
return;
}
}
}
示例3: createNewCollection
import org.opensourcephysics.controls.XMLControl; //导入方法依赖的package包/类
/**
* Creates a new LibraryCollection file.
* @return the path to the new collection
*/
protected String createNewCollection() {
String title = ToolsRes.getString("LibraryBrowser.FileChooser.Title.SaveCollectionAs"); //$NON-NLS-1$
String path = getChooserSavePath(title);
if (path!=null) {
LibraryCollection collection = new LibraryCollection(null);
// save new collection
XMLControl control = new XMLControlElement(collection);
control.write(path);
path = XML.forwardSlash(path);
TabLoader tabAdder = addTab(path, null);
if (tabAdder==null) return null;
tabAdder.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) {
if ("progress".equals(e.getPropertyName())) { //$NON-NLS-1$
Integer n = (Integer)e.getNewValue();
if (n>-1) {
tabbedPane.setSelectedIndex(n);
LibraryTreePanel treePanel = getSelectedTreePanel();
treePanel.setEditing(true);
refreshGUI();
}
}
}
});
tabAdder.execute();
}
return path;
}
示例4: save
import org.opensourcephysics.controls.XMLControl; //导入方法依赖的package包/类
/**
* Saves a tab to the specified file.
*
* @param tab the tab
* @param fileName the file name
* @return the name of the saved file, or null if not saved
*/
protected String save(DataToolTab tab, String fileName) {
if((fileName==null)||fileName.equals("")) { //$NON-NLS-1$
return saveAs();
}
XMLControl control = new XMLControlElement(tab);
if(control.write(fileName)==null) {
return null;
}
tab.fileName = fileName;
tab.tabChanged(false);
return fileName;
}
示例5: saveXML
import org.opensourcephysics.controls.XMLControl; //导入方法依赖的package包/类
public void saveXML() {
JFileChooser chooser = OSPRuntime.getChooser();
int result = chooser.showSaveDialog(null);
if(result==JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
// check to see if file already exists
if(file.exists()) {
int selected = JOptionPane.showConfirmDialog(null, EjsRes.getString("EjsControlFrame.ReplaceExisting_dialog")+file.getName() //$NON-NLS-1$
+EjsRes.getString("EjsControlFrame.question_mark"), EjsRes.getString( //$NON-NLS-1$
"EjsControlFrame.RepalceFile_dialog_message"), //$NON-NLS-1$
JOptionPane.YES_NO_CANCEL_OPTION);
if(selected!=JOptionPane.YES_OPTION) {
return;
}
}
OSPRuntime.chooserDir = chooser.getCurrentDirectory().toString();
String fileName = XML.getRelativePath(file.getAbsolutePath());
if((fileName==null)||fileName.trim().equals("")) { //$NON-NLS-1$
return;
}
int i = fileName.toLowerCase().lastIndexOf(".xml"); //$NON-NLS-1$
if(i!=fileName.length()-4) {
fileName += ".xml"; //$NON-NLS-1$
}
XMLControl xml = new XMLControlElement(getOSPApp());
xml.write(fileName);
}
}
示例6: savePreferences
import org.opensourcephysics.controls.XMLControl; //导入方法依赖的package包/类
/**
* Saves the current preference XMLControl by writing to a file.
*/
public static void savePreferences() {
XMLControl control = getPrefsControl();
File file = new File(prefsPath, prefsFileName);
control.write(file.getAbsolutePath());
}
示例7: save
import org.opensourcephysics.controls.XMLControl; //导入方法依赖的package包/类
/**
* Saves this library in an xml file.
*
* @param path the path to the saved file
*/
protected void save(String path) {
if (path==null) return;
XMLControl control = new XMLControlElement(this);
control.write(path);
}