@Override public Component getTableCellEditorComponent( JTable table, Object value, boolean isSelected, int row, int column) { JComboBox box = (JComboBox) super.getTableCellEditorComponent(table, value, isSelected, row, column); // set the correct selected value... Misc.setComboBoxTag(true, value, box); return box; }
public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (isSelected) { setForeground(table.getSelectionForeground()); super.setBackground(table.getSelectionBackground()); } else { setForeground(table.getForeground()); setBackground(table.getBackground()); } // Select the current value // set the correct selected value... Misc.setComboBoxTag(true, value, this); return this; }
/** * Creates and initializes a file chooser. * * @return the initialized file chooser */ protected JFileChooser prepareFileChooser() { JFileChooser chooser = new JFileChooser(); File currDir = Misc.findStartingDirectory(); FileUtil.preventFileChooserSymlinkTraversal(chooser, currDir); HelpCtx.setHelpIDString(chooser, getHelpCtx().getHelpID()); FileFilterAdapter mainFilter = new FileFilterAdapter(".jrxml", "JasperReports Template (.jrxml)"); chooser.addChoosableFileFilter(mainFilter); chooser.addChoosableFileFilter(new FileFilterAdapter(".jrctx", "Chart Theme file (.jrctx)")); chooser.addChoosableFileFilter(new FileFilterAdapter(".jrtx", "Style Template file (.jrtx)")); chooser.addChoosableFileFilter( new FileFilterAdapter(".properties", "Resource Bundle (.properties)")); chooser.addChoosableFileFilter( new FileFilterAdapter(".jasper", "Compiled JasperReport (.jasper)")); chooser.setFileFilter(mainFilter); chooser.setMultiSelectionEnabled(true); return chooser; }
@Override public JRDesignElement createReportElement(JasperDesign jd) { JRDesignTextField element = (JRDesignTextField) super.createReportElement(jd); FieldPercentageDialog dialog = new FieldPercentageDialog(Misc.getMainFrame()); dialog.setJasperDesign(jd); dialog.setVisible(true); if (dialog.getDialogResult() == JOptionPane.OK_OPTION) { JRField f = dialog.getSelectedField(); ResetTypeEnum resetType = dialog.getSelectedResetTypeValue(); JRGroup group = null; if (resetType == ResetTypeEnum.GROUP) { group = dialog.getSelectedGroup(); } // Let's create the variable... JRDesignVariable variable = new JRDesignVariable(); for (int i = 0; ; ++i) { String vname = f.getName() + "_SUM"; if (i > 0) vname += "_" + i; if (jd.getVariablesMap().containsKey(vname)) { continue; } variable.setName(vname); break; } variable.setExpression( Misc.createExpression(f.getValueClassName(), "$F{" + f.getName() + "}")); variable.setValueClassName(f.getValueClassName()); variable.setCalculation(CalculationEnum.SUM); variable.setResetType(resetType); if (resetType == ResetTypeEnum.GROUP) { variable.setResetGroup(group); } try { jd.addVariable(variable); } catch (JRException ex) { ex.printStackTrace(); } ((JRDesignExpression) element.getExpression()) .setText( "new Double( $F{" + f.getName() + "}.doubleValue() / $V{" + variable.getName() + "}.doubleValue() )"); ((JRDesignExpression) element.getExpression()).setValueClassName("java.lang.Double"); element.setPattern("#,##0.00%"); setMatchingClassExpression( ((JRDesignExpression) element.getExpression()), ((JRDesignExpression) element.getExpression()).getValueClassName(), true); element.setEvaluationTime(EvaluationTimeEnum.AUTO); return element; } return null; }