Search in sources :

Example 1 with PropertyClient

use of org.jetbrains.idea.svn.properties.PropertyClient in project intellij-community by JetBrains.

the class SvnEditFileProvider method editFiles.

public void editFiles(VirtualFile[] files) throws VcsException {
    File[] ioFiles = new File[files.length];
    for (int i = 0; i < files.length; i++) {
        ioFiles[i] = virtualToIoFile(files[i]);
        PropertyClient client = myVCS.getFactory(ioFiles[i]).createPropertyClient();
        PropertyValue property = client.getProperty(SvnTarget.fromFile(ioFiles[i], SVNRevision.WORKING), SvnPropertyKeys.SVN_NEEDS_LOCK, false, SVNRevision.WORKING);
        if (property == null) {
            throw new VcsException(SvnBundle.message("exception.text.file.miss.svn", ioFiles[i].getName()));
        }
    }
    SvnUtil.doLockFiles(myVCS.getProject(), myVCS, ioFiles);
}
Also used : PropertyClient(org.jetbrains.idea.svn.properties.PropertyClient) VcsException(com.intellij.openapi.vcs.VcsException) PropertyValue(org.jetbrains.idea.svn.properties.PropertyValue) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)

Example 2 with PropertyClient

use of org.jetbrains.idea.svn.properties.PropertyClient in project intellij-community by JetBrains.

the class SetPropertyDialog method fillPropertyNames.

private void fillPropertyNames(File[] files) {
    final Collection<String> names = new TreeSet<>();
    if (files.length == 1) {
        File file = files[0];
        try {
            PropertyConsumer handler = new PropertyConsumer() {

                public void handleProperty(File path, PropertyData property) {
                    String name = property.getName();
                    if (name != null) {
                        names.add(name);
                    }
                }

                public void handleProperty(SVNURL url, PropertyData property) {
                }

                public void handleProperty(long revision, PropertyData property) {
                }
            };
            PropertyClient client = myVCS.getFactory(file).createPropertyClient();
            client.list(SvnTarget.fromFile(file, SVNRevision.WORKING), SVNRevision.WORKING, Depth.EMPTY, handler);
        } catch (VcsException e) {
            LOG.info(e);
        }
    }
    fillProperties(names);
    for (final String name : names) {
        myPropertyNameBox.addItem(name);
    }
}
Also used : PropertyClient(org.jetbrains.idea.svn.properties.PropertyClient) PropertyConsumer(org.jetbrains.idea.svn.properties.PropertyConsumer) PropertyData(org.jetbrains.idea.svn.properties.PropertyData) TreeSet(java.util.TreeSet) SVNURL(org.tmatesoft.svn.core.SVNURL) VcsException(com.intellij.openapi.vcs.VcsException) File(java.io.File)

Example 3 with PropertyClient

use of org.jetbrains.idea.svn.properties.PropertyClient in project intellij-community by JetBrains.

the class SetPropertyDialog method getProperty.

@Nullable
private PropertyValue getProperty(@NotNull File file, @NotNull String name) {
    PropertyValue result;
    try {
        PropertyClient client = myVCS.getFactory(file).createPropertyClient();
        result = client.getProperty(SvnTarget.fromFile(file, SVNRevision.WORKING), name, false, SVNRevision.WORKING);
    } catch (VcsException e) {
        LOG.info(e);
        result = null;
    }
    return result;
}
Also used : PropertyClient(org.jetbrains.idea.svn.properties.PropertyClient) VcsException(com.intellij.openapi.vcs.VcsException) PropertyValue(org.jetbrains.idea.svn.properties.PropertyValue) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with PropertyClient

use of org.jetbrains.idea.svn.properties.PropertyClient in project intellij-community by JetBrains.

the class SvnMergeProvider method isBinary.

public boolean isBinary(@NotNull final VirtualFile file) {
    SvnVcs vcs = SvnVcs.getInstance(myProject);
    try {
        File ioFile = virtualToIoFile(file);
        PropertyClient client = vcs.getFactory(ioFile).createPropertyClient();
        PropertyValue value = client.getProperty(SvnTarget.fromFile(ioFile), SvnPropertyKeys.SVN_MIME_TYPE, false, SVNRevision.WORKING);
        if (value != null && isBinaryMimeType(value.toString())) {
            return true;
        }
    } catch (VcsException e) {
        LOG.warn(e);
    }
    return false;
}
Also used : PropertyClient(org.jetbrains.idea.svn.properties.PropertyClient) VcsException(com.intellij.openapi.vcs.VcsException) PropertyValue(org.jetbrains.idea.svn.properties.PropertyValue) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) File(java.io.File) SvnVcs(org.jetbrains.idea.svn.SvnVcs)

Example 5 with PropertyClient

use of org.jetbrains.idea.svn.properties.PropertyClient in project intellij-community by JetBrains.

the class SetPropertyAction method batchPerform.

@Override
protected void batchPerform(@NotNull SvnVcs vcs, @NotNull VirtualFile[] files, @NotNull DataContext context) throws VcsException {
    File[] ioFiles = toIoFiles(files);
    SetPropertyDialog dialog = new SetPropertyDialog(vcs.getProject(), ioFiles, null, true);
    if (dialog.showAndGet()) {
        String name = dialog.getPropertyName();
        String value = dialog.getPropertyValue();
        boolean recursive = dialog.isRecursive();
        for (File ioFile : ioFiles) {
            PropertyClient client = vcs.getFactory(ioFile).createPropertyClient();
            // TODO: most likely SVNDepth.getInfinityOrEmptyDepth should be used instead of SVNDepth.fromRecursive - to have either "infinity"
            // TODO: or "empty" depth, and not "infinity" or "files" depth. But previous logic used SVNDepth.fromRecursive implicitly
            client.setProperty(ioFile, name, PropertyValue.create(value), Depth.allOrFiles(recursive), false);
        }
        for (VirtualFile file : files) {
            if (recursive && file.isDirectory()) {
                VcsDirtyScopeManager.getInstance(vcs.getProject()).dirDirtyRecursively(file, true);
            } else {
                VcsDirtyScopeManager.getInstance(vcs.getProject()).fileDirty(file);
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PropertyClient(org.jetbrains.idea.svn.properties.PropertyClient) SetPropertyDialog(org.jetbrains.idea.svn.dialogs.SetPropertyDialog) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Aggregations

PropertyClient (org.jetbrains.idea.svn.properties.PropertyClient)6 File (java.io.File)5 VcsException (com.intellij.openapi.vcs.VcsException)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 PropertyValue (org.jetbrains.idea.svn.properties.PropertyValue)4 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)3 Nullable (org.jetbrains.annotations.Nullable)2 Pair (com.intellij.openapi.util.Pair)1 Trinity (com.intellij.openapi.util.Trinity)1 TreeSet (java.util.TreeSet)1 SvnVcs (org.jetbrains.idea.svn.SvnVcs)1 SetPropertyDialog (org.jetbrains.idea.svn.dialogs.SetPropertyDialog)1 PropertyConsumer (org.jetbrains.idea.svn.properties.PropertyConsumer)1 PropertyData (org.jetbrains.idea.svn.properties.PropertyData)1 SVNURL (org.tmatesoft.svn.core.SVNURL)1