Search in sources :

Example 1 with FileChooserFilter

use of org.cytoscape.util.swing.FileChooserFilter in project EnrichmentMapApp by BaderLab.

the class ExportTXTAction method promptForFile.

private File promptForFile() {
    List<FileChooserFilter> filter = Collections.singletonList(new FileChooserFilter("txt Files", "txt"));
    File file = fileUtil.getFile(jframeProvider.get(), "Export Heatmap as txt File", FileUtil.SAVE, filter);
    if (file == null)
        return null;
    String fileName = file.toString();
    if (!fileName.endsWith(".txt")) {
        fileName += ".txt";
        file = new File(fileName);
    }
    return file;
}
Also used : File(java.io.File) FileChooserFilter(org.cytoscape.util.swing.FileChooserFilter)

Example 2 with FileChooserFilter

use of org.cytoscape.util.swing.FileChooserFilter in project EnrichmentMapApp by BaderLab.

the class ExportPDFAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    List<FileChooserFilter> filter = Collections.singletonList(new FileChooserFilter("pdf Files", "pdf"));
    File file = fileUtil.getFile(jframeProvider.get(), "Export Heatmap as PDF File", FileUtil.SAVE, filter);
    if (file != null) {
        String fileName = file.toString();
        if (!fileName.endsWith(".pdf")) {
            fileName += ".pdf";
            file = new File(fileName);
        }
        HeatMapExporterTask task = new HeatMapExporterTask(file);
        dialogTaskManager.execute(new TaskIterator(task));
    }
}
Also used : TaskIterator(org.cytoscape.work.TaskIterator) File(java.io.File) FileChooserFilter(org.cytoscape.util.swing.FileChooserFilter)

Example 3 with FileChooserFilter

use of org.cytoscape.util.swing.FileChooserFilter in project cytoscape-impl by cytoscape.

the class DataSourceSelectDialog method browseButtonActionPerformed.

private void browseButtonActionPerformed(ActionEvent evt) {
    File file = null;
    final FileUtil fileUtil = serviceRegistrar.getService(FileUtil.class);
    if (sourceType == ONTOLOGY_TYPE) {
        final FileChooserFilter filter = new FileChooserFilter("OBO File", "obo");
        List<FileChooserFilter> filterCollection = new ArrayList<FileChooserFilter>(1);
        filterCollection.add(filter);
        file = fileUtil.getFile(this.getParent(), "Select OBO Source File", FileUtil.LOAD, filterCollection);
    } else {
        // Currently, there is no pre-defined extension for this file type.
        final List<FileChooserFilter> filterCollection = new ArrayList<FileChooserFilter>();
        file = fileUtil.getFile(this.getParent(), "Select Gene Annotation Source File", FileUtil.LOAD, filterCollection);
    }
    if (file == null)
        return;
    sourceFileName = file.getName();
    if (sourceType == ONTOLOGY_TYPE) {
        ontologyNameTextField.setText("Local Ontology File: " + sourceFileName);
    } else {
        ontologyNameTextField.setText("Local Annotation File: " + sourceFileName);
    }
    try {
        dataSourceTextField.setText(file.toURI().toURL().toString());
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    this.toFront();
}
Also used : MalformedURLException(java.net.MalformedURLException) ArrayList(java.util.ArrayList) File(java.io.File) FileUtil(org.cytoscape.util.swing.FileUtil) FileChooserFilter(org.cytoscape.util.swing.FileChooserFilter)

Example 4 with FileChooserFilter

use of org.cytoscape.util.swing.FileChooserFilter in project EnrichmentMapApp by BaderLab.

the class PostAnalysisInputPanel method chooseGMTFile.

protected File chooseGMTFile(JFormattedTextField textField) {
    FileChooserFilter filter = new FileChooserFilter("All GMT Files", "gmt");
    List<FileChooserFilter> all_filters = Arrays.asList(filter);
    // Get the file name
    File file = fileUtil.getFile(SwingUtil.getWindowInstance(this), "Import Signature GMT File", FileUtil.LOAD, all_filters);
    if (file != null) {
        String absolutePath = file.getAbsolutePath();
        textField.setForeground(PostAnalysisInputPanel.checkFile(absolutePath));
        textField.setText(absolutePath);
        textField.setValue(absolutePath);
        textField.setToolTipText(absolutePath);
        textField.setCaretPosition(textField.getText().length());
    }
    return file;
}
Also used : File(java.io.File) FileChooserFilter(org.cytoscape.util.swing.FileChooserFilter)

Example 5 with FileChooserFilter

use of org.cytoscape.util.swing.FileChooserFilter in project cytoscape-impl by cytoscape.

the class SupportedFileTypesManager method getSupportedFileTypes.

private List<FileChooserFilter> getSupportedFileTypes(final DataCategory category, final Set<CyFileFilterProvider> factories) {
    List<FileChooserFilter> types = new ArrayList<FileChooserFilter>();
    Set<String> allExtensions = new HashSet<String>();
    for (final CyFileFilterProvider factory : factories) {
        CyFileFilter filter = factory.getFileFilter();
        // this is a hack to exclude internal session table format
        if (filter.getExtensions().contains("cytable") || filter.getDataCategory() != category)
            continue;
        String description = filter.getDescription();
        Set<String> filterExtensions = filter.getExtensions();
        String[] extensions = new String[filterExtensions.size()];
        int index = 0;
        for (String extension : filterExtensions) {
            allExtensions.add(extension);
            extensions[index] = extension;
            index++;
        }
        types.add(new FileChooserFilter(description, extensions));
    }
    if (types.isEmpty())
        return types;
    Collections.sort(types, new Comparator<FileChooserFilter>() {

        @Override
        public int compare(FileChooserFilter o1, FileChooserFilter o2) {
            return o1.getDescription().compareTo(o2.getDescription());
        }
    });
    String description = String.format("All %1$s files", category.getDisplayName().toLowerCase());
    types.add(new FileChooserFilter(description, new ArrayList<String>(allExtensions).toArray(new String[allExtensions.size()])));
    return types;
}
Also used : ArrayList(java.util.ArrayList) FileChooserFilter(org.cytoscape.util.swing.FileChooserFilter) CyFileFilterProvider(org.cytoscape.io.CyFileFilterProvider) CyFileFilter(org.cytoscape.io.CyFileFilter) HashSet(java.util.HashSet)

Aggregations

FileChooserFilter (org.cytoscape.util.swing.FileChooserFilter)9 File (java.io.File)7 ArrayList (java.util.ArrayList)4 FileUtil (org.cytoscape.util.swing.FileUtil)2 TaskIterator (org.cytoscape.work.TaskIterator)2 Dialog (java.awt.Dialog)1 FileDialog (java.awt.FileDialog)1 Frame (java.awt.Frame)1 MalformedURLException (java.net.MalformedURLException)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 JComponent (javax.swing.JComponent)1 JFileChooser (javax.swing.JFileChooser)1 JMenuItem (javax.swing.JMenuItem)1 App (org.cytoscape.app.internal.manager.App)1 WebApp (org.cytoscape.app.internal.net.WebApp)1 InstallAppsFromFileTask (org.cytoscape.app.internal.task.InstallAppsFromFileTask)1 ShowInstalledAppsIfChangedTask (org.cytoscape.app.internal.task.ShowInstalledAppsIfChangedTask)1