1:
31:
32: package ;
33:
34: import ;
35: import ;
36: import ;
37: import ;
38:
39: import ;
40: import ;
41: import ;
42: import ;
43:
44:
49: public abstract class AbstractExportActionPlugin extends AbstractActionPlugin
50: implements ExportActionPlugin
51: {
52:
53: public AbstractExportActionPlugin()
54: {
55: }
56:
57:
58:
64: protected ExportDialog createExportDialog(final String className)
65: throws InstantiationException
66: {
67: final Window proxy = getContext().getWindow();
68: if (proxy instanceof Frame)
69: {
70: final ClassLoader classLoader =
71: ObjectUtilities.getClassLoader(AbstractActionPlugin.class);
72: try
73: {
74: final Class aClass = classLoader.loadClass(className);
75: final Constructor constructor =
76: aClass.getConstructor(new Class[]{Frame.class});
77: return (ExportDialog) constructor.newInstance(new Object[]{proxy});
78: }
79: catch (Exception e)
80: {
81: Log.error("Failed to instantiate Export-Dialog with a 'Frame'-parent: " + className);
82: }
83: }
84: else if (proxy instanceof Dialog)
85: {
86: final ClassLoader classLoader =
87: ObjectUtilities.getClassLoader(AbstractActionPlugin.class);
88: try
89: {
90: final Class aClass = classLoader.loadClass(className);
91: final Constructor constructor =
92: aClass.getConstructor(new Class[]{Dialog.class});
93: return (ExportDialog) constructor.newInstance(new Object[]{proxy});
94: }
95: catch (Exception e)
96: {
97: Log.error("Failed to instantiate Export-Dialog with a 'Dialog'-parent: " + className, e);
98: }
99: }
100:
101: final Object fallBack = ObjectUtilities.loadAndInstantiate
102: (className, AbstractActionPlugin.class, ExportDialog.class);
103: if (fallBack != null)
104: {
105: return (ExportDialog) fallBack;
106: }
107:
108: Log.error ("Failed to instantiate Export-Dialog without a parent: " + className);
109: throw new InstantiationException("Failed to instantiate Export-Dialog");
110: }
111:
112:
113:
119: public boolean performShowExportDialog(final ReportJob job, final String configKey)
120: {
121: try
122: {
123: final Configuration configuration = job.getConfiguration();
124: final String dialogClassName = configuration.getConfigProperty(configKey);
125: final ExportDialog dialog = createExportDialog(dialogClassName);
126: return dialog.performQueryForExport(job, getContext());
127: }
128: catch (InstantiationException e)
129: {
130: Log.error ("Unable to configure the report job.");
131: setStatusText("Unable to configure the report job.");
132: return false;
133: }
134: }
135:
136: }