Package org.openide.filesystems

Examples of org.openide.filesystems.FileObject


    public void savePreset(String name, Layout layout) {
        Preset preset = addPreset(new Preset(name, layout));

        try {
            //Create file if dont exist
            FileObject folder = FileUtil.getConfigFile("layoutpresets");
            if (folder == null) {
                folder = FileUtil.getConfigRoot().createFolder("layoutpresets");
            }
            FileObject presetFile = folder.getFileObject(name, "xml");
            if (presetFile == null) {
                presetFile = folder.createData(name, "xml");
            }

            //Create doc
View Full Code Here


    public List<Preset> getPresets(Layout layout) {
        return presets.get(layout.getClass().getName());
    }

    private void loadPresets() {
        FileObject folder = FileUtil.getConfigFile("layoutpresets");
        if (folder != null) {
            for (FileObject child : folder.getChildren()) {
                if (child.isValid() && child.hasExt("xml")) {
                    try {
                        InputStream stream = child.getInputStream();
                        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                        DocumentBuilder builder = factory.newDocumentBuilder();
View Full Code Here

        //Show
        int returnFile = chooser.showSaveDialog(null);
        if (returnFile == JFileChooser.APPROVE_OPTION) {
            File file = chooser.getSelectedFile();
            file = FileUtil.normalizeFile(file);
            FileObject fileObject = FileUtil.toFileObject(file);

            //Save last path
            NbPreferences.forModule(GraphFileExporterUI.class).put(LAST_PATH, file.getAbsolutePath());

            //Save variable
View Full Code Here

        //Show
        int returnFile = chooser.showSaveDialog(null);
        if (returnFile == JFileChooser.APPROVE_OPTION) {
            File file = chooser.getSelectedFile();
            file = FileUtil.normalizeFile(file);
            FileObject fileObject = FileUtil.toFileObject(file);

            //Save last path
            NbPreferences.forModule(VectorialFileExporterUI.class).put(LAST_PATH, file.getAbsolutePath());

            //Do
View Full Code Here

        MinifyProperty minifyProperty = MinifyProperty.getInstance();
        InputOutput io = IOProvider.getDefault().getIO(Bundle.CTL_Minify(), false);
        MinifyUtil util = new MinifyUtil();
        try {
            long startTime = new Date().getTime();
            FileObject source = context.getPrimaryFile();
            FileObject target = null;
            if (minifyProperty.isSeparatBuild()) {
                File sourceFile = FileUtil.toFile(source);
                File targetFile = getTargetFolder(new File(sourceFile.getParentFile().getPath() + File.separator + sourceFile.getName() + "_BUILD"));
                FileUtils.copyDirectory(sourceFile, targetFile);
                target = FileUtil.toFileObject(targetFile);
View Full Code Here

    }

    void compress() {
        ImageUtil imageUtil = new ImageUtil();
        FileObject file = context.getPrimaryFile();
        imageUtil.compress(file.getPath(), file.getParent().getPath() + File.separator + file.getName() + "-min." + file.getExt(), file.getExt());
    }
View Full Code Here

    public void cssMinify() {
        MinifyProperty minifyProperty = MinifyProperty.getInstance();
        MinifyUtil util = new MinifyUtil();
        try {
            FileObject file = context.getPrimaryFile();

            String inputFilePath = file.getPath();
            String outputFilePath;

            if (minifyProperty.isNewCSSFile() && minifyProperty.getPreExtensionCSS() != null && !minifyProperty.getPreExtensionCSS().trim().isEmpty()) {
                outputFilePath = file.getParent().getPath() + File.separator + file.getName() + minifyProperty.getSeparatorCSS() + minifyProperty.getPreExtensionCSS() + "." + file.getExt();
            } else {
                outputFilePath = inputFilePath;
            }

View Full Code Here

    void decode() {
        InputOutput io = IOProvider.getDefault().getIO(Bundle.CTL_Base64Encode(), false);
        ImageUtil imageUtil = new ImageUtil();
        try {
            FileObject file = context.getPrimaryFile();
            if (file.getExt().equalsIgnoreCase("ENCODE")) {
                File newFile = new File(file.getPath());
                String fileType = file.getName().substring(file.getName().lastIndexOf('.') + 1);
                imageUtil.decodeToImage(FileUtils.readFileToString(newFile), file.getParent().getPath() + File.separator + file.getName(), fileType);
            } else {
                JOptionPane.showMessageDialog(null, "Invalid file to decode", "Warning", JOptionPane.WARNING_MESSAGE);
            }
        } catch (IOException ex) {
            io.getOut().println("Exception: " + ex.toString());
View Full Code Here

    public void jsMinify() {
        MinifyProperty minifyProperty = MinifyProperty.getInstance();
        MinifyUtil util = new MinifyUtil();
        try {
            FileObject file = context.getPrimaryFile();
            String inputFilePath = file.getPath();
            String outputFilePath;

            if (minifyProperty.isNewJSFile() && minifyProperty.getPreExtensionJS() != null && !minifyProperty.getPreExtensionJS().trim().isEmpty()) {
                outputFilePath = file.getParent().getPath() + File.separator + file.getName() + minifyProperty.getSeparatorJS() + minifyProperty.getPreExtensionJS() + "." + file.getExt();
            } else {
                outputFilePath = inputFilePath;
            }

            MinifyFileResult minifyFileResult = util.compressJavaScript(inputFilePath, outputFilePath, minifyProperty);
View Full Code Here

    void encode() {
        InputOutput io = IOProvider.getDefault().getIO(Bundle.CTL_Base64Encode(), false);
        ImageUtil imageUtil = new ImageUtil();
        try {
            FileObject file = context.getPrimaryFile();
            String imgstr;
            imgstr = imageUtil.encodeToString(file.getPath(), file.getExt());
            File newFile = new File(file.getParent().getPath() + File.separator + file.getName() + "." + file.getExt() + ".encode");
            FileUtils.writeStringToFile(newFile, imgstr);
            io.getOut().println("Image Base64 Encoding : " + imgstr);
        } catch (IOException ex) {
            io.getOut().println("Exception: " + ex.toString());
        }
View Full Code Here

TOP

Related Classes of org.openide.filesystems.FileObject

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.