blob: d909cae3f15d755b7056b2bc3733a62085abbe84 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/*****************************************************************************
* Copyright (c) 2011 Atos Origin.
*
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.svn;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.team.FileModificationValidationContext;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.papyrus.readonly.IReadOnlyHandler;
import org.eclipse.team.svn.core.IStateFilter;
import org.eclipse.team.svn.core.svnstorage.SVNRemoteStorage;
import org.eclipse.team.svn.core.utility.FileUtility;
import org.eclipse.team.svn.ui.SVNTeamModificationValidator;
public class SVNLockHandler implements IReadOnlyHandler {
SVNTeamModificationValidator validator = new SVNTeamModificationValidator();
public boolean isReadOnly(IFile[] files) {
IResource[] needsLockResources = FileUtility.filterResources(files, IStateFilter.SF_NEEDS_LOCK, IResource.DEPTH_ZERO);
for(IResource needsLockResource : needsLockResources) {
if(!SVNRemoteStorage.instance().asLocalResource(needsLockResource).isLocked()) {
return true;
}
}
return false;
}
public boolean enableWrite(IFile[] files) {
IStatus result = validator.validateEdit(files, FileModificationValidationContext.VALIDATE_PROMPT);
return result.isOK();
}
}
|