List of usage examples for com.itextpdf.text Font BOLD
int BOLD
To view the source code for com.itextpdf.text Font BOLD.
Click Source Link
From source file:br.com.tcc.view.MovimentoOrcamentoView.java
private void relat(String sql) throws IOException, DocumentException, SQLException { /* Create Connection objects */ Connection con = new ConnectionFactory().getConnection(); Statement stmt = con.createStatement(); int row = tblRegistro.getSelectedRow(); int id = orcamentoRegistroList.get(row).getId(); SimpleDateFormat horaformatada = new SimpleDateFormat("HH:mm:ss"); Date horaAtual = new Date(); hora = horaformatada.format(horaAtual); Date data = new Date(); // mes = ""+Data.getMonth();//0 a 11 dia = "" + data.getDate(); ano = "" + (1900 + data.getYear()); switch (data.getMonth()) { case 0:/*from www. ja v a2 s . c om*/ mes = "Janeiro"; break; case 1: mes = "Fevereiro"; break; case 2: mes = "Maro"; break; case 3: mes = "Abril"; break; case 4: mes = "Maio"; break; case 5: mes = "Junho"; break; case 6: mes = "Julho"; break; case 7: mes = "Agosto"; break; case 8: mes = "Setembro"; break; case 9: mes = "Outubro"; break; case 10: mes = "Novembro"; break; case 11: mes = "Dezembro"; break; } /* Define the SQL query */ // sql = "SELECT cliente.nome, funcionario.nome, tipopagamento.descricao, vendaregistro.dataVenda, vendaregistro.vlrSugerido, vendaregistro.totalVenda, vendaregistro.parcela, vendaregistro.1vencimento, vendaregistro.ativo FROM vendaregistro as vendaregistro INNER JOIN cliente as cliente ON (vendaregistro.idCliente = cliente.id) \n" + //"INNER JOIN funcionario as funcionario ON (vendaregistro.idFuncionario = funcionario.id) INNER JOIN tipopagamento as tipopagamento ON (vendaregistro.idTipoPagamento = tipopagamento.id) WHERE dataVenda = CURRENT_DATE"; ResultSet query = stmt.executeQuery(sql); /* Step-2: Initialize PDF documents - logical objects */ Document PDFLogReport = new Document(); PdfWriter.getInstance(PDFLogReport, new FileOutputStream("C:\\Users\\Leonardo P Souza\\Desktop\\Relat\\Oramento " + id + ".pdf")); PDFLogReport.open(); Paragraph cabecalho = new Paragraph("AGRO EMPRESARIAL - SISTEMA DE GERENCIAMENTO\n" + "RUA GONALVES CHAVES, 602 PELOTAS/RS\n" + "FONE:(53) 3232-3232 BAIRRO: CENTRO\n" + "CNPJ: 12.345.678/1011-12\n" + "-------------------------------------------\n" + dia + "/" + mes + "/" + ano + " " + hora + " COD: " + id + " \n\n"); cabecalho.setAlignment(Element.ALIGN_CENTER); PDFLogReport.add(cabecalho); //we have two columns in our table PdfPTable LogTable = new PdfPTable(4); // Ttulo para a tabela Paragraph tableHeader = new Paragraph("Oramento"); PdfPCell header = new PdfPCell(tableHeader); // Definindo que o header vai ocupar as 2 colunas header.setColspan(4); // Definindo alinhamento do header header.setHorizontalAlignment(Paragraph.ALIGN_CENTER); // Adicionando o header tabela Font fonte = new Font(Font.FontFamily.HELVETICA, 7, Font.BOLD, BaseColor.BLACK); Font fonteDados = new Font(Font.FontFamily.TIMES_ROMAN, 6, Font.NORMAL, BaseColor.BLACK); LogTable.addCell(header); LogTable.addCell(new Paragraph("Produto ", fonte)); LogTable.addCell(new Paragraph("Quantidade", fonte)); LogTable.addCell(new Paragraph("Valor Unitrio", fonte)); LogTable.addCell(new Paragraph("Valor Total", fonte)); //create a cell object // PdfPCell table_cell; while (query.next()) { String produto = query.getString("produto.descricao"); LogTable.addCell(new Paragraph(produto, fonteDados)); String quantidade = query.getString("qtde"); LogTable.addCell(new Paragraph(quantidade, fonteDados)); String vlrSugerido = query.getString("vlrUnitario"); LogTable.addCell(new Paragraph(vlrSugerido, fonteDados)); String vlrTotal = query.getString("vlrTotal"); LogTable.addCell(new Paragraph(vlrTotal, fonteDados)); } /* Attach report table to PDF */ PDFLogReport.add(LogTable); double valor = orcamentoRegistroList.get(row).getVlrTotalOrcamento(); Paragraph paragrafoValor = new Paragraph("Valor R$: " + valor); paragrafoValor.setAlignment(Element.ALIGN_RIGHT); PDFLogReport.add(paragrafoValor); PDFLogReport.close(); /* Close all DB related objects */ query.close(); stmt.close(); con.close(); String file; file = "C:\\Users\\Leonardo P Souza\\Desktop\\Relat\\Oramento " + id + ".pdf"; Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL " + file); }
From source file:br.com.tcc.view.MovimentoPedidoView.java
private void relat(String sql) throws SQLException, DocumentException, FileNotFoundException, IOException { /* Create Connection objects */ Connection con = new ConnectionFactory().getConnection(); Statement stmt = con.createStatement(); int row = tblRegistro.getSelectedRow(); int id = pedidoRegistroList.get(row).getId(); SimpleDateFormat horaformatada = new SimpleDateFormat("HH:mm:ss"); Date horaAtual = new Date(); hora = horaformatada.format(horaAtual); Date data = new Date(); // mes = ""+Data.getMonth();//0 a 11 dia = "" + data.getDate(); ano = "" + (1900 + data.getYear()); switch (data.getMonth()) { case 0:// w w w . j a v a 2 s. c om mes = "Janeiro"; break; case 1: mes = "Fevereiro"; break; case 2: mes = "Maro"; break; case 3: mes = "Abril"; break; case 4: mes = "Maio"; break; case 5: mes = "Junho"; break; case 6: mes = "Julho"; break; case 7: mes = "Agosto"; break; case 8: mes = "Setembro"; break; case 9: mes = "Outubro"; break; case 10: mes = "Novembro"; break; case 11: mes = "Dezembro"; break; } /* Define the SQL query */ // sql = "SELECT cliente.nome, funcionario.nome, tipopagamento.descricao, vendaregistro.dataVenda, vendaregistro.vlrSugerido, vendaregistro.totalVenda, vendaregistro.parcela, vendaregistro.1vencimento, vendaregistro.ativo FROM vendaregistro as vendaregistro INNER JOIN cliente as cliente ON (vendaregistro.idCliente = cliente.id) \n" + //"INNER JOIN funcionario as funcionario ON (vendaregistro.idFuncionario = funcionario.id) INNER JOIN tipopagamento as tipopagamento ON (vendaregistro.idTipoPagamento = tipopagamento.id) WHERE dataVenda = CURRENT_DATE"; ResultSet query = stmt.executeQuery(sql); /* Step-2: Initialize PDF documents - logical objects */ Document PDFLogReport = new Document(); PdfWriter.getInstance(PDFLogReport, new FileOutputStream("C:\\Users\\Leonardo P Souza\\Desktop\\Relat\\Pedidos " + id + ".pdf")); PDFLogReport.open(); Paragraph cabecalho = new Paragraph("AGRO EMPRESARIAL - SISTEMA DE GERENCIAMENTO\n" + "RUA GONALVES CHAVES, 602 PELOTAS/RS\n" + "FONE:(53) 3232-3232 BAIRRO: CENTRO\n" + "CNPJ: 12.345.678/1011-12\n" + "-------------------------------------------\n" + dia + "/" + mes + "/" + ano + " " + hora + " COD: " + id + " \n\n"); cabecalho.setAlignment(Element.ALIGN_CENTER); PDFLogReport.add(cabecalho); //we have two columns in our table PdfPTable LogTable = new PdfPTable(4); // Ttulo para a tabela Paragraph tableHeader = new Paragraph("Lista de Pedidos"); PdfPCell header = new PdfPCell(tableHeader); // Definindo que o header vai ocupar as 2 colunas header.setColspan(4); // Definindo alinhamento do header header.setHorizontalAlignment(Paragraph.ALIGN_CENTER); // Adicionando o header tabela Font fonte = new Font(Font.FontFamily.HELVETICA, 7, Font.BOLD, BaseColor.BLACK); Font fonteDados = new Font(Font.FontFamily.TIMES_ROMAN, 6, Font.NORMAL, BaseColor.BLACK); LogTable.addCell(header); LogTable.addCell(new Paragraph("Produto ", fonte)); LogTable.addCell(new Paragraph("Quantidade", fonte)); LogTable.addCell(new Paragraph("Valor Unitrio", fonte)); LogTable.addCell(new Paragraph("Valor Total", fonte)); //create a cell object // PdfPCell table_cell; while (query.next()) { String produto = query.getString("produto.descricao"); LogTable.addCell(new Paragraph(produto, fonteDados)); String quantidade = query.getString("qtdePedido"); LogTable.addCell(new Paragraph(quantidade, fonteDados)); String vlrSugerido = query.getString("vlrUnitario"); LogTable.addCell(new Paragraph(vlrSugerido, fonteDados)); String vlrTotal = query.getString("vlrTotal"); LogTable.addCell(new Paragraph(vlrTotal, fonteDados)); } /* Attach report table to PDF */ PDFLogReport.add(LogTable); double valor = pedidoRegistroList.get(row).getVlrPedido(); Paragraph paragrafoValor = new Paragraph("Valor R$: " + valor); paragrafoValor.setAlignment(Element.ALIGN_RIGHT); PDFLogReport.add(paragrafoValor); PDFLogReport.close(); /* Close all DB related objects */ query.close(); stmt.close(); con.close(); String file; file = "C:\\Users\\Leonardo P Souza\\Desktop\\Relat\\Pedidos " + id + ".pdf"; Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL " + file); }
From source file:br.edu.unipampa.recipemanager.pdf.CreatePDF.java
public boolean newPdf(List<MenuRecipe> menuRecipe, String month, String responsibleName) { double valueMonth = 0; try {/* w w w . ja v a2s .c o m*/ Document doc = new Document(PageSize.A4, 72, 72, 72, 72); OutputStream os = new FileOutputStream(namePdf(menuRecipe)); PdfWriter.getInstance(doc, os); doc.open(); Paragraph p; Font f = new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD); p = new Paragraph("Ms: " + month, f); doc.add(p); f = new Font(Font.FontFamily.COURIER, 14, Font.ITALIC); for (MenuRecipe menu : menuRecipe) { valueMonth += menu.priceMenu(); p.setSpacingBefore(5); p.setSpacingAfter(5); p = new Paragraph(menu.toString(), f); doc.add(p); } p = new Paragraph("Preo total de todos os cardpios: " + valueMonth, f); doc.add(p); f = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD); p = new Paragraph("_____________________________________\n" + responsibleName, f); p.setSpacingAfter(15); p.setAlignment(Element.ALIGN_RIGHT); doc.add(p); doc.close(); os.close(); return true; } catch (Exception e) { return false; } }
From source file:br.unisc.video_locadora.controll.Generator_PDF.java
public void geraRelatorio() throws DocumentException, FileNotFoundException { // Cria um novo documento com tamanho e margens definidas pelo usurio // new Document(tamanho da pgina, margem esquerda, margem direita, // margem topo, margem rodap); Document doc = new Document(PageSize.A4, 10, 10, 10, 10); try {//from ww w . j a va 2s . c o m JFileChooser jFileChooser = new JFileChooser(); //seta para selecionar apenas arquivos jFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); //desabilita todos os tipos de arquivos jFileChooser.setAcceptAllFileFilterUsed(false); //filtra por extensao jFileChooser.setFileFilter(new FileFilter() { @Override public String getDescription() { return "Extenso PDF"; } @Override public boolean accept(File f) { return f.getName().toLowerCase().endsWith("pdf"); } }); //mostra janela para salvar int acao = jFileChooser.showSaveDialog(null); //executa acao conforme opcao selecionada if (acao == JFileChooser.APPROVE_OPTION) { //escolheu arquivo System.out.println(jFileChooser.getSelectedFile().getAbsolutePath()); PdfWriter.getInstance(doc, new FileOutputStream(jFileChooser.getSelectedFile().getAbsolutePath() + ".pdf")); doc.open(); listaF = f.buscaFilme(""); // Definindo uma fonte, com tamanho 20 e negrito Font f = new Font(Font.FontFamily.COURIER, 30, Font.BOLD); Font f2 = new Font(Font.FontFamily.HELVETICA, 20, Font.BOLD); // adicionando um pargrafo ao documento com a fonte acima Paragraph pa = new Paragraph("Relatrio", f); // Setando o alinhamento p/ o centro pa.setAlignment(Paragraph.ALIGN_CENTER); // Definindo pa.setSpacingAfter(50); doc.add(pa); //doc.add(new Paragraph(" ")); // Criando uma tabela com 4 colunas PdfPTable table = new PdfPTable(7); // Ttulo para a tabela Paragraph tableHeader = new Paragraph("Todos os Ttulos", f2); PdfPCell header = new PdfPCell(tableHeader); // Definindo que o header vai ocupar as 4 colunas header.setColspan(7); // Definindo alinhamento do header header.setHorizontalAlignment(Paragraph.ALIGN_CENTER); // Adicionando o header tabela table.addCell(header); List<String> list = new ArrayList<>(); list.add("Id"); list.add("Ttulo"); list.add("Ano"); list.add("Diretor"); list.add("Gnero"); list.add("Linguagem"); list.add("Locado"); for (Filmes p : listaF) { list.add(String.valueOf(p.getId())); list.add(p.getTitulo()); list.add(String.valueOf(p.getAno())); list.add(p.getDiretor()); list.add(p.getGenero()); list.add(p.getIdioma()); list.add(p.getLocado()); } for (String s : list) { table.addCell(s); } doc.add(table); /* doc.add(new Paragraph(" ID | Nome | Idade | Cidade")); for (Pessoa p : lista) { doc.add(new Paragraph(p.getId() + " | " + p.getNome() + " | " + p.getIdade() + " | " + p.getCidade())); }*/ } } catch (FileNotFoundException | DocumentException e) { System.err.println(e.getMessage()); } doc.close(); }
From source file:BusinessLogic.Controller.HandleCertificate.java
public void downloadCertificate(ContractDAO contrDAO, CertificateDAO certificateDAO, UserDAO usDAO, HttpServletResponse response, int idUser, int option) throws DocumentException, IOException { User user = usDAO.searchByPkID(idUser); List<Certificate> certificateObject = certificateDAO.searchUserAproved(); List<Certificate> certificateReturn = new ArrayList<Certificate>(); if (certificateObject != null) { certificateReturn.clear();//from w w w . ja v a 2s . co m for (int i = 0; i < certificateObject.size(); i++) { if (certificateObject.get(i).getFkuserID().getPkID().equals(user.getPkID())) { certificateReturn.add(certificateObject.get(i)); } } } Contract contractObject = contrDAO.getUserContract(new User(user.getPkID())); Certificate cert = certificateReturn.get(option); Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); document.open(); Font fuente = new Font(); fuente.setStyle(Font.BOLD); fuente.setColor(BaseColor.BLACK); fuente.setFamily(Font.FontFamily.TIMES_ROMAN.toString()); fuente.setSize(15); Paragraph header = new Paragraph("\n\n\n\n\nEL DEPARTAMENTO DE GESTION HUMANA\n" + "DE TALENTO-HUMANO LTDA\n\n\n\n\n" + "CERTIFICA QUE:\n\n\n\n\n", fuente); header.setAlignment(Element.ALIGN_CENTER); Calendar fecha = new GregorianCalendar(); int annio = fecha.get(Calendar.YEAR); int mes = fecha.get(Calendar.MONTH) + 1; int dia = fecha.get(Calendar.DAY_OF_MONTH); Paragraph endtext = new Paragraph("\n\nSe expide la presente certificacion a solicitud" + " del interesado a la fecha de : " + dia + "/" + mes + "/" + annio + "\n\n\nCordialmente\n\n\nEdwin Alexander Bohorquez\nGERENTE GENERAL DE TALENTO-HUMANO LTDA"); endtext.setAlignment(Element.ALIGN_LEFT); String typeCertificate = ""; if (cert.getType().toLowerCase().equals("laboral")) { typeCertificate = "Laboral"; document.add(header); List<String> positionlist = new ArrayList<String>(); for (Position cargo : contractObject.getPositionSet()) { positionlist.add(cargo.getName()); } Paragraph body = new Paragraph(user.getName().toUpperCase() + " " + user.getLastname().toUpperCase() + " con cedula de ciudadania No." + user.getIdentifyCard() + ", trabaja en esta empresa" + " desde " + contractObject.getStartDate() + ", desempeandose actualmente como " + positionlist + " con una asignacion mensual de $" + contractObject.getSalary() + ".Su contrato de trabajo es a termino " + contractObject.getType() + "."); body.setAlignment(Element.ALIGN_JUSTIFIED_ALL); document.add(body); document.add(endtext); } else if (cert.getType().toLowerCase().equals("nmina")) { typeCertificate = "Nomina"; Paragraph Payroll_header = new Paragraph("DEPARTAMENTO DE CONTABILIDAD\n" + "TALENTO-HUMANO LTDA\n\n" + "LIQUIDACION DE NOMINA:\n" + "Nombre del empleado : " + user.getName() + " " + user.getLastname() + "\n" + "Cedula : " + user.getIdentifyCard() + "\n\n", fuente); Payroll_header.setAlignment(Element.ALIGN_CENTER); document.add(Payroll_header); double commissions = 10000; double extra_hours = 50000; double transportation_aid = 63600; double totalAccrued = contractObject.getSalary() + commissions + extra_hours + transportation_aid; PdfPTable basetable = new PdfPTable(2); PdfPCell headertable = new PdfPCell(new Paragraph("Tabla Base", fuente)); headertable.setColspan(2); basetable.addCell(headertable); PdfPCell cell1 = new PdfPCell(new Paragraph("Salario Basico : ")); PdfPCell cell2 = new PdfPCell(new Paragraph(String.valueOf(contractObject.getSalary()))); PdfPCell cell3 = new PdfPCell(new Paragraph("Comisiones : ")); PdfPCell cell4 = new PdfPCell(new Paragraph(String.valueOf(commissions))); PdfPCell cell5 = new PdfPCell(new Paragraph("Horas Extras : ")); PdfPCell cell6 = new PdfPCell(new Paragraph(String.valueOf(extra_hours))); PdfPCell cell7 = new PdfPCell(new Paragraph("Auxilio de transporte : ")); PdfPCell cell8 = new PdfPCell(new Paragraph(String.valueOf(transportation_aid))); PdfPCell ce9 = new PdfPCell(new Paragraph("Total Devengado : ")); PdfPCell ce10 = new PdfPCell(new Paragraph(" $ " + String.valueOf(totalAccrued))); basetable.setWidthPercentage(100F); basetable.setHorizontalAlignment(Element.ALIGN_CENTER); basetable.addCell(cell1); basetable.addCell(cell2); basetable.addCell(cell3); basetable.addCell(cell4); basetable.addCell(cell5); basetable.addCell(cell6); basetable.addCell(cell7); basetable.addCell(cell8); basetable.addCell(ce9); basetable.addCell(ce10); document.add(basetable); PdfPTable tableliquidation = new PdfPTable(2); PdfPCell title = new PdfPCell( new Paragraph("Liquidacion. Deducciones de nomina(Conceptos a cargo del empleado) ", fuente)); title.setColspan(2); tableliquidation.addCell(title); PdfPCell cell9 = new PdfPCell(new Paragraph("Salud (4%) : ")); PdfPCell cell10 = new PdfPCell(new Paragraph(String.valueOf(contractObject.getSalary() * 0.04))); PdfPCell cell11 = new PdfPCell(new Paragraph("Pension (4%) : ")); PdfPCell cell12 = new PdfPCell(new Paragraph(String.valueOf(contractObject.getSalary() * 0.04))); tableliquidation.setWidthPercentage(100F); tableliquidation.setHorizontalAlignment(Element.ALIGN_CENTER); tableliquidation.addCell(cell9); tableliquidation.addCell(cell10); tableliquidation.addCell(cell11); tableliquidation.addCell(cell12); document.add(tableliquidation); PdfPTable tablesocialSecurity = new PdfPTable(2); PdfPCell title2 = new PdfPCell(new Paragraph("Seguridad Social a cargo del empleador", fuente)); title2.setColspan(2); tablesocialSecurity.addCell(title2); PdfPCell cell13 = new PdfPCell(new Paragraph("Salud (8.5%) : ")); PdfPCell cell14 = new PdfPCell(new Paragraph(String.valueOf(contractObject.getSalary() * 0.085))); PdfPCell cell15 = new PdfPCell(new Paragraph("Pension (12%) : ")); PdfPCell cell16 = new PdfPCell(new Paragraph(String.valueOf(contractObject.getSalary() * 0.12))); PdfPCell cell17 = new PdfPCell(new Paragraph("A.R.P : ")); PdfPCell cell18 = new PdfPCell(new Paragraph(String.valueOf(contractObject.getSalary() * 0.00522))); tablesocialSecurity.setWidthPercentage(100F); tablesocialSecurity.setHorizontalAlignment(Element.ALIGN_CENTER); tablesocialSecurity.addCell(cell13); tablesocialSecurity.addCell(cell14); tablesocialSecurity.addCell(cell15); tablesocialSecurity.addCell(cell16); tablesocialSecurity.addCell(cell17); tablesocialSecurity.addCell(cell18); document.add(tablesocialSecurity); PdfPTable social_benefits = new PdfPTable(2); PdfPCell title3 = new PdfPCell(new Paragraph("Prestaciones Sociales", fuente)); title3.setColspan(2); social_benefits.addCell(title3); PdfPCell cell19 = new PdfPCell(new Paragraph("Prima de servicios : ")); PdfPCell cell20 = new PdfPCell(new Paragraph(String.valueOf(totalAccrued * 0.0833))); PdfPCell cell21 = new PdfPCell(new Paragraph("Cesantias : ")); PdfPCell cell22 = new PdfPCell(new Paragraph(String.valueOf(totalAccrued * 0.0833))); PdfPCell cell23 = new PdfPCell(new Paragraph("Intereses sobre las cesantias : ")); PdfPCell cell24 = new PdfPCell(new Paragraph(String.valueOf(totalAccrued * 0.0833 * 0.12))); PdfPCell cell25 = new PdfPCell(new Paragraph("Vacaciones : ")); PdfPCell cell26 = new PdfPCell(new Paragraph(String.valueOf(contractObject.getSalary() * 0.0417))); social_benefits.setWidthPercentage(100F); social_benefits.setHorizontalAlignment(Element.ALIGN_CENTER); social_benefits.addCell(cell19); social_benefits.addCell(cell20); social_benefits.addCell(cell21); social_benefits.addCell(cell22); social_benefits.addCell(cell23); social_benefits.addCell(cell24); social_benefits.addCell(cell25); social_benefits.addCell(cell26); document.add(social_benefits); PdfPTable fiscal_contributions = new PdfPTable(2); PdfPCell title4 = new PdfPCell(new Paragraph("Aportes Parafiscales", fuente)); title4.setColspan(2); fiscal_contributions.addCell(title4); PdfPCell cell27 = new PdfPCell(new Paragraph("Cajas de compensacion familiar (4%) : ")); PdfPCell cell28 = new PdfPCell( new Paragraph(String.valueOf((contractObject.getSalary() + extra_hours + commissions) * 0.04))); PdfPCell cell29 = new PdfPCell(new Paragraph("I.CB.F (3%) : ")); PdfPCell cell30 = new PdfPCell( new Paragraph(String.valueOf((contractObject.getSalary() + extra_hours + commissions) * 0.03))); PdfPCell cell31 = new PdfPCell(new Paragraph("Sena (2%) : ")); PdfPCell cell32 = new PdfPCell( new Paragraph(String.valueOf((contractObject.getSalary() + extra_hours + commissions) * 0.02))); fiscal_contributions.setWidthPercentage(100F); fiscal_contributions.setHorizontalAlignment(Element.ALIGN_CENTER); fiscal_contributions.addCell(cell27); fiscal_contributions.addCell(cell28); fiscal_contributions.addCell(cell29); fiscal_contributions.addCell(cell30); fiscal_contributions.addCell(cell31); fiscal_contributions.addCell(cell32); document.add(fiscal_contributions); PdfPTable totalValue = new PdfPTable(2); PdfPCell title5 = new PdfPCell(new Paragraph("Neto a pagar al empleado", fuente)); title5.setColspan(2); totalValue.addCell(title5); PdfPCell cell33 = new PdfPCell(new Paragraph(" Total devengado - salud - pension")); cell33.setColspan(2); PdfPCell cell34 = new PdfPCell(new Paragraph( " $ " + String.valueOf(totalAccrued - contractObject.getSalary() * 0.08), fuente)); cell34.setColspan(2); totalValue.setWidthPercentage(100F); totalValue.setHorizontalAlignment(Element.ALIGN_CENTER); totalValue.addCell(cell33); totalValue.addCell(cell34); document.add(totalValue); document.add(endtext); } else if (cert.getType().toLowerCase().equals("salud")) { typeCertificate = "Salud"; document.add(header); Paragraph body = new Paragraph(user.getName().toUpperCase() + " " + user.getLastname().toUpperCase() + " con cedula de ciudadania No." + user.getIdentifyCard() + ", esta afiliado desde " + contractObject.getStartHealthDate() + " a la empresa de salud " + contractObject.getHealthEnterprise() + "."); body.setAlignment(Element.ALIGN_JUSTIFIED_ALL); document.add(body); document.add(endtext); } else if (cert.getType().toLowerCase().equals("pensin")) { typeCertificate = "Pension"; document.add(header); Paragraph body = new Paragraph(user.getName().toUpperCase() + " " + user.getLastname().toUpperCase() + " con cedula de ciudadania No." + user.getIdentifyCard() + ", esta afiliado a la empresa de pension " + contractObject.getPensionEnterprise() + ".La fecha de inicio de pension es " + contractObject.getStartPensionDate() + "."); body.setAlignment(Element.ALIGN_JUSTIFIED_ALL); document.add(body); document.add(endtext); } document.close(); response.setHeader("Expires", "0"); response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); response.setHeader("Pragma", "public"); response.setContentType("application/octet-strem"); File f = new File("Certificado" + typeCertificate + ".pdf"); response.setHeader("Content-Disposition", "attachment;filename=" + f.getName()); response.setContentLength(baos.size()); System.out.println("Hasta aca crea el pdf bien"); OutputStream os = response.getOutputStream(); System.out.println("Ac'a ya deberia haber descargado"); baos.writeTo(os); os.flush(); os.close(); }
From source file:ca.sqlpower.wabit.swingui.chart.ChartPanel.java
License:Open Source License
private void buildUI() { // First level in the panel has only 2 rows of 1 column panel.setLayout(new MigLayout("fill", "[grow, fill]", "[shrink]10[grow, fill]")); panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.GRAY), BorderFactory.createEmptyBorder(5, 5, 5, 5))); // Now we build the upper part. // The "data" section. JPanel topPanel = new JPanel(new MigLayout("fill", "[115]10[fill, grow]", "[]10[]10[400]")); JLabel dataCategoryLabel = new JLabel("Data"); dataCategoryLabel.setFont(dataCategoryLabel.getFont().deriveFont(Font.BOLD)); topPanel.add(dataCategoryLabel, "span, wrap"); topPanel.add(new JLabel("Data source"), "gapleft 15"); topPanel.add(queryComboBox, "wrap"); JScrollPane tableScrollPane = new JScrollPane(resultTable); topPanel.add(headerLegendContainer, "gapleft 15, aligny top"); topPanel.add(tableScrollPane);/*from w w w .jav a 2 s.c om*/ panel.add(topPanel, "wrap"); // Now the lower part. It has two parts. The options scrolling pane and the preview. JPanel bottomPanel = new JPanel( new MigLayout("fill, hidemode 2", "[grow]10[fill, shrinkprio 101]", "[fill]")); JLabel optionsCategoryLabel = new JLabel("Options"); optionsCategoryLabel.setFont(optionsCategoryLabel.getFont().deriveFont(Font.BOLD)); bottomPanel.add(optionsCategoryLabel); JLabel previewCategoryLabel = new JLabel("Preview"); previewCategoryLabel.setFont(previewCategoryLabel.getFont().deriveFont(Font.BOLD)); bottomPanel.add(previewCategoryLabel, "wrap"); JScrollPane optionsScrollPane = new JScrollPane(buildChartPrefsPanel(), JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); optionsScrollPane.setBorder(null); bottomPanel.add(optionsScrollPane, "push, gapleft 15"); JPanel chartAndErrorPanel = new JPanel(new BorderLayout()); chartAndErrorPanel.add(chartError, BorderLayout.NORTH); chartAndErrorPanel.add(chartPanel, BorderLayout.CENTER); bottomPanel.add(chartAndErrorPanel, "width 100%, alignx left, gapleft 15"); panel.add(bottomPanel, "height 100%"); toolBarBuilder.add(refreshDataAction); toolBarBuilder.add(revertToDefaultsAction); //Since the first button on the tool bar will be displayed this size will be the //same as the font size of a displayed button. If the button wasn't being displayed //the font size ends up incorrect float fontSize = toolBarBuilder.getToolbar().getComponentAtIndex(0).getFont().getSize(); toolBarBuilder.addSeparator(); toolBarBuilder.add(makeChartTypeButton("Bar", ChartType.BAR, BAR_CHART_ICON, fontSize)); toolBarBuilder.add(makeChartTypeButton("Pie", ChartType.PIE, PIE_CHART_ICON, fontSize)); toolBarBuilder .add(makeChartTypeButton("Category Line", ChartType.CATEGORY_LINE, LINE_CHART_ICON, fontSize)); toolBarBuilder.addSeparator(); toolBarBuilder.add(makeChartTypeButton("Line", ChartType.LINE, LINE_CHART_ICON, fontSize)); toolBarBuilder.add(makeChartTypeButton("Scatter", ChartType.SCATTER, SCATTER_CHART_ICON, fontSize)); }
From source file:ca.sqlpower.wabit.swingui.olap.SlicerPanel.java
License:Open Source License
/** * This method updates the view and sets up the panel *///www .j ava 2 s .com private void updatePanel() { removeAll(); Member slicerMember = olapQuery.getSlicerMember(); if (slicerMember != null) { slicerDisplay = new JPanel(); JLabel axisTitle = new JLabel("Filter By: "); slicerDisplay.add(axisTitle); if (slicerMember instanceof Measure) { if (slicerMember instanceof Measure) { slicerDisplay.add(new JLabel(OlapIcons.MEASURE_ICON)); } slicerDisplay.add(new JLabel(slicerMember.getName())); } else { String point = " > "; slicerDisplay.add(new JLabel(OlapIcons.DIMENSION_ICON)); slicerDisplay.add(new JLabel(slicerMember.getDimension().getName() + point)); slicerDisplay.add(new JLabel(OlapIcons.HIERARCHY_ICON)); slicerDisplay.add(new JLabel(slicerMember.getHierarchy().getName() + point)); slicerDisplay.add(new JLabel(OlapIcons.LEVEL_ICON)); slicerDisplay.add(new JLabel(slicerMember.getLevel().getName() + point)); List<JLabel> labels = new ArrayList<JLabel>(); point = ""; while (slicerMember != null) { labels.add(0, new JLabel(slicerMember.getName() + point)); if (slicerMember instanceof Measure) { labels.add(0, new JLabel(OlapIcons.MEASURE_ICON)); } slicerMember = slicerMember.getParentMember(); point = " > "; } for (JLabel label : labels) { slicerDisplay.add(label); } } slicerDisplay.setBorder(DEFAULT_BORDER); slicerDisplay.setVisible(true); add(slicerDisplay); slicerDisplay.setBackground(Color.WHITE); } else { JLabel filterAxisLabel = new JLabel("Filter Axis:"); filterAxisLabel.setFont(filterAxisLabel.getFont().deriveFont(Font.BOLD)); add(filterAxisLabel); add(new JLabel(SLICER_TEXT)); setBorder(CellSetTableHeaderComponent.ROUNDED_DASHED_BORDER); setBackground(Color.WHITE); CellSetTableHeaderComponent.addGreyedButtonsToPanel(this); } }
From source file:ca.sqlpower.wabit.swingui.report.ResultSetSwingRenderer.java
License:Open Source License
public DataEntryPanel getPropertiesPanel() { FormLayout layout = new FormLayout("20dlu, 4dlu, pref, 4dlu, 300dlu:grow, 4dlu, pref"); final DefaultFormBuilder fb = new DefaultFormBuilder(layout); final JLabel visOptionsLabel = new JLabel("Visual"); visOptionsLabel.setFont(visOptionsLabel.getFont().deriveFont(Font.BOLD)); fb.append(visOptionsLabel, 7);//from w w w. j a v a 2 s. c o m fb.nextLine(); fb.append(""); final JLabel headerFontExample = new JLabel("Header Font Example"); headerFontExample.setFont(renderer.getHeaderFont()); fb.append("Headers Font", headerFontExample, ReportUtil.createFontButton(headerFontExample, renderer)); fb.nextLine(); fb.append(""); final JLabel bodyFontExample = new JLabel("Body Font Example"); bodyFontExample.setFont(renderer.getBodyFont()); fb.append("Body Font", bodyFontExample, ReportUtil.createFontButton(bodyFontExample, renderer)); fb.nextLine(); fb.append(""); final JLabel backgroundColourLabel = new JLabel(" "); final JButton backgroundColorPickerButton = new JButton("Choose..."); backgroundColourLabel.setOpaque(true); backgroundColourLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); backgroundColourLabel.setBackground( renderer.getBackgroundColour() == null ? Color.WHITE : renderer.getBackgroundColour()); backgroundColourLabel.addMouseListener(new MouseListener() { public void mouseReleased(MouseEvent e) { // no op } public void mousePressed(MouseEvent e) { // no op } public void mouseExited(MouseEvent e) { // no op } public void mouseEntered(MouseEvent e) { // no op } public void mouseClicked(MouseEvent e) { Color c; c = JColorChooser.showDialog(backgroundColorPickerButton, "Choose a background color", backgroundColourLabel.getBackground()); if (c != null) { backgroundColourLabel.setBackground(c); } } }); backgroundColorPickerButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Color c; c = JColorChooser.showDialog(backgroundColorPickerButton, "Choose a background color", backgroundColourLabel.getBackground()); if (c != null) { backgroundColourLabel.setBackground(c); } } }); fb.append("Background color", backgroundColourLabel, backgroundColorPickerButton); fb.append(""); fb.nextLine(); fb.append(""); final JLabel headerColourLabel = new JLabel(" "); final JButton headerColorPickerButton = new JButton("Choose..."); headerColourLabel.setOpaque(true); headerColourLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); headerColourLabel .setBackground(renderer.getHeaderColour() == null ? Color.WHITE : renderer.getHeaderColour()); headerColourLabel.addMouseListener(new MouseListener() { public void mouseReleased(MouseEvent e) { // no op } public void mousePressed(MouseEvent e) { // no op } public void mouseExited(MouseEvent e) { // no op } public void mouseEntered(MouseEvent e) { // no op } public void mouseClicked(MouseEvent e) { Color c; c = JColorChooser.showDialog(headerColorPickerButton, "Choose a header color", headerColourLabel.getBackground()); if (c != null) { headerColourLabel.setBackground(c); } } }); headerColorPickerButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Color c; c = JColorChooser.showDialog(headerColorPickerButton, "Choose a header color", headerColourLabel.getBackground()); if (c != null) { headerColourLabel.setBackground(c); } } }); fb.append("Headers color", headerColourLabel, headerColorPickerButton); fb.append(""); fb.nextLine(); fb.append(""); final JLabel dataColourLabel = new JLabel(" "); final JButton dataColorPickerButton = new JButton("Choose..."); dataColourLabel.setOpaque(true); dataColourLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); dataColourLabel.setBackground(renderer.getDataColour() == null ? Color.WHITE : renderer.getDataColour()); dataColourLabel.addMouseListener(new MouseListener() { public void mouseReleased(MouseEvent e) { // no op } public void mousePressed(MouseEvent e) { // no op } public void mouseExited(MouseEvent e) { // no op } public void mouseEntered(MouseEvent e) { // no op } public void mouseClicked(MouseEvent e) { Color c; c = JColorChooser.showDialog(dataColorPickerButton, "Choose a data color", dataColourLabel.getBackground()); if (c != null) { dataColourLabel.setBackground(c); } } }); dataColorPickerButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Color c; c = JColorChooser.showDialog(dataColorPickerButton, "Choose a data color", dataColourLabel.getBackground()); if (c != null) { dataColourLabel.setBackground(c); } } }); fb.append("Data cells color", dataColourLabel, dataColorPickerButton); fb.append(""); fb.nextLine(); fb.append(""); final JComboBox borderComboBox = new JComboBox(BorderStyles.values()); borderComboBox.setSelectedItem(renderer.getBorderType()); fb.append("Border", borderComboBox); fb.nextLine(); fb.append(""); fb.appendUnrelatedComponentsGapRow(); fb.nextLine(); final JLabel dataOptionsLabel = new JLabel("Data"); dataOptionsLabel.setFont(dataOptionsLabel.getFont().deriveFont(Font.BOLD)); fb.append(dataOptionsLabel, 7); fb.nextLine(); fb.append(""); final JTextField nullStringField = new JTextField(renderer.getNullString()); fb.append("Null string", nullStringField); fb.nextLine(); fb.append(""); final JCheckBox grandTotalsCheckBox = new JCheckBox("Add Grand totals"); grandTotalsCheckBox.setSelected(renderer.isPrintingGrandTotals()); fb.append("", grandTotalsCheckBox); fb.nextLine(); fb.appendUnrelatedComponentsGapRow(); final JLabel columnOptionsLabel = new JLabel("Columns"); columnOptionsLabel.setFont(columnOptionsLabel.getFont().deriveFont(Font.BOLD)); fb.append(columnOptionsLabel, 7); fb.nextLine(); fb.append(""); JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); final List<DataEntryPanel> columnPanels = new ArrayList<DataEntryPanel>(); for (ColumnInfo ci : renderer.getColumnInfoList()) { DataEntryPanel dep = createColumnPropsPanel(ci); columnPanels.add(dep); tabbedPane.add(ci.getName(), dep.getPanel()); } fb.append(tabbedPane, 5); fb.nextLine(); fb.appendUnrelatedComponentsGapRow(); return new DataEntryPanel() { public boolean applyChanges() { renderer.setHeaderFont(headerFontExample.getFont()); renderer.setBodyFont(bodyFontExample.getFont()); renderer.setNullString(nullStringField.getText()); renderer.setBackgroundColour(backgroundColourLabel.getBackground()); renderer.setDataColour(dataColourLabel.getBackground()); renderer.setHeaderColour(headerColourLabel.getBackground()); renderer.setBorderType((BorderStyles) borderComboBox.getSelectedItem()); renderer.setPrintingGrandTotals(grandTotalsCheckBox.isSelected()); boolean applied = true; for (DataEntryPanel columnPropsPanel : columnPanels) { applied &= columnPropsPanel.applyChanges(); } return applied; } public void discardChanges() { for (DataEntryPanel columnPropsPanel : columnPanels) { columnPropsPanel.discardChanges(); } } public JComponent getPanel() { return fb.getPanel(); } public boolean hasUnsavedChanges() { boolean hasUnsaved = false; for (DataEntryPanel columnPropsPanel : columnPanels) { hasUnsaved |= columnPropsPanel.hasUnsavedChanges(); } return hasUnsaved; } }; }
From source file:ca.sqlpower.wabit.swingui.report.ResultSetSwingRenderer.java
License:Open Source License
/** * Helper method for {@link #getPropertiesPanel()}. *///from ww w .ja va 2 s.c om private DataEntryPanel createColumnPropsPanel(final ColumnInfo ci) { final FormLayout layout = new FormLayout( "80dlu, 10dlu, min(pref; 100dlu):grow, 4dlu, pref:grow, 10dlu, pref:grow"); DefaultFormBuilder fb = new DefaultFormBuilder(layout); final JTextField columnLabel = new JTextField(ci.getName()); final JLabel widthLabel = new JLabel("Size"); final JSpinner widthSpinner = new JSpinner(new SpinnerNumberModel(ci.getWidth(), 0, Integer.MAX_VALUE, 12)); final JComboBox dataTypeComboBox = new JComboBox(DataType.values()); final JLabel dataTypeLabel = new JLabel("Type"); final JComboBox formatComboBox = new JComboBox(); formatComboBox.setEditable(true); final JLabel formatLabel = new JLabel("Format"); final JCheckBox subtotalCheckbox = new JCheckBox("Print Subtotals"); final JLabel linkingLabel = new JLabel("Link to report"); final JComboBox linkingBox = new JComboBox(); // XXX Enable only when this is working. linkingBox.setEnabled(false); final ButtonGroup breakAndGroupButtons = new ButtonGroup(); final JRadioButton noBreakOrGroupButton = new JRadioButton("None"); breakAndGroupButtons.add(noBreakOrGroupButton); final JRadioButton breakRadioButton = new JRadioButton("Break Into Sections"); breakAndGroupButtons.add(breakRadioButton); final JRadioButton pageBreakRadioButton = new JRadioButton("Break Into Sections (page break)"); breakAndGroupButtons.add(pageBreakRadioButton); final JRadioButton groupRadioButton = new JRadioButton("Group (Suppress Repeating Values)"); breakAndGroupButtons.add(groupRadioButton); final JLabel alignmentLabel = new JLabel("Alignment"); ButtonGroup hAlignmentGroup = new ButtonGroup(); final JToggleButton leftAlign = new JToggleButton(AlignmentIcons.LEFT_ALIGN_ICON, ci.getHorizontalAlignment() == HorizontalAlignment.LEFT); hAlignmentGroup.add(leftAlign); final JToggleButton centreAlign = new JToggleButton(AlignmentIcons.CENTRE_ALIGN_ICON, ci.getHorizontalAlignment() == HorizontalAlignment.CENTER); hAlignmentGroup.add(centreAlign); final JToggleButton rightAlign = new JToggleButton(AlignmentIcons.RIGHT_ALIGN_ICON, ci.getHorizontalAlignment() == HorizontalAlignment.RIGHT); hAlignmentGroup.add(rightAlign); Box alignmentBox = Box.createHorizontalBox(); alignmentBox.add(leftAlign); alignmentBox.add(centreAlign); alignmentBox.add(rightAlign); alignmentBox.add(Box.createHorizontalGlue()); /* * ROW 1 - Caption text field + two labels */ JLabel captionLabel = new JLabel("Caption"); captionLabel.setFont(captionLabel.getFont().deriveFont(Font.BOLD)); fb.append(captionLabel); JLabel visLabel = new JLabel("Visual options"); visLabel.setFont(visLabel.getFont().deriveFont(Font.BOLD)); fb.append(visLabel, 3); JLabel advLabel = new JLabel("Advanced options"); advLabel.setFont(advLabel.getFont().deriveFont(Font.BOLD)); fb.append(advLabel); fb.nextLine(); /* * Separator row */ fb.append(new JSeparator(), 7); fb.nextLine(); /* * Row 2 */ fb.append(columnLabel); fb.append(widthLabel); fb.append(widthSpinner); fb.append(subtotalCheckbox); subtotalCheckbox.setSelected(ci.getWillSubtotal()); if (ci.getDataType().equals(DataType.NUMERIC)) { subtotalCheckbox.setEnabled(true); } else { subtotalCheckbox.setEnabled(false); } fb.nextLine(); /* * Row 3 */ fb.append(new JLabel()); fb.append(dataTypeLabel); fb.append(dataTypeComboBox); fb.append(linkingLabel); fb.nextLine(); /* * Row 4 */ fb.append(new JLabel()); fb.append(formatLabel); fb.append(formatComboBox); fb.append(linkingBox); fb.nextLine(); /* * Row 5 */ fb.append(new JLabel()); fb.append(alignmentLabel); fb.append(alignmentBox); fb.append(new JLabel("Breaking and Grouping")); fb.nextLine(); /* * Row 6 */ fb.append(new JLabel(), 5); fb.append(noBreakOrGroupButton); fb.nextLine(); /* * Row 7 */ fb.append(new JLabel(), 5); fb.append(breakRadioButton); fb.nextLine(); /* * Row 8 */ fb.append(new JLabel(), 5); fb.append(pageBreakRadioButton); fb.nextLine(); /* * spacer */ fb.append(new JLabel(), 5); fb.append(groupRadioButton); fb.nextLine(); dataTypeComboBox.setSelectedItem(ci.getDataType()); if (dataTypeComboBox.getSelectedItem() == DataType.TEXT) { formatComboBox.setEnabled(false); } else { setItemforFormatComboBox(formatComboBox, (DataType) dataTypeComboBox.getSelectedItem()); if (ci.getFormat() != null) { this.setOrInsertFormat(formatComboBox, ci.getFormat()); } } dataTypeComboBox.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent e) { if (((JComboBox) e.getSource()).getSelectedItem() == DataType.TEXT) { formatComboBox.setEnabled(false); subtotalCheckbox.setEnabled(false); } else if (((JComboBox) e.getSource()).getSelectedItem() == DataType.DATE) { formatComboBox.setEnabled(true); subtotalCheckbox.setEnabled(false); } else if (((JComboBox) e.getSource()).getSelectedItem() == DataType.NUMERIC) { formatComboBox.setEnabled(true); subtotalCheckbox.setEnabled(true); } setItemforFormatComboBox(formatComboBox, (DataType) dataTypeComboBox.getSelectedItem()); } }); if (ci.getWillGroupOrBreak().equals(GroupAndBreak.GROUP)) { groupRadioButton.setSelected(true); } else if (ci.getWillGroupOrBreak().equals(GroupAndBreak.BREAK)) { breakRadioButton.setSelected(true); } else if (ci.getWillGroupOrBreak().equals(GroupAndBreak.PAGEBREAK)) { pageBreakRadioButton.setSelected(true); } else { noBreakOrGroupButton.setSelected(true); } // XXX Enable only when this is working // for (Report report : WabitUtils.getWorkspace(ci).getReports()) { // linkingBox.addItem(report); // } // linkingBox.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent e) { // // TODO populate and add a listener to the linking box // } // }); final JPanel panel = fb.getPanel(); panel.setBorder(BorderFactory.createEmptyBorder(5, 3, 3, 5)); return new DataEntryPanel() { public boolean applyChanges() { ci.setName(columnLabel.getText()); if (leftAlign.isSelected()) { ci.setHorizontalAlignment(HorizontalAlignment.LEFT); } else if (centreAlign.isSelected()) { ci.setHorizontalAlignment(HorizontalAlignment.CENTER); } else if (rightAlign.isSelected()) { ci.setHorizontalAlignment(HorizontalAlignment.RIGHT); } ci.setDataType((DataType) dataTypeComboBox.getSelectedItem()); logger.debug("formatCombobBox.getSelectedItem is" + (String) formatComboBox.getSelectedItem()); if (((DataType) dataTypeComboBox.getSelectedItem()).equals(DataType.TEXT) || (formatComboBox.getSelectedItem() != null && ((String) formatComboBox.getSelectedItem()) .equals(ReportUtil.DEFAULT_FORMAT_STRING))) { ci.setFormat(null); } else { ci.setFormat(getFormat(ci.getDataType(), (String) formatComboBox.getSelectedItem())); } ci.setWidth((Integer) widthSpinner.getValue()); if (groupRadioButton.isSelected()) { ci.setWillGroupOrBreak(GroupAndBreak.GROUP); } else if (breakRadioButton.isSelected()) { ci.setWillGroupOrBreak(GroupAndBreak.BREAK); } else if (pageBreakRadioButton.isSelected()) { ci.setWillGroupOrBreak(GroupAndBreak.PAGEBREAK); } else { ci.setWillGroupOrBreak(GroupAndBreak.NONE); } ci.setWillSubtotal(subtotalCheckbox.isSelected()); renderer.refresh(); return true; } public void discardChanges() { // no op } public JComponent getPanel() { return panel; } public boolean hasUnsavedChanges() { return true; } }; }
From source file:ca.sqlpower.wabit.swingui.report.selectors.ComboBoxSelectorPanel.java
License:Open Source License
private void buildPanel() { JLabel logo = new JLabel(WabitIcons.PARAMETERS_COMBO_16); JLabel title = new JLabel("Drop down list"); title.setFont(title.getFont().deriveFont(Font.BOLD)); title.setFont(title.getFont().deriveFont(12f)); Box titleBox = Box.createHorizontalBox(); titleBox.add(logo);//from w w w. j a v a 2 s.c o m titleBox.add(new JLabel(" ")); titleBox.add(title); // Build the 'general' section JLabel generalLabel = new JLabel("General"); generalLabel.setFont(generalLabel.getFont().deriveFont(Font.BOLD)); JLabel genLabelLabel = new JLabel("Name"); JLabel valuesLabel = new JLabel("Values"); valuesLabel.setFont(valuesLabel.getFont().deriveFont(Font.BOLD)); JLabel valTypeLabel = new JLabel("Source type"); valTypeCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (!valTypeCombo.getSelectedItem().equals(currentMode)) { currentMode = (Mode) valTypeCombo.getSelectedItem(); updateUi(); } } }); JLabel valSpecLabel = new JLabel("Source"); this.valSpecVarButton.setAction(insertVariableAction); valSpecField.addMouseListener(new MouseListener() { public void mouseReleased(MouseEvent e) { // Not interested. } public void mousePressed(MouseEvent e) { // Not interested. } public void mouseExited(MouseEvent e) { // Not interested. } public void mouseEntered(MouseEvent e) { // Not interested. } public void mouseClicked(MouseEvent e) { if (currentMode.equals(Mode.Variable)) { insertVariableAction.actionPerformed(null); } } }); panel.add(titleBox, "span, wrap"); panel.add(new JLabel(" "), "span, wrap"); panel.add(generalLabel, "span, wrap"); panel.add(genLabelLabel, "gapleft 15px"); panel.add(genLabelField, "span, wrap, wmin 300px, wmax 300px"); panel.add(new JLabel(" "), "span, wrap"); panel.add(valuesLabel, "span, wrap"); panel.add(valTypeLabel, "gapleft 15px"); panel.add(valTypeCombo, "span, wrap, wmin 300px, wmax 300px"); panel.add(valSpecLabel, "gapleft 15px"); Box specBox = Box.createHorizontalBox(); specBox.add(valSpecField, "growx, wmin 200px, wmax 300px"); specBox.add(valSpecVarButton, "wrap, wmin 100px, wmax 100px"); panel.add(specBox, "wrap, wmin 300px, wmax 300px"); panel.add(defValueLabel, "gapleft 15px"); panel.add(defValueField, "span, wrap, wmin 300px, wmax 300px"); panel.add(includeDefValueLabel, "gapleft 15px"); panel.add(includeDefValueBox, "span, wrap"); panel.add(staticHelpLabel, "gapleft 15px, span, wrap"); panel.add(new JLabel(" ")); }