Functionality to resize columns to content width in the report screen.
<Property name="text" type="java.lang.String" value="Reports"/>
</Properties>
<SubComponents>
+ <MenuItem class="javax.swing.JMenuItem" name="menuNoticesToBeDrafted">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="To Be Drafted..."/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuNoticesToBeDraftedActionPerformed"/>
+ </Events>
+ </MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="menuNoticesClarificationPending">
<Properties>
<Property name="mnemonic" type="int" value="99"/>
jSeparator1 = new javax.swing.JPopupMenu.Separator();
menuGenerateRaisedBills = new javax.swing.JMenuItem();
menuNoticesReports = new javax.swing.JMenu();
+ menuNoticesToBeDrafted = new javax.swing.JMenuItem();
menuNoticesClarificationPending = new javax.swing.JMenuItem();
menuNoticeDraftAwaitingApproval = new javax.swing.JMenuItem();
menuNoticesSentNotYetDelivered = new javax.swing.JMenuItem();
menuNoticesReports.setMnemonic('r');
menuNoticesReports.setText("Reports");
+ menuNoticesToBeDrafted.setText("To Be Drafted...");
+ menuNoticesToBeDrafted.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ menuNoticesToBeDraftedActionPerformed(evt);
+ }
+ });
+ menuNoticesReports.add(menuNoticesToBeDrafted);
+
menuNoticesClarificationPending.setMnemonic('c');
menuNoticesClarificationPending.setText("Clarifications pending...");
menuNoticesClarificationPending.addActionListener(new java.awt.event.ActionListener() {
frm.setupReportTable(rep, REPORT_TITLE_CLARIFICATIONS_PENDING, cols, data);
frm.setVisible(true);
}//GEN-LAST:event_menuNoticesClarificationPendingActionPerformed
+
+ private void menuNoticesToBeDraftedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuNoticesToBeDraftedActionPerformed
+ // TODO add your handling code here:
+ NoticesReportViewDialog frm = new NoticesReportViewDialog(this, false);
+ String cols[] = {"Reference Number", "Description", "Entrustment Date",
+ "Clarification Remarks", "Client" };
+ int rep = 4;
+ ArrayList<Object> data = Utility.getReportData(rep, -1);
+ if (data == null) {
+ JOptionPane.showMessageDialog(this , ERROR_DISPLAYING_REPORT);
+ return;
+ }
+ frm.setupReportTable(rep, REPORT_TITLE_TO_BE_DRAFTED, cols, data);
+ frm.setVisible(true);
+
+ }//GEN-LAST:event_menuNoticesToBeDraftedActionPerformed
+ private static final String REPORT_TITLE_TO_BE_DRAFTED = "To Be Drafted";
private static final String REPORT_TITLE_CLARIFICATIONS_PENDING = "Clarifications Pending";
private static final String REPORT_TITLE_DRAFTS_AWAITING_APPROVAL = "Drafts To Be Approved";
public static final String REPORT_TITLE_NOTICES_SENT_NOT_DELIVERED = "Notices Sent Not Yet Delivered";
private javax.swing.JMenuItem menuNoticesClarificationPending;
private javax.swing.JMenu menuNoticesReports;
private javax.swing.JMenuItem menuNoticesSentNotYetDelivered;
+ private javax.swing.JMenuItem menuNoticesToBeDrafted;
private javax.swing.JMenu menuSettings;
private javax.swing.JMenuItem menuStationery;
// End of variables declaration//GEN-END:variables
<EmptySpace max="-2" attributes="0"/>
<Component id="checkFilterByClient" min="-2" pref="196" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
- <Component id="comboClients" min="-2" pref="322" max="-2" attributes="0"/>
+ <Component id="comboClients" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
- <Component id="buttonApply" max="32767" attributes="0"/>
+ <Component id="buttonApply" min="-2" pref="106" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
<Table columnCount="0" rowCount="0"/>
</Property>
+ <Property name="autoResizeMode" type="int" value="0"/>
<Property name="cellSelectionEnabled" type="boolean" value="true"/>
<Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor">
<TableColumnModel selectionModel="0"/>
</Property>
+ <Property name="componentPopupMenu" type="javax.swing.JPopupMenu" editor="org.netbeans.modules.form.ComponentChooserEditor">
+ <ComponentRef name="popMenu"/>
+ </Property>
<Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor">
<TableHeader reorderingAllowed="true" resizingAllowed="true"/>
</Property>
*/
package habeas;
+import java.awt.Component;
import java.util.ArrayList;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
+import javax.swing.JTable;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.DefaultTableModel;
+import javax.swing.table.TableCellRenderer;
+import javax.swing.table.TableColumn;
+import javax.swing.table.TableColumnModel;
/**
*
}
));
+ tableReport.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
tableReport.setCellSelectionEnabled(true);
+ tableReport.setComponentPopupMenu(popMenu);
jScrollPane2.setViewportView(tableReport);
checkFilterByClient.setText("Filter by Client");
.addContainerGap()
.addComponent(checkFilterByClient, javax.swing.GroupLayout.PREFERRED_SIZE, 196, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(comboClients, javax.swing.GroupLayout.PREFERRED_SIZE, 322, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(comboClients, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(buttonApply, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addComponent(buttonApply, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
}
};
tableReport.setModel(mdl);
- tableReport.setComponentPopupMenu(popMenu);
labelReportTitle.setText(title);
populateReport ();
for (int j = 0; j < reportCols.length; j ++)
row[j] = reportData.get(i+j);
mdl.addRow (row);
-
}
+ // resize the column widths to content size
+ for (int i = 0; i < tableReport.getColumnCount(); i ++) {
+
+ TableColumn clm = tableReport.getColumnModel().getColumn (i);
+ int preferredWidth = clm.getMinWidth()+10;
+ int maxWidth = 300;
+ int minWidth = 100;
+ for (int r = 0; r < tableReport.getRowCount(); r ++) {
+ TableCellRenderer rend = tableReport.getCellRenderer(r, i);
+ Component c = tableReport.prepareRenderer(rend, r, i);
+ int width = c.getPreferredSize().width + tableReport.getIntercellSpacing().width;
+ preferredWidth = Math.max (preferredWidth, width+10);
+ if (preferredWidth >= maxWidth)
+ {
+ preferredWidth = maxWidth;
+ break;
+ }
+ }
+ clm.setPreferredWidth(Math.max(minWidth, preferredWidth));
+ }
}
private void populateClients() {
"SELECT ReferenceNumber, Description, EntrustmentDate, "
+ "ClarificationRemarks, ClientName FROM legalnotices INNER JOIN clients ON"
- + " ClientId=clients.id WHERE ClarificationPending=1;"
+ + " ClientId=clients.id WHERE ClarificationPending=1;",
+ "SELECT ReferenceNumber, Description, EntrustmentDate, ClarificationRemarks"
+ + ", ClientName from legalnotices INNER JOIN clients ON ClientId=clients.id "
+ + "WHERE DraftCreated=0;"
} ;
private static final String[] REPORTS_FILTERED = { "SELECT ReferenceNumber, Description"
"SELECT ReferenceNumber, Description, EntrustmentDate, "
+ "ClarificationRemarks, ClientName FROM legalnotices INNER JOIN clients ON"
- + " ClientId=clients.id WHERE ClarificationPending=1 AND ClientId=?;"
+ + " ClientId=clients.id WHERE ClarificationPending=1 AND ClientId=?;",
+
+ "SELECT ReferenceNumber, Description, EntrustmentDate, ClarificationRemarks"
+ + ", ClientName from legalnotices INNER JOIN clients ON ClientId=clients.id "
+ + "WHERE DraftCreated=0 AND ClientId=?;"
} ;
static void saveStationerySettings (String left_header,