Package lmnd.controller

Source Code of lmnd.controller.ViewController

package lmnd.controller;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import lmnd.view.FileListPanel;
import lmnd.model.command.CommandData;
import lmnd.model.command.Keys;
import lmnd.model.command.View;

/**
*
*/
public class ViewController implements ActionListener {
        private FileListPanel[] panels;
        public ViewController() {
        }
        public void setPanels(FileListPanel[] panels) {
                this.panels = panels;
        }
        @Override
        public void actionPerformed(ActionEvent event) {
                // Get directory name.
                File file = getSelectedFile();
                CommandData data = new CommandData();
                data.addItem(Keys.FILE, file);
                // Create command.
                View view = new View();
                try {
                        view.perform(data);
                } catch (Exception exception) {
                        exception.printStackTrace();
                }
        }
        private File getSelectedFile() {
                for (FileListPanel panel : panels) {
                        if (panel.isSelected()) {
                                File result = panel.getSelectedFile();
                                return result;
                        }
                }
                return null;
        }
}
TOP

Related Classes of lmnd.controller.ViewController

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.