/** @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent) */
 public void propertyChange(PropertyChangeEvent evt) {
   SuffixFilter filter = (SuffixFilter) evt.getNewValue();
   String fileName = defaultName + "." + filter.getSuffix();
   /* The next line does not work: */
   // chooser.setSelectedFile(new File(fileName));
   /* So, let's do it the hard way: */
   SwingUtilities.invokeLater(new Anonymous1(fileName));
 }
 /** @param suffix the extension of the new default file-format */
 public void setDefaultFilterBySuffix(String suffix) {
   Iterator i = otherFilters.iterator();
   while (i.hasNext()) {
     SuffixFilter sf = (SuffixFilter) i.next();
     if (sf.getSuffix().equalsIgnoreCase(suffix)) {
       setDefaultFilter(sf);
       break;
     }
   }
 }
 /**
  * @param name the filename
  * @return the filter
  */
 public SuffixFilter getFilterFromFileName(String name) {
   if (name.toLowerCase().endsWith("." + defaultFilter.getSuffix())) {
     return defaultFilter;
   }
   Iterator iter = otherFilters.iterator();
   while (iter.hasNext()) {
     SuffixFilter filter = (SuffixFilter) iter.next();
     if (name.toLowerCase().endsWith("." + filter.getSuffix())) {
       return filter;
     }
   }
   return null;
 }
 /** The constructor. */
 private SaveGraphicsManager() {
   defaultFilter = FileFilters.PNG_FILTER;
   otherFilters.add(FileFilters.GIF_FILTER);
   otherFilters.add(FileFilters.SVG_FILTER);
   otherFilters.add(FileFilters.PS_FILTER);
   otherFilters.add(FileFilters.EPS_FILTER);
   setDefaultFilterBySuffix(
       Configuration.getString(KEY_DEFAULT_GRAPHICS_FILTER, defaultFilter.getSuffix()));
 }
 /** @param chooser the filechooser of which the filters will be set */
 public void setFileChooserFilters(JFileChooser chooser, String defaultName) {
   chooser.addChoosableFileFilter(defaultFilter);
   Iterator iter = otherFilters.iterator();
   while (iter.hasNext()) {
     chooser.addChoosableFileFilter((SuffixFilter) iter.next());
   }
   chooser.setFileFilter(defaultFilter);
   String fileName = defaultName + "." + defaultFilter.getSuffix();
   chooser.setSelectedFile(new File(fileName));
   chooser.addPropertyChangeListener(
       JFileChooser.FILE_FILTER_CHANGED_PROPERTY,
       new FileFilterChangedListener(chooser, defaultName));
 }
  /** @param f the new default file-format */
  public void setDefaultFilter(SuffixFilter f) {
    otherFilters.remove(f);
    if (!otherFilters.contains(defaultFilter)) {
      otherFilters.add(defaultFilter);
    }
    defaultFilter = f;
    Configuration.setString(KEY_DEFAULT_GRAPHICS_FILTER, f.getSuffix());

    Collections.sort(
        otherFilters,
        new Comparator() {
          public int compare(Object arg0, Object arg1) {
            return ((SuffixFilter) arg0)
                .getSuffix()
                .compareToIgnoreCase(((SuffixFilter) arg1).getSuffix());
          }
        });
  }
 /** @return the extension of the default filter (just the text, not the ".") */
 public String getDefaultSuffix() {
   return defaultFilter.getSuffix();
 }