118 lines
2.1 KiB
Java
118 lines
2.1 KiB
Java
package Application1;
|
|
|
|
import java.io.BufferedWriter;
|
|
import java.io.FileNotFoundException;
|
|
import java.io.FileOutputStream;
|
|
import java.io.FileReader;
|
|
import java.io.FileWriter;
|
|
import java.io.IOException;
|
|
import java.io.Writer;
|
|
import java.nio.file.Files;
|
|
import java.nio.file.*;
|
|
|
|
import javax.swing.JFileChooser;
|
|
import javax.swing.JPanel;
|
|
|
|
public class PathVar {
|
|
private String pathTrinus;
|
|
private String pathRevit;
|
|
|
|
|
|
public PathVar() {
|
|
pathTrinus = ".";
|
|
pathRevit = ".";
|
|
|
|
}
|
|
|
|
|
|
public void readPathFile() throws IOException{
|
|
String pathData = "";
|
|
|
|
pathData = new String(Files.readAllBytes(Paths.get("Path/Path.txt")));
|
|
String[] parts = pathData.split("\n");
|
|
if (parts[0].contentEquals("Trinus")){
|
|
pathTrinus = parts[1];
|
|
|
|
|
|
}else if (parts[2].contentEquals("Trinus")) {
|
|
pathTrinus = parts[3];
|
|
|
|
}
|
|
if (parts[2].contentEquals("Revit")) {
|
|
pathRevit = parts[3];
|
|
|
|
}else if (parts[0].contentEquals("Revit")) {
|
|
pathRevit = parts[1];
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
public void writePathFile(String pathToWrite) {
|
|
try {
|
|
BufferedWriter output;
|
|
output = new BufferedWriter(new FileWriter("Path/Path.txt",true));
|
|
output.append(pathToWrite.concat("\n"));
|
|
output.close();
|
|
|
|
} catch (FileNotFoundException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
} catch (IOException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
public void getPath (String program) {
|
|
String path = ".";
|
|
int result = -99;
|
|
JFileChooser fileChooser = new JFileChooser();
|
|
|
|
result = fileChooser.showOpenDialog(new JPanel());
|
|
if(result == JFileChooser.APPROVE_OPTION)
|
|
{
|
|
path = fileChooser.getSelectedFile().getAbsolutePath();
|
|
}
|
|
|
|
|
|
if (program == "Trinus") {
|
|
writePathFile("Trinus");
|
|
writePathFile(path);
|
|
pathTrinus = path;
|
|
|
|
}
|
|
else if (program == "Revit") {
|
|
writePathFile("Revit");
|
|
writePathFile(path);
|
|
pathRevit = path;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
public String getPathTrinus() {
|
|
return pathTrinus;
|
|
}
|
|
|
|
public String getPathRevit() {
|
|
return pathRevit;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|