Java Code Examples for javax.swing.JFileChooser.setFileFilter()

The following are Jave code examples for showing how to use setFileFilter() of the javax.swing.JFileChooser class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: jaer   File: DavisDeepLearnCnnProcessor_HJ.java   Source Code and License Vote up 6 votes
/**
 * Loads a convolutional neural network (CNN) trained using DeapLearnToolbox
 * for Matlab (https://github.com/rasmusbergpalm/DeepLearnToolbox) that was
 * exported using Danny Neil's XML Matlab script cnntoxml.m.
 *
 */
synchronized public void doLoadApsDvsNetworkFromXML() {
    JFileChooser c = new JFileChooser(lastApsDvsNetXMLFilename);
    FileFilter filt = new FileNameExtensionFilter("XML File", "xml");
    c.addChoosableFileFilter(filt);
    c.setFileFilter(filt);
    c.setSelectedFile(new File(lastApsDvsNetXMLFilename));
    int ret = c.showOpenDialog(chip.getAeViewer());
    if (ret != JFileChooser.APPROVE_OPTION) {
        return;
    }
    lastApsDvsNetXMLFilename = c.getSelectedFile().toString();
    putString("lastAPSNetXMLFilename", lastApsDvsNetXMLFilename);
    try {
        apsDvsNet.loadFromXMLFile(c.getSelectedFile());
        dvsSubsampler = new DvsFramerSingleFrame(chip);
        dvsSubsampler.setFromNetwork(apsDvsNet);
    } catch (Exception ex) {
        Logger.getLogger(DavisDeepLearnCnnProcessor_HJ.class.getName()).log(Level.SEVERE, null, ex);
        JOptionPane.showMessageDialog(chip.getAeViewer().getFilterFrame(), "Couldn't load net from this file, caught exception " + ex + ". See console for logging.", "Bad network file", JOptionPane.WARNING_MESSAGE);
    }

}
 
Example 2
Project: applecommander   File: SwingAppleCommander.java   Source Code and License Vote up 6 votes
/**
 * Open a file.
 */
protected void openFile() {
	JFileChooser jc = new JFileChooser();
	String pathName = userPreferences.getDiskImageDirectory();
	if (null == pathName) {
		pathName = ""; //$NON-NLS-1$
		}
	jc.setCurrentDirectory(new File(pathName));
	EmulatorFileFilter ff = new EmulatorFileFilter();
	jc.setFileFilter(ff);
	int rc = jc.showDialog(this, textBundle.get("Open")); //$NON-NLS-1$
	if (rc == 0) {
		userPreferences.setDiskImageDirectory(jc.getSelectedFile().getParent());
		UserPreferences.getInstance().save();
		addDiskExplorerTab(jc.getSelectedFile());
	}
}
 
Example 3
Project: jaer   File: AbstractDavisCNNProcessor.java   Source Code and License Vote up 6 votes
private File openFileDialogAndGetFile(String tip, String key, String type, String... ext) {
    File file = null;
    JFileChooser c = new JFileChooser(lastNetworkFilename);
    File f = new File(lastNetworkFilename);
    c.setCurrentDirectory(new File(getString("lastNetworkPathname", "")));
    c.setToolTipText(tip);
    FileFilter filt = new FileNameExtensionFilter(type, ext);
    c.addChoosableFileFilter(filt);
    c.setFileFilter(filt);
    c.setSelectedFile(new File(lastNetworkFilename));
    int ret = c.showOpenDialog(chip.getAeViewer());
    if (ret != JFileChooser.APPROVE_OPTION) {
        return null;
    }
    lastNetworkFilename = c.getSelectedFile().toString();
    putString(key, lastNetworkFilename);
    lastNetworkPathname = f.getPath();
    putString("lastNetworkPathname", lastNetworkPathname);
    file = c.getSelectedFile();
    return file;
}
 
