001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)ChartPanel.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package charting.chart;
030:
031: import org.openesb.tools.charting.persist.ChartApplicationBeansContainer;
032: import org.openesb.tools.extchart.jfchart.Chart;
033: import com.sun.rave.web.ui.appbase.AbstractPageBean;
034: import com.sun.web.ui.component.Body;
035: import com.sun.web.ui.component.Button;
036: import com.sun.web.ui.component.DropDown;
037: import com.sun.web.ui.component.Form;
038: import com.sun.web.ui.component.Head;
039: import com.sun.web.ui.component.Html;
040: import com.sun.web.ui.component.Label;
041: import com.sun.web.ui.component.Link;
042: import com.sun.web.ui.component.Page;
043: import com.sun.web.ui.model.Option;
044: import com.sun.web.ui.model.SingleSelectOptionsList;
045: import java.util.Iterator;
046: import java.util.Map;
047: import java.util.logging.Logger;
048: import javax.faces.FacesException;
049: import javax.faces.event.ValueChangeEvent;
050:
051: /**
052: * <p>Page bean that corresponds to a similarly named JSP page. This
053: * class contains component definitions (and initialization code) for
054: * all components that you have defined on this page, as well as
055: * lifecycle methods and event handlers where you may add behavior
056: * to respond to incoming events.</p>
057: */
058: public class ChartPanel extends AbstractPageBean {
059: // <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
060: private int __placeholder;
061:
062: /**
063: * <p>Automatically managed component initialization. <strong>WARNING:</strong>
064: * This method is automatically generated, so any user-specified code inserted
065: * here is subject to being replaced.</p>
066: */
067: private void _init() throws Exception {
068: }
069:
070: private Page page1 = new Page();
071:
072: public Page getPage1() {
073: return page1;
074: }
075:
076: public void setPage1(Page p) {
077: this .page1 = p;
078: }
079:
080: private Html html1 = new Html();
081:
082: public Html getHtml1() {
083: return html1;
084: }
085:
086: public void setHtml1(Html h) {
087: this .html1 = h;
088: }
089:
090: private Head head1 = new Head();
091:
092: public Head getHead1() {
093: return head1;
094: }
095:
096: public void setHead1(Head h) {
097: this .head1 = h;
098: }
099:
100: private Link link1 = new Link();
101:
102: public Link getLink1() {
103: return link1;
104: }
105:
106: public void setLink1(Link l) {
107: this .link1 = l;
108: }
109:
110: private Body body1 = new Body();
111:
112: public Body getBody1() {
113: return body1;
114: }
115:
116: public void setBody1(Body b) {
117: this .body1 = b;
118: }
119:
120: private Form form1 = new Form();
121:
122: public Form getForm1() {
123: return form1;
124: }
125:
126: public void setForm1(Form f) {
127: this .form1 = f;
128: }
129:
130: private DropDown dropDown1 = new DropDown();
131:
132: public DropDown getDropDown1() {
133: return dropDown1;
134: }
135:
136: public void setDropDown1(DropDown dd) {
137: this .dropDown1 = dd;
138: }
139:
140: private SingleSelectOptionsList dropDown1DefaultOptions = new SingleSelectOptionsList();
141:
142: public SingleSelectOptionsList getDropDown1DefaultOptions() {
143: return dropDown1DefaultOptions;
144: }
145:
146: public void setDropDown1DefaultOptions(SingleSelectOptionsList ssol) {
147: this .dropDown1DefaultOptions = ssol;
148: }
149:
150: private Label label1 = new Label();
151:
152: public Label getLabel1() {
153: return label1;
154: }
155:
156: public void setLabel1(Label l) {
157: this .label1 = l;
158: }
159:
160: private Button button1 = new Button();
161:
162: public Button getButton1() {
163: return button1;
164: }
165:
166: public void setButton1(Button b) {
167: this .button1 = b;
168: }
169:
170: private Button button2 = new Button();
171:
172: public Button getButton2() {
173: return button2;
174: }
175:
176: public void setButton2(Button b) {
177: this .button2 = b;
178: }
179:
180: // </editor-fold>
181:
182: /**
183: * <p>Construct a new Page bean instance.</p>
184: */
185: public ChartPanel() {
186: }
187:
188: /**
189: * <p>Callback method that is called whenever a page is navigated to,
190: * either directly via a URL, or indirectly via page navigation.
191: * Customize this method to acquire resources that will be needed
192: * for event handlers and lifecycle methods, whether or not this
193: * page is performing post back processing.</p>
194: *
195: * <p>Note that, if the current request is a postback, the property
196: * values of the components do <strong>not</strong> represent any
197: * values submitted with this request. Instead, they represent the
198: * property values that were saved for this view when it was rendered.</p>
199: */
200: public void init() {
201: // Perform initializations inherited from our superclass
202: super .init();
203: // Perform application initialization that must complete
204: // *before* managed components are initialized
205: // TODO - add your own initialiation code here
206:
207: // <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
208: // Initialize automatically managed components
209: // *Note* - this logic should NOT be modified
210: try {
211: _init();
212: } catch (Exception e) {
213: log("ChartPanel Initialization Failure", e);
214: throw e instanceof FacesException ? (FacesException) e
215: : new FacesException(e);
216: }
217:
218: // </editor-fold>
219: // Perform application initialization that must complete
220: // *after* managed components are initialized
221: // TODO - add your own initialization code here
222: }
223:
224: /**
225: * <p>Callback method that is called after the component tree has been
226: * restored, but before any event processing takes place. This method
227: * will <strong>only</strong> be called on a postback request that
228: * is processing a form submit. Customize this method to allocate
229: * resources that will be required in your event handlers.</p>
230: */
231: public void preprocess() {
232: }
233:
234: /**
235: * <p>Callback method that is called just before rendering takes place.
236: * This method will <strong>only</strong> be called for the page that
237: * will actually be rendered (and not, for example, on a page that
238: * handled a postback and then navigated to a different page). Customize
239: * this method to allocate resources that will be required for rendering
240: * this page.</p>
241: */
242: public void prerender() {
243: }
244:
245: /**
246: * <p>Callback method that is called after rendering is completed for
247: * this request, if <code>init()</code> was called (regardless of whether
248: * or not this was the page that was actually rendered). Customize this
249: * method to release resources acquired in the <code>init()</code>,
250: * <code>preprocess()</code>, or <code>prerender()</code> methods (or
251: * acquired during execution of an event handler).</p>
252: */
253: public void destroy() {
254: }
255:
256: private ChartApplicationBeansContainer getChartApplicationBeansContainer() {
257: return (ChartApplicationBeansContainer) getBean("ChartApplicationBeansContainer");
258:
259: }
260:
261: SingleSelectOptionsList l = new SingleSelectOptionsList();
262:
263: public SingleSelectOptionsList getOptions() {
264: String sType = getChartApplicationBeansContainer()
265: .getDataAccessBeanForCurrentChart().getDataSetType();
266:
267: Map map = Chart.getAllowedChartsForDatasetType(sType);
268: Option[] options = new Option[map.size()];
269: Iterator iter = map.keySet().iterator();
270: int index = 0;
271: while (iter.hasNext()) {
272: String key = (String) iter.next();
273: String dValue = (String) map.get(key);
274: Option opt = new Option();
275: opt.setLabel(dValue);
276: opt.setValue(key);
277: options[index++] = opt;
278: }
279:
280: l.setOptions(options);
281: // String t = getChartApplicationBeansContainer().getCurrentChartBeanOnEditor().getChartType();
282: // l.setSelectedValue(t);
283: return l;
284: }
285:
286: public void dropDown1_processValueChange(ValueChangeEvent event) {
287: // TODO: Replace with your code
288: //String cType = (String)this.getDropDown1().getSelected();
289: //getChartApplicationBeansContainer().getCurrentChartBeanOnEditor().resetChartType(cType);
290:
291: }
292:
293: private static Logger mLogger = Logger
294: .getLogger("/chart/ChartPanel.jsp");
295:
296: public String submit_action() {
297: String cType = (String) this .getDropDown1().getSelected();
298: getChartApplicationBeansContainer()
299: .getCurrentChartBeanOnEditor().resetChartType(cType);
300: return "success";
301:
302: }
303:
304: public String button1_action() {
305: // TODO: Process the button click action. Return value is a navigation
306: // case name where null will return to the same page.
307:
308: return submit_action();
309: }
310:
311: public String button2_action() {
312: // TODO: Process the button click action. Return value is a navigation
313: // case name where null will return to the same page.
314: try {
315: getChartApplicationBeansContainer()
316: .persistCurrentChartOnEditor();
317: } catch (Exception e) {
318: e.printStackTrace();
319: return "failure";
320: }
321: return "success";
322: }
323: }
|