Sorting columns of puck loading dialog.

This commit is contained in:
2020-09-16 10:56:03 +02:00
parent 8686cbb639
commit c541e58ace
2 changed files with 14 additions and 11 deletions

View File

@@ -110,13 +110,14 @@
<SubComponents>
<Component class="javax.swing.JTable" name="table">
<Properties>
<Property name="autoCreateRowSorter" type="boolean" value="true"/>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Lucida Grande" size="30" style="0"/>
</Property>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
<Table columnCount="3" rowCount="0">
<Column editable="false" title="Dewar" type="java.lang.String"/>
<Column editable="false" title="Datamatrix / Puck Id" type="java.lang.String"/>
<Column editable="false" title="Puck Id/Datamatrix" type="java.lang.String"/>
<Column editable="false" title="Puck Position" type="java.lang.String"/>
</Table>
</Property>
@@ -125,7 +126,7 @@
<JTableSelectionModel selectionMode="0"/>
</Property>
<Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor">
<TableHeader reorderingAllowed="false" resizingAllowed="false"/>
<TableHeader reorderingAllowed="false" resizingAllowed="true"/>
</Property>
</Properties>
<AuxValues>

View File

@@ -39,9 +39,9 @@ public class PuckLoadingDialog extends JDialog {
setSugestionLabel(null,-1);
model = (DefaultTableModel) table.getModel();
table.getTableHeader().setFont(table.getTableHeader().getFont().deriveFont(20.0f));
panelTable.getVerticalScrollBar().setPreferredSize(new Dimension(30, 0));
panelTable.getVerticalScrollBar().setPreferredSize(new Dimension(30, 0));
}
@Override
public void setVisible(boolean value){
boolean visible = isVisible();
@@ -185,14 +185,15 @@ public class PuckLoadingDialog extends JDialog {
}
}
void makeVisible(String datamatrix){
if (datamatrix!=null){
datamatrix = datamatrix.trim();
for (int i=0; i<model.getRowCount(); i++){
if (datamatrix.equals(model.getValueAt(i, INDEX_DATAMATRIX))){
SwingUtils.scrollToVisible(table, i, 0);
table.setRowSelectionInterval(i, i);
int index = table.convertRowIndexToView(i);
SwingUtils.scrollToVisible(table, index, 0);
table.setRowSelectionInterval(index, index);
break;
}
}
@@ -203,8 +204,9 @@ public class PuckLoadingDialog extends JDialog {
if (puck!=null){
for (int i=0; i<model.getRowCount(); i++){
if (puck.getName().equals(model.getValueAt(i, INDEX_POSITION))){
SwingUtils.scrollToVisible(table, i, 0);
table.setRowSelectionInterval(i, i);
int index = table.convertRowIndexToView(i);
SwingUtils.scrollToVisible(table, index, 0);
table.setRowSelectionInterval(index, index);
break;
}
}
@@ -241,13 +243,14 @@ public class PuckLoadingDialog extends JDialog {
textScannedDatamatrix.setFont(new java.awt.Font("Lucida Grande", 0, 30)); // NOI18N
textScannedDatamatrix.setHorizontalAlignment(javax.swing.JTextField.CENTER);
table.setAutoCreateRowSorter(true);
table.setFont(new java.awt.Font("Lucida Grande", 0, 30)); // NOI18N
table.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"Dewar", "Datamatrix / Puck Id", "Puck Position"
"Dewar", "Puck Id/Datamatrix", "Puck Position"
}
) {
Class[] types = new Class [] {
@@ -267,7 +270,6 @@ public class PuckLoadingDialog extends JDialog {
});
table.setRowHeight(40);
table.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
table.getTableHeader().setResizingAllowed(false);
table.getTableHeader().setReorderingAllowed(false);
panelTable.setViewportView(table);