This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 160404
Collapse All | Expand All

(-)a/java.api.common/src/org/netbeans/modules/java/api/common/project/ui/Bundle.properties (+2 lines)
Lines 68-70 Link Here
68
LBL_Properties_Action=Properties
68
LBL_Properties_Action=Properties
69
# {0} - folder name
69
# {0} - folder name
70
JavaSourceNodeFactory.gensrc=Generated Sources ({0})
70
JavaSourceNodeFactory.gensrc=Generated Sources ({0})
71
UNSUPPORTED_ENCODING=Project {0} specifies an unknown character encoding {1}
72
CLOSE=Close
(-)a/java.api.common/src/org/netbeans/modules/java/api/common/project/ui/ProjectUISupport.java (+5 lines)
Lines 41-46 Link Here
41
41
42
package org.netbeans.modules.java.api.common.project.ui;
42
package org.netbeans.modules.java.api.common.project.ui;
43
43
44
import java.nio.charset.Charset;
44
import javax.swing.AbstractAction;
45
import javax.swing.AbstractAction;
45
import javax.swing.Icon;
46
import javax.swing.Icon;
46
import org.netbeans.api.project.Project;
47
import org.netbeans.api.project.Project;
Lines 108-111 Link Here
108
        return new JavaSourceNodeFactory.PreselectPropertiesAction(project, nodeName, panelName);
109
        return new JavaSourceNodeFactory.PreselectPropertiesAction(project, nodeName, panelName);
109
    }
110
    }
110
111
112
    public static Charset showUnsupportedEncodingDialog(String projectName, String unknownCharset) {
113
        return UnsupportedEncodingDialog.showDialog (projectName, unknownCharset);
114
    }
115
111
}
116
}
(-)00b61a6ecacf (+50 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8" ?>
2
3
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4
  <AuxValues>
5
    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
6
    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
7
    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
8
    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
9
    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
10
    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
11
    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
12
    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
13
    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
14
    <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,80,0,0,1,-113"/>
15
  </AuxValues>
16
17
  <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
18
  <SubComponents>
19
    <Component class="javax.swing.JLabel" name="instructions">
20
      <Properties>
21
        <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
22
          <ComponentRef name="charsetComboBox"/>
23
        </Property>
24
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
25
          <ResourceString bundle="org/netbeans/modules/javacard/project/ui/Bundle.properties" key="UnsupportedEncodingDialog.instructions.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;, {arguments})"/>
26
        </Property>
27
      </Properties>
28
      <Constraints>
29
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
30
          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="12" insetsBottom="0" insetsRight="12" anchor="18" weightX="0.5" weightY="0.0"/>
31
        </Constraint>
32
      </Constraints>
33
    </Component>
34
    <Component class="javax.swing.JComboBox" name="charsetComboBox">
35
      <Properties>
36
        <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
37
          <StringArray count="1">
38
            <StringItem index="0" value="[Loading all character sets]"/>
39
          </StringArray>
40
        </Property>
41
        <Property name="enabled" type="boolean" value="false"/>
42
      </Properties>
43
      <Constraints>
44
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
45
          <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="5" insetsLeft="12" insetsBottom="12" insetsRight="12" anchor="18" weightX="0.5" weightY="0.0"/>
46
        </Constraint>
47
      </Constraints>
48
    </Component>
49
  </SubComponents>
50
</Form>
(-)00b61a6ecacf (+162 lines)
Added Link Here
1
package org.netbeans.modules.java.api.common.project.ui;
2
3
import java.awt.Cursor;
4
import java.awt.EventQueue;
5
import java.nio.charset.Charset;
6
import java.text.MessageFormat;
7
import java.util.Map;
8
import java.util.SortedMap;
9
import javax.swing.DefaultComboBoxModel;
10
import org.netbeans.api.queries.FileEncodingQuery;
11
import org.openide.DialogDescriptor;
12
import org.openide.DialogDisplayer;
13
import org.openide.util.HelpCtx;
14
import org.openide.util.NbBundle;
15
import org.openide.util.RequestProcessor;
16
17
/**
18
 *
19
 * @author Tim Boudreau
20
 */
21
final class UnsupportedEncodingDialog extends javax.swing.JPanel implements Runnable {
22
23
    private final DefaultComboBoxModel mdl = new DefaultComboBoxModel();
24
    private DialogDescriptor descriptor;
25
26
    /** Creates new form UnsupportedEncodingDialog */
27
    public UnsupportedEncodingDialog() {
28
        initComponents();
29
        Cursor cursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
30
        setCursor(cursor);
31
        instructions.setCursor(cursor);
32
        charsetComboBox.setCursor(cursor);
33
    }
34
35
    void setDialogDescriptor(DialogDescriptor d) {
36
        this.descriptor = d;
37
    }
38
39
    public static Charset showDialog(String projectName, String requestedCharset) {
40
        UnsupportedEncodingDialog pnl = new UnsupportedEncodingDialog();
41
        String s = pnl.instructions.getText();
42
        MessageFormat.format(s, new Object[] { requestedCharset });
43
        String title = NbBundle.getMessage(UnsupportedEncodingDialog.class,
44
                "UNSUPPORTED_ENCODING", requestedCharset, projectName); //NO18N
45
        String close = NbBundle.getMessage(UnsupportedEncodingDialog.class,
46
                "CLOSE"); //NOI18N
47
        DialogDescriptor des = new DialogDescriptor (pnl,
48
                title, true, new Object[] { close },
49
                close, DialogDescriptor.DEFAULT_ALIGN,
50
                HelpCtx.DEFAULT_HELP, null); //NOI18N
51
        pnl.setDialogDescriptor(des);
52
        DialogDisplayer.getDefault().notify(des);
53
        return pnl.getSelectedCharset();
54
    }
55
56
    private Charset getSelectedCharset() {
57
        Object o = charsetComboBox.getSelectedItem();
58
        if (o instanceof Entry) {
59
            return ((Entry) o).charset;
60
        } else {
61
            //should never happen
62
            return FileEncodingQuery.getDefaultEncoding();
63
        }
64
    }
65
66
    /** This method is called from within the constructor to
67
     * initialize the form.
68
     * WARNING: Do NOT modify this code. The content of this method is
69
     * always regenerated by the Form Editor.
70
     */
71
    @SuppressWarnings("unchecked")
72
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
73
    private void initComponents() {
74
        java.awt.GridBagConstraints gridBagConstraints;
75
76
        instructions = new javax.swing.JLabel();
77
        charsetComboBox = new javax.swing.JComboBox();
78
79
        setLayout(new java.awt.GridBagLayout());
80
81
        instructions.setLabelFor(charsetComboBox);
82
        instructions.setText(org.openide.util.NbBundle.getMessage(UnsupportedEncodingDialog.class, "UnsupportedEncodingDialog.instructions.text", new Object[] {})); // NOI18N
83
        gridBagConstraints = new java.awt.GridBagConstraints();
84
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
85
        gridBagConstraints.weightx = 0.5;
86
        gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 12);
87
        add(instructions, gridBagConstraints);
88
89
        charsetComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "[Loading all character sets]" }));