Example 4
Project: incubator-netbeans   File: JFXIconsPanel.java   Source Code and License Vote up 6 votes
private void nativeIconButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nativeIconButtonActionPerformed
    JFileChooser chooser = new JFileChooser();
    chooser.setCurrentDirectory(null);
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.setMultiSelectionEnabled(false);
    chooser.setFileFilter(new IconFileFilter(false));
    String current = nativeIconTextField.getText();
    File lastFolder = current!=null ? getFileFromPath(current) : null;
    if (lastFolder != null) {
        chooser.setSelectedFile(lastFolder);
    } else if (lastImageFolder != null) {
        chooser.setSelectedFile(lastImageFolder);
    } else { // ???
        // workDir = FileUtil.toFile(project.getProjectDirectory()).getAbsolutePath();
        // chooser.setSelectedFile(new File(workDir));
    }
    chooser.setDialogTitle(NbBundle.getMessage(JFXIconsPanel.class, "LBL_Select_Icon_Image")); // NOI18N
    if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
        File file = FileUtil.normalizeFile(chooser.getSelectedFile());
        String relPath = JFXProjectUtils.getRelativePath(project.getProjectDirectory(), FileUtil.toFileObject(file));
        nativeIconTextField.setText(relPath);
        lastImageFolder = file;
    }
}
 
Example 5
Project: incubator-netbeans   File: ConfigureFXMLControllerPanelVisual.java   Source Code and License Vote up 6 votes
private void chooseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chooseButtonActionPerformed
    JFileChooser chooser = new JFileChooser(new FXMLTemplateWizardIterator.SrcFileSystemView(support.getSourceGroupsAsFiles()));
    chooser.setDialogTitle(NbBundle.getMessage(ConfigureFXMLControllerPanelVisual.class, "LBL_ConfigureFXMLPanel_FileChooser_Select_Controller")); // NOI18N
    chooser.setFileFilter(FXMLTemplateWizardIterator.FXMLTemplateFileFilter.createJavaFilter());
    String existingPath = existingNameTextField.getText();
    if (existingPath.length() > 0) {
        File f = new File(support.getCurrentChooserFolder().getPath() + File.pathSeparator + existingPath);
        if (f.exists()) {
            chooser.setSelectedFile(f);
        } else {
            chooser.setCurrentDirectory(FileUtil.toFile(support.getCurrentChooserFolder()));
        }
    } else {
        chooser.setCurrentDirectory(FileUtil.toFile(support.getCurrentChooserFolder()));
    }
    
    if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
        String controllerClass = FileUtil.normalizeFile(chooser.getSelectedFile()).getPath();
        // XXX check other roots ?
        final String srcPath = FileUtil.normalizeFile(FileUtil.toFile(support.getCurrentSourceGroupFolder())).getPath();
        final String relativePath = controllerClass.substring(srcPath.length() + 1);
        final String relativePathWithoutExt = relativePath.substring(0, relativePath.indexOf(FXMLTemplateWizardIterator.JAVA_FILE_EXTENSION));
        existingNameTextField.setText(relativePathWithoutExt.replace(File.separatorChar, '.')); // NOI18N
    }
}
 
Example 6
Project: cuttlefish   File: NetworkInitializer.java   Source Code and License Vote up 6 votes
public void initCxfNetwork(CxfNetwork cxfNetwork) {
	 JFileChooser fc = new FileChooser();		 		 
	 fc.setDialogTitle("Select a CXF file");
	 fc.setFileFilter(new FileNameExtensionFilter(".cxf files", "cxf"));
	 int returnVal = fc.showOpenDialog(null);

        if (returnVal == JFileChooser.APPROVE_OPTION) {
       	 ch.ethz.sg.cuttlefish.gui2.Cuttlefish.currentDirectory = fc.getCurrentDirectory();
       	 System.out.println("Current directory: " + fc.getCurrentDirectory());
            File file = fc.getSelectedFile();             
            cxfNetwork.load(file);
            cxfNetwork.setNetworkLoaded(true);
        } else {
            System.out.println("Input cancelled by user");
        }
}
 
