2 * Copyright 2000-2012 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.jetbrains.idea.svn.history;
18 import com.intellij.openapi.application.ApplicationManager;
19 import com.intellij.openapi.progress.ProgressManager;
20 import com.intellij.openapi.util.Ref;
21 import com.intellij.openapi.vcs.FilePath;
22 import com.intellij.openapi.vcs.VcsException;
23 import com.intellij.openapi.vcs.history.VcsRevisionNumber;
24 import org.jetbrains.annotations.NotNull;
25 import org.jetbrains.annotations.Nullable;
26 import org.jetbrains.idea.svn.SvnBaseContentRevision;
27 import org.jetbrains.idea.svn.SvnBundle;
28 import org.jetbrains.idea.svn.SvnRevisionNumber;
29 import org.jetbrains.idea.svn.SvnVcs;
30 import org.jetbrains.idea.svn.properties.PropertyData;
31 import org.tmatesoft.svn.core.SVNURL;
33 import java.util.List;
35 import static org.jetbrains.idea.svn.actions.ShowPropertiesDiffAction.getPropertyList;
36 import static org.jetbrains.idea.svn.actions.ShowPropertiesDiffAction.toSortedStringPresentation;
38 public class SvnLazyPropertyContentRevision extends SvnBaseContentRevision implements PropertyRevision {
39 private final VcsRevisionNumber myNumber;
40 private final SVNURL myUrl;
41 private List<PropertyData> myContent;
43 public SvnLazyPropertyContentRevision(@NotNull SvnVcs vcs, @NotNull FilePath file, VcsRevisionNumber number, SVNURL url) {
51 public List<PropertyData> getProperties() throws VcsException {
52 if (myContent == null) {
53 myContent = loadContent();
59 public String getContent() throws VcsException {
60 return toSortedStringPresentation(getProperties());
63 private List<PropertyData> loadContent() throws VcsException {
64 final Ref<List<PropertyData>> ref = new Ref<>();
65 final Ref<VcsException> exceptionRef = new Ref<>();
66 final Runnable runnable = () -> {
68 ref.set(getPropertyList(myVcs, myUrl, ((SvnRevisionNumber)myNumber).getRevision()));
70 catch (VcsException e) {
74 if (ApplicationManager.getApplication().isDispatchThread()) {
75 boolean completed = ProgressManager.getInstance()
76 .runProcessWithProgressSynchronously(runnable, SvnBundle.message("progress.title.loading.file.properties"), true,
79 throw new VcsException("Properties load for revision " + getRevisionNumber().asString() + " was canceled.");
85 if (!exceptionRef.isNull()) throw exceptionRef.get();
91 public VcsRevisionNumber getRevisionNumber() {