private void saveTo(File file) {
		if (file == null)
			return;
		String s = file.toString().toLowerCase();
		if (s.endsWith(".cml")) {
			isWriting = true;
			nameModels(file);
			((AbstractDocument) getDocument()).readLock();
			try {
				encoder.write(file);
				setAddress(file.toString());
				setTitle(getTitle());
			} catch (Exception e) {
				EventQueue.invokeLater(new Runnable() {
					public void run() {
						JOptionPane.showMessageDialog(JOptionPane.getFrameForComponent(Page.this), "The content on this page contains errors that\n" + "cannot be saved. Please correct them, and try\n" + "again.", "Output data error", JOptionPane.ERROR_MESSAGE);
					}
				});
				e.printStackTrace();
			} finally {
				isWriting = false;
				((AbstractDocument) getDocument()).readUnlock();
			}
		} else if (s.endsWith(".mml") || s.endsWith(".gbl")) {
			Object o = getEmbeddedComponent(ModelCanvas.class, 0);
			if (o instanceof ModelCanvas) {
				ModelCanvas mc = (ModelCanvas) o;
				Model model = mc.getMdContainer().getModel();
				model.output(file);
				properties.put(mc, mc.getURL());
			}
		} else if (s.endsWith(".txt") || s.endsWith(".mws")) {
			if (plainTextWriter == null) {
				plainTextWriter = new PlainTextWriter(this);
				plainTextWriter.setProgressBar(encoder.getProgressBar());
			}
			plainTextWriter.write(file);
		} else if (s.endsWith(".gif") || s.endsWith(".jpg") || s.endsWith(".png") || s.endsWith(".jpeg") || s.endsWith(".pdb") || s.endsWith(".xyz")) {
			if (!pageAddress.equalsIgnoreCase(s))
				ModelerUtilities.copyResource(pageAddress, file);
		}
		saveReminder.setChanged(false);
	}