01: /*
02: * Copyright (C) 2005 Jeff Tassin
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18:
19: package com.jeta.swingbuilder.codegen.gui.editor;
20:
21: import java.awt.event.ActionEvent;
22: import java.awt.event.ActionListener;
23:
24: import com.jeta.forms.store.memento.FormMemento;
25: import com.jeta.open.gui.framework.JETAController;
26: import com.jeta.open.gui.framework.JETADialog;
27: import com.jeta.open.gui.utils.JETAToolbox;
28: import com.jeta.open.i18n.I18N;
29: import com.jeta.swingbuilder.codegen.builder.DefaultSourceBuilder;
30: import com.jeta.swingbuilder.codegen.gui.config.OptionsView;
31: import com.jeta.swingbuilder.store.CodeModel;
32:
33: public class SourceController extends JETAController {
34: private SourceEditor m_view;
35: private FormMemento m_form_state;
36:
37: public SourceController(SourceEditor view) {
38: super (view);
39: m_view = view;
40: assignAction(SourceNames.ID_OPTIONS_BTN, new OptionsAction());
41: }
42:
43: public class OptionsAction implements ActionListener {
44: public void actionPerformed(ActionEvent evt) {
45: OptionsView view = new OptionsView(CodeModel
46: .createInstance(m_view.getFormMemento()));
47: JETADialog dlg = JETAToolbox
48: .invokeDialog(
49: view,
50: m_view,
51: I18N
52: .getLocalizedMessage("Code Generation Options"));
53: if (dlg.isOk()) {
54: view.saveToModel();
55: CodeModel model = view.getModel();
56: CodeModel.save(model);
57:
58: String txt = DefaultSourceBuilder.buildSource(model,
59: m_view.getFormMemento());
60: m_view.setText(txt);
61: }
62: }
63: }
64: }
|