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;
}
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));
}
}
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();
}
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;
}
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;
}
Aggregations