90
        charsetComboBox.setEnabled(false);
91
        gridBagConstraints = new java.awt.GridBagConstraints();
92
        gridBagConstraints.gridx = 0;
93
        gridBagConstraints.gridy = 1;
94
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
95
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
96
        gridBagConstraints.weightx = 0.5;
97
        gridBagConstraints.insets = new java.awt.Insets(5, 12, 12, 12);
98
        add(charsetComboBox, gridBagConstraints);
99
    }// </editor-fold>//GEN-END:initComponents
100
101
    @Override
102
    public void addNotify() {
103
        super.addNotify();
104
        RequestProcessor.getDefault().post(this);
105
    }
106
    
107
    // Variables declaration - do not modify//GEN-BEGIN:variables
108
    private javax.swing.JComboBox charsetComboBox;
109
    private javax.swing.JLabel instructions;
110
    // End of variables declaration//GEN-END:variables
111
112
    @Override
113
    public void run() {
114
        if (!EventQueue.isDispatchThread()) {
115
            try {
116
                Entry use = null;
117
                Charset def = FileEncodingQuery.getDefaultEncoding();
118
                if (!EventQueue.isDispatchThread()) {
119
                    SortedMap<String, Charset> m = Charset.availableCharsets();
120
                    for (Map.Entry<String, Charset> e : m.entrySet()) {
121
                        Entry entry = new Entry(e.getKey(), e.getValue());
122
                        if (def.equals(e.getValue())) {
123
                            use = entry;
124
                        }
125
                        mdl.addElement(entry);
126
                    }
127
                }
128
                if (use != null) {
129
                    mdl.setSelectedItem(use);
130
                }
131
            } finally {
132
                EventQueue.invokeLater(this);
133
            }
134
        } else {
135
            charsetComboBox.setModel(mdl);
136
            charsetComboBox.setEnabled(true);
137
            Cursor cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
138
            setCursor(cursor);
139
            instructions.setCursor(cursor);
140
            charsetComboBox.setCursor(cursor);
141
            if (descriptor != null) {
142
                descriptor.setValid(false);
143
            }
144
        }
145
    }
146
147
    private static final class Entry {
148
149
        String nm;
150
        Charset charset;
151
152
        public Entry(String nm, Charset charset) {
153
            this.nm = nm;
154
            this.charset = charset;
155
        }
156
157
        @Override
158
        public String toString() {
159
            return charset.displayName();
160
        }
161
    }
