From 5b97e63ac7c7559721bde72cc417741e7bd5cbf8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Kov=C3=A1r?= <matko@192.168.1.105>
Date: Thu, 15 Apr 2021 09:58:13 +0200
Subject: [PATCH] updated javadocs, added "remove primary face" method

---
 .../fidentis/analyst/gui/ProjectTopComp.form  |  3 ++
 .../fidentis/analyst/gui/ProjectTopComp.java  | 29 ++++++++++++++++---
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/GUI/src/main/java/cz/fidentis/analyst/gui/ProjectTopComp.form b/GUI/src/main/java/cz/fidentis/analyst/gui/ProjectTopComp.form
index 3d1f550a..4f1add03 100644
--- a/GUI/src/main/java/cz/fidentis/analyst/gui/ProjectTopComp.form
+++ b/GUI/src/main/java/cz/fidentis/analyst/gui/ProjectTopComp.form
@@ -181,6 +181,9 @@
                   <ResourceString bundle="cz/fidentis/analyst/gui/Bundle.properties" key="ProjectTopComp.removeButton1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
                 </Property>
               </Properties>
+              <Events>
+                <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="removeButton1MouseClicked"/>
+              </Events>
               <Constraints>
                 <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
                   <GridBagConstraints gridX="1" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="16" insetsLeft="22" insetsBottom="13" insetsRight="4" anchor="18" weightX="0.0" weightY="0.0"/>
diff --git a/GUI/src/main/java/cz/fidentis/analyst/gui/ProjectTopComp.java b/GUI/src/main/java/cz/fidentis/analyst/gui/ProjectTopComp.java
index 2b7073b1..f64d1a36 100644
--- a/GUI/src/main/java/cz/fidentis/analyst/gui/ProjectTopComp.java
+++ b/GUI/src/main/java/cz/fidentis/analyst/gui/ProjectTopComp.java
@@ -15,7 +15,6 @@ import cz.fidentis.analyst.face.HumanFace;
 import cz.fidentis.analyst.mesh.io.ModelFileFilter;
 import java.awt.Dimension;
 import java.io.File;
-import java.io.IOException;
 import javax.swing.ImageIcon;
 import javax.swing.JFileChooser;
 import javax.swing.JOptionPane;
@@ -52,6 +51,9 @@ public final class ProjectTopComp extends TopComponent {
 
     private Project project;
     
+    /**
+     * Creates new ProjectTopComp, initializes new project
+     */
     public ProjectTopComp() {
         project = new Project();
         initComponents();
@@ -139,6 +141,11 @@ public final class ProjectTopComp extends TopComponent {
 
         removeButton1.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
         org.openide.awt.Mnemonics.setLocalizedText(removeButton1, org.openide.util.NbBundle.getMessage(ProjectTopComp.class, "ProjectTopComp.removeButton1.text")); // NOI18N
+        removeButton1.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                removeButton1MouseClicked(evt);
+            }
+        });
         gridBagConstraints = new java.awt.GridBagConstraints();
         gridBagConstraints.gridx = 1;
         gridBagConstraints.gridy = 0;
@@ -213,11 +220,25 @@ public final class ProjectTopComp extends TopComponent {
         add(jPanel1, java.awt.BorderLayout.CENTER);
     }// </editor-fold>//GEN-END:initComponents
 
-    
+    /**
+     * 
+     * @param evt starts function for loading model
+     */
     private void addButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_addButton1MouseClicked
         loadModel();
     }//GEN-LAST:event_addButton1MouseClicked
 
+    /**
+     * TEMP. behavior, remove button will be removing selected secondary face later
+     * @param evt Removes primary face
+     */
+    private void removeButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_removeButton1MouseClicked
+        if (this.project.getPrimaryFace() != null) {
+            this.project.removePrimaryFace();
+            jLabel1.setText("");   
+        }
+    }//GEN-LAST:event_removeButton1MouseClicked
+
     // Variables declaration - do not modify//GEN-BEGIN:variables
     private javax.swing.JButton addButton1;
     private javax.swing.JButton analyzeButton1;
@@ -297,8 +318,8 @@ public final class ProjectTopComp extends TopComponent {
             HumanFace loadedFace;
             loadedFace = new HumanFace(new File (file.getPath()));
             this.project.setPrimaryFace(loadedFace);
-            jLabel1.setText("Loaded");
-        } catch (IOException e) {
+            jLabel1.setText(file.getName());
+        } catch (Exception e) {
             System.out.println(e.getMessage());
             JOptionPane.showMessageDialog(this, "File doesn't contain any model", "Model is not loaded.",
                     0, new ImageIcon(getClass().getResource("/notLoadedModel.png")));
-- 
GitLab