Package net.sourceforge.marathon.util

Examples of net.sourceforge.marathon.util.FileHandler


    TextAreaOutput outputPane = new TextAreaOutput();
    State state = State.STOPPED_WITH_APP_CLOSED;
    private IEditor editor;

    public MockDisplayView() throws IOException {
        FileHandler fileHandler = new FileHandler(new MarathonFileFilter(".py", ScriptModelClientPart.getModel()), new File(
                System.getProperty(Constants.PROP_TEST_DIR)), new File(System.getProperty(Constants.PROP_FIXTURE_DIR)),
                Constants.getMarathonDirectories(Constants.PROP_MODULE_DIRS), null);
        editor = new RSTAEditor(true, 1);
        editor.setData("filehandler", fileHandler);
    }
View Full Code Here


        newFile(editor, getDefaultTestHeader(), new File(System.getProperty(Constants.PROP_TEST_DIR)));
        updateView();
    }

    public void newFile(IEditor editor, String script, File directory) {
        FileHandler fileHandler = (FileHandler) editor.getData("filehandler");
        fileHandler.setCurrentDirectory(directory);
        fileHandler.clearCurrentFile();
        String newFileName = "Untitled1";
        editor.setText(script);
        editor.setMode(fileHandler.getMode(newFileName));
        editor.setData("filename", newFileName);
        editor.clearUndo();
    }
View Full Code Here

        }
        updateView();
    }

    public void openFile(IEditor editor, File file) throws IOException {
        FileHandler fileHandler = (FileHandler) editor.getData("filehandler");
        String script = fileHandler.readFile(file);
        if (script != null) {
            editor.setText(script);
            editor.setMode(fileHandler.getMode(fileHandler.getCurrentFile().getName()));
            editor.setData("filename", fileHandler.getCurrentFile().getName());
            editor.setCaretLine(0);
        }
        editor.clearUndo();
    }
View Full Code Here

    }


    public File save() {
        try {
            FileHandler fileHandler = (FileHandler) editor.getData("filehandler");
            File file = fileHandler.save(editor.getText(), editor.getComponent(), "");
            if (file != null) {
                editor.clearUndo();
                editor.setData("filename", fileHandler.getCurrentFile().getName());
            }
            updateView();
            return file;
        } catch (IOException e) {
            e.printStackTrace();
View Full Code Here

    }

    public File saveAs() {
        File file = null;
        try {
            FileHandler fileHandler = (FileHandler) editor.getData("filehandler");
            file = fileHandler.saveAs(editor.getText(), editor.getComponent(), "");
            if (file != null) {
                editor.clearUndo();
                editor.setData("filename", fileHandler.getCurrentFile().getName());
            }
            updateView();
        } catch (IOException e) {
            e.printStackTrace();
        }
View Full Code Here

    public String getScript() {
        return editor.getText() + "\n" + Indent.getIndent() + "pass\n";
    }

    public String getFilePath() {
        FileHandler fileHandler = (FileHandler) editor.getData("filehandler");
        if (fileHandler.getCurrentFile() == null)
            return (String) editor.getData("filename");
        try {
            return fileHandler.getCurrentFile().getCanonicalPath();
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }
View Full Code Here

                }
            };
            navigator = new Navigator(rootDirs, null, rootDesc, fileEventHandler, this);
            navigator.setInitialExpansion(Constants.getAllMarathonDirectoriesAsStringArray());
            navigator.setActions(openAction, null);
            FileHandler fileHandler = new FileHandler(new MarathonFileFilter(scriptModel.getSuffix(), scriptModel), new File(
                    System.getProperty(Constants.PROP_TEST_DIR)), new File(System.getProperty(Constants.PROP_FIXTURE_DIR)),
                    Constants.getMarathonDirectories(Constants.PROP_MODULE_DIRS), this);
            DisplayWindowNavigatorActions actions = new DisplayWindowNavigatorActions(this, navigator, fileHandler);
            navigator.setMenuItems(actions.getMenuItems());
            navigator.setToolbar(actions.getToolBar());
View Full Code Here

    }

    private File save(IEditor e) {
        File file = null;
        try {
            FileHandler fileHandler = getFileHandler(e);
            file = fileHandler.save(e.getText(), this, (String) e.getData("filename"));
            if (file != null) {
                e.setData("filename", fileHandler.getCurrentFile().getName());
                e.setDirty(false);
                if (isModuleFile()) {
                    scriptModel.fileUpdated(file, SCRIPT_FILE_TYPE.MODULE);
                }
                navigator.refresh(new File[] { file });
            }
            updateDockName(e);
            updateView();
            ((EditorDockable) e.getData("dockable")).updateKey();
            if (fileHandler.isModuleFile())
                resetModuleFunctions();
        } catch (IOException e1) {
            reportException(e1);
        }
        return file;
View Full Code Here

    private class NavigatorListener implements IFileEventListener {
        public void fileRenamed(File from, File to) {
            EditorDockable dockable = findEditorDockable(from);
            if (dockable != null) {
                FileHandler fileHandler = (FileHandler) dockable.getEditor().getData("filehandler");
                try {
                    fileHandler.readFile(to);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                dockable.getEditor().setData("filename", fileHandler.getCurrentFile().getName());
                dockable.updateKey();
                updateDockName(dockable.getEditor());
            }
        }
View Full Code Here

        public void fileUpdated(File file) {
            String selectedFileName = file.getAbsolutePath();
            navigator.refresh(new File[] { new File(selectedFileName) });
            EditorDockable dockable = findEditorDockable(new File(selectedFileName));
            if (dockable != null) {
                FileHandler fileHandler = (FileHandler) dockable.getEditor().getData("filehandler");
                try {
                    String script = fileHandler.readFile(new File(selectedFileName));
                    dockable.getEditor().setText(script);
                    dockable.getEditor().setDirty(false);
                } catch (IOException e) {
                    e.printStackTrace();
                }
View Full Code Here

TOP

Related Classes of net.sourceforge.marathon.util.FileHandler

Copyright © 2018 www.massapicom. 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.