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 @@ ...@@ -76,6 +76,17 @@
<artifactId>org-openide-modules</artifactId> <artifactId>org-openide-modules</artifactId>
<version>${netbeans.version}</version> <version>${netbeans.version}</version>
</dependency> </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> <dependency>
<groupId>org.jogamp.gluegen</groupId> <groupId>org.jogamp.gluegen</groupId>
<artifactId>gluegen-rt-main</artifactId> <artifactId>gluegen-rt-main</artifactId>
......
...@@ -13,19 +13,12 @@ import org.openide.windows.TopComponent; ...@@ -13,19 +13,12 @@ import org.openide.windows.TopComponent;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
import cz.fidentis.analyst.Project; import cz.fidentis.analyst.Project;
import cz.fidentis.analyst.face.HumanFace; import cz.fidentis.analyst.face.HumanFace;
import cz.fidentis.analyst.mesh.io.ModelFileFilter; import cz.fidentis.analyst.face.HumanFaceFactory;
import cz.fidentis.analyst.gui.scene.DrawableMesh;
import java.awt.Dimension;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Scanner; import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.ImageIcon; import org.openide.filesystems.FileChooserBuilder;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
/** /**
* The main panel enabling analysts to select the primary and secondary faces, * The main panel enabling analysts to select the primary and secondary faces,
...@@ -289,6 +282,25 @@ public final class ProjectTopComp extends TopComponent { ...@@ -289,6 +282,25 @@ public final class ProjectTopComp extends TopComponent {
* Loads model selected in file chooser by user * Loads model selected in file chooser by user
*/ */
public void loadModel () { 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]; String[] extensions = new String[2];
extensions[0] = "obj"; extensions[0] = "obj";
extensions[1] = "OBJ"; extensions[1] = "OBJ";
...@@ -314,7 +326,9 @@ public final class ProjectTopComp extends TopComponent { ...@@ -314,7 +326,9 @@ public final class ProjectTopComp extends TopComponent {
System.out.print("No file chosen."); System.out.print("No file chosen.");
} else { } else {
this.addModel(fileArray[0]); this.addModel(fileArray[0]);
} }
*/
} }
/** /**
...@@ -323,6 +337,7 @@ public final class ProjectTopComp extends TopComponent { ...@@ -323,6 +337,7 @@ public final class ProjectTopComp extends TopComponent {
* *
* @param file File from which model will be read * @param file File from which model will be read
*/ */
/*
private void addModel (final File file) { private void addModel (final File file) {
try { try {
HumanFace loadedFace; HumanFace loadedFace;
...@@ -353,7 +368,7 @@ public final class ProjectTopComp extends TopComponent { ...@@ -353,7 +368,7 @@ public final class ProjectTopComp extends TopComponent {
//TODO remove duplicate with PreferenceTopComponent //TODO remove duplicate with PreferenceTopComponent
String data = ""; String data = "";
try { try {
File myObj = new File(/*propPath + */"preferences.fip"); File myObj = new File("preferences.fip");
if (myObj.length() == 0) if (myObj.length() == 0)
return data; return data;
try (Scanner myReader = new Scanner(myObj)) { try (Scanner myReader = new Scanner(myObj)) {
...@@ -365,6 +380,7 @@ public final class ProjectTopComp extends TopComponent { ...@@ -365,6 +380,7 @@ public final class ProjectTopComp extends TopComponent {
} }
return data; return data;
} }
*/
private void createSingleFaceTab(HumanFace face, String name) { private void createSingleFaceTab(HumanFace face, String name) {
SingleFaceTab newTab = new SingleFaceTab(); SingleFaceTab newTab = new SingleFaceTab();
......
...@@ -9,7 +9,7 @@ import java.io.File; ...@@ -9,7 +9,7 @@ import java.io.File;
* Class that enables to choose just extensions we want in the filechooser * Class that enables to choose just extensions we want in the filechooser
*/ */
public class ModelFileFilter extends FileFilter { public class ModelFileFilter extends FileFilter {
private final String[] extension; private final String[] extension;
private final String description; 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