當前位置: 首頁>>代碼示例>>Java>>正文


Java XMLControlElement.write方法代碼示例

本文整理匯總了Java中org.opensourcephysics.controls.XMLControlElement.write方法的典型用法代碼示例。如果您正苦於以下問題:Java XMLControlElement.write方法的具體用法?Java XMLControlElement.write怎麽用?Java XMLControlElement.write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.opensourcephysics.controls.XMLControlElement的用法示例。


在下文中一共展示了XMLControlElement.write方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: save

import org.opensourcephysics.controls.XMLControlElement; //導入方法依賴的package包/類
/**
 * Saves the current xml control to the specified file.
 *
 * @param fileName the file name
 * @return the name of the saved file, or null if not saved
 */
private String save(String fileName) {
  if((fileName==null)||fileName.equals("")) { //$NON-NLS-1$   
    return null;
  }
  if(passwordField.getBackground()==Color.yellow) {
    passwordField.setBackground(Color.white);
    setPassword(passwordField.getText());
  }
  XMLControlElement control = getCurrentControl();
  if(control==null) {
    return null;
  }
  if(control.getObjectClass()==Cryptic.class) {
    control = decrypt(control);
  }
  if(control.write(fileName)==null) {
    return null;
  }
  this.fileName = fileName;
  refreshGUI();
  return fileName;
}
 
開發者ID:OpenSourcePhysics,項目名稱:osp,代碼行數:29,代碼來源:EncryptionTool.java

示例2: save

import org.opensourcephysics.controls.XMLControlElement; //導入方法依賴的package包/類
/**
 * Saves a node to the specified file.
 *
 * @param node the node
 * @param fileName the desired name of the file
 * @return the name of the saved file, or null if not saved
 */
public String save(LaunchNode node, String fileName) {
  if(node==null) {
    return null;
  }
  if((fileName==null)||fileName.trim().equals("")) { //$NON-NLS-1$
    return saveAs(node);
  }
  // add .xml extension if none but don't require it
  if(XML.getExtension(fileName)==null) {
    while(fileName.endsWith(".")) { //$NON-NLS-1$
      fileName = fileName.substring(0, fileName.length()-1);
    }
    fileName += ".xml";             //$NON-NLS-1$
  }
  if(!saveOwnedNodes(node)) {
    return null;
  }
  String filepath = fileName;
  if(!tabSetBasePath.equals("")) { //$NON-NLS-1$
    filepath = XML.getResolvedPath(fileName, tabSetBasePath);
  } else {
    String jarBase = OSPRuntime.getLaunchJarDirectory();
    filepath = XML.getResolvedPath(fileName, jarBase);
  }
  File file = new File(filepath);
  OSPLog.fine(fileName+" = "+file.getAbsolutePath()); //$NON-NLS-1$
  String fullName = XML.forwardSlash(file.getAbsolutePath());
  String path = XML.getDirectoryPath(fullName);
  XML.createFolders(path);
  XMLControlElement control = new XMLControlElement(node);
  control.write(fullName);
  if(!control.canWrite) {
    OSPLog.info(LaunchRes.getString("Dialog.SaveFailed.Message")+" "+fullName);                        //$NON-NLS-1$//$NON-NLS-2$
    JOptionPane.showMessageDialog(null, LaunchRes.getString("Dialog.SaveFailed.Message")+" "+fileName, //$NON-NLS-1$//$NON-NLS-2$
      LaunchRes.getString("Dialog.SaveFailed.Title"), //$NON-NLS-1$
        JOptionPane.WARNING_MESSAGE);
    return null;
  }
  node.setFileName(fileName);
  changedFiles.remove(node.getFileName());
  return fileName;
}
 
開發者ID:OpenSourcePhysics,項目名稱:osp,代碼行數:50,代碼來源:LaunchBuilder.java

示例3: saveTabSet

import org.opensourcephysics.controls.XMLControlElement; //導入方法依賴的package包/類
/**
 * Saves the current tabset.
 *
 * @return the full path to the saved file, or null if not saved
 */
public String saveTabSet() {
  if(tabSetName==null) {
    return null;
  }
  if(tabSetName.trim().equals("")) { //$NON-NLS-1$
    return saveTabSetAs();
  }
  // check for read-only files
  if(!isTabSetWritable()) {
    return saveTabSetAs();
  }
  if(!selfContained&&!saveTabs()) {
    return null;
  }
  // save tab set
  String fileName = tabSetName;
  if(!tabSetBasePath.equals("")) { //$NON-NLS-1$
    fileName = XML.getResolvedPath(tabSetName, tabSetBasePath);
  } else {
    String jarBase = OSPRuntime.getLaunchJarDirectory();
    fileName = XML.getResolvedPath(tabSetName, jarBase);
  }
  OSPLog.fine(fileName);
  File file = new File(fileName);
  fileName = XML.forwardSlash(file.getAbsolutePath());
  String path = XML.getDirectoryPath(fileName);
  XML.createFolders(path);
  LaunchSet tabset = new LaunchSet(this, tabSetName);
  XMLControlElement control = new XMLControlElement(tabset);
  if(control.write(fileName)==null) {
    return null;
  }
  changedFiles.clear();
  jarBasePath = null; // signals tabset is now a file
  if(spawner!=null) {
    spawner.open(fileName);
    spawner.refreshGUI();
  }
  return fileName;
}
 
開發者ID:OpenSourcePhysics,項目名稱:osp,代碼行數:46,代碼來源:LaunchBuilder.java


注:本文中的org.opensourcephysics.controls.XMLControlElement.write方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。