2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6
* The contents of this file are subject to the terms of either the GNU
7
* General Public License Version 2 only ("GPL") or the Common
8
* Development and Distribution License("CDDL") (collectively, the
9
* "License"). You may not use this file except in compliance with the
10
* License. You can obtain a copy of the License at
11
* http://www.netbeans.org/cddl-gplv2.html
12
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
* specific language governing permissions and limitations under the
14
* License. When distributing the software, include this License Header
15
* Notice in each file and include the License file at
16
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17
* particular file as subject to the "Classpath" exception as provided
18
* by Sun in the GPL Version 2 section of the License file that
19
* accompanied this code. If applicable, add the following below the
20
* License Header, with the fields enclosed by brackets [] replaced by
21
* your own identifying information:
22
* "Portions Copyrighted [year] [name of copyright owner]"
26
* The Original Software is NetBeans. The Initial Developer of the Original
27
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
* Microsystems, Inc. All Rights Reserved.
30
* If you wish your version of this file to be governed by only the CDDL
31
* or only the GPL Version 2, indicate your decision by adding
32
* "[Contributor] elects to include this software in this distribution
33
* under the [CDDL or GPL Version 2] license." If you do not indicate a
34
* single choice of license, a recipient has the option to distribute
35
* your version of this file under either the CDDL, the GPL Version 2 or
36
* to extend the choice of license to its licensees as provided above.
37
* However, if you add GPL Version 2 code and therefore, elected the GPL
38
* Version 2 license, then the option applies only if the new code is
39
* made subject to such option by the copyright holder.
41
package org.netbeans.modules.subversion.ui.copy;
43
import java.awt.Dialog;
44
import java.beans.PropertyChangeEvent;
45
import java.beans.PropertyChangeListener;
46
import java.util.HashMap;
47
import java.util.Iterator;
48
import java.util.List;
50
import java.util.Vector;
51
import javax.swing.ComboBoxModel;
52
import javax.swing.DefaultComboBoxModel;
53
import javax.swing.JButton;
54
import javax.swing.JComboBox;
55
import javax.swing.JPanel;
56
import org.netbeans.modules.subversion.SvnModuleConfig;
57
import org.netbeans.modules.versioning.util.Utils;
58
import org.openide.DialogDescriptor;
59
import org.openide.DialogDisplayer;
60
import org.openide.util.HelpCtx;
61
import org.openide.util.NbBundle;
65
* @author Tomas Stupka
67
public abstract class CopyDialog {
69
private DialogDescriptor dialogDescriptor;
70
private JButton okButton, cancelButton;
73
private Map<String, JComboBox> urlComboBoxes;
75
public CopyDialog(JPanel panel, String title, String okLabel) {
77
dialogDescriptor = new DialogDescriptor(panel, title);
79
okButton = new JButton(okLabel);
80
okButton.getAccessibleContext().setAccessibleDescription(okLabel);
81
okButton.setEnabled(false);
82
cancelButton = new JButton(org.openide.util.NbBundle.getMessage(CopyDialog.class, "CTL_Copy_Cancel")); // NOI18N
83
cancelButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CopyDialog.class, "CTL_Copy_Cancel")); // NOI18N
84
dialogDescriptor.setOptions(new Object[] {okButton, cancelButton});
86
dialogDescriptor.setModal(true);
87
dialogDescriptor.setHelpCtx(new HelpCtx(this.getClass()));
88
dialogDescriptor.setValid(false);
89
Dialog dialog = DialogDisplayer.getDefault().createDialog(dialogDescriptor);
90
dialog.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CopyDialog.class, "CTL_Title")); // NOI18N
93
protected void resetUrlComboBoxes() {
94
getUrlComboBoxes().clear();
97
protected void setupUrlComboBox(JComboBox cbo, String key) {
101
List<String> recentFolders = Utils.getStringList(SvnModuleConfig.getDefault().getPreferences(), key);
102
ComboBoxModel rootsModel = new DefaultComboBoxModel(new Vector<String>(recentFolders));
103
cbo.setModel(rootsModel);
105
getUrlComboBoxes().put(key, cbo);
108
private Map<String, JComboBox> getUrlComboBoxes() {
109
if(urlComboBoxes == null) {
110
urlComboBoxes = new HashMap<String, JComboBox>();
112
return urlComboBoxes;
115
protected JPanel getPanel() {
119
public boolean showDialog() {
120
Dialog dialog = DialogDisplayer.getDefault().createDialog(dialogDescriptor);
121
dialog.setVisible(true);
122
dialog.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CopyDialog.class, "CTL_Title")); // NOI18N
123
boolean ret = dialogDescriptor.getValue()==okButton;
130
private void storeValidValues() {
131
for (Iterator it = urlComboBoxes.keySet().iterator(); it.hasNext();) {
132
String key = (String) it.next();
133
JComboBox cbo = (JComboBox) urlComboBoxes.get(key);
134
Object item = cbo.getEditor().getItem();
135
if(item != null && !item.equals("")) { // NOI18N
136
Utils.insert(SvnModuleConfig.getDefault().getPreferences(), key, (String) item, 8);
141
protected JButton getOKButton() {