KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > zanthan > sequence > SaveAsAction


1 /**
2  * SEQUENCE - A very simple sequence diagram editor
3  * Copyright (C) 2002 Alex Moffat
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19 package com.zanthan.sequence;
20
21 import java.io.File JavaDoc;
22
23 import javax.swing.JFileChooser JavaDoc;
24
25 // MODIFIED: so that it doesn't disable itself.
26
public class SaveAsAction
27     extends ModelAction {
28
29     SaveAsAction(Model model) {
30     super("SaveAsAction", model);
31     }
32
33     boolean doIt() {
34     final JFileChooser JavaDoc chooser = new JFileChooser JavaDoc();
35     chooser.setDialogType(JFileChooser.SAVE_DIALOG);
36     chooser.setDialogTitle(getResource("dialogTitle"));
37
38     int returnVal = chooser.showSaveDialog(Sequence.getInstance());
39     if (returnVal == JFileChooser.APPROVE_OPTION) {
40         File JavaDoc file = chooser.getSelectedFile();
41         return getModel().writeToFile(file);
42     } else {
43         return false;
44     }
45     }
46 }
47
Popular Tags