162
}
(-)a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java (-13 / +27 lines)
Lines 82-87 Link Here
82
import org.netbeans.modules.java.api.common.classpath.ClassPathModifier;
82
import org.netbeans.modules.java.api.common.classpath.ClassPathModifier;
83
import org.netbeans.modules.java.api.common.classpath.ClassPathProviderImpl;
83
import org.netbeans.modules.java.api.common.classpath.ClassPathProviderImpl;
84
import org.netbeans.modules.java.api.common.project.ProjectProperties;
84
import org.netbeans.modules.java.api.common.project.ProjectProperties;
85
import org.netbeans.modules.java.api.common.project.ui.ProjectUISupport;
85
import org.netbeans.modules.java.api.common.queries.QuerySupport;
86
import org.netbeans.modules.java.api.common.queries.QuerySupport;
86
import org.netbeans.modules.java.j2seproject.api.J2SEPropertyEvaluator;
87
import org.netbeans.modules.java.j2seproject.api.J2SEPropertyEvaluator;
87
import org.netbeans.modules.java.j2seproject.ui.J2SELogicalViewProvider;
88
import org.netbeans.modules.java.j2seproject.ui.J2SELogicalViewProvider;
Lines 540-545 Link Here
540
            //the updater is active only on the opened projects
541
            //the updater is active only on the opened projects
541
	    mainClassUpdater = new MainClassUpdater (J2SEProject.this, eval, updateHelper,
542
	    mainClassUpdater = new MainClassUpdater (J2SEProject.this, eval, updateHelper,
542
                    cpProvider.getProjectClassPaths(ClassPath.SOURCE)[0], J2SEProjectProperties.MAIN_CLASS);
543
                    cpProvider.getProjectClassPaths(ClassPath.SOURCE)[0], J2SEProjectProperties.MAIN_CLASS);
544
            String prop = eval.getProperty(J2SEProjectProperties.SOURCE_ENCODING);
545
            Charset c = null;
546
            boolean updated = false;
547
            if (prop != null) {
548
                try {
549
                    c = Charset.forName(prop);
550
                } catch (IllegalCharsetNameException e) {
551
                    //Broken property, log & ignore
552
                    Logger LOG = Logger.getLogger(J2SEProject.class.getName());
553
                    LOG.warning("Illegal charset: " + prop + " in project: " + FileUtil.getFileDisplayName(getProjectDirectory())); //NOI18N
554
                    } catch (UnsupportedCharsetException e) {
555
                    //todo: Needs UI notification like broken references.
556
                    Logger LOG = Logger.getLogger(J2SEProject.class.getName());
557
                    LOG.warning("Unsupported charset: " + prop + " in project: " + FileUtil.getFileDisplayName(getProjectDirectory())); //NOI18N
558
                    }
559
                if (c == null) {
560
                    String name = getLookup().lookup(ProjectInformation.class).getDisplayName();
561
                    c = ProjectUISupport.showUnsupportedEncodingDialog(name, prop);
562
                    updated = true;
563
                }
564
            }
565
            final Charset updatedCharset = updated ? c : null;
543
566
544
            // Make it easier to run headless builds on the same machine at least.
567
            // Make it easier to run headless builds on the same machine at least.
545
            try {
568
            try {
Lines 586-591 Link Here
586
609
587
                                updateHelper.putProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH, ep);
610
                                updateHelper.putProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH, ep);
588
                                ep = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
611
                                ep = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
612
                                if (updatedCharset != null) {
613
                                    ep.setProperty(J2SEProjectProperties.SOURCE_ENCODING,
614
                                            updatedCharset.name());
615
                                }
589
                                if (!ep.containsKey(ProjectProperties.INCLUDES)) {
616
                                if (!ep.containsKey(ProjectProperties.INCLUDES)) {
590
                                    ep.setProperty(ProjectProperties.INCLUDES, "**"); // NOI18N
617
                                    ep.setProperty(ProjectProperties.INCLUDES, "**"); // NOI18N
591
                                }
618
                                }
Lines 620-638 Link Here
620
            if (physicalViewProvider != null &&  physicalViewProvider.hasBrokenLinks()) {   
647
            if (physicalViewProvider != null &&  physicalViewProvider.hasBrokenLinks()) {   
621
                BrokenReferencesSupport.showAlert();
648
                BrokenReferencesSupport.showAlert();
622
            }
649
            }
623
            String prop = eval.getProperty(J2SEProjectProperties.SOURCE_ENCODING);
624
            if (prop != null) {
625
                try {
626
                    Charset c = Charset.forName(prop);
627
                } catch (IllegalCharsetNameException e) {
628
                    //Broken property, log & ignore
629
                    LOG.warning("Illegal charset: " + prop+ " in project: " + FileUtil.getFileDisplayName(getProjectDirectory())); //NOI18N
630
                }
631
                catch (UnsupportedCharsetException e) {
632
                    //todo: Needs UI notification like broken references.
633
                    LOG.warning("Unsupported charset: " + prop+ " in project: " + FileUtil.getFileDisplayName(getProjectDirectory())); //NOI18N
634
                }
635
            }
636
        }
650
        }
637
        
651
        
638
        protected void projectClosed() {
652
        protected void projectClosed() {

Return to bug 160404