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
;
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
);
48 setTitle(SvnBundle
.message("dialog.upgrade.wcopy.format.title"));
55 protected Action
[] createActions() {
56 return new Action
[]{getOKAction(), getCancelAction()};
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);
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());
86 protected JComponent
createCenterPanel() {
87 JPanel panel
= new JPanel();
88 panel
.setLayout(new GridBagLayout());
90 GridBagConstraints gb
= new GridBagConstraints();
94 gb
.insets
= new Insets(2, 2, 2, 2);
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
);
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
);
125 panel
.add(myUpgradeAutoButton
, gb
);
127 panel
.add(myUpgradeAuto15Button
, gb
);
129 panel
.add(myUpgradeAuto16Button
, gb
);
132 myUpgradeNoneButton
.setSelected(true);
134 final JPanel auxiliaryPanel
= getBottomAuxiliaryPanel();
135 if (auxiliaryPanel
!= null) {
136 panel
.add(auxiliaryPanel
, gb
);
144 protected JPanel
getBottomAuxiliaryPanel() {
148 protected String
getMiddlePartOfResourceKey(final boolean adminPathIsDirectory
) {
149 return ! adminPathIsDirectory ?
"create" : "upgrade";
152 protected boolean showHints() {
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
;