Package lmnd.controller

Source Code of lmnd.controller.EditController

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.Edit;
import lmnd.model.command.Keys;

/**
*
*/
public class EditController implements ActionListener {
        private FileListPanel[] panels;
        public EditController() {
        }
        public void setPanels(FileListPanel[] panels) {
                this.panels = panels;
        }
        public void actionPerformed(ActionEvent event) {
                // Get directory name.
                File file = getSelectedFile();
                CommandData data = new CommandData();
                data.addItem(Keys.FILE, file);
                // Create command.
                Edit edit = new Edit();
                try {
                        edit.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.EditController

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.