private void createGUI(final Window parent, final Program program) {
UiUtilities.registerForClosing(this);
mDialog.setTitle(mLocalizer.msg("title","Print program info"));
final OrderChooser fieldChooser = new OrderChooser(ProgramInfoPrintSettings.getInstance().getFieldTypes(),ProgramTextCreator.getDefaultOrder(),true);
final FontChooserPanel fontChooser = new FontChooserPanel("",ProgramInfoPrintSettings.getInstance().getFont(), false);
final JCheckBox printImage = new JCheckBox(mLocalizer.msg("printImage","Print image"), ProgramInfoPrintSettings.getInstance().isPrintImage());
final JCheckBox printPluginIcons = new JCheckBox(mLocalizer.msg("printPluginIcons","Print plugin icons"), ProgramInfoPrintSettings.getInstance().isPrintPluginIcons());
final PrinterJob printerJob = PrinterJob.getPrinterJob();
mPageFormat = printerJob.defaultPage();
JButton printerSetupBtn = new JButton(SettingsDialog.mLocalizer.ellipsisMsg("printer","Printer"),PrintPlugin.getInstance().createImageIcon("devices", "printer", 16));
printerSetupBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new Thread("Printer setup") {
public void run() {
printerJob.printDialog();
}
}.start();
}
});
JButton pageBtn = new JButton(SettingsDialog.mLocalizer.ellipsisMsg("page","Page"), PrintPlugin.getInstance().createImageIcon("actions", "document-properties", 16));
pageBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
new Thread("Document setup (printing)"){
public void run(){
if (mPageFormat == null) {
mPageFormat = printerJob.defaultPage();
}
mPageFormat = printerJob.pageDialog(mPageFormat);
}
}.start();
}
});
JButton previewBtn = new JButton(SettingsDialog.mLocalizer.ellipsisMsg("preview","Preview"), PrintPlugin.getInstance().createImageIcon("actions", "document-print-preview", 16));
previewBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (mPageFormat == null) {
mPageFormat = printerJob.defaultPage();
}
mFieldTypes = fieldChooser.getOrder();
DocumentRenderer printJob = createPrintjob(program, fontChooser, printImage, printPluginIcons);
PreviewDlg dlg = new PreviewDlg(mDialog, printJob, mPageFormat, printJob.getPageCount());
PrintPlugin.getInstance().layoutWindow("previewDlg",dlg);
dlg.setVisible(true);
}
});
JButton print = new JButton(SettingsDialog.mLocalizer.msg("print","Drucken"));
print.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (mPageFormat == null) {
mPageFormat = printerJob.defaultPage();
}
mFieldTypes = fieldChooser.getOrder();
ProgramInfoPrintSettings.getInstance().setFont(fontChooser.getChosenFont());
ProgramInfoPrintSettings.getInstance().setFieldTypes(mFieldTypes);
ProgramInfoPrintSettings.getInstance().setPrintImage(printImage.isSelected());
ProgramInfoPrintSettings.getInstance().setPrintPluginIcons(printPluginIcons.isSelected());