/* * SaveAsDialog.java * * Created on March 28, 2002, 2:44 PM */ package jas.hist; import jas.util.Application; import jas.util.JASDialog; import jas.util.JASState; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Frame; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.Properties; import java.util.Vector; import javax.swing.DefaultListCellRenderer; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFileChooser; import javax.swing.JList; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.SwingUtilities; /** * * @author tonyj * @version $Id: SaveAsDialog.java 11553 2007-06-05 22:06:23Z duns $ */ public class SaveAsDialog extends JASDialog implements ActionListener { private static Vector list = new Vector(); private static Properties props; static { Application app = Application.getApplication(); if (app != null) props = app.getUserProperties(); else props = new Properties(); String prop = "org.freehep.graphics2d.exportchooser.EPS_PSExportFileType.EmbedFonts"; String embed = props.getProperty(prop); if (embed == null) props.setProperty(prop,"Embed unknown as Type3"); register(new SaveAsPlotML()); register(new SaveAsGIF()); } public static void register(SaveAsPlugin plugin) { list.addElement(plugin); plugin.restoreOptions(props); } /** Creates a new instance of SaveAsDialog */ public SaveAsDialog(Component c) { super((Frame) SwingUtilities.getAncestorOfClass(Frame.class,c),"Save As..."); this.component = c; JPanel pane = new JPanel(); pane.setLayout(new GridBagLayout()); GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); pane.add(file, gridBagConstraints); gridBagConstraints.fill = 1; gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; pane.add(browse, gridBagConstraints); Vector fileTypes = new Vector(); for (int i=0; i0); } private JButton browse = new JButton("Browse..."); private JButton advanced = new JButton("Options..."); private JTextField file = new JTextField(40); private JComboBox type; private Component component; private class SaveAsRenderer extends DefaultListCellRenderer { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list,value,index,isSelected,cellHasFocus); if (value instanceof SaveAsPlugin) { this.setText(((SaveAsPlugin) value).getFileFilter().getDescription()); } return this; } } }