Skip to content

Commit

Permalink
Implement filter select-all functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanhab committed Dec 28, 2024
1 parent 7bfb70e commit 20d9e70
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 51 deletions.
2 changes: 2 additions & 0 deletions Gui/opensim/rice_cnl/src/org/opensim/rcnl/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,5 @@ EditCostTermJPanel.jErrorCenterTextField.text=0.
EditCosnstraintTermJPanel.jComponentTypeTextField.text=\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
EditCosnstraintTermJPanel.jMaxErrorTextField.text=0
EditCosnstraintTermJPanel.jMinErrorTextField.text=0
SelectQuantitiesFromListJPanel.jSelectAllCheckBox.toolTipText=select all shown quantities
SelectQuantitiesFromListJPanel.jSelectAllCheckBox.text=select all shown
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,12 @@ void restrictNamesBy(String pattern){
fireTableDataChanged();

}

void selectShown() {
for (int q=0; q<shownQuantities.size(); q++){
selected.set(shownQuantities.get(q), true);
}
fireTableDataChanged();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,12 @@ void restrictNamesBy(String pattern){
fireTableDataChanged();

}

void selectShown() {
for (int q=0; q<shownQuantities.size(); q++){
selected.set(shownQuantities.get(q), true);
}
fireTableDataChanged();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ public void setToolAsObject(OpenSimObject toolAsObject) {
public PropertyObjectList getJointTaskListAsObjectList() {
AbstractProperty ap = toolAsObject.getPropertyByName("JMPTaskList");
PropertyObjectList olist = PropertyObjectList.getAs(ap);
for (int i=0; i< olist.size(); i++){
OpenSimObject ithTask = olist.getValue(i);
}

return olist;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,12 @@ void restrictNamesBy(String pattern){
fireTableDataChanged();

}
void selectShown() {
for (int q=0; q<shownQuantities.size(); q++){
selected.set(shownQuantities.get(q), true);
}
fireTableDataChanged();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@
<Component id="jPanel" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane1" pref="335" max="32767" attributes="2"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
<Component id="jSelectAllCheckBox" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
Expand All @@ -35,14 +33,9 @@
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="268" max="32767" attributes="0"/>
</Group>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="73" max="-2" attributes="0"/>
<Component id="jScrollPane1" min="-2" pref="227" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<Component id="jSelectAllCheckBox" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
Expand All @@ -56,7 +49,10 @@
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="FilterTextField" pref="243" max="32767" attributes="0"/>
<Component id="FilterTextField" pref="388" max="32767" attributes="0"/>
</Group>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" alignment="1" pref="504" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
Expand All @@ -67,7 +63,13 @@
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<Component id="FilterTextField" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="433" max="-2" attributes="0"/>
</Group>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="52" max="32767" attributes="0"/>
<Component id="jScrollPane1" min="-2" pref="420" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</DimensionLayout>
Expand All @@ -87,24 +89,45 @@
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<Container class="javax.swing.JScrollPane" name="jScrollPane1">

<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTable" name="jTable1">
<Properties>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="tableModel" type="code"/>
</Property>
<Property name="autoResizeMode" type="int" value="3"/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_CreateCodePost" type="java.lang.String" value="&#xa;"/>
</AuxValues>
</Component>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTable" name="jTable1">
<Properties>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="tableModel" type="code"/>
</Property>
<Property name="autoResizeMode" type="int" value="3"/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_CreateCodePost" type="java.lang.String" value="&#xa;"/>
</AuxValues>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
<Component class="javax.swing.JCheckBox" name="jSelectAllCheckBox">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/opensim/rcnl/Bundle.properties" key="SelectQuantitiesFromListJPanel.jSelectAllCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/opensim/rcnl/Bundle.properties" key="SelectQuantitiesFromListJPanel.jSelectAllCheckBox.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
<EmptyBorder bottom="0" left="0" right="0" top="0"/>
</Border>
</Property>
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
<Insets value="[0, 0, 0, 0]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jSelectAllCheckBoxActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package org.opensim.rcnl;

import java.util.ArrayList;
import javax.swing.JCheckBox;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.TableModelListener;
Expand Down Expand Up @@ -55,31 +56,49 @@ private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();

jSelectAllCheckBox = new javax.swing.JCheckBox();

org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(SelectQuantitiesFromListJPanel.class, "SelectQuantitiesFromListJPanel.jLabel1.text")); // NOI18N

FilterTextField.setToolTipText(org.openide.util.NbBundle.getMessage(SelectQuantitiesFromListJPanel.class, "SelectQuantitiesFromListJPanel.FilterTextField.toolTipText")); // NOI18N

jTable1.setModel(tableModel);
jTable1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_LAST_COLUMN);
jScrollPane1.setViewportView(jTable1);

javax.swing.GroupLayout jPanelLayout = new javax.swing.GroupLayout(jPanel);
jPanel.setLayout(jPanelLayout);
jPanelLayout.setHorizontalGroup(
jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelLayout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(FilterTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE))
.addComponent(FilterTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE))
.addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 504, Short.MAX_VALUE))
);
jPanelLayout.setVerticalGroup(
jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelLayout.createSequentialGroup()
.addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(FilterTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(0, 0, Short.MAX_VALUE))
.addGap(433, 433, 433))
.addGroup(jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelLayout.createSequentialGroup()
.addGap(0, 52, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 420, javax.swing.GroupLayout.PREFERRED_SIZE)))
);

jTable1.setModel(tableModel);
jTable1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_LAST_COLUMN);
jScrollPane1.setViewportView(jTable1);
org.openide.awt.Mnemonics.setLocalizedText(jSelectAllCheckBox, org.openide.util.NbBundle.getMessage(SelectQuantitiesFromListJPanel.class, "SelectQuantitiesFromListJPanel.jSelectAllCheckBox.text")); // NOI18N
jSelectAllCheckBox.setToolTipText(org.openide.util.NbBundle.getMessage(SelectQuantitiesFromListJPanel.class, "SelectQuantitiesFromListJPanel.jSelectAllCheckBox.toolTipText")); // NOI18N
jSelectAllCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
jSelectAllCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
jSelectAllCheckBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jSelectAllCheckBoxActionPerformed(evt);
}
});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
Expand All @@ -89,32 +108,43 @@ private void initComponents() {
.addContainerGap()
.addComponent(jPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 335, Short.MAX_VALUE)
.addContainerGap()))
.addGroup(layout.createSequentialGroup()
.addGap(9, 9, 9)
.addComponent(jSelectAllCheckBox)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(268, Short.MAX_VALUE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(73, 73, 73)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 227, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jSelectAllCheckBox)
.addGap(12, 12, 12))
);
}// </editor-fold>//GEN-END:initComponents

private void jSelectAllCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jSelectAllCheckBoxActionPerformed
// tableModel.selectShown(true);
// updateSelected();
((JCheckBox)evt.getSource()).setSelected(false);
if (tableModel instanceof MuscleGroupTableModel)
((MuscleGroupTableModel) tableModel).selectShown();
else if (tableModel instanceof CoordinateTableModel)
((CoordinateTableModel) tableModel).selectShown();
else if (tableModel instanceof ComponentTableModel)
((ComponentTableModel) tableModel).selectShown();

// TODO add your handling code here:
}//GEN-LAST:event_jSelectAllCheckBoxActionPerformed


// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JFormattedTextField FilterTextField;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JCheckBox jSelectAllCheckBox;
private javax.swing.JTable jTable1;
// End of variables declaration//GEN-END:variables

Expand Down

0 comments on commit 20d9e70

Please sign in to comment.