Search in sources :

Example 1 with PropertyConsumer

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

the class ShowPropertiesDiffAction method createHandler.

@NotNull
private static PropertyConsumer createHandler(SVNRevision revision, @NotNull final List<PropertyData> lines) {
    final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
    if (indicator != null) {
        indicator.checkCanceled();
        indicator.setText(SvnBundle.message("show.properties.diff.progress.text.revision.information", revision.toString()));
    }
    return new PropertyConsumer() {

        public void handleProperty(final File path, final PropertyData property) throws SVNException {
            registerProperty(property);
        }

        public void handleProperty(final SVNURL url, final PropertyData property) throws SVNException {
            registerProperty(property);
        }

        public void handleProperty(final long revision, final PropertyData property) throws SVNException {
        // revision properties here
        }

        private void registerProperty(@NotNull PropertyData property) {
            if (indicator != null) {
                indicator.checkCanceled();
                indicator.setText2(SvnBundle.message("show.properties.diff.progress.text2.property.information", property.getName()));
            }
            lines.add(property);
        }
    };
}
Also used : PropertyConsumer(org.jetbrains.idea.svn.properties.PropertyConsumer) PropertyData(org.jetbrains.idea.svn.properties.PropertyData) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) SVNURL(org.tmatesoft.svn.core.SVNURL) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with PropertyConsumer

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

the class Reverter method moveRenamesToTmp.

public void moveRenamesToTmp(@NotNull UnversionedAndNotTouchedFilesGroupCollector collector) {
    try {
        // copy also directories here - for moving with svn
        // also, maybe still use just patching? -> well-tested thing, only deletion of folders might suffer
        // todo: special case: addition + move. mark it
        final File tmp = FileUtil.createTempDirectory("forRename", "");
        final PropertyConsumer handler = createPropertyHandler(myProperties, collector);
        for (Map.Entry<File, ThroughRenameInfo> entry : collector.getFromTo().entrySet()) {
            final File source = entry.getKey();
            final ThroughRenameInfo info = entry.getValue();
            if (info.isVersioned()) {
                myVcs.getFactory(source).createPropertyClient().list(SvnTarget.fromFile(source), SVNRevision.WORKING, Depth.EMPTY, handler);
            }
            if (source.isDirectory()) {
                if (!FileUtil.filesEqual(info.getTo(), info.getFirstTo())) {
                    myFromToModified.add(new CopiedAsideInfo(info.getParentImmediateReverted(), info.getTo(), info.getFirstTo(), null));
                }
                continue;
            }
            final File tmpFile = FileUtil.createTempFile(tmp, source.getName(), "", false);
            tmpFile.mkdirs();
            FileUtil.delete(tmpFile);
            FileUtil.copy(source, tmpFile);
            myFromToModified.add(new CopiedAsideInfo(info.getParentImmediateReverted(), info.getTo(), info.getFirstTo(), tmpFile));
        }
    } catch (IOException e) {
        myExceptions.add(new VcsException(e));
    } catch (VcsException e) {
        myExceptions.add(e);
    }
}
Also used : PropertyConsumer(org.jetbrains.idea.svn.properties.PropertyConsumer) VcsException(com.intellij.openapi.vcs.VcsException) IOException(java.io.IOException) File(java.io.File) Map(java.util.Map) PropertiesMap(org.jetbrains.idea.svn.properties.PropertiesMap)

Example 3 with PropertyConsumer

use of org.jetbrains.idea.svn.properties.PropertyConsumer 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 4 with PropertyConsumer

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

the class ShowPropertiesDiffAction method getPropertyList.

@NotNull
private static List<PropertyData> getPropertyList(@NotNull SvnVcs vcs, @NotNull SvnTarget target, @Nullable SVNRevision revision) throws VcsException {
    final List<PropertyData> lines = new ArrayList<>();
    final PropertyConsumer propertyHandler = createHandler(revision, lines);
    vcs.getFactory(target).createPropertyClient().list(target, revision, Depth.EMPTY, propertyHandler);
    return lines;
}
Also used : PropertyData(org.jetbrains.idea.svn.properties.PropertyData) PropertyConsumer(org.jetbrains.idea.svn.properties.PropertyConsumer) ArrayList(java.util.ArrayList) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with PropertyConsumer

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

the class PropertiesComponent method collectProperties.

private static void collectProperties(@NotNull SvnVcs vcs, @NotNull File file, @NotNull final Map<String, String> props) {
    try {
        PropertyConsumer handler = new PropertyConsumer() {

            public void handleProperty(File path, PropertyData property) throws SVNException {
                final PropertyValue value = property.getValue();
                if (value != null) {
                    props.put(property.getName(), PropertyValue.toString(property.getValue()));
                }
            }

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

            public void handleProperty(long revision, PropertyData property) throws SVNException {
            }
        };
        vcs.getFactory(file).createPropertyClient().list(SvnTarget.fromFile(file, SVNRevision.UNDEFINED), SVNRevision.WORKING, Depth.EMPTY, handler);
    } catch (VcsException e) {
        props.clear();
    }
}
Also used : PropertyConsumer(org.jetbrains.idea.svn.properties.PropertyConsumer) PropertyData(org.jetbrains.idea.svn.properties.PropertyData) SVNURL(org.tmatesoft.svn.core.SVNURL) 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)

Aggregations

PropertyConsumer (org.jetbrains.idea.svn.properties.PropertyConsumer)5 File (java.io.File)4 PropertyData (org.jetbrains.idea.svn.properties.PropertyData)4 VcsException (com.intellij.openapi.vcs.VcsException)3 SVNURL (org.tmatesoft.svn.core.SVNURL)3 NotNull (org.jetbrains.annotations.NotNull)2 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 TreeSet (java.util.TreeSet)1 PropertiesMap (org.jetbrains.idea.svn.properties.PropertiesMap)1 PropertyClient (org.jetbrains.idea.svn.properties.PropertyClient)1 PropertyValue (org.jetbrains.idea.svn.properties.PropertyValue)1