Revision 33982 branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/SelectBundlesPanel.java

View differences:

SelectBundlesPanel.java
34 34
import java.awt.event.ItemEvent;
35 35
import java.awt.event.ItemListener;
36 36
import java.io.File;
37
import java.net.MalformedURLException;
38
import java.net.URL;
37 39

  
38 40
import javax.swing.ButtonGroup;
39 41
import javax.swing.JPanel;
......
61 63
    private ButtonGroup buttonGroup;
62 64
    private JPanel northPanel;
63 65
    private FileTextField selectFileText;
64
    private JRadioButton standardRadionButton;
66
    private JRadioButton standardRadioButton;
67
    private JTextField urlText;
68
    private JRadioButton urlRadioButton;
65 69

  
66 70
    public SelectBundlesPanel() {
67 71
        super();
......
70 74
                .getSwingInstallerManager();
71 75
        initComponents();
72 76
        initListeners();
73
        standardRadionButton.setSelected(true);
77
        standardRadioButton.setSelected(true);
74 78
    }
75 79

  
76 80
    private void initListeners() {
77
        standardRadionButton.addItemListener(this);
81
        standardRadioButton.addItemListener(this);
78 82
        fileRadioButton.addItemListener(this);
83
        urlRadioButton.addItemListener(this);
79 84
        Object obj = selectFileText.getComponent(0);
80 85
        if ((obj != null) && (obj instanceof JTextField)) {
81 86
            ((JTextField) obj).getDocument().addDocumentListener(this);
82 87
        }
88
        urlText.getDocument().addDocumentListener(this);
83 89
    }
84 90

  
85 91
    private void initComponents() {
86 92
        java.awt.GridBagConstraints gridBagConstraints;
87 93

  
88 94
        northPanel = new JPanel();
89
        standardRadionButton = new JRadioButton();
95
        standardRadioButton = new JRadioButton();
90 96
        fileRadioButton = new JRadioButton();
97
        urlRadioButton = new JRadioButton();
91 98
        selectFileText = new FileTextField();
99
        urlText = new JTextField();
92 100
        buttonGroup = new ButtonGroup();
93 101

  
94
        buttonGroup.add(standardRadionButton);
102
        buttonGroup.add(standardRadioButton);
95 103
        buttonGroup.add(fileRadioButton);
104
        buttonGroup.add(urlRadioButton);
96 105

  
97 106
        setLayout(new BorderLayout());
98 107

  
99 108
        northPanel.setLayout(new GridBagLayout());
100 109

  
101
        standardRadionButton.setText(swingInstallerManager
110
        standardRadioButton.setText(swingInstallerManager
102 111
            .getText("standard_installation"));
103 112
        gridBagConstraints = new GridBagConstraints();
104 113
        gridBagConstraints.anchor = GridBagConstraints.WEST;
105 114
        gridBagConstraints.insets = new Insets(2, 2, 2, 2);
106
        northPanel.add(standardRadionButton, gridBagConstraints);
115
        northPanel.add(standardRadioButton, gridBagConstraints);
107 116

  
108 117
        fileRadioButton.setText(swingInstallerManager
109 118
            .getText("installation_from_file"));
......
121 130
        gridBagConstraints.insets = new Insets(2, 20, 2, 2);
122 131
        northPanel.add(selectFileText, gridBagConstraints);
123 132

  
133
        urlRadioButton.setText(swingInstallerManager
134
            .getText("installation_from_url"));
135
        gridBagConstraints = new GridBagConstraints();
136
        gridBagConstraints.gridx = 0;
137
        gridBagConstraints.gridy = 3;
138
        gridBagConstraints.anchor = GridBagConstraints.WEST;
139
        gridBagConstraints.insets = new Insets(2, 2, 2, 2);
140
        northPanel.add(urlRadioButton, gridBagConstraints);
141
        gridBagConstraints = new GridBagConstraints();
142
        gridBagConstraints.gridx = 0;
143
        gridBagConstraints.gridy = 4;
144
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
145
        gridBagConstraints.weightx = 1.0;
146
        gridBagConstraints.insets = new Insets(2, 20, 2, 2);
147
        northPanel.add(urlText, gridBagConstraints);
148

  
124 149
        add(northPanel, java.awt.BorderLayout.NORTH);
125 150
    }
126 151

  
......
133 158
        return selectFileText.getSelectedFile();
134 159
    }
135 160

  
161
    protected URL getSelectedURL() throws MalformedURLException {
162
        return new URL(urlText.getText());
163
    }
164

  
136 165
    protected boolean isStandardSelected() {
137
        return standardRadionButton.isSelected();
166
        return standardRadioButton.isSelected();
138 167
    }
139 168

  
169
    protected boolean isFileSelected() {
170
        return fileRadioButton.isSelected();
171
    }
172

  
173
    protected boolean isURLSelected() {
174
        return urlRadioButton.isSelected();
175
    }
176

  
140 177
    protected boolean isNextButtonEnabled() {
141 178
        if (isStandardSelected()) {
142 179
            return true;
143 180
        }
144
        File file = selectFileText.getSelectedFile();
145
        if (file == null) {
146
            return false;
181
        if (isFileSelected()) {
182
            File file = selectFileText.getSelectedFile();
183
            if (file == null) {
184
                return false;
185
            }
186
            return file.exists();
147 187
        }
148
        return file.exists();
188
        if (isURLSelected()) {
189
            try {
190
                getSelectedURL();
191
                return true;
192
            } catch (MalformedURLException e) {
193
                return false;
194
            }
195
        }
196
        return false;
149 197
    }
150 198

  
151 199
    protected void checkNextButtonEnabled() {

Also available in: Unified diff