Lines 41-47
Link Here
|
41 |
|
41 |
|
42 |
package org.netbeans.modules.java.j2seproject.ui.customizer; |
42 |
package org.netbeans.modules.java.j2seproject.ui.customizer; |
43 |
|
43 |
|
44 |
import java.awt.Component; |
|
|
45 |
import java.awt.Font; |
44 |
import java.awt.Font; |
46 |
import java.awt.Graphics; |
45 |
import java.awt.Graphics; |
47 |
import java.awt.event.ActionEvent; |
46 |
import java.awt.event.ActionEvent; |
Lines 50-75
Link Here
|
50 |
import java.awt.event.ComponentEvent; |
49 |
import java.awt.event.ComponentEvent; |
51 |
import java.io.File; |
50 |
import java.io.File; |
52 |
import java.nio.charset.Charset; |
51 |
import java.nio.charset.Charset; |
53 |
import java.nio.charset.CharsetDecoder; |
|
|
54 |
import java.nio.charset.CharsetEncoder; |
55 |
import java.nio.charset.IllegalCharsetNameException; |
56 |
import java.util.logging.Logger; |
57 |
import javax.swing.DefaultCellEditor; |
52 |
import javax.swing.DefaultCellEditor; |
58 |
import javax.swing.DefaultComboBoxModel; |
|
|
59 |
import javax.swing.JLabel; |
60 |
import javax.swing.JList; |
61 |
import javax.swing.JTable; |
53 |
import javax.swing.JTable; |
62 |
import javax.swing.JTextField; |
54 |
import javax.swing.JTextField; |
63 |
import javax.swing.ListCellRenderer; |
|
|
64 |
import javax.swing.ListSelectionModel; |
55 |
import javax.swing.ListSelectionModel; |
65 |
import javax.swing.UIManager; |
56 |
import javax.swing.UIManager; |
66 |
import javax.swing.event.ListDataEvent; |
57 |
import javax.swing.event.ListDataEvent; |
67 |
import javax.swing.event.ListDataListener; |
58 |
import javax.swing.event.ListDataListener; |
68 |
import javax.swing.plaf.UIResource; |
|
|
69 |
import javax.swing.table.TableColumn; |
59 |
import javax.swing.table.TableColumn; |
70 |
import javax.swing.table.TableModel; |
60 |
import javax.swing.table.TableModel; |
71 |
import org.netbeans.modules.java.api.common.project.ui.customizer.SourceRootsUi; |
61 |
import org.netbeans.modules.java.api.common.project.ui.customizer.SourceRootsUi; |
72 |
import org.netbeans.spi.java.project.support.ui.IncludeExcludeVisualizer; |
62 |
import org.netbeans.spi.java.project.support.ui.IncludeExcludeVisualizer; |
|
|
63 |
import org.netbeans.spi.project.ui.support.ProjectCustomizer; |
73 |
import org.openide.DialogDescriptor; |
64 |
import org.openide.DialogDescriptor; |
74 |
import org.openide.DialogDisplayer; |
65 |
import org.openide.DialogDisplayer; |
75 |
import org.openide.NotifyDescriptor; |
66 |
import org.openide.NotifyDescriptor; |
Lines 152-159
Link Here
|
152 |
this.originalEncoding = Charset.defaultCharset().name(); |
143 |
this.originalEncoding = Charset.defaultCharset().name(); |
153 |
} |
144 |
} |
154 |
|
145 |
|
155 |
this.encoding.setModel(new EncodingModel(this.originalEncoding)); |
146 |
this.encoding.setModel(ProjectCustomizer.createEncodingModel(originalEncoding)); |
156 |
this.encoding.setRenderer(new EncodingRenderer()); |
147 |
this.encoding.setRenderer(ProjectCustomizer.createEncodingRenderer()); |
157 |
final String lafid = UIManager.getLookAndFeel().getID(); |
148 |
final String lafid = UIManager.getLookAndFeel().getID(); |
158 |
if (!"Aqua".equals(lafid)) { //NOI18N |
149 |
if (!"Aqua".equals(lafid)) { //NOI18N |
159 |
this.encoding.putClientProperty ("JComboBox.isTableCellEditor", Boolean.TRUE); //NOI18N |
150 |
this.encoding.putClientProperty ("JComboBox.isTableCellEditor", Boolean.TRUE); //NOI18N |
Lines 243-326
Link Here
|
243 |
this.sourceLevel.setEnabled(sourceLevel.getItemCount()>0); |
234 |
this.sourceLevel.setEnabled(sourceLevel.getItemCount()>0); |
244 |
} |
235 |
} |
245 |
|
236 |
|
246 |
|
|
|
247 |
private static class EncodingRenderer extends JLabel implements ListCellRenderer, UIResource { |
248 |
|
249 |
public EncodingRenderer() { |
250 |
setOpaque(true); |
251 |
} |
252 |
|
253 |
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
254 |
assert value instanceof Charset; |
255 |
setName("ComboBox.listRenderer"); // NOI18N |
256 |
setText(((Charset) value).displayName()); |
257 |
setIcon(null); |
258 |
if (isSelected) { |
259 |
setBackground(list.getSelectionBackground()); |
260 |
setForeground(list.getSelectionForeground()); |
261 |
} else { |
262 |
setBackground(list.getBackground()); |
263 |
setForeground(list.getForeground()); |
264 |
} |
265 |
return this; |
266 |
} |
267 |
|
268 |
@Override |
269 |
public String getName() { |
270 |
String name = super.getName(); |
271 |
return name == null ? "ComboBox.renderer" : name; // NOI18N |
272 |
} |
273 |
|
274 |
} |
275 |
|
276 |
private static class EncodingModel extends DefaultComboBoxModel { |
277 |
|
278 |
public EncodingModel (String originalEncoding) { |
279 |
Charset defEnc = null; |
280 |
for (Charset c : Charset.availableCharsets().values()) { |
281 |
if (c.name().equals(originalEncoding)) { |
282 |
defEnc = c; |
283 |
} |
284 |
addElement(c); |
285 |
} |
286 |
if (defEnc == null) { |
287 |
//Create artificial Charset to keep the original value |
288 |
//May happen when the project was set up on the platform |
289 |
//which supports more encodings |
290 |
try { |
291 |
defEnc = new UnknownCharset (originalEncoding); |
292 |
addElement(defEnc); |
293 |
} catch (IllegalCharsetNameException e) { |
294 |
//The source.encoding property is completely broken |
295 |
Logger.getLogger(this.getClass().getName()).info("IllegalCharsetName: " + originalEncoding); |
296 |
} |
297 |
} |
298 |
if (defEnc == null) { |
299 |
defEnc = Charset.defaultCharset(); |
300 |
} |
301 |
setSelectedItem(defEnc); |
302 |
} |
303 |
} |
304 |
|
305 |
private static class UnknownCharset extends Charset { |
306 |
|
307 |
UnknownCharset (String name) { |
308 |
super (name, new String[0]); |
309 |
} |
310 |
|
311 |
public boolean contains(Charset c) { |
312 |
throw new UnsupportedOperationException(); |
313 |
} |
314 |
|
315 |
public CharsetDecoder newDecoder() { |
316 |
throw new UnsupportedOperationException(); |
317 |
} |
318 |
|
319 |
public CharsetEncoder newEncoder() { |
320 |
throw new UnsupportedOperationException(); |
321 |
} |
322 |
} |
323 |
|
324 |
private static class ResizableRowHeightTable extends JTable { |
237 |
private static class ResizableRowHeightTable extends JTable { |
325 |
|
238 |
|
326 |
private boolean needResize = true; |
239 |
private boolean needResize = true; |