Example 7
Project: incubator-netbeans   File: LocationCustomizer.java   Source Code and License Vote up 6 votes
private JFileChooser getFileChooser() {
    if (fileChooser == null) {
        JFileChooser chooser = new JFileChooser();
        chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
        chooser.setMultiSelectionEnabled(false);
        chooser.setAcceptAllFileFilterUsed(false);
        chooser.setDialogType(JFileChooser.OPEN_DIALOG);
        chooser.setDialogTitle(Bundle.LocationCustomizer_ChooseFileDialogCaption());
        chooser.setFileFilter(new FileFilter() {
                public boolean accept(File f) {
                    return f.isDirectory() || f.getName().toLowerCase().endsWith(".java");
                } // NOI18N

                public String getDescription() {
                    return Bundle.LocationCustomizer_FileDialogFilterName();
                }
            });
        fileChooser = chooser;
    }

    return fileChooser;
}
 
Example 8
Project: ISO8583   File: PnlMain.java   Source Code and License Vote up 5 votes
private void openFile() {
	JFileChooser file = new JFileChooser();
	file.setAcceptAllFileFilterUsed(false);
	file.setFileFilter(new FileNameExtensionFilter("xml files (*.xml)", "xml"));
	
	if (lastCurrentDirectory != null) 
		file.setCurrentDirectory(lastCurrentDirectory);
	
	if (file.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
		txtFilePath.setText(file.getSelectedFile().getAbsolutePath());
		lastCurrentDirectory = file.getSelectedFile();			

		openXML();
	}
}
 
Example 9
Project: incubator-netbeans   File: Selenium2Customizer.java   Source Code and License Vote up 5 votes
private void bSeleniumServerJarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bSeleniumServerJarActionPerformed
    JFileChooser chooser = new JFileChooser();
    chooser.setAcceptAllFileFilterUsed(false);
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.setFileFilter(new FileNameExtensionFilter("Jar File", "jar"));
    chooser.setSelectedFile(new File(tfSeleniumServerJar.getText().trim()));
    if (chooser.showOpenDialog(SwingUtilities.getWindowAncestor(this)) == JFileChooser.APPROVE_OPTION) {
        tfSeleniumServerJar.setText(chooser.getSelectedFile().getAbsolutePath());
        updateValidity();
    }
}
 
Example 10
Project: ramus   File: Preferences.java   Source Code and License Vote up 5 votes
private void addItem() {
    JFileChooser chooser = new JFileChooser();
    chooser.setFileFilter(fileFilter);
    int r = chooser.showOpenDialog(this);
    if (r == JFileChooser.APPROVE_OPTION) {
        File f = chooser.getSelectedFile();
        Item item = new Item();
        item.fileName = f.getAbsolutePath();
        items.add(item);
        model.fireTableRowsInserted(items.size() - 1, items.size() - 1);
    }
}
 
Example 11
Project: geomapapp   File: PDB.java   Source Code and License Vote up 5 votes
protected void saveAsExcel(Iterator it) {
	JFileChooser jfc = new JFileChooser(System.getProperty("user.home"));
	ExcelFileFilter eff = new ExcelFileFilter();
	jfc.setFileFilter(eff);
	File f=new File("PDB_Export.xls");
	jfc.setSelectedFile(f);
	do {
		int c = jfc.showSaveDialog(null);
		if (c==jfc.CANCEL_OPTION||c==jfc.ERROR_OPTION) return;
		f = jfc.getSelectedFile();
		if (f.exists()) {
			c=JOptionPane.showConfirmDialog(null, "File Already Exists\nConfirm Overwrite");
			if (c==JOptionPane.OK_OPTION) break;
			if (c==JOptionPane.CANCEL_OPTION) return;
		}
	} while (f.exists());

	try {
		WritableWorkbook wb = Workbook.createWorkbook(f);
		WritableSheet sheet = wb.createSheet("First Sheet", 0);

		int r = 0;
		while (it.hasNext()) {
			String[] split = it.next().toString().split("\\t");
			for (int i = 0; i < split.length; i++)
				sheet.addCell( new Label(i,r,split[i]) );
			r++;
		}

		wb.write();
		wb.close();
	} catch (Exception ex){
	}
}
 
