From 9e090d11a6f8307ef8d4f8f2e489775931b69801 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Kov=C3=A1r?= <matko@192.168.1.105>
Date: Tue, 12 Oct 2021 15:33:20 +0200
Subject: [PATCH] added checkbox to table and reduced name of models

---
 .../fidentis/analyst/core/ProjectTopComp.form | 35 ++++++--------
 .../fidentis/analyst/core/ProjectTopComp.java | 48 +++++++++----------
 .../fidentis/analyst/core/Bundle.properties   |  1 +
 3 files changed, 39 insertions(+), 45 deletions(-)

diff --git a/GUI/src/main/java/cz/fidentis/analyst/core/ProjectTopComp.form b/GUI/src/main/java/cz/fidentis/analyst/core/ProjectTopComp.form
index ed7614e9..db9edbb5 100644
--- a/GUI/src/main/java/cz/fidentis/analyst/core/ProjectTopComp.form
+++ b/GUI/src/main/java/cz/fidentis/analyst/core/ProjectTopComp.form
@@ -57,19 +57,14 @@
                       <Component id="jPanel2" alignment="0" max="32767" attributes="0"/>
                       <Component id="jPanel5" alignment="0" max="32767" attributes="0"/>
                   </Group>
-                  <EmptySpace max="-2" attributes="0"/>
-                  <Component id="jLabel1" min="-2" pref="80" max="-2" attributes="0"/>
-                  <EmptySpace min="0" pref="380" max="32767" attributes="0"/>
+                  <EmptySpace min="0" pref="450" max="32767" attributes="0"/>
               </Group>
           </Group>
         </DimensionLayout>
         <DimensionLayout dim="1">
           <Group type="103" groupAlignment="0" attributes="0">
               <Group type="102" alignment="0" attributes="0">
-                  <Group type="103" groupAlignment="0" attributes="0">
-                      <Component id="jLabel1" min="-2" pref="50" max="-2" attributes="0"/>
-                      <Component id="jPanel5" min="-2" pref="56" max="-2" attributes="0"/>
-                  </Group>
+                  <Component id="jPanel5" min="-2" pref="56" max="-2" attributes="0"/>
                   <EmptySpace max="-2" attributes="0"/>
                   <Component id="jPanel2" max="32767" attributes="0"/>
               </Group>
@@ -215,17 +210,6 @@
             </Component>
           </SubComponents>
         </Container>
-        <Component class="javax.swing.JLabel" name="jLabel1">
-          <Properties>
-            <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
-              <Font name="Tahoma" size="18" style="0"/>
-            </Property>
-            <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
-              <Color blue="cc" green="cc" red="cc" type="rgb"/>
-            </Property>
-            <Property name="horizontalAlignment" type="int" value="0"/>
-          </Properties>
-        </Component>
         <Container class="javax.swing.JPanel" name="jPanel2">
 
           <Layout>
@@ -254,12 +238,20 @@
                       <Font name="Tahoma" size="18" style="0"/>
                     </Property>
                     <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
-                      <Table columnCount="1" rowCount="0">
+                      <Table columnCount="2" rowCount="0">
+                        <Column editable="true" title="" type="java.lang.Boolean"/>
                         <Column editable="false" title="Models" type="java.lang.Object"/>
                       </Table>
                     </Property>
                     <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor">
-                      <TableColumnModel selectionModel="0">
+                      <TableColumnModel selectionModel="3">
+                        <Column maxWidth="50" minWidth="-1" prefWidth="50" resizable="true">
+                          <Title editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+                            <ResourceString bundle="cz/fidentis/analyst/core/Bundle.properties" key="ProjectTopComp.jTable1.columnModel.title1_1" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
+                          </Title>
+                          <Editor/>
+                          <Renderer/>
+                        </Column>
                         <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
                           <Title editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
                             <ResourceString bundle="cz/fidentis/analyst/core/Bundle.properties" key="ProjectTopComp.jTable1.columnModel.title0_1" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
@@ -269,10 +261,11 @@
                         </Column>
                       </TableColumnModel>
                     </Property>
+                    <Property name="columnSelectionAllowed" type="boolean" value="true"/>
                     <Property name="dragEnabled" type="boolean" value="true"/>
                     <Property name="rowHeight" type="int" value="40"/>
                     <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor">
-                      <TableHeader reorderingAllowed="true" resizingAllowed="true"/>
+                      <TableHeader reorderingAllowed="false" resizingAllowed="true"/>
                     </Property>
                   </Properties>
                 </Component>
