Package floobits.common.interfaces

Examples of floobits.common.interfaces.IFile


        return true;
    }

    @Override
    public void removeHighlight(final Integer userId, final String path) {
        final IFile iFile = findFileByPath(path);
        if (iFile == null) {
            return;
        }
        editor.queue(new Runnable() {
            @Override
View Full Code Here


        return null;
    }
   
    @Override
    public IFile getOrCreateFile(String path) {
        IFile fileByPath = findFileByPath(path);
        if (fileByPath != null) {
            return fileByPath;
        }
        return createFile(path);
    }
View Full Code Here

        return new DocImpl(context, document);
    }

    @Override
    public IDoc getDocument(String relPath) {
        IFile fileByPath = findFileByPath(context.absPath(relPath));
        return getDocument(fileByPath);
    }
View Full Code Here

            outbound.saveBuf(buf);
        }


        for (String path : paths) {
            IFile fileByPath = context.iFactory.findFileByPath(context.absPath(path));
            if (fileByPath == null || !fileByPath.isValid()) {
                Flog.warn(String.format("path is no longer a valid virtual file"));
                continue;
            }
            outbound.createBuf(fileByPath);
        }
        String flooignore = FilenameUtils.concat(context.colabDir, ".flooignore");

        try {
            File f = new File(flooignore);
            List<String> strings;
            if (f.exists()) {
                strings = FileUtils.readLines(f);
            } else {
                strings = new ArrayList<String>();
            }

            for (Ignore ig : tooBigIgnores) {
                String rule = "/" + context.toProjectRelPath(ig.stringPath);
                if (!rule.endsWith("/")) {
                    rule += "/";
                }
                rule += "*";
                strings.add(rule);
            }
            context.setListener(false);
            FileUtils.writeLines(f, strings);
            IFile fileByIoFile = context.iFactory.findFileByIoFile(f);
            if (fileByIoFile != null) {
                fileByIoFile.refresh();
                ignoreTree.addRules(fileByIoFile);
            }
        } catch (IOException e) {
            Flog.warn(e);
        } finally {
View Full Code Here

        }

        editor.queue(buf, new RunLater<Buf>() {
                @Override
                public void run(Buf buf) {
                    final IFile foundFile = context.iFactory.findFileByPath(oldPath);
                    if (foundFile == null) {
                        Flog.warn("File we want to move was not found %s %s.", oldPath, newPath);
                        return;
                    }
                    String newRelativePath = context.toProjectRelPath(newPath);
                    if (newRelativePath == null) {
                        context.errorMessage("A file is now outside the workspace.");
                        return;
                    }
                    state.setBufPath(buf, newRelativePath);

                    File oldFile = new File(oldPath);
                    File newFile = new File(newPath);
                    String newFileName = newFile.getName();
                    // Rename file

                    if (foundFile.rename(null, newFileName)) {
                        return;
                    }

                    // Move file
                    String newParentDirectoryPath = newFile.getParent();
                    String oldParentDirectoryPath = oldFile.getParent();
                    if (newParentDirectoryPath.equals(oldParentDirectoryPath)) {
                        Flog.warn("Only rename file, don't need to move %s %s", oldPath, newPath);
                        return;
                    }
                    IFile directory = context.iFactory.createDirectories(newParentDirectoryPath);
                    if (directory == null) {
                        return;
                    }

                    foundFile.move(null, directory);
View Full Code Here

                if (!deleteBuf.unlink) {
                    fileRemovedMessageThrottler.statusMessage(String.format("Removed the file, %s, from the workspace.", buf.path));
                    return;
                }
                String absPath = context.absPath(buf.path);
                final IFile fileByPath = context.iFactory.findFileByPath(absPath);

                if (fileByPath == null) {
                    return;
                }

                fileByPath.delete(this);
            }
        });
    }
View Full Code Here

            Flog.warn(error);
        }
    }

    public void beforeChange(IDoc doc) {
        final IFile virtualFile = doc.getVirtualFile();
        final String path = virtualFile.getPath();
        final Buf bufByPath = state.getBufByPath(path);
        if (bufByPath == null) {
            return;
        }
        String msg;
View Full Code Here

    }

    @Override
    public void after(@NotNull List<? extends VFileEvent> events) {
        for (VFileEvent event : events) {
            IFile virtualFile = new FileImpl(event.getFile());
            if (Ignore.isIgnoreFile(virtualFile) && !context.isIgnored(virtualFile)) {
                context.refreshIgnores();
                break;
            }
        }
        if (!isListening.get()) {
            return;
        }
        for (VFileEvent event : events) {
            Flog.debug(" after event type %s", event.getClass().getSimpleName());
            if (event instanceof VFilePropertyChangeEvent) {
                VFilePropertyChangeEvent propertyEvent = (VFilePropertyChangeEvent) event;
                if (propertyEvent.getPropertyName() != "name") {
                    continue;
                }
                VirtualFile virtualFile = propertyEvent.getFile();
                renameAllNestedFiles(virtualFile,  oldRenamePath, virtualFile.getPath());
                oldRenamePath = null;
                continue;
            }
            if (event instanceof VFileMoveEvent) {
                Flog.info("move event %s", event);
View Full Code Here

            }
        }

        Flog.warn("Tried to write to null document: %s", path);

        IFile virtualFile = getOrCreateFile();
        try {
            virtualFile.setBytes(buf.getBytes());
        } catch (Throwable e) {
            Flog.warn(e);
            context.errorMessage("The Floobits plugin was unable to write to a file.");
        }
    }
View Full Code Here

    public void patch(final FlooPatch res) {
        final TextBuf b = this;
        Flog.info("Got _on_patch");

        String oldText = buf;
        IFile virtualFile = b.getVirtualFile();
        if (virtualFile == null) {
            Flog.warn("VirtualFile is null, no idea what do do. Aborting everything %s", this);
            getBuf();
            return;
        }
        IDoc d = context.iFactory.getDocument(virtualFile);
        if (d == null) {
            Flog.warn("Document not found for %s", virtualFile);
            getBuf();
            return;
        }
        String viewText;
        if (!virtualFile.exists()) {
            viewText = oldText;
        } else {
            viewText = d.getText();
            if (viewText.equals(oldText)) {
                b.forced_patch = false;
View Full Code Here

TOP

Related Classes of floobits.common.interfaces.IFile

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.