01: package org.netbeans.modules.reportgenerator.api;
02:
03: import java.awt.Dimension;
04: import java.awt.event.ActionEvent;
05:
06: import javax.swing.AbstractAction;
07: import javax.swing.Icon;
08: import javax.swing.ImageIcon;
09: import javax.swing.KeyStroke;
10: import org.netbeans.api.options.OptionsDisplayer;
11: import org.netbeans.modules.reportgenerator.generator.DataObjectSettings;
12: import org.netbeans.modules.reportgenerator.customization.ReportCustomizationPanel;
13: import org.openide.DialogDescriptor;
14: import org.openide.DialogDisplayer;
15: import org.openide.ErrorManager;
16:
17: import org.openide.loaders.DataObject;
18: import org.openide.util.NbBundle;
19: import org.openide.util.Utilities;
20:
21: /**
22: * Action which provides report generation customization option.
23: * An editor can add this action to its tool bar to get report
24: * generation customization option.
25: *
26: * Typical options may include generate verbose report. Select report
27: * generation type (pdf/html etc)
28: *
29: * @author radval
30: *
31: */
32: public class CustomizeReportAction extends AbstractAction {
33:
34: public static final String ACCELERATOR = "alt shift F11"; // NOI18N
35:
36: private static final Icon icon = new ImageIcon(
37: Utilities
38: .loadImage("org/netbeans/modules/reportgenerator/api/impl/resources/images/customizeReport.png"));
39:
40: private static final String label = NbBundle.getMessage(
41: GenerateReportAction.class, "NAME_Customize_Report");
42:
43: private DataObject mDataObject;
44:
45: public CustomizeReportAction(DataObject dataObject) {
46: super (label, icon);
47: this .mDataObject = dataObject;
48: putValue(NAME, label);
49: putValue(SHORT_DESCRIPTION, label);
50: putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(ACCELERATOR));
51: }
52:
53: public void actionPerformed(ActionEvent e) {
54:
55: //OptionsDisplayer.getDefault().open("ReportElementCustomizationPanel"); //NOI18N
56: //OptionsDisplayer.getDefault().open("Advanced"); //NOI18N
57:
58: ReportCustomizationOptions options = DataObjectSettings
59: .getOrStoreOptions(mDataObject);
60: ReportCustomizationPanel panel = new ReportCustomizationPanel(
61: options);
62: panel.setPreferredSize(new Dimension(300, 300));
63:
64: String title = NbBundle.getMessage(CustomizeReportAction.class,
65: "NAME_Customize_Report");
66: DialogDescriptor dd = new DialogDescriptor(panel, title, true,
67: DialogDescriptor.OK_CANCEL_OPTION,
68: DialogDescriptor.OK_OPTION, null);
69: if (DialogDisplayer.getDefault().notify(dd) == DialogDescriptor.OK_OPTION) {
70: options.setGenerateVerboseReport(panel
71: .isGenerateVerboseReport());
72: options.setIncludeOnlyElementsWithDocumentation(panel
73: .isIncludeOnlyElementsWithDocumentation());
74: }
75: }
76:
77: }
|