SVN auth
[fedora-idea.git] / plugins / svn4idea / src / org / jetbrains / idea / svn / dialogs / UpgradeFormatDialog.java
blob8146e78bf67a52c5b9cc1e850a80d2af61aea0f4
1 /*
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.
16 package org.jetbrains.idea.svn.dialogs;
18 import com.intellij.openapi.application.ApplicationNamesInfo;
19 import com.intellij.openapi.project.Project;
20 import com.intellij.openapi.ui.DialogWrapper;
21 import com.intellij.openapi.ui.MultiLineLabelUI;
22 import org.jetbrains.annotations.NonNls;
23 import org.jetbrains.annotations.Nullable;
24 import org.jetbrains.idea.svn.SvnBundle;
25 import org.jetbrains.idea.svn.SvnConfiguration;
26 import org.tmatesoft.svn.core.internal.wc.SVNFileUtil;
28 import javax.swing.*;
29 import java.awt.*;
30 import java.io.File;
32 public class UpgradeFormatDialog extends DialogWrapper {
33 private JRadioButton myUpgradeNoneButton;
34 private JRadioButton myUpgradeAutoButton;
35 private JRadioButton myUpgradeAuto15Button;
36 private JRadioButton myUpgradeAuto16Button;
38 protected File myPath;
40 public UpgradeFormatDialog(Project project, File path, boolean canBeParent) {
41 this(project, path, canBeParent, true);
44 protected UpgradeFormatDialog(Project project, File path, boolean canBeParent, final boolean initHere) {
45 super(project, canBeParent);
46 myPath = path;
47 setResizable(false);
48 setTitle(SvnBundle.message("dialog.upgrade.wcopy.format.title"));
50 if (initHere) {
51 init();
55 protected Action[] createActions() {
56 return new Action[]{getOKAction(), getCancelAction()};
59 @NonNls
60 protected String getDimensionServiceKey() {
61 return "svn.upgradeDialog";
64 public void setData(final boolean display13format, final String selectedFormat) {
65 if (SvnConfiguration.UPGRADE_AUTO_16.equals(selectedFormat)) {
66 myUpgradeAuto16Button.setSelected(true);
67 } else if (SvnConfiguration.UPGRADE_AUTO.equals(selectedFormat)) {
68 myUpgradeAutoButton.setSelected(true);
69 } else if (SvnConfiguration.UPGRADE_AUTO_15.equals(selectedFormat)) {
70 myUpgradeAuto15Button.setSelected(true);
71 } else {
72 myUpgradeNoneButton.setSelected(true);
74 myUpgradeNoneButton.setVisible(display13format);
75 if (myUpgradeNoneButton.isSelected() && (! display13format)) {
76 myUpgradeAutoButton.setSelected(true);
80 protected String getTopMessage(final String label) {
81 return SvnBundle.message(new StringBuilder().append("label.configure.").append(label).append(".label").toString(),
82 ApplicationNamesInfo.getInstance().getFullProductName());
85 @Nullable
86 protected JComponent createCenterPanel() {
87 JPanel panel = new JPanel();
88 panel.setLayout(new GridBagLayout());
90 GridBagConstraints gb = new GridBagConstraints();
93 // top label.
94 gb.insets = new Insets(2, 2, 2, 2);
95 gb.weightx = 1;
96 gb.weighty = 0;
97 gb.gridwidth = 2;
98 gb.gridheight = 1;
99 gb.gridx = 0;
100 gb.gridy = 0;
101 gb.anchor = GridBagConstraints.WEST;
102 gb.fill = GridBagConstraints.HORIZONTAL;
104 File adminPath = new File(myPath, SVNFileUtil.getAdminDirectoryName());
105 final boolean adminPathIsDirectory = adminPath.isDirectory();
106 final String label = getMiddlePartOfResourceKey(adminPathIsDirectory);
108 JLabel topLabel = new JLabel(getTopMessage(label));
109 topLabel.setUI(new MultiLineLabelUI());
110 panel.add(topLabel, gb);
111 gb.gridy += 1;
113 myUpgradeNoneButton = new JRadioButton(SvnBundle.message(new StringBuilder().append("radio.configure.").append(label).append(".none").toString()));
114 myUpgradeAutoButton = new JRadioButton(SvnBundle.message(new StringBuilder().append("radio.configure.").append(label).append(".auto").toString()));
115 myUpgradeAuto15Button = new JRadioButton(SvnBundle.message(new StringBuilder().append("radio.configure.").append(label).append(".auto.15format").toString()));
116 myUpgradeAuto16Button = new JRadioButton(SvnBundle.message(new StringBuilder().append("radio.configure.").append(label).append(".auto.16format").toString()));
118 ButtonGroup group = new ButtonGroup();
119 group.add(myUpgradeNoneButton);
120 group.add(myUpgradeAutoButton);
121 group.add(myUpgradeAuto15Button);
122 group.add(myUpgradeAuto16Button);
123 panel.add(myUpgradeNoneButton, gb);
124 gb.gridy += 1;
125 panel.add(myUpgradeAutoButton, gb);
126 gb.gridy += 1;
127 panel.add(myUpgradeAuto15Button, gb);
128 gb.gridy += 1;
129 panel.add(myUpgradeAuto16Button, gb);
130 gb.gridy += 1;
132 myUpgradeNoneButton.setSelected(true);
134 final JPanel auxiliaryPanel = getBottomAuxiliaryPanel();
135 if (auxiliaryPanel != null) {
136 panel.add(auxiliaryPanel, gb);
137 gb.gridy += 1;
140 return panel;
143 @Nullable
144 protected JPanel getBottomAuxiliaryPanel() {
145 return null;
148 protected String getMiddlePartOfResourceKey(final boolean adminPathIsDirectory) {
149 return ! adminPathIsDirectory ? "create" : "upgrade";
152 protected boolean showHints() {
153 return true;
156 @Nullable
157 public String getUpgradeMode() {
158 if (myUpgradeNoneButton.isSelected()) {
159 return SvnConfiguration.UPGRADE_NONE;
160 } else if (myUpgradeAutoButton.isSelected()) {
161 return SvnConfiguration.UPGRADE_AUTO;
162 } else if (myUpgradeAuto15Button.isSelected()) {
163 return SvnConfiguration.UPGRADE_AUTO_15;
164 } else if (myUpgradeAuto16Button.isSelected()) {
165 return SvnConfiguration.UPGRADE_AUTO_16;
167 return null;