Skip to content
Snippets Groups Projects
Commit b8872bfd authored by Radek Ošlejšek's avatar Radek Ošlejšek
Browse files

Added FileChooserBuilder

parent 97993b7b
No related branches found
No related tags found
No related merge requests found
......@@ -76,6 +76,17 @@
<artifactId>org-openide-modules</artifactId>
<version>${netbeans.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-filesystems-nb</artifactId>
<version>${netbeans.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-netbeans-modules-options-api</artifactId>
<version>${netbeans.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.jogamp.gluegen</groupId>
<artifactId>gluegen-rt-main</artifactId>
......
......@@ -13,19 +13,12 @@ import org.openide.windows.TopComponent;
import org.openide.util.NbBundle.Messages;
import cz.fidentis.analyst.Project;
import cz.fidentis.analyst.face.HumanFace;
import cz.fidentis.analyst.mesh.io.ModelFileFilter;
import cz.fidentis.analyst.gui.scene.DrawableMesh;
import java.awt.Dimension;
import cz.fidentis.analyst.face.HumanFaceFactory;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileNameExtensionFilter;
import org.openide.filesystems.FileChooserBuilder;
/**
* The main panel enabling analysts to select the primary and secondary faces,
......@@ -289,6 +282,25 @@ public final class ProjectTopComp extends TopComponent {
* Loads model selected in file chooser by user
*/
public void loadModel () {
File file = new FileChooserBuilder(ProjectTopComp.class)
.setTitle("Open human face(s)")
.setDefaultWorkingDirectory(new File (System.getProperty("user.home")))
//.setApproveText("Add")
.setFileFilter(new FileNameExtensionFilter("obj files (*.obj)", "obj"))
.setAcceptAllFileFilterUsed(true)
.showOpenDialog();
if (file== null) {
System.out.print("No file chosen.");
} else {
String faceId = HumanFaceFactory.instance().loadFace(file);
HumanFace face = HumanFaceFactory.instance().getFace(faceId);
this.project.setPrimaryFace(face);
jLabel1.setText(face.getName());
createSingleFaceTab(face, face.getName());
}
/*
String[] extensions = new String[2];
extensions[0] = "obj";
extensions[1] = "OBJ";
......@@ -314,7 +326,9 @@ public final class ProjectTopComp extends TopComponent {
System.out.print("No file chosen.");
} else {
this.addModel(fileArray[0]);
}
}
*/
}
/**
......@@ -323,6 +337,7 @@ public final class ProjectTopComp extends TopComponent {
*
* @param file File from which model will be read
*/
/*
private void addModel (final File file) {
try {
HumanFace loadedFace;
......@@ -353,7 +368,7 @@ public final class ProjectTopComp extends TopComponent {
//TODO remove duplicate with PreferenceTopComponent
String data = "";
try {
File myObj = new File(/*propPath + */"preferences.fip");
File myObj = new File("preferences.fip");
if (myObj.length() == 0)
return data;
try (Scanner myReader = new Scanner(myObj)) {
......@@ -365,6 +380,7 @@ public final class ProjectTopComp extends TopComponent {
}
return data;
}
*/
private void createSingleFaceTab(HumanFace face, String name) {
SingleFaceTab newTab = new SingleFaceTab();
......
......@@ -9,7 +9,7 @@ import java.io.File;
* Class that enables to choose just extensions we want in the filechooser
*/
public class ModelFileFilter extends FileFilter {
private final String[] extension;
private final String description;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment