1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package command.commands;
-
- import command.CommandInterface;
- import java.io.File;
- import java.io.IOException;
- import java.io.UnsupportedEncodingException;
- import java.util.prefs.Preferences;
- import javax.swing.JFileChooser;
- import model.AdressVerwaltungModel;
- import view.MainWindow;
-
- /**
- *
- * @author PC
- */
- public class CommandSaveFile implements CommandInterface{
-
- private MainWindow view;
- private AdressVerwaltungModel model;
- private Preferences prefs;
-
- public CommandSaveFile(MainWindow view, AdressVerwaltungModel model) {
-
- this.view = view;
- this.model = model;
- this.prefs = model.getPreferences();
-
- }
-
-
- @Override
- public void execute() {
- int wahl = view.getjFileChooser().showSaveDialog(view);
- if(wahl == JFileChooser.APPROVE_OPTION)
- {
- File file = view.getjFileChooser().getSelectedFile();
- view.getStatusbar().setText("Datei wird gespeichert...");
- try
- {
- model.datenSpeichern(file);
- }
- catch (UnsupportedEncodingException ex)
- {
- view.getStatusbar().setText(ex.toString());
- }
- catch (IOException ex )
- {
- view.getStatusbar().setText(ex.toString());
- }
- }
- }
-
- @Override
- public void undo() {
-
- }
-
- @Override
- public boolean isUndoable() {
- return false;
- }
-
- }
|