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.
17 package com
.intellij
.cvsSupport2
.connections
;
19 import com
.intellij
.cvsSupport2
.config
.CvsRootConfiguration
;
20 import com
.intellij
.cvsSupport2
.connections
.ext
.ExtConnectionCvsSettings
;
21 import com
.intellij
.cvsSupport2
.connections
.local
.LocalConnectionSettings
;
22 import com
.intellij
.cvsSupport2
.connections
.pserver
.PServerCvsSettings
;
23 import com
.intellij
.cvsSupport2
.connections
.pserver
.PServerLoginProvider
;
24 import com
.intellij
.cvsSupport2
.connections
.ssh
.SshConnectionSettings
;
26 public class IDEARootFormatter
implements CvsRootSettingsBuilder
<CvsConnectionSettings
>{
27 private final CvsRootConfiguration myCvsRootConfiguration
;
30 public IDEARootFormatter(final CvsRootConfiguration cvsRootConfiguration
) {
31 myCvsRootConfiguration
= cvsRootConfiguration
;
34 public CvsConnectionSettings
createConfiguration() {
35 return new RootFormatter
<CvsConnectionSettings
>(this).createConfiguration(myCvsRootConfiguration
.getCvsRootAsString());
38 public CvsConnectionSettings
createSettings(final CvsMethod method
, final String cvsRootAsString
) {
39 if (method
.equals(CvsMethod
.LOCAL_METHOD
)) {
40 return new LocalConnectionSettings(cvsRootAsString
, myCvsRootConfiguration
);
42 else if (method
.equals(CvsMethod
.PSERVER_METHOD
)) {
43 return new PServerCvsSettings(myCvsRootConfiguration
);
45 else if (method
.equals(CvsMethod
.EXT_METHOD
)) {
46 return new ExtConnectionCvsSettings(myCvsRootConfiguration
);
48 else if (method
.equals(CvsMethod
.SSH_METHOD
)) {
49 return new SshConnectionSettings(myCvsRootConfiguration
);
52 throw new RuntimeException(com
.intellij
.CvsBundle
.message("exception.text.unsupported.method", method
));
55 public String
getPServerPassword(final String cvsRoot
) {
56 return PServerLoginProvider
.getInstance().getScrambledPasswordForCvsRoot(cvsRoot
);