@Override
public void saveAs_actionPerformed(ActionEvent e)
{
+ String format = currentFileFormat == null ? null : currentFileFormat
+ .toString();
JalviewFileChooser chooser = JalviewFileChooser.forWrite(
- Cache.getProperty("LAST_DIRECTORY"),
- // AppletFormatAdapter.WRITABLE_EXTENSIONS,
- // AppletFormatAdapter.WRITABLE_FNAMES,
- currentFileFormat.toString(), false);
+ Cache.getProperty("LAST_DIRECTORY"), format);
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(MessageManager
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JProgressBar;
}
});
- // displayed.
// Thread off a new instance of the file chooser - this reduces the time it
// takes to open it later on.
new Thread(new Runnable()
Cache.log.debug("Filechooser init thread started.");
String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
JalviewFileChooser.forRead(Cache.getProperty("LAST_DIRECTORY"),
- // jalview.io.AppletFormatAdapter.READABLE_EXTENSIONS,
- // jalview.io.AppletFormatAdapter.READABLE_FNAMES,
- fileFormat, true);
+ fileFormat);
Cache.log.debug("Filechooser init thread finished.");
}
}).start();
{
String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
JalviewFileChooser chooser = JalviewFileChooser.forRead(
- Cache.getProperty("LAST_DIRECTORY"),
- // AppletFormatAdapter.READABLE_EXTENSIONS,
- // AppletFormatAdapter.READABLE_FNAMES,
- fileFormat, true);
+ Cache.getProperty("LAST_DIRECTORY"), fileFormat);
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(MessageManager
public void saveState_actionPerformed(ActionEvent e)
{
JalviewFileChooser chooser = new JalviewFileChooser(
- Cache.getProperty("LAST_DIRECTORY"), "jvp", "Jalview Project",
- "Jalview Project");
+ Cache.getProperty("LAST_DIRECTORY"), "jvp", "Jalview Project");
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(MessageManager.getString("label.save_state"));
{
JalviewFileChooser chooser = new JalviewFileChooser(
Cache.getProperty("LAST_DIRECTORY"), "vdj",// TODO: VAMSAS DOCUMENT EXTENSION is VDJ
- "Vamsas Document", "Vamsas Document");
+ "Vamsas Document");
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(MessageManager
import jalview.datamodel.SequenceI;
import jalview.gui.Help.HelpId;
import jalview.io.JalviewFileChooser;
+import jalview.io.JalviewFileView;
import jalview.schemabinding.version2.JalviewUserColours;
import jalview.schemes.FeatureColour;
import jalview.util.Format;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
{
JalviewFileChooser chooser = new JalviewFileChooser(
Cache.getProperty("LAST_DIRECTORY"), "fc",
- "Sequence Feature Colours", "Sequence Feature Colours");
- chooser.setFileView(new jalview.io.JalviewFileView());
+ "Sequence Feature Colours");
+ chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(MessageManager
.getString("label.load_feature_colours"));
chooser.setToolTipText(MessageManager.getString("action.load"));
{
JalviewFileChooser chooser = new JalviewFileChooser(
Cache.getProperty("LAST_DIRECTORY"), "fc",
- "Sequence Feature Colours", "Sequence Feature Colours");
- chooser.setFileView(new jalview.io.JalviewFileView());
+ "Sequence Feature Colours");
+ chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(MessageManager
.getString("label.save_feature_colours"));
chooser.setToolTipText(MessageManager.getString("action.save"));
import javax.swing.JColorChooser;
import javax.swing.JFileChooser;
import javax.swing.JInternalFrame;
-import javax.swing.JOptionPane;
import javax.swing.JPanel;
import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
{
String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
JalviewFileChooser chooser = JalviewFileChooser.forRead(
- Cache.getProperty("LAST_DIRECTORY"), fileFormat, true);
- // new String[] {
- // "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc",
- // "jar" }, new String[] { "Fasta", "Clustal", "PFAM", "MSF",
- // "PIR", "BLC", "Jalview" },
- // fileFormat);
+ Cache.getProperty("LAST_DIRECTORY"), fileFormat);
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(MessageManager
.getString("label.select_startup_file"));
{
JalviewFileChooser chooser = new JalviewFileChooser(
Cache.getProperty("LAST_DIRECTORY"),
- ImageMaker.EPS_EXTENSION, ImageMaker.EPS_EXTENSION,
- ImageMaker.EPS_EXTENSION);
+ ImageMaker.EPS_EXTENSION, ImageMaker.EPS_EXTENSION);
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(MessageManager
.getString("label.create_eps_from_tree"));
{
JalviewFileChooser chooser = new JalviewFileChooser(
Cache.getProperty("LAST_DIRECTORY"),
- ImageMaker.PNG_EXTENSION, ImageMaker.PNG_DESCRIPTION,
- ImageMaker.PNG_DESCRIPTION);
+ ImageMaker.PNG_EXTENSION, ImageMaker.PNG_DESCRIPTION);
chooser.setFileView(new jalview.io.JalviewFileView());
chooser.setDialogTitle(MessageManager
import jalview.bin.Cache;
import jalview.datamodel.SequenceGroup;
import jalview.io.JalviewFileChooser;
+import jalview.io.JalviewFileView;
import jalview.jbgui.GUserDefinedColours;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.ResidueProperties;
import javax.swing.JButton;
import javax.swing.JInternalFrame;
-import javax.swing.JOptionPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
JalviewFileChooser chooser = new JalviewFileChooser(
Cache.getProperty("LAST_DIRECTORY"), "jc",
- "Jalview User Colours", "Jalview User Colours");
- chooser.setFileView(new jalview.io.JalviewFileView());
+ "Jalview User Colours");
+ chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(MessageManager
.getString("label.load_colour_scheme"));
chooser.setToolTipText(MessageManager.getString("action.load"));
}
JalviewFileChooser chooser = new JalviewFileChooser(
Cache.getProperty("LAST_DIRECTORY"), "jc",
- "Jalview User Colours", "Jalview User Colours");
+ "Jalview User Colours");
- chooser.setFileView(new jalview.io.JalviewFileView());
+ chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(MessageManager
.getString("label.save_colour_scheme"));
chooser.setToolTipText(MessageManager.getString("action.save"));
import java.util.List;
import java.util.StringTokenizer;
-import javax.swing.JOptionPane;
-
/**
* store and retrieve web service parameter sets.
*
{
JalviewFileChooser chooser = new JalviewFileChooser(
Cache.getProperty("LAST_DIRECTORY"), "wsparams",
- "Web Service Parameter File", "Web Service Parameter File");
+ "Web Service Parameter File");
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(MessageManager
.getString("label.choose_filename_for_param_file"));
package jalview.io;
import jalview.api.AlignExportSettingI;
+import jalview.bin.Cache;
import jalview.datamodel.AlignmentExportData;
import jalview.exceptions.NoFileSelectedException;
import jalview.gui.AlignmentPanel;
}
JalviewFileChooser jvFileChooser = new JalviewFileChooser(
- jalview.bin.Cache.getProperty("LAST_DIRECTORY"),
- new String[] { "html" }, new String[] { "HTML files" },
- "HTML files");
+ Cache.getProperty("LAST_DIRECTORY"), "html", "HTML files");
jvFileChooser.setFileView(new JalviewFileView());
jvFileChooser.setDialogTitle(MessageManager
new Thread(this).start();
}
-
- static JalviewFileChooser getHTMLChooser()
- {
- return new jalview.io.JalviewFileChooser(
- jalview.bin.Cache.getProperty("LAST_DIRECTORY"),
- new String[] { "html" },
- new String[] { "Hypertext Markup Language" },
- "Hypertext Markup Language");
- }
-
public int printUnwrapped(int pwidth, int pheight, int pi,
Graphics idGraphics, Graphics alignmentGraphics)
throws PrinterException
import java.awt.event.MouseEvent;
import java.io.File;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;
import java.util.Vector;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SpringLayout;
-import javax.swing.filechooser.FileView;
import javax.swing.plaf.basic.BasicFileChooserUI;
/**
*
* @param directory
* @param selected
- * @param selectAll
* @return
*/
- public static JalviewFileChooser forRead(String directory,
- String selected, boolean selectAll)
+ public static JalviewFileChooser forRead(String directory, String selected)
{
List<String> extensions = new ArrayList<String>();
List<String> descs = new ArrayList<String>();
}
return new JalviewFileChooser(directory,
extensions.toArray(new String[extensions.size()]),
- descs.toArray(new String[descs.size()]),
- selected);
+ descs.toArray(new String[descs.size()]), selected, true);
}
/**
*
* @param directory
* @param selected
- * @param selectAll
* @return
*/
public static JalviewFileChooser forWrite(String directory,
- String selected, boolean selectAll)
+ String selected)
{
// TODO in Java 8, forRead and forWrite can be a single method
// with a lambda expression parameter for isReadable/isWritable
}
return new JalviewFileChooser(directory,
extensions.toArray(new String[extensions.size()]),
- descs.toArray(new String[descs.size()]), selected);
+ descs.toArray(new String[descs.size()]), selected, false);
}
public JalviewFileChooser(String dir)
setAccessory(new RecentlyOpened());
}
- public JalviewFileChooser(String dir, String extension, String desc,
+ public JalviewFileChooser(String dir, String[] suffix, String[] desc,
String selected)
{
- super(safePath(dir));
- init(Collections.singletonList(new String[] { extension, desc }),
- selected);
+ this(dir, suffix, desc, selected, true);
}
- public JalviewFileChooser(String dir, String[] extensions, String[] descs,
- String selected)
+ /**
+ * Constructor for a single choice of file extension and description
+ *
+ * @param dir
+ * @param extension
+ * @param desc
+ */
+ public JalviewFileChooser(String dir, String extension, String desc)
+ {
+ // TODO inline dir as Cache.getProperty("LAST_DIRECTORY") ? if applet
+ // builds ok
+ this(dir, new String[] { extension }, new String[] { desc }, desc,
+ true);
+ }
+
+ JalviewFileChooser(String dir, String[] extensions, String[] descs,
+ String selected, boolean allFiles)
{
super(safePath(dir));
if (extensions.length == descs.length)
{
formats.add(new String[] { extensions[i], descs[i] });
}
- init(formats, selected);
+ init(formats, selected, allFiles);
}
else
{
* @param formats
* a list of {extensions, description} for each file format
* @param selected
+ * @param allFiles
+ * if true, 'any format' option is included
*/
- void init(List<String[]> formats, String selected)
+ void init(List<String[]> formats, String selected, boolean allFiles)
{
JalviewFileFilter chosen = null;
// SelectAllFilter needs to be set first before adding further
// file filters to fix bug on Mac OSX
- setAcceptAllFileFilterUsed(true);
+ setAcceptAllFileFilterUsed(allFiles);
for (String[] format : formats)
{
return null;
}
return new JalviewFileChooser(Cache.getProperty("LAST_DIRECTORY"),
- PNG_EXTENSION, PNG_DESCRIPTION, PNG_DESCRIPTION);
+ PNG_EXTENSION, PNG_DESCRIPTION);
}
static JalviewFileChooser getEPSChooser()
return null;
}
return new JalviewFileChooser(Cache.getProperty("LAST_DIRECTORY"),
- EPS_EXTENSION, EPS_DESCRIPTION, EPS_DESCRIPTION);
+ EPS_EXTENSION, EPS_DESCRIPTION);
}
private void setProgressMessage(String message)
return null;
}
return new JalviewFileChooser(Cache.getProperty("LAST_DIRECTORY"),
- SVG_EXTENSION, SVG_DESCRIPTION, SVG_DESCRIPTION);
+ SVG_EXTENSION, SVG_DESCRIPTION);
}
}