88 lines
2.1 KiB
Java
88 lines
2.1 KiB
Java
package fenetres;
|
|
|
|
import java.awt.Component;
|
|
import java.awt.Dimension;
|
|
import java.awt.HeadlessException;
|
|
import java.awt.Image;
|
|
import java.io.File;
|
|
import javax.swing.ImageIcon;
|
|
import javax.swing.JDialog;
|
|
import javax.swing.JFileChooser;
|
|
import javax.swing.filechooser.FileNameExtensionFilter;
|
|
import MEPTL.commandes;
|
|
import baseEvaluations.recupeNodeBaseEvaluations;
|
|
|
|
/**
|
|
*
|
|
* @author pabr6
|
|
*
|
|
*/
|
|
public class ChargePathBaseEvaluation extends JFileChooser {
|
|
|
|
/**
|
|
*
|
|
*/
|
|
private static final long serialVersionUID = 1L;
|
|
boolean avecFusion = false;
|
|
|
|
/**
|
|
*
|
|
* @param avecFusion : Si True ajoute les évaluations de la seconde base
|
|
*/
|
|
public ChargePathBaseEvaluation() {
|
|
|
|
setDialogTitle("Sélectionner la base de données des évaluations.");
|
|
|
|
FileNameExtensionFilter filter = new FileNameExtensionFilter("Base de données des évaluations", "xml");
|
|
setFileFilter(filter);
|
|
setPreferredSize(new Dimension(550, 420));
|
|
|
|
int response = showOpenDialog(null);
|
|
if(response == JFileChooser.APPROVE_OPTION) {
|
|
|
|
|
|
File file = new File(getSelectedFile().getAbsolutePath());
|
|
String ext = file.getName().substring(file.getName().lastIndexOf("."));
|
|
|
|
if(ext.equals(".xml")){
|
|
openFileXML(file);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
protected JDialog createDialog( Component parent ) throws HeadlessException {
|
|
JDialog dialog = super.createDialog( parent );
|
|
Image img = new ImageIcon(getClass().getResource("/evalwriter.png") ).getImage();
|
|
dialog.setIconImage(img);
|
|
return dialog;
|
|
}
|
|
|
|
|
|
/**
|
|
*
|
|
* @param file
|
|
*/
|
|
private void openFileXML(File file) {
|
|
|
|
|
|
if(commandes.os.contains("Win")) {
|
|
commandes.path = file.getPath().substring(0,file.getPath().lastIndexOf("\\")); // Sur Windows
|
|
}else {
|
|
commandes.path = file.getPath().substring(0,file.getPath().lastIndexOf("/")); // Sur mac & Linux
|
|
}
|
|
|
|
String directoryName = getCurrentDirectory().getPath();
|
|
String nameNewBase = file.getName().toString();
|
|
|
|
|
|
new recupeNodeBaseEvaluations(directoryName,nameNewBase);
|
|
|
|
}
|
|
|
|
|
|
}
|