diff --git a/GUI/src/main/java/cz/fidentis/analyst/core/ProjectTopComp.java b/GUI/src/main/java/cz/fidentis/analyst/core/ProjectTopComp.java
index 00925490..7cff4527 100644
--- a/GUI/src/main/java/cz/fidentis/analyst/core/ProjectTopComp.java
+++ b/GUI/src/main/java/cz/fidentis/analyst/core/ProjectTopComp.java
@@ -93,7 +93,6 @@ public final class ProjectTopComp extends TopComponent {
         collapseButton1 = new javax.swing.JButton();
         inflateButton1 = new javax.swing.JButton();
         analyzeButton1 = new javax.swing.JButton();
-        jLabel1 = new javax.swing.JLabel();
         jPanel2 = new javax.swing.JPanel();
         jScrollPane1 = new javax.swing.JScrollPane();
         jTable1 = new javax.swing.JTable();
@@ -198,10 +197,6 @@ public final class ProjectTopComp extends TopComponent {
         gridBagConstraints.insets = new java.awt.Insets(16, 43, 13, 25);
         jPanel5.add(analyzeButton1, gridBagConstraints);
 
-        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
-        jLabel1.setForeground(new java.awt.Color(204, 204, 204));
-        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
-
         jTable1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
         jTable1.getTableHeader().setOpaque(false);
         jTable1.getTableHeader().setBackground(new java.awt.Color(204,204,204));
@@ -211,22 +206,35 @@ public final class ProjectTopComp extends TopComponent {
 
             },
             new String [] {
-                "Models"
+                "", "Models"
             }
         ) {
+            Class[] types = new Class [] {
+                java.lang.Boolean.class, java.lang.Object.class
+            };
             boolean[] canEdit = new boolean [] {
-                false
+                true, false
             };
 
+            public Class getColumnClass(int columnIndex) {
+                return types [columnIndex];
+            }
+
             public boolean isCellEditable(int rowIndex, int columnIndex) {
                 return canEdit [columnIndex];
             }
         });
+        jTable1.setColumnSelectionAllowed(true);
         jTable1.setDragEnabled(true);
         jTable1.setRowHeight(40);
+        jTable1.getTableHeader().setReorderingAllowed(false);
         jScrollPane1.setViewportView(jTable1);
+        jTable1.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
         if (jTable1.getColumnModel().getColumnCount() > 0) {
-            jTable1.getColumnModel().getColumn(0).setHeaderValue(org.openide.util.NbBundle.getMessage(ProjectTopComp.class, "ProjectTopComp.jTable1.columnModel.title0_1")); // NOI18N
+            jTable1.getColumnModel().getColumn(0).setPreferredWidth(50);
+            jTable1.getColumnModel().getColumn(0).setMaxWidth(50);
+            jTable1.getColumnModel().getColumn(0).setHeaderValue(org.openide.util.NbBundle.getMessage(ProjectTopComp.class, "ProjectTopComp.jTable1.columnModel.title1_1")); // NOI18N
+            jTable1.getColumnModel().getColumn(1).setHeaderValue(org.openide.util.NbBundle.getMessage(ProjectTopComp.class, "ProjectTopComp.jTable1.columnModel.title0_1")); // NOI18N
         }
 
         javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
@@ -248,16 +256,12 @@ public final class ProjectTopComp extends TopComponent {
                 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                     .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                     .addComponent(jPanel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
-                .addGap(0, 380, Short.MAX_VALUE))
+                .addGap(0, 450, Short.MAX_VALUE))
         );
         jPanel1Layout.setVerticalGroup(
             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
             .addGroup(jPanel1Layout.createSequentialGroup()
-                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
-                    .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE))
+                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                 .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
         );
@@ -280,7 +284,6 @@ public final class ProjectTopComp extends TopComponent {
     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
 
@@ -308,7 +311,6 @@ public final class ProjectTopComp extends TopComponent {
     private javax.swing.JButton collapseButton1;
     private javax.swing.JButton deselectAllButton1;
     private javax.swing.JButton inflateButton1;
-    private javax.swing.JLabel jLabel1;
     private javax.swing.JPanel jPanel1;
     private javax.swing.JPanel jPanel2;
     private javax.swing.JPanel jPanel5;
@@ -371,14 +373,13 @@ public final class ProjectTopComp extends TopComponent {
             }
             
             this.project.setPrimaryFace(face);
-            jLabel1.setText(face.getName());
-            //gbc.gridy = lastY;
-            //javax.swing.JButton b1 = new javax.swing.JButton(face.getName());
-            //jScrollPane1.add(b1, gbc);
-            //lastY++;
             javax.swing.table.DefaultTableModel model = (javax.swing.table.DefaultTableModel)jTable1.getModel();
-            model.addRow(new Object[]{face.getName()});
-            createSingleFaceTab(face, face.getName());
+            String name = face.getName();
+            int from = name.length() - 1;
+            while (Character.valueOf('\\').compareTo(name.charAt(from)) != 0) {from--;}
+            name = name.substring(from + 1);
+            model.addRow(new Object[]{false, name});
+            createSingleFaceTab(face, name);
         } 
     }
     
@@ -438,7 +439,6 @@ public final class ProjectTopComp extends TopComponent {
             
             this.project.setPrimaryFace(face1);
             this.project.setSecondaryFaces(List.of(face2));
-            jLabel1.setText(face1.getName());
             createFaceToFaceTab(face1, face2, "1:1");
         } 
     }
diff --git a/GUI/src/main/resources/cz/fidentis/analyst/core/Bundle.properties b/GUI/src/main/resources/cz/fidentis/analyst/core/Bundle.properties
index c8b7e5c1..81152880 100644
--- a/GUI/src/main/resources/cz/fidentis/analyst/core/Bundle.properties
+++ b/GUI/src/main/resources/cz/fidentis/analyst/core/Bundle.properties
@@ -20,3 +20,4 @@ ProjectTopComp.jTable1.columnModel.title0=Title 1
 ProjectTopComp.jTable1.columnModel.title3=Title 4
 ProjectTopComp.jTable1.columnModel.title1=Title 2
 ProjectTopComp.jTable1.columnModel.title0_1=Models
+ProjectTopComp.jTable1.columnModel.title1_1=
-- 
GitLab