wizarddialog.java
来自「优秀的打印控件全源代码,类似水晶表的设计器!」· Java 代码 · 共 1,696 行 · 第 1/5 页
JAVA
1,696 行
sre.setBand(columns); template.getElements().addElement(sre); currentx += fwidth; currentx = Math.min(template.getWidth() - template.getRightMargin()+10-30, currentx); } // Remove template groups...**************** e = template.getElements().elements(); Vector elements_to_delete = new Vector(); while (e.hasMoreElements()) { ReportElement rElement = (ReportElement)e.nextElement(); Group g = null; if ((g=template.getGroupByName("Group1"))!=null && (rElement.getBand() == g.getGroupHeader() || rElement.getBand() == g.getGroupFooter())) elements_to_delete.addElement(rElement); else if ((g=template.getGroupByName("Group2"))!=null && (rElement.getBand() == g.getGroupHeader() || rElement.getBand() == g.getGroupFooter())) elements_to_delete.addElement(rElement); else if ((g=template.getGroupByName("Group3"))!=null && (rElement.getBand() == g.getGroupHeader() || rElement.getBand() == g.getGroupFooter())) elements_to_delete.addElement(rElement); else if ((g=template.getGroupByName("Group4"))!=null && (rElement.getBand() == g.getGroupHeader() || rElement.getBand() == g.getGroupFooter())) elements_to_delete.addElement(rElement); } e =elements_to_delete.elements(); while (e.hasMoreElements()) { template.getElements().removeElement(e.nextElement()); } Group g; if ((g=template.getGroupByName("Group1"))!=null) { template.getBands().removeElement(g.getGroupFooter()); template.getBands().removeElement(g.getGroupHeader()); template.getGroups().removeElement(g); } if ((g=template.getGroupByName("Group2"))!=null) { template.getBands().removeElement(g.getGroupFooter()); template.getBands().removeElement(g.getGroupHeader()); template.getGroups().removeElement(g); } if ((g=template.getGroupByName("Group3"))!=null) { template.getBands().removeElement(g.getGroupFooter()); template.getBands().removeElement(g.getGroupHeader()); template.getGroups().removeElement(g); } if ((g=template.getGroupByName("Group4"))!=null) { template.getBands().removeElement(g.getGroupFooter()); template.getBands().removeElement(g.getGroupHeader()); template.getGroups().removeElement(g); } // Positioning columns band... /* if ((g=template.getGroupByName("Columns"))!=null) { template.getGroups().removeElement(g); template.getBands().removeElement(g.getGroupHeader()); template.getBands().removeElement(g.getGroupFooter()); template.addGroup(g); // we must adjust band position... } */ // Adjust vertical position of elements e = template.getElements().elements(); while (e.hasMoreElements()) { ReportElement rElement = (ReportElement)e.nextElement(); rElement.trasform(new java.awt.Point(0,+ template.getBandYLocation( rElement.getBand() )),TransformationType.TRANSFORMATION_MOVE ); } template.setQuery( jRSQLExpressionArea1.getText() ); return template; } /********************************************************** * */ public Report createColumnarReport(String templateFileName) { Report template = new Report(templateFileName); template.setDirty(true); template.setFilename(null); //2. Find detail and column header bands... Band detail=null; Band columns=null; Enumeration e = template.getBands().elements(); while (e.hasMoreElements()) { Band band = (Band)e.nextElement(); if (band.getName().equals("detail")) { detail = band; } else if (band.getName().equals("columnHeader")) { columns = band; } } // 1. Normalize position to band... e = template.getElements().elements(); while (e.hasMoreElements()) { ReportElement rElement = (ReportElement)e.nextElement(); rElement.trasform(new java.awt.Point(0,- template.getBandYLocation( rElement.getBand() )),TransformationType.TRANSFORMATION_MOVE ); } //1. Adding groups... if (this.jComboBox1.getSelectedIndex() > 0) { Group g = template.getGroupByName("Group1"); Group g1 = new Group( template, ""+jComboBox1.getSelectedItem(), g.getGroupFooter().getHeight(),g.getGroupHeader().getHeight()); g1.setGroupExpression("$F{"+ jComboBox1.getSelectedItem() + "}" ); template.addGroup(g1); // Add to g1 all elements attached to g.header and g.footer... e = template.getElements().elements(); while (e.hasMoreElements()) { ReportElement rElement = (ReportElement)e.nextElement(); if (rElement.getBand() == g.getGroupHeader()) rElement.setBand(g1.getGroupHeader() ); else if (rElement.getBand() == g.getGroupFooter()) rElement.setBand(g1.getGroupFooter() ); // Set text to Group1 label... if (rElement instanceof StaticTextReportElement) { StaticTextReportElement stre = (StaticTextReportElement)rElement; if (stre.getText().equals("G1Label")) stre.setText( ""+jComboBox1.getSelectedItem()); } else if (rElement instanceof TextFieldReportElement) { TextFieldReportElement tfre = (TextFieldReportElement)rElement; if (tfre.getText().equals("G1Field")) tfre.setText("$F{"+jComboBox1.getSelectedItem()+"}"); } } } if (this.jComboBox2.getSelectedIndex() > 0) { Group g = template.getGroupByName("Group2"); Group g2 = new Group( template, ""+jComboBox2.getSelectedItem(), g.getGroupFooter().getHeight(),g.getGroupHeader().getHeight()); g2.setGroupExpression("$F{"+ jComboBox2.getSelectedItem() + "}" ); template.addGroup(g2); // Add to g2 all elements attached to g.header and g.footer... e = template.getElements().elements(); while (e.hasMoreElements()) { ReportElement rElement = (ReportElement)e.nextElement(); if (rElement.getBand() == g.getGroupHeader()) rElement.setBand(g2.getGroupHeader() ); else if (rElement.getBand() == g.getGroupFooter()) rElement.setBand(g2.getGroupFooter() ); // Set text to Group2 label... if (rElement instanceof StaticTextReportElement) { StaticTextReportElement stre = (StaticTextReportElement)rElement; if (stre.getText().equals("G2Label")) stre.setText( ""+jComboBox2.getSelectedItem()); } else if (rElement instanceof TextFieldReportElement) { TextFieldReportElement tfre = (TextFieldReportElement)rElement; if (tfre.getText().equals("G2Field")) tfre.setText("$F{"+jComboBox2.getSelectedItem()+"}"); } } } if (this.jComboBox3.getSelectedIndex() > 0) { Group g = template.getGroupByName("Group3"); Group g3 = new Group( template, ""+jComboBox3.getSelectedItem(), g.getGroupFooter().getHeight(),g.getGroupHeader().getHeight()); g3.setGroupExpression("$F{"+ jComboBox3.getSelectedItem() + "}" ); template.addGroup(g3); // Add to g3 all elements attached to g.header and g.footer... e = template.getElements().elements(); while (e.hasMoreElements()) { ReportElement rElement = (ReportElement)e.nextElement(); if (rElement.getBand() == g.getGroupHeader()) rElement.setBand(g3.getGroupHeader() ); else if (rElement.getBand() == g.getGroupFooter()) rElement.setBand(g3.getGroupFooter() ); // Set text to Group3 label... if (rElement instanceof StaticTextReportElement) { StaticTextReportElement stre = (StaticTextReportElement)rElement; if (stre.getText().equals("G3Label")) stre.setText( ""+jComboBox3.getSelectedItem()); } else if (rElement instanceof TextFieldReportElement) { TextFieldReportElement tfre = (TextFieldReportElement)rElement; if (tfre.getText().equals("G3Field")) tfre.setText("$F{"+jComboBox3.getSelectedItem()+"}"); } } } if (this.jComboBox4.getSelectedIndex() > 0) { Group g = template.getGroupByName("Group4"); Group g4 = new Group( template, ""+jComboBox4.getSelectedItem(), g.getGroupFooter().getHeight(),g.getGroupHeader().getHeight()); g4.setGroupExpression("$F{"+ jComboBox4.getSelectedItem() + "}" ); template.addGroup(g4); // Add to g4 all elements attached to g.header and g.footer... e = template.getElements().elements(); while (e.hasMoreElements()) { ReportElement rElement = (ReportElement)e.nextElement(); if (rElement.getBand() == g.getGroupHeader()) rElement.setBand(g4.getGroupHeader() ); else if (rElement.getBand() == g.getGroupFooter()) rElement.setBand(g4.getGroupFooter() ); // Set text to Group4 label... if (rElement instanceof StaticTextReportElement) { StaticTextReportElement stre = (StaticTextReportElement)rElement; if (stre.getText().equals("G4Label")) stre.setText( ""+jComboBox4.getSelectedItem()); } else if (rElement instanceof TextFieldReportElement) { TextFieldReportElement tfre = (TextFieldReportElement)rElement; if (tfre.getText().equals("G4Field")) tfre.setText("$F{"+jComboBox4.getSelectedItem()+"}"); } } } //1. Adding fields... int currentx = template.getLeftMargin()+10; int currenty = 10; e = template.getElements().elements(); StaticTextReportElement detailLabel = null; TextFieldReportElement detailField = null; while (e.hasMoreElements() && (detailLabel==null || detailField == null) ) { ReportElement rElement = (ReportElement)e.nextElement(); if (rElement instanceof StaticTextReportElement) { StaticTextReportElement stre = (StaticTextReportElement)rElement; if (stre.getText().equalsIgnoreCase("DetailLabel")) detailLabel =stre; } else if (rElement instanceof TextFieldReportElement) { TextFieldReportElement tfre = (TextFieldReportElement)rElement; if (tfre.getText().equalsIgnoreCase("DetailField")) detailField = tfre; } } if (detailField != null) template.getElements().removeElement(detailField); if (detailLabel != null) template.getElements().removeElement(detailLabel); if (detailField == null) detailField = new TextFieldReportElement(0,0,100,20); if (detailLabel == null) detailLabel = new StaticTextReportElement(0,0,100,18); int nfields = jList2.getModel().getSize(); if (jComboBox1.getSelectedIndex()>0) nfields--; if (jComboBox2.getSelectedIndex()>0) nfields--; if (jComboBox3.getSelectedIndex()>0) nfields--; if (jComboBox4.getSelectedIndex()>0) nfields--; int fwidth = template.getColumnWidth()/nfields; int ffheight = detailField.getPosition().y; for (int i=0; i<jList2.getModel().getSize(); ++i) { // FIELD it.businesslogic.ireport.JRField f = (it.businesslogic.ireport.JRField)jList2.getModel().getElementAt(i); template.addField(f); if (jComboBox1.getSelectedIndex()>0 && f.getName().equalsIgnoreCase( ""+jComboBox1.getSelectedItem() )) continue; if (jComboBox2.getSelectedIndex()>0 && f.getName().equalsIgnoreCase( ""+jComboBox2.getSelectedItem() )) continue; if (jComboBox3.getSelectedIndex()>0 && f.getName().equalsIgnoreCase( ""+jComboBox3.getSelectedItem() )) continue; if (jComboBox4.getSelectedIndex()>0 && f.getName().equalsIgnoreCase( ""+jComboBox4.getSelectedItem() )) continue; TextFieldReportElement re = (TextFieldReportElement)detailField.cloneMe(); re.setPosition(new java.awt.Point(detailField.getPosition().x, ffheight)); re.updateBounds(); re.setText("$F{"+ f.getName() +"}"); re.setBand(detail); re.setClassExpression(f.getClassType()); template.getElements().addElement(re); // COLUMN LABEL... StaticTextReportElement sre = (StaticTextReportElement)detailLabel.cloneMe(); sre.setPosition(new java.awt.Point(detailLabel.getPosition().x,ffheight)); sre.setWidth(fwidth); sre.updateBounds(); sre.setText(""+ f.getName() +""); sre.setBand(detail); template.getElements().addElement(sre); ffheight += detailField.position.y+detailField.height-10; } detail.setHeight(ffheight); // Remove template groups...**************** e = template.getElements().elements(); Vector elements_to_delete = new Vector(); while (e.hasMoreElements()) { ReportElement rElement = (ReportElement)e.nextElement(); Group g = null; if ((g=template.getGroupByName("Group1"))!=null && (rElement.getBand() == g.getGroupHeader() || rElement.getBand() == g.getGroupFooter())) elements_to_delete.addElement(rElement); else if ((g=template.getGroupByName("Group2"))!=null && (rElement.getBand() == g.getGroupHeader() || rElement.g
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?