Example 12
Project: SASS   File: FluorophoreGenerator.java   Source Code and License Vote up 5 votes
private static File getFileFromDialog() {
    JFileChooser fc = new JFileChooser();
    int returnVal;
    fc.setDialogType(JFileChooser.OPEN_DIALOG);
    //set a default filename 
    fc.setSelectedFile(new File("emitters.csv"));
    //Set an extension filter
    fc.setFileFilter(new FileNameExtensionFilter("CSV file","csv"));
    returnVal = fc.showOpenDialog(null);
    if  (returnVal != JFileChooser.APPROVE_OPTION) {
        throw new RuntimeException("You need to select an emitter file!");
    }
    return fc.getSelectedFile();
}
 
Example 13
Project: jaer   File: SyncPlayer.java   Source Code and License Vote up 5 votes
/** this call shows a file chooser for index files: files containing
     * information on which AE data files go together. This method is only called when an index file is opened.
     */
    public void openAEInputFileDialog() {
        fileChooser = new JFileChooser();
        IndexFileFilter filter = new IndexFileFilter();
        String lastFilePath = prefs.get("JAERViewer.lastFile", "");
        // get the last folder
        lastFile = new File(lastFilePath);
        fileChooser.setFileFilter(filter);
        fileChooser.setCurrentDirectory(lastFile);
        // sets the working directory of the chooser
//            boolean wasPaused=isPaused();
        setPaused(true);
        int retValue = fileChooser.showOpenDialog(null);
        if (retValue == JFileChooser.APPROVE_OPTION) {
            try {
                lastFile = fileChooser.getSelectedFile();
//                    if(lastFile!=null) recentFiles.addFile(lastFile);
                startPlayback(lastFile);
                lastFilePath = lastFile.getPath();
                prefs.put("JAERViewer.lastFile", lastFilePath);
            } catch (IOException fnf) {
                fnf.printStackTrace();
            }
        }
        fileChooser = null;
        setPaused(false);
    }
 
Example 14
Project: Equella   File: JFileSelector.java   Source Code and License Vote up 5 votes
@Override
protected void buttonSelected()
{
	JFileChooser chooser = new JFileChooser(currentDirectory);
	chooser.setMultiSelectionEnabled(false);
	chooser.setFileSelectionMode(selectionMode);
	chooser.setFileFilter(filter);

	int result = chooser.showOpenDialog(this);
	if( result == JFileChooser.APPROVE_OPTION )
	{
		setSelectedFile(chooser.getSelectedFile());
	}
}
 
Example 15
Project: iTrace-Archive   File: JSONBasicFixationFilter.java   Source Code and License Vote up 5 votes
@Override
public File[] filterUI() {
	JFileChooser chooser = new JFileChooser();
	FileNameExtensionFilter filter = new FileNameExtensionFilter(
			"JSON Files", "json");
	chooser.setFileFilter(filter);
	chooser.setMultiSelectionEnabled(true);
	int returnVal = chooser.showOpenDialog(null);
	if(returnVal == JFileChooser.APPROVE_OPTION) {
		return chooser.getSelectedFiles();
	} else {
		return null;
	}
}
 
