Lines 40-46
Link Here
|
40 |
|
40 |
|
41 |
package org.netbeans.modules.ada.project.ui.properties; |
41 |
package org.netbeans.modules.ada.project.ui.properties; |
42 |
|
42 |
|
43 |
import java.awt.Component; |
|
|
44 |
import java.awt.Font; |
43 |
import java.awt.Font; |
45 |
import java.awt.Graphics; |
44 |
import java.awt.Graphics; |
46 |
import java.awt.event.ActionEvent; |
45 |
import java.awt.event.ActionEvent; |
Lines 49-76
Link Here
|
49 |
import java.awt.event.ComponentEvent; |
48 |
import java.awt.event.ComponentEvent; |
50 |
import java.io.File; |
49 |
import java.io.File; |
51 |
import java.nio.charset.Charset; |
50 |
import java.nio.charset.Charset; |
52 |
import java.nio.charset.CharsetDecoder; |
|
|
53 |
import java.nio.charset.CharsetEncoder; |
54 |
import java.nio.charset.IllegalCharsetNameException; |
55 |
import java.util.LinkedList; |
51 |
import java.util.LinkedList; |
56 |
import java.util.List; |
52 |
import java.util.List; |
57 |
import java.util.logging.Logger; |
|
|
58 |
import javax.swing.DefaultCellEditor; |
53 |
import javax.swing.DefaultCellEditor; |
59 |
import javax.swing.DefaultComboBoxModel; |
|
|
60 |
import javax.swing.JLabel; |
61 |
import javax.swing.JList; |
62 |
import javax.swing.JTable; |
54 |
import javax.swing.JTable; |
63 |
import javax.swing.JTextField; |
55 |
import javax.swing.JTextField; |
64 |
import javax.swing.ListCellRenderer; |
|
|
65 |
import javax.swing.ListSelectionModel; |
56 |
import javax.swing.ListSelectionModel; |
66 |
import javax.swing.UIManager; |
57 |
import javax.swing.UIManager; |
67 |
import javax.swing.event.ChangeEvent; |
58 |
import javax.swing.event.ChangeEvent; |
68 |
import javax.swing.event.ChangeListener; |
59 |
import javax.swing.event.ChangeListener; |
69 |
import javax.swing.plaf.UIResource; |
|
|
70 |
import javax.swing.table.TableColumn; |
60 |
import javax.swing.table.TableColumn; |
71 |
import javax.swing.table.TableModel; |
61 |
import javax.swing.table.TableModel; |
72 |
import org.netbeans.modules.ada.project.Pair; |
62 |
import org.netbeans.modules.ada.project.Pair; |
73 |
import org.netbeans.modules.ada.project.ui.Utils; |
63 |
import org.netbeans.modules.ada.project.ui.Utils; |
|
|
64 |
import org.netbeans.spi.project.ui.support.ProjectCustomizer; |
74 |
import org.openide.DialogDisplayer; |
65 |
import org.openide.DialogDisplayer; |
75 |
import org.openide.NotifyDescriptor; |
66 |
import org.openide.NotifyDescriptor; |
76 |
import org.openide.filesystems.FileObject; |
67 |
import org.openide.filesystems.FileObject; |
Lines 139-146
Link Here
|
139 |
this.originalEncoding = Charset.defaultCharset().name(); |
130 |
this.originalEncoding = Charset.defaultCharset().name(); |
140 |
} |
131 |
} |
141 |
|
132 |
|
142 |
this.encoding.setModel(new EncodingModel(this.originalEncoding)); |
133 |
this.encoding.setModel(ProjectCustomizer.encodingModel(this.originalEncoding)); |
143 |
this.encoding.setRenderer(new EncodingRenderer()); |
134 |
this.encoding.setRenderer(ProjectCustomizer.encodingRenderer()); |
144 |
final String lafid = UIManager.getLookAndFeel().getID(); |
135 |
final String lafid = UIManager.getLookAndFeel().getID(); |
145 |
if (!"Aqua".equals(lafid)) { //NOI18N |
136 |
if (!"Aqua".equals(lafid)) { //NOI18N |
146 |
this.encoding.putClientProperty ("JComboBox.isTableCellEditor", Boolean.TRUE); //NOI18N |
137 |
this.encoding.putClientProperty ("JComboBox.isTableCellEditor", Boolean.TRUE); //NOI18N |
Lines 226-260
Link Here
|
226 |
return new HelpCtx(this.getClass()); |
217 |
return new HelpCtx(this.getClass()); |
227 |
} |
218 |
} |
228 |
|
219 |
|
229 |
private static class EncodingRenderer extends JLabel implements ListCellRenderer, UIResource { |
|
|
230 |
|
231 |
public EncodingRenderer() { |
232 |
setOpaque(true); |
233 |
} |
234 |
|
235 |
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
236 |
assert value instanceof Charset; |
237 |
setName("ComboBox.listRenderer"); // NOI18N |
238 |
setText(((Charset) value).displayName()); |
239 |
setIcon(null); |
240 |
if (isSelected) { |
241 |
setBackground(list.getSelectionBackground()); |
242 |
setForeground(list.getSelectionForeground()); |
243 |
} else { |
244 |
setBackground(list.getBackground()); |
245 |
setForeground(list.getForeground()); |
246 |
} |
247 |
return this; |
248 |
} |
249 |
|
250 |
@Override |
251 |
public String getName() { |
252 |
String name = super.getName(); |
253 |
return name == null ? "ComboBox.renderer" : name; // NOI18N |
254 |
} |
255 |
|
256 |
} |
257 |
|
258 |
private class MediatorListener implements ChangeListener { |
220 |
private class MediatorListener implements ChangeListener { |
259 |
|
221 |
|
260 |
public void stateChanged(ChangeEvent e) { |
222 |
public void stateChanged(ChangeEvent e) { |
Lines 279-332
Link Here
|
279 |
|
241 |
|
280 |
} |
242 |
} |
281 |
|
243 |
|
282 |
private static class EncodingModel extends DefaultComboBoxModel { |
|
|
283 |
|
284 |
public EncodingModel (String originalEncoding) { |
285 |
Charset defEnc = null; |
286 |
for (Charset c : Charset.availableCharsets().values()) { |
287 |
if (c.name().equals(originalEncoding)) { |
288 |
defEnc = c; |
289 |
} |
290 |
addElement(c); |
291 |
} |
292 |
if (defEnc == null) { |
293 |
//Create artificial Charset to keep the original value |
294 |
//May happen when the project was set up on the platform |
295 |
//which supports more encodings |
296 |
try { |
297 |
defEnc = new UnknownCharset (originalEncoding); |
298 |
addElement(defEnc); |
299 |
} catch (IllegalCharsetNameException e) { |
300 |
//The source.encoding property is completely broken |
301 |
Logger.getLogger(this.getClass().getName()).info("IllegalCharsetName: " + originalEncoding); |
302 |
} |
303 |
} |
304 |
if (defEnc == null) { |
305 |
defEnc = Charset.defaultCharset(); |
306 |
} |
307 |
setSelectedItem(defEnc); |
308 |
} |
309 |
} |
310 |
|
311 |
private static class UnknownCharset extends Charset { |
312 |
|
313 |
UnknownCharset (String name) { |
314 |
super (name, new String[0]); |
315 |
} |
316 |
|
317 |
public boolean contains(Charset c) { |
318 |
throw new UnsupportedOperationException(); |
319 |
} |
320 |
|
321 |
public CharsetDecoder newDecoder() { |
322 |
throw new UnsupportedOperationException(); |
323 |
} |
324 |
|
325 |
public CharsetEncoder newEncoder() { |
326 |
throw new UnsupportedOperationException(); |
327 |
} |
328 |
} |
329 |
|
330 |
private static class ResizableRowHeightTable extends JTable { |
244 |
private static class ResizableRowHeightTable extends JTable { |
331 |
|
245 |
|
332 |
private boolean needResize = true; |
246 |
private boolean needResize = true; |