Lines 41-69
Link Here
|
41 |
|
41 |
|
42 |
package org.netbeans.modules.web.project.ui.customizer; |
42 |
package org.netbeans.modules.web.project.ui.customizer; |
43 |
|
43 |
|
44 |
import java.awt.Component; |
|
|
45 |
import java.awt.event.ActionEvent; |
44 |
import java.awt.event.ActionEvent; |
46 |
import java.awt.event.ActionListener; |
45 |
import java.awt.event.ActionListener; |
47 |
import java.awt.event.ItemEvent; |
46 |
import java.awt.event.ItemEvent; |
48 |
import java.awt.event.ItemListener; |
47 |
import java.awt.event.ItemListener; |
49 |
import java.io.File; |
48 |
import java.io.File; |
50 |
import java.nio.charset.Charset; |
49 |
import java.nio.charset.Charset; |
51 |
import java.nio.charset.CharsetDecoder; |
|
|
52 |
import java.nio.charset.CharsetEncoder; |
53 |
import java.util.logging.Logger; |
54 |
import javax.swing.DefaultComboBoxModel; |
55 |
import javax.swing.JComboBox; |
50 |
import javax.swing.JComboBox; |
56 |
import javax.swing.JFileChooser; |
51 |
import javax.swing.JFileChooser; |
57 |
import javax.swing.JLabel; |
|
|
58 |
import javax.swing.JList; |
59 |
import javax.swing.JTable; |
52 |
import javax.swing.JTable; |
60 |
import javax.swing.JTextField; |
53 |
import javax.swing.JTextField; |
61 |
import javax.swing.ListCellRenderer; |
|
|
62 |
import javax.swing.ListSelectionModel; |
54 |
import javax.swing.ListSelectionModel; |
63 |
import javax.swing.UIManager; |
55 |
import javax.swing.UIManager; |
64 |
import javax.swing.event.ListDataEvent; |
56 |
import javax.swing.event.ListDataEvent; |
65 |
import javax.swing.event.ListDataListener; |
57 |
import javax.swing.event.ListDataListener; |
66 |
import javax.swing.plaf.UIResource; |
|
|
67 |
import javax.swing.table.TableColumn; |
58 |
import javax.swing.table.TableColumn; |
68 |
import org.openide.filesystems.FileObject; |
59 |
import org.openide.filesystems.FileObject; |
69 |
import org.openide.filesystems.FileUtil; |
60 |
import org.openide.filesystems.FileUtil; |
Lines 74-79
Link Here
|
74 |
import org.netbeans.spi.project.support.ant.PropertyUtils; |
65 |
import org.netbeans.spi.project.support.ant.PropertyUtils; |
75 |
import org.netbeans.modules.web.project.WebProject; |
66 |
import org.netbeans.modules.web.project.WebProject; |
76 |
import org.netbeans.spi.java.project.support.ui.IncludeExcludeVisualizer; |
67 |
import org.netbeans.spi.java.project.support.ui.IncludeExcludeVisualizer; |
|
|
68 |
import org.netbeans.spi.project.ui.support.ProjectCustomizer; |
77 |
import org.openide.DialogDescriptor; |
69 |
import org.openide.DialogDescriptor; |
78 |
import org.openide.DialogDisplayer; |
70 |
import org.openide.DialogDisplayer; |
79 |
import org.openide.NotifyDescriptor; |
71 |
import org.openide.NotifyDescriptor; |
Lines 154-161
Link Here
|
154 |
this.originalEncoding = Charset.defaultCharset().name(); |
146 |
this.originalEncoding = Charset.defaultCharset().name(); |
155 |
} |
147 |
} |
156 |
|
148 |
|
157 |
this.encoding.setModel(new EncodingModel(this.originalEncoding)); |
149 |
this.encoding.setModel(ProjectCustomizer.encodingModel(originalEncoding)); |
158 |
this.encoding.setRenderer(new EncodingRenderer()); |
150 |
this.encoding.setRenderer(ProjectCustomizer.encodingRenderer()); |
159 |
final String lafid = UIManager.getLookAndFeel().getID(); |
151 |
final String lafid = UIManager.getLookAndFeel().getID(); |
160 |
if (!"Aqua".equals(lafid)) { // NOI18N |
152 |
if (!"Aqua".equals(lafid)) { // NOI18N |
161 |
encoding.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE); // NOI18N |
153 |
encoding.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE); // NOI18N |
Lines 640-720
Link Here
|
640 |
private javax.swing.JLabel webInfLabel; |
632 |
private javax.swing.JLabel webInfLabel; |
641 |
private javax.swing.JTextField webInfTextField; |
633 |
private javax.swing.JTextField webInfTextField; |
642 |
// End of variables declaration//GEN-END:variables |
634 |
// End of variables declaration//GEN-END:variables |
643 |
|
|
|
644 |
private static class EncodingRenderer extends JLabel implements ListCellRenderer, UIResource { |
645 |
|
646 |
public EncodingRenderer() { |
647 |
setOpaque(true); |
648 |
} |
649 |
|
650 |
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
651 |
assert value instanceof Charset; |
652 |
setName("ComboBox.listRenderer"); // NOI18N |
653 |
setText(((Charset) value).displayName()); |
654 |
setIcon(null); |
655 |
if (isSelected) { |
656 |
setBackground(list.getSelectionBackground()); |
657 |
setForeground(list.getSelectionForeground()); |
658 |
} else { |
659 |
setBackground(list.getBackground()); |
660 |
setForeground(list.getForeground()); |
661 |
} |
662 |
return this; |
663 |
} |
664 |
|
665 |
@Override |
666 |
public String getName() { |
667 |
String name = super.getName(); |
668 |
return name == null ? "ComboBox.renderer" : name; // NOI18N |
669 |
} |
670 |
|
671 |
} |
672 |
|
673 |
private static class EncodingModel extends DefaultComboBoxModel { |
674 |
|
675 |
public EncodingModel(String originalEncoding) { |
676 |
Charset defEnc = null; |
677 |
for (Charset c : Charset.availableCharsets().values()) { |
678 |
if (c.name().equals(originalEncoding)) { |
679 |
defEnc = c; |
680 |
} |
681 |
addElement(c); |
682 |
} |
683 |
if (defEnc == null) { |
684 |
//Create artificial Charset to keep the original value |
685 |
//May happen when the project was set up on the platform |
686 |
//which supports more encodings |
687 |
try { |
688 |
defEnc = new UnknownCharset(originalEncoding); |
689 |
addElement(defEnc); |
690 |
} catch (java.nio.charset.IllegalCharsetNameException e) { |
691 |
//The source.encoding property is completely broken |
692 |
Logger.getLogger(this.getClass().getName()).info("IllegalCharsetName: " + originalEncoding); |
693 |
} |
694 |
} |
695 |
if (defEnc == null) { |
696 |
defEnc = Charset.defaultCharset(); |
697 |
} |
698 |
setSelectedItem(defEnc); |
699 |
} |
700 |
} |
701 |
|
702 |
private static class UnknownCharset extends Charset { |
703 |
|
704 |
UnknownCharset(String name) { |
705 |
super(name, new String[0]); |
706 |
} |
707 |
|
708 |
public boolean contains(Charset c) { |
709 |
throw new UnsupportedOperationException(); |
710 |
} |
711 |
|
712 |
public CharsetDecoder newDecoder() { |
713 |
throw new UnsupportedOperationException(); |
714 |
} |
715 |
|
716 |
public CharsetEncoder newEncoder() { |
717 |
throw new UnsupportedOperationException(); |
718 |
} |
719 |
} |
720 |
} |
635 |
} |