Example 16
Project: Mujeed-Arabic-Prolog   File: OpenFileListener.java   Source Code and License Vote up 5 votes
@Override
public void actionPerformed(ActionEvent e) {
	// TODO Auto-generated method stub
	JFileChooser fileChooser = new JFileChooser(WorkspaceFile.getPathWorkspace());
	FileNameExtensionFilter filter = new FileNameExtensionFilter("Arabic Prolog", "apl", "Arabic Prolog");
	fileChooser.setFileFilter(filter);
	int status = fileChooser.showOpenDialog(null);
	if (status == JFileChooser.APPROVE_OPTION) {
		String absolutePath = fileChooser.getSelectedFile().getAbsolutePath();	
		String fileName = "";
		try {
			 fileName = getNameFile(absolutePath);
		} catch (Exception e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		int showedAt = showedTabAt(PrincipalWindow.tabbedPaneProgram,fileName+".apl");
		if(showedAt == -1){
			PanelCode panelCode = new PanelCode(fileName,absolutePath,true);
			PrincipalWindow.tabbedPaneProgram.addTab(fileName+".apl", panelCode);
			PrincipalWindow.tabbedPaneProgram.setSelectedComponent(panelCode);
			PrincipalWindow.tabbedPaneProgram.setTabComponentAt(PrincipalWindow.tabbedPaneProgram.getSelectedIndex(),
				new gui_tools.ButtonTabComponent(PrincipalWindow.tabbedPaneProgram));}
		else{
			PrincipalWindow.tabbedPaneProgram.setSelectedIndex(showedAt);
		}
	}	

}
 
Example 17
Project: Tarski   File: EditorActions.java   Source Code and License Vote up 4 votes
/**
 * 
 */
public void actionPerformed(ActionEvent e) {
  BasicGraphEditor editor = getEditor(e);

  if (editor != null) {
    if (!editor.isModified() || JOptionPane.showConfirmDialog(editor,
        mxResources.get("loseChanges")) == JOptionPane.YES_OPTION) {
      mxGraph graph = editor.getGraphComponent().getGraph();

      if (graph != null) {
        String wd = (lastDir != null) ? lastDir : System.getProperty("user.dir");

        JFileChooser fc = new JFileChooser(wd);

        // Adds file filter for supported file format
        DefaultFileFilter defaultFilter = new DefaultFileFilter(".mxe",
            mxResources.get("allSupportedFormats") + " (.mxe, .png, .vdx)") {

          public boolean accept(File file) {
            String lcase = file.getName().toLowerCase();

            return super.accept(file) || lcase.endsWith(".png") || lcase.endsWith(".vdx");
          }
        };
        fc.addChoosableFileFilter(defaultFilter);

        fc.addChoosableFileFilter(new DefaultFileFilter(".mxe",
            "mxGraph Editor " + mxResources.get("file") + " (.mxe)"));
        fc.addChoosableFileFilter(
            new DefaultFileFilter(".png", "PNG+XML  " + mxResources.get("file") + " (.png)"));

        // Adds file filter for VDX import
        fc.addChoosableFileFilter(new DefaultFileFilter(".vdx",
            "XML Drawing  " + mxResources.get("file") + " (.vdx)"));

        // Adds file filter for GD import
        fc.addChoosableFileFilter(new DefaultFileFilter(".txt",
            "Graph Drawing  " + mxResources.get("file") + " (.txt)"));

        fc.setFileFilter(defaultFilter);

        int rc = fc.showDialog(null, mxResources.get("openFile"));

        if (rc == JFileChooser.APPROVE_OPTION) {
          lastDir = fc.getSelectedFile().getParent();

          try {
            if (fc.getSelectedFile().getAbsolutePath().toLowerCase().endsWith(".png")) {
              openXmlPng(editor, fc.getSelectedFile());
            } else if (fc.getSelectedFile().getAbsolutePath().toLowerCase().endsWith(".txt")) {
              openGD(editor, fc.getSelectedFile(),
                  mxUtils.readFile(fc.getSelectedFile().getAbsolutePath()));
            } else {
              Document document =
                  mxXmlUtils.parseXml(mxUtils.readFile(fc.getSelectedFile().getAbsolutePath()));

              mxCodec codec = new mxCodec(document);
              codec.decode(document.getDocumentElement(), graph.getModel());
              editor.setCurrentFile(fc.getSelectedFile());

              resetEditor(editor);
            }
          } catch (IOException ex) {
            ex.printStackTrace();
            JOptionPane.showMessageDialog(editor.getGraphComponent(), ex.toString(),
                mxResources.get("error"), JOptionPane.ERROR_MESSAGE);
          }
        }
      }
    }
  }
}
 
Example 18
Project: jaer   File: CypressFX2EEPROM.java   Source Code and License Vote up 4 votes
private void chooseFileButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chooseFileButtonActionPerformed
        String defaultPath = System.getProperty("user.dir") + File.separatorChar + "devices/firmware/CypressFX2";
        String startDir = prefs.get("CypressFX2EEPROM.filepath", defaultPath);
        JFileChooser chooser = new JFileChooser(startDir);
//        JFileChooser chooser=new JFileChooser();
        FileFilter filter = new FileFilter() {

            @Override
			public boolean accept(File f) {
                //if(f.getName().toLowerCase().endsWith(".iic") || f.getName().toLowerCase().endsWith(".hex") || f.isDirectory())
                if (f.getName().toLowerCase().endsWith(".iic") || f.getName().toLowerCase().endsWith(".bix") || f.getName().toLowerCase().endsWith(".hex") || f.isDirectory()) // hex download stopped working, only accept iic for the moment
                {
                    return true;
                } else {
                    return false;
                }
            }

            @Override
			public String getDescription() {
                return "Binary IIC format firmware download file for Cypress FX2";
            }
        };
        chooser.setFileFilter(filter);
        chooser.setApproveButtonText("Choose");
        chooser.setToolTipText("Choose a binary download file (they are in the source path, e.g. ch/unizh/ini/caviar/hardwareinterface/usb)");
        int returnVal = chooser.showOpenDialog(this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = chooser.getSelectedFile();
            try {
                log.info("You chose this file: " + file.getCanonicalFile());
                filenameTextField.setText(file.getCanonicalPath());
                filenameTextField.setToolTipText(file.getCanonicalPath());
                prefs.put("CypressFX2EEPROM.filename", file.getCanonicalPath());
                prefs.put("CypressFX2EEPROM.filepath", file.getCanonicalPath());
                setEEPROMRAMRadioButtonsAccordingToFileType(file);
            } catch (IOException ex) {
                JOptionPane.showMessageDialog(this, ex);
            }
        }
    }
 
