1:
31:
32: package ;
33:
34: import ;
35: import ;
36: import ;
37: import ;
38: import ;
39:
40: import ;
41: import ;
42: import ;
43: import ;
44:
45:
51: public abstract class AbstractActionPlugin implements ActionPlugin
52: {
53: private PropertyChangeSupport propertyChangeSupport;
54:
55: private boolean enabled;
56:
57:
60: private ResourceBundleSupport baseResources;
61: private IconTheme iconTheme;
62: private String statusText;
63:
64:
67: public static final String BASE_RESOURCE_CLASS =
68: "org.jfree.report.modules.gui.common.resources";
69: private SwingGuiContext context;
70: private ExtendedConfiguration configuration;
71:
72: protected AbstractActionPlugin()
73: {
74: propertyChangeSupport = new PropertyChangeSupport(this);
75: }
76:
77: public boolean initialize(final SwingGuiContext context)
78: {
79: this.context = context;
80: this.baseResources = new ResourceBundleSupport
81: (context.getLocale(), BASE_RESOURCE_CLASS);
82: this.iconTheme = context.getIconTheme();
83: this.configuration = new ExtendedConfigurationWrapper
84: (context.getConfiguration());
85: return true;
86: }
87:
88: protected PropertyChangeSupport getPropertyChangeSupport()
89: {
90: return propertyChangeSupport;
91: }
92:
93: public SwingGuiContext getContext()
94: {
95: return context;
96: }
97:
98: public ExtendedConfiguration getConfig()
99: {
100: return configuration;
101: }
102:
103:
111: public boolean isSeparated()
112: {
113: return getConfig().getBoolProperty
114: (getConfigurationPrefix() + "separated");
115: }
116:
117:
124: public String getFailureDescription()
125: {
126: return baseResources.formatMessage
127: ("statusline.export.generic-failure-description", getDisplayName());
128: }
129:
130: public String getStatusText()
131: {
132: return statusText;
133: }
134:
135: public void setStatusText(final String statusText)
136: {
137: final String oldText = this.statusText;
138: this.statusText = statusText;
139: propertyChangeSupport.firePropertyChange("statusText", oldText, statusText);
140: }
141:
142:
149: public boolean isAddToToolbar()
150: {
151: return getConfig().getBoolProperty
152: (getConfigurationPrefix() + "add-to-toolbar");
153: }
154:
155:
161: public boolean isAddToMenu()
162: {
163: final String name = getConfigurationPrefix() + "add-to-menu";
164: return getConfig().getBoolProperty(name);
165: }
166:
167:
173: protected ReportProgressDialog createProgressDialog()
174: {
175: final Window proxy = context.getWindow();
176: if (proxy instanceof Frame)
177: {
178: return new ReportProgressDialog((Frame) proxy);
179: }
180: else if (proxy instanceof Dialog)
181: {
182: return new ReportProgressDialog((Dialog) proxy);
183: }
184: else
185: {
186: return new ReportProgressDialog();
187: }
188: }
189:
190: public void addPropertyChangeListener(final PropertyChangeListener l)
191: {
192: propertyChangeSupport.addPropertyChangeListener(l);
193: }
194:
195: public void addPropertyChangeListener(final String property,
196: final PropertyChangeListener l)
197: {
198: propertyChangeSupport.addPropertyChangeListener(property, l);
199: }
200:
201: public void removePropertyChangeListener(final PropertyChangeListener l)
202: {
203: propertyChangeSupport.removePropertyChangeListener(l);
204: }
205:
206: public void setEnabled(final boolean enabled)
207: {
208: final boolean oldEnabled = this.enabled;
209: this.enabled = enabled;
210: propertyChangeSupport.firePropertyChange("enabled", oldEnabled, enabled);
211: }
212:
213: public boolean isEnabled()
214: {
215: return enabled;
216: }
217:
218: public IconTheme getIconTheme()
219: {
220: return iconTheme;
221: }
222:
223: protected abstract String getConfigurationPrefix();
224:
225:
226:
231: public int getMenuOrder()
232: {
233: return getConfig().getIntProperty
234: (getConfigurationPrefix() + "menu-order", 0);
235: }
236:
237: public int getToolbarOrder()
238: {
239: return getConfig().getIntProperty
240: (getConfigurationPrefix() + "toolbar-order", 0);
241: }
242:
243: public String getRole()
244: {
245: return getConfig().getConfigProperty
246: (getConfigurationPrefix() + "role");
247: }
248:
249: public int getRolePreference()
250: {
251: return getConfig().getIntProperty
252: (getConfigurationPrefix() + "role-preference", 0);
253: }
254: }