1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- /*
- * 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 controller.commands;
-
- import adressverwaltung.model.AdressverwaltungModel;
- import controller.Interface;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import javax.swing.JFileChooser;
- import prfourgui.View.AdressbuchView;
-
- /**
- *
- * @author jechowma68968
- */
- public class CommandOpen implements Interface
- {
- private final AdressbuchView view;
- private final AdressverwaltungModel model;
-
- public CommandOpen(AdressbuchView view, AdressverwaltungModel model)
- {
- this.view = view;
- this.model = model;
- }
-
- @Override
- public void execute()
- {
- File datei;
- JFileChooser fc = view.getjFileChooser1();
- int wahl = fc.showOpenDialog(view);
- if(wahl == JFileChooser.APPROVE_OPTION){
- datei = fc.getSelectedFile();
- String dateiname = datei.getAbsolutePath();
- view.getTxtStatus().setText("Dateipfad:" + dateiname);
-
- try{
- model.datenLesen(datei);
- }
- catch(FileNotFoundException e){
- System.out.println("File not Found Error");
- }
- catch(IOException e){
- System.out.println("Reading Error");
- }
- catch(ClassNotFoundException e){
- System.out.println("Class not found");
- }
- }
- }
-
- @Override
- public void undo()
- {
- }
- }
|