Example 19
Project: jaer   File: AEPlayer.java   Source Code and License Vote up 4 votes
/**
     * Called when user asks to open data file file dialog.
     */
    @Override
    public void openAEInputFileDialog() {
//        try{Thread.currentThread().sleep(200);}catch(InterruptedException e){}
        float oldScale = viewer.chipCanvas.getScale();
        fileChooser = new JFileChooser();
//            new TypeAheadSelector(fileChooser);
        //com.sun.java.plaf.windows.WindowsFileChooserUI;
//            fileChooser.addKeyListener(new KeyAdapter() {
//                public void keyTyped(KeyEvent e){
//                    System.out.println("keycode="+e.getKeyCode());
//                }
//            });
//            System.out.println("fileChooser.getUIClassID()="+fileChooser.getUIClassID());
//            KeyListener[] keyListeners=fileChooser.getKeyListeners();
        ChipDataFilePreview preview = new ChipDataFilePreview(fileChooser, viewer.getChip());
        // from book swing hacks
        new FileDeleter(fileChooser, preview);
        fileChooser.addPropertyChangeListener(preview);
        fileChooser.setAccessory(preview);
        String lastFilePath = AEViewer.prefs.get("AEViewer.lastFile", "");
        // get the last folder
        viewer.lastFile = new File(lastFilePath);
//            fileChooser.setFileFilter(datFileFilter);
        IndexFileFilter indexFileFilter = new IndexFileFilter();
        fileChooser.addChoosableFileFilter(indexFileFilter);
        DATFileFilter datFileFilter = new DATFileFilter();
        fileChooser.addChoosableFileFilter(datFileFilter);
        if (lastFilter == null) {
            fileChooser.setFileFilter(datFileFilter);
        } else {
            fileChooser.setFileFilter(lastFilter);
        }
        fileChooser.setCurrentDirectory(viewer.lastFile);
        // sets the working directory of the chooser
//            boolean wasPaused=isPaused();
        setPaused(true);
        try {
            int retValue = fileChooser.showOpenDialog(viewer);
            if (retValue == JFileChooser.APPROVE_OPTION) {
                lastFilter = fileChooser.getFileFilter();
                try {
                    viewer.lastFile = fileChooser.getSelectedFile();
                    if (viewer.lastFile != null) {
                        viewer.recentFiles.addFile(viewer.lastFile);
                    }
                    startPlayback(viewer.lastFile);
                } catch (IOException fnf) {
                    log.warning(fnf.toString());
                }
            } else {
                preview.showFile(null);
            }
        } catch (GLException e) {
            log.warning(e.toString());
            preview.showFile(null);
        }
        fileChooser = null;
//        viewer.chipCanvas.setScale(oldScale);
        // restore persistent scale so that we don't get tiny size on next startup
        setPaused(false);
    }
 
