VCS: allow Git to report changed on server files comparing the whole tree. !! require...
[fedora-idea.git] / plugins / svn4idea / src / org / jetbrains / idea / svn / SvnConfigurable.java
blobf8afa69c65bfd9d97754caea528948aa01ab79bb
1 /**
2 * @copyright
3 * ====================================================================
4 * Copyright (c) 2003-2004 QintSoft. All rights reserved.
6 * This software is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at http://subversion.tigris.org/license-1.html.
9 * If newer versions of this license are posted there, you may use a
10 * newer version instead, at your option.
12 * This software consists of voluntary contributions made by many
13 * individuals. For exact contribution history, see the revision
14 * history and logs, available at http://svnup.tigris.org/.
15 * ====================================================================
16 * @endcopyright
19 * Copyright 2000-2005 JetBrains s.r.o.
21 * Licensed under the Apache License, Version 2.0 (the "License");
22 * you may not use this file except in compliance with the License.
23 * You may obtain a copy of the License at
25 * http://www.apache.org/licenses/LICENSE-2.0
27 * Unless required by applicable law or agreed to in writing, software
28 * distributed under the License is distributed on an "AS IS" BASIS,
29 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30 * See the License for the specific language governing permissions and
31 * limitations under the License.
33 package org.jetbrains.idea.svn;
35 import com.intellij.ide.util.PropertiesComponent;
36 import com.intellij.openapi.application.ApplicationNamesInfo;
37 import com.intellij.openapi.fileChooser.FileChooser;
38 import com.intellij.openapi.fileChooser.FileChooserDescriptor;
39 import com.intellij.openapi.options.Configurable;
40 import com.intellij.openapi.options.ConfigurationException;
41 import com.intellij.openapi.project.Project;
42 import com.intellij.openapi.ui.Messages;
43 import com.intellij.openapi.ui.TextFieldWithBrowseButton;
44 import com.intellij.openapi.vfs.VirtualFile;
45 import com.intellij.openapi.vfs.VirtualFileManager;
46 import com.intellij.ui.MultiLineTooltipUI;
47 import org.jetbrains.annotations.NonNls;
48 import org.jetbrains.idea.svn.config.ConfigureProxiesListener;
49 import org.tmatesoft.svn.core.wc.SVNWCUtil;
51 import javax.swing.*;
52 import java.awt.event.ActionEvent;
53 import java.awt.event.ActionListener;
54 import java.io.File;
56 public class SvnConfigurable implements Configurable {
58 private final Project myProject;
59 private JCheckBox myUseDefaultCheckBox;
60 private TextFieldWithBrowseButton myConfigurationDirectoryText;
61 private JButton myClearAuthButton;
62 private JCheckBox myUseCommonProxy;
63 private JButton myEditProxiesButton;
64 private JPanel myComponent;
66 private JLabel myConfigurationDirectoryLabel;
67 private JLabel myClearCacheLabel;
68 private JLabel myUseCommonProxyLabel;
69 private JLabel myEditProxyLabel;
70 private JCheckBox myLockOnDemand;
71 private JCheckBox myDetectNestedWorkingCopiesCheckBox;
72 private JCheckBox myIgnoreWhitespaceDifferenciesInCheckBox;
73 private JCheckBox myShowMergeSourceInAnnotate;
75 @NonNls private static final String HELP_ID = "project.propSubversion";
77 public SvnConfigurable(Project project) {
78 myProject = project;
80 myUseDefaultCheckBox.addActionListener(new ActionListener(){
81 public void actionPerformed(final ActionEvent e) {
82 boolean enabled = !myUseDefaultCheckBox.isSelected();
83 myConfigurationDirectoryText.setEnabled(enabled);
84 myConfigurationDirectoryLabel.setEnabled(enabled);
85 SvnConfiguration configuration = SvnConfiguration.getInstance(myProject);
86 String path = configuration.getConfigurationDirectory();
87 if (!enabled || path == null) {
88 myConfigurationDirectoryText.setText(SVNWCUtil.getDefaultConfigurationDirectory().getAbsolutePath());
90 else {
91 myConfigurationDirectoryText.setText(path);
94 });
96 myClearAuthButton.addActionListener(new ActionListener(){
97 public void actionPerformed(final ActionEvent e) {
98 String path = myConfigurationDirectoryText.getText();
99 if (path != null) {
100 int result = Messages.showYesNoDialog(myComponent, SvnBundle.message("confirmation.text.delete.stored.authentication.information"),
101 SvnBundle.message("confirmation.title.clear.authentication.cache"),
102 Messages.getWarningIcon());
103 if (result == 0) {
104 SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
105 SvnConfiguration.getInstance(myProject).clearAuthenticationDirectory();
113 final FileChooserDescriptor descriptor = createFileDescriptor();
115 myConfigurationDirectoryText.addActionListener(new ActionListener() {
116 public void actionPerformed(ActionEvent e) {
117 @NonNls String path = myConfigurationDirectoryText.getText().trim();
118 path = "file://" + path.replace(File.separatorChar, '/');
119 VirtualFile root = VirtualFileManager.getInstance().findFileByUrl(path);
121 String oldValue = PropertiesComponent.getInstance().getValue("FileChooser.showHiddens");
122 PropertiesComponent.getInstance().setValue("FileChooser.showHiddens", Boolean.TRUE.toString());
123 VirtualFile[] files = FileChooser.chooseFiles(myComponent, descriptor, root);
124 PropertiesComponent.getInstance().setValue("FileChooser.showHiddens", oldValue);
125 if (files.length != 1 || files[0] == null) {
126 return;
128 myConfigurationDirectoryText.setText(files[0].getPath().replace('/', File.separatorChar));
131 myConfigurationDirectoryText.setEditable(false);
133 myConfigurationDirectoryLabel.setLabelFor(myConfigurationDirectoryText);
135 myUseCommonProxy.setText(SvnBundle.message("use.idea.proxy.as.default", ApplicationNamesInfo.getInstance().getProductName()));
136 myEditProxiesButton.addActionListener(new ConfigureProxiesListener(myProject));
139 private FileChooserDescriptor createFileDescriptor() {
140 final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, false, false, false, false);
141 descriptor.setShowFileSystemRoots(true);
142 descriptor.setTitle(SvnBundle.message("dialog.title.select.configuration.directory"));
143 descriptor.setDescription(SvnBundle.message("dialog.description.select.configuration.directory"));
144 descriptor.setHideIgnored(false);
145 return descriptor;
148 public JComponent createComponent() {
150 return myComponent;
153 public String getDisplayName() {
154 return null;
157 public Icon getIcon() {
158 return null;
161 public String getHelpTopic() {
162 return HELP_ID;
165 public boolean isModified() {
166 if (myComponent == null) {
167 return false;
169 SvnConfiguration configuration = SvnConfiguration.getInstance(myProject);
170 if (configuration.isUseDefaultConfiguation() != myUseDefaultCheckBox.isSelected()) {
171 return true;
173 if (configuration.isIsUseDefaultProxy() != myUseCommonProxy.isSelected()) {
174 return true;
176 if (configuration.UPDATE_LOCK_ON_DEMAND != myLockOnDemand.isSelected()) {
177 return true;
179 if (configuration.DETECT_NESTED_COPIES != myDetectNestedWorkingCopiesCheckBox.isSelected()) {
180 return true;
182 if (configuration.IGNORE_SPACES_IN_ANNOTATE != myIgnoreWhitespaceDifferenciesInCheckBox.isSelected()) {
183 return true;
185 if (configuration.SHOW_MERGE_SOURCES_IN_ANNOTATE != myShowMergeSourceInAnnotate.isSelected()) {
186 return true;
188 return !configuration.getConfigurationDirectory().equals(myConfigurationDirectoryText.getText().trim());
191 public void apply() throws ConfigurationException {
192 SvnConfiguration configuration = SvnConfiguration.getInstance(myProject);
193 configuration.setConfigurationDirectory(myConfigurationDirectoryText.getText());
194 configuration.setUseDefaultConfiguation(myUseDefaultCheckBox.isSelected());
195 configuration.setIsUseDefaultProxy(myUseCommonProxy.isSelected());
196 configuration.DETECT_NESTED_COPIES = myDetectNestedWorkingCopiesCheckBox.isSelected();
197 configuration.UPDATE_LOCK_ON_DEMAND = myLockOnDemand.isSelected();
198 configuration.setIgnoreSpacesInAnnotate(myIgnoreWhitespaceDifferenciesInCheckBox.isSelected());
199 configuration.SHOW_MERGE_SOURCES_IN_ANNOTATE = myShowMergeSourceInAnnotate.isSelected();
202 public void reset() {
203 SvnConfiguration configuration = SvnConfiguration.getInstance(myProject);
204 String path = configuration.getConfigurationDirectory();
205 if (configuration.isUseDefaultConfiguation() || path == null) {
206 path = SVNWCUtil.getDefaultConfigurationDirectory().getAbsolutePath();
208 myConfigurationDirectoryText.setText(path);
209 myUseDefaultCheckBox.setSelected(configuration.isUseDefaultConfiguation());
210 myUseCommonProxy.setSelected(configuration.isIsUseDefaultProxy());
211 myDetectNestedWorkingCopiesCheckBox.setSelected(configuration.DETECT_NESTED_COPIES);
213 boolean enabled = !myUseDefaultCheckBox.isSelected();
214 myConfigurationDirectoryText.setEnabled(enabled);
215 myConfigurationDirectoryLabel.setEnabled(enabled);
216 myLockOnDemand.setSelected(configuration.UPDATE_LOCK_ON_DEMAND);
217 myIgnoreWhitespaceDifferenciesInCheckBox.setSelected(configuration.IGNORE_SPACES_IN_ANNOTATE);
218 myShowMergeSourceInAnnotate.setSelected(configuration.SHOW_MERGE_SOURCES_IN_ANNOTATE);
221 public void disposeUIResources() {
224 private void createUIComponents() {
225 myLockOnDemand = new JCheckBox() {
226 @Override
227 public JToolTip createToolTip() {
228 JToolTip toolTip = new JToolTip(){{
229 setUI(new MultiLineTooltipUI());
231 toolTip.setComponent(this);
232 return toolTip;