2 * Copyright 2000-2009 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.
18 package org
.jetbrains
.idea
.svn
.actions
;
20 import com
.intellij
.openapi
.actionSystem
.DataContext
;
21 import com
.intellij
.openapi
.project
.Project
;
22 import com
.intellij
.openapi
.vcs
.AbstractVcs
;
23 import com
.intellij
.openapi
.vcs
.FileStatus
;
24 import com
.intellij
.openapi
.vcs
.FileStatusManager
;
25 import com
.intellij
.openapi
.vcs
.VcsException
;
26 import com
.intellij
.openapi
.vcs
.changes
.VcsDirtyScopeManager
;
27 import com
.intellij
.openapi
.vfs
.VirtualFile
;
28 import org
.jetbrains
.idea
.svn
.SvnBundle
;
29 import org
.jetbrains
.idea
.svn
.SvnVcs
;
30 import org
.jetbrains
.idea
.svn
.dialogs
.SetPropertyDialog
;
31 import org
.tmatesoft
.svn
.core
.SVNException
;
32 import org
.tmatesoft
.svn
.core
.SVNPropertyValue
;
33 import org
.tmatesoft
.svn
.core
.wc
.SVNWCClient
;
37 public class SetPropertyAction
extends BasicAction
{
38 protected String
getActionName(AbstractVcs vcs
) {
39 return SvnBundle
.message("action.name.set.property");
42 protected boolean needsAllFiles() {
46 protected boolean isEnabled(Project project
, SvnVcs vcs
, VirtualFile file
) {
47 if (file
== null || project
== null || vcs
== null) return false;
48 final FileStatus status
= FileStatusManager
.getInstance(project
).getStatus(file
);
49 return (! FileStatus
.IGNORED
.equals(status
)) && (! FileStatus
.UNKNOWN
.equals(status
));
52 protected boolean needsFiles() {
56 protected void perform(Project project
, SvnVcs activeVcs
, VirtualFile file
, DataContext context
)
58 batchPerform(project
, activeVcs
, new VirtualFile
[]{file
}, context
);
61 protected void batchPerform(Project project
, SvnVcs activeVcs
, VirtualFile
[] file
, DataContext context
)
63 File
[] ioFiles
= new File
[file
.length
];
64 for (int i
= 0; i
< ioFiles
.length
; i
++) {
65 ioFiles
[i
] = new File(file
[i
].getPath());
68 SetPropertyDialog dialog
= new SetPropertyDialog(project
, ioFiles
, null, true);
72 String name
= dialog
.getPropertyName();
73 String value
= dialog
.getPropertyValue();
74 boolean recursive
= dialog
.isRecursive();
76 SVNWCClient wcClient
= activeVcs
.createWCClient();
77 for (int i
= 0; i
< ioFiles
.length
; i
++) {
78 File ioFile
= ioFiles
[i
];
80 wcClient
.doSetProperty(ioFile
, name
, SVNPropertyValue
.create(value
), false, recursive
, null);
82 catch (SVNException e
) {
83 throw new VcsException(e
);
86 for(int i
= 0; i
< file
.length
; i
++) {
87 if (recursive
&& file
[i
].isDirectory()) {
88 VcsDirtyScopeManager
.getInstance(project
).dirDirtyRecursively(file
[i
], true);
90 VcsDirtyScopeManager
.getInstance(project
).fileDirty(file
[i
]);
96 protected boolean isBatchAction() {