Example 20
Project: AgentWorkbench   File: ChartEditorJPanel.java   Source Code and License Vote up 4 votes
@Override
public void actionPerformed(ActionEvent ae) {
	
	if (ae.getSource() == jButtonCsvImport){
		// --- Import CSV data / Choose file ----------
		JFileChooser jFileChooserImportCSV = new JFileChooser(Application.getGlobalInfo().getLastSelectedFolder());
		jFileChooserImportCSV.setFileFilter(new FileNameExtensionFilter(Language.translate("CSV-Dateien"), "csv"));
		jFileChooserImportCSV.setDialogTitle(Language.translate("CSV-Datei importieren"));
		if(jFileChooserImportCSV.showOpenDialog(this) == JFileChooser.APPROVE_OPTION){
			Application.getGlobalInfo().setLastSelectedFolder(jFileChooserImportCSV.getCurrentDirectory());
			File csvFile = jFileChooserImportCSV.getSelectedFile();
			
			// --- Separate DataModel --------------------------- 
			if (this.getDataModel() instanceof TimeSeriesDataModel) {
				// --- Ask for time format ----------------------
				TimeFormatImportConfiguration importFormatDialog = new TimeFormatImportConfiguration(Application.getMainWindow(), csvFile); 
				importFormatDialog.setVisible(true);
				// - - - - - - - - - - - - - - - - - - - - - - -  
				if (importFormatDialog.isCanceled()==true) return;
				// --- Import data ------------------------------
				this.importDataSeriesFromCSV(csvFile, importFormatDialog.getTimeFormat(), importFormatDialog.getTimeOffset());
				
			} else {
				// --- Import data ------------------------------
				this.importDataSeriesFromCSV(csvFile, null, null);	
				
			}
			this.getTableTab().setButtonsEnabledToSituation();
		}
		
	} else if(ae.getSource() == jButtonSaveAsImage) {
		// --- Export the image ---------------------------------
		this.saveAsImage();
	} else if(ae.getSource() == tfImageWidth) {
		// --- Recalculate image size when enter was pressed ----
		this.recalculateImageHeight();
	}else if(ae.getSource() == tfImageHeight){
		// --- Recalculate image size when enter was pressed-----
		this.recalculateImageWidth();
	}else if(ae.getSource() == cbImageAspectRatio){
		// --- Recalculate image size when aspect ratio changed -
		this.recalculateImageHeight();
	}else if(ae.getSource() == jButtonCsvExport){
		this.exportDataAsCSV();
	}

}