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 226773
Collapse All | Expand All

(-)java.j2seproject/nbproject/project.properties (-1 / +1 lines)
Lines 42-48 Link Here
42
42
43
javac.compilerargs=-Xlint -Xlint:-serial
43
javac.compilerargs=-Xlint -Xlint:-serial
44
javac.source=1.6
44
javac.source=1.6
45
spec.version.base=1.58.0
45
spec.version.base=1.59.0
46
46
47
javadoc.arch=${basedir}/arch.xml
47
javadoc.arch=${basedir}/arch.xml
48
javadoc.apichanges=${basedir}/apichanges.xml
48
javadoc.apichanges=${basedir}/apichanges.xml
(-)java.j2seproject/nbproject/project.xml (-1 / +1 lines)
Lines 185-191 Link Here
185
                    <compile-dependency/>
185
                    <compile-dependency/>
186
                    <run-dependency>
186
                    <run-dependency>
187
                        <release-version>1</release-version>
187
                        <release-version>1</release-version>
188
                        <specification-version>1.33</specification-version>
188
                        <specification-version>1.53</specification-version>
189
                    </run-dependency>
189
                    </run-dependency>
190
                </dependency>
190
                </dependency>
191
                <dependency>
191
                <dependency>
(-)java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/J2SECompositePanelProvider.java (-2 / +93 lines)
Lines 47-56 Link Here
47
import java.util.ResourceBundle;
47
import java.util.ResourceBundle;
48
import javax.swing.JComponent;
48
import javax.swing.JComponent;
49
import javax.swing.JPanel;
49
import javax.swing.JPanel;
50
import javax.swing.text.BadLocationException;
50
import org.netbeans.api.project.Project;
51
import org.netbeans.api.project.Project;
51
import org.netbeans.modules.java.j2seproject.J2SEProject;
52
import org.netbeans.modules.java.j2seproject.J2SEProject;
52
import org.netbeans.modules.java.j2seproject.J2SEProjectUtil;
53
import org.netbeans.modules.java.j2seproject.J2SEProjectUtil;
54
import org.netbeans.spi.project.support.ant.ui.CustomizerUtilities;
53
import org.netbeans.spi.project.ui.support.ProjectCustomizer;
55
import org.netbeans.spi.project.ui.support.ProjectCustomizer;
56
import org.openide.filesystems.FileObject;
57
import org.openide.util.Exceptions;
54
import org.openide.util.Lookup;
58
import org.openide.util.Lookup;
55
import org.openide.util.NbBundle;
59
import org.openide.util.NbBundle;
56
60
Lines 68-73 Link Here
68
    private static final String JAVADOC = "Javadoc";
72
    private static final String JAVADOC = "Javadoc";
69
    public static final String RUN = "Run";
73
    public static final String RUN = "Run";
70
    private static final String APPLICATION = "Application";
74
    private static final String APPLICATION = "Application";
75
    private static final String LICENSE = "License";
71
76
72
    private String name;
77
    private String name;
73
    
78
    
Lines 75-80 Link Here
75
        this.name = name;
80
        this.name = name;
76
    }
81
    }
77
82
83
    @Override
78
    public ProjectCustomizer.Category createCategory(Lookup context) {
84
    public ProjectCustomizer.Category createCategory(Lookup context) {
79
        ResourceBundle bundle = NbBundle.getBundle( CustomizerProviderImpl.class );
85
        ResourceBundle bundle = NbBundle.getBundle( CustomizerProviderImpl.class );
80
        ProjectCustomizer.Category toReturn = null;
86
        ProjectCustomizer.Category toReturn = null;
Lines 103-108 Link Here
103
                    JAVADOC,
109
                    JAVADOC,
104
                    bundle.getString( "LBL_Config_Javadoc" ), // NOI18N
110
                    bundle.getString( "LBL_Config_Javadoc" ), // NOI18N
105
                    null);
111
                    null);
112
        } else if (LICENSE.equals(name)) {
113
            toReturn = ProjectCustomizer.Category.create(
114
                    LICENSE,
115
                    "License Headers", // NOI18N
116
                    null);
106
        } else if (RUN.equals(name)) {
117
        } else if (RUN.equals(name)) {
107
            boolean fxOverride = false;
118
            boolean fxOverride = false;
108
            final Project project = context.lookup(Project.class);
119
            final Project project = context.lookup(Project.class);
Lines 123-131 Link Here
123
        return toReturn;
134
        return toReturn;
124
    }
135
    }
125
136
126
    public JComponent createComponent(ProjectCustomizer.Category category, Lookup context) {
137
    @Override
138
    public JComponent createComponent(ProjectCustomizer.Category category, final Lookup context) {
127
        String nm = category.getName();
139
        String nm = category.getName();
128
        J2SEProjectProperties uiProps = context.lookup(J2SEProjectProperties.class);
140
        final J2SEProjectProperties uiProps = context.lookup(J2SEProjectProperties.class);
129
        if (SOURCES.equals(nm)) {
141
        if (SOURCES.equals(nm)) {
130
            return new CustomizerSources(uiProps);
142
            return new CustomizerSources(uiProps);
131
        } else if (LIBRARIES.equals(nm)) {
143
        } else if (LIBRARIES.equals(nm)) {
Lines 142-148 Link Here
142
            return new CustomizerRun(uiProps);
154
            return new CustomizerRun(uiProps);
143
        } else if (APPLICATION.equals(nm)) {
155
        } else if (APPLICATION.equals(nm)) {
144
            return new CustomizerApplication(uiProps);
156
            return new CustomizerApplication(uiProps);
157
        } else if (LICENSE.equals(nm)) {
158
            CustomizerUtilities.LicensePanelContentHandler handler =
159
                    new CustomizerUtilities.LicensePanelContentHandler() {
160
                @Override
161
                public String getProjectLicenseLocation() {
162
                    try {
163
                        String path = uiProps.LICENSE_PATH_DOC.getText(0, uiProps.LICENSE_PATH_DOC.getLength());
164
                        if (path != null && path.trim().isEmpty()) {
165
                            path = null;
145
        }
166
        }
167
                        return path;
168
                    } catch (BadLocationException ex) {
169
                        Exceptions.printStackTrace(ex);
170
                    }
171
                    return null;
172
                }
173
174
                @Override
175
                public String getGlobalLicenseName() {
176
                    try {
177
                        String name = uiProps.LICENSE_NAME_DOC.getText(0, uiProps.LICENSE_NAME_DOC.getLength());
178
                        if (name != null && name.trim().isEmpty()) {
179
                            name = null;
180
                        }
181
                        return name;
182
                    } catch (BadLocationException ex) {
183
                        Exceptions.printStackTrace(ex);
184
                    }
185
                    return null;
186
                }
187
188
                @Override
189
                public FileObject resolveProjectLocation(String path) {
190
                    final J2SEProject project = context.lookup(J2SEProject.class);
191
                    String evaluated = uiProps.getEvaluator().evaluate(path);
192
                    return project.getAntProjectHelper().resolveFileObject(evaluated);
193
                }
194
195
                @Override
196
                public void setProjectLicenseLocation(String newLocation) {
197
                    try {
198
                        uiProps.LICENSE_PATH_DOC.remove(0, uiProps.LICENSE_PATH_DOC.getLength());
199
                        uiProps.LICENSE_PATH_DOC.insertString(0, newLocation, null);
200
                    } catch (BadLocationException ex) {
201
                        Exceptions.printStackTrace(ex);
202
                    }
203
                }
204
205
                @Override
206
                public void setGlobalLicenseName(String newName) {
207
                    try {
208
                        uiProps.LICENSE_NAME_DOC.remove(0, uiProps.LICENSE_NAME_DOC.getLength());
209
                        uiProps.LICENSE_NAME_DOC.insertString(0, newName, null);
210
                    } catch (BadLocationException ex) {
211
                        Exceptions.printStackTrace(ex);
212
                    }
213
                }
214
215
                @Override
216
                public String getDefaultProjectLicenseLocation() {
217
                    return "./nbproject/licenseheader.txt";
218
                }
219
220
                @Override
221
                public void setProjectLicenseContent(String text) {
222
                    uiProps.CHANGED_LICENSE_PATH_CONTENT = text;
223
                }
224
            };
225
            
226
            return CustomizerUtilities.createLicenseHeaderCustomizerPanel(category, handler);
227
        }
146
        return new JPanel();
228
        return new JPanel();
147
229
148
    }
230
    }
Lines 207-210 Link Here
207
    public static J2SECompositePanelProvider createApplication() {
289
    public static J2SECompositePanelProvider createApplication() {
208
        return new J2SECompositePanelProvider(APPLICATION);
290
        return new J2SECompositePanelProvider(APPLICATION);
209
    }
291
    }
292
    
293
    @ProjectCustomizer.CompositeCategoryProvider.Registration(
294
        projectType="org-netbeans-modules-java-j2seproject",
295
        position=600
296
    )
297
    public static J2SECompositePanelProvider createLicense() {
298
        return new J2SECompositePanelProvider(LICENSE);
210
}
299
}
300
    
301
}
(-)java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/J2SEProjectProperties.java (+52 lines)
Lines 45-52 Link Here
45
package org.netbeans.modules.java.j2seproject.ui.customizer;
45
package org.netbeans.modules.java.j2seproject.ui.customizer;
46
46
47
import java.awt.event.ActionListener;
47
import java.awt.event.ActionListener;
48
import java.io.ByteArrayInputStream;
48
import java.io.File;
49
import java.io.File;
49
import java.io.IOException;
50
import java.io.IOException;
51
import java.io.OutputStream;
52
import java.io.StringReader;
50
import java.net.MalformedURLException;
53
import java.net.MalformedURLException;
51
import java.net.URI;
54
import java.net.URI;
52
import java.net.URISyntaxException;
55
import java.net.URISyntaxException;
Lines 176-181 Link Here
176
    public static final String APPLICATION_HOMEPAGE ="application.homepage"; // NOI18N
179
    public static final String APPLICATION_HOMEPAGE ="application.homepage"; // NOI18N
177
    public static final String APPLICATION_SPLASH ="application.splash"; // NOI18N
180
    public static final String APPLICATION_SPLASH ="application.splash"; // NOI18N
178
    
181
    
182
    public static final String LICENSE_NAME = "project.license";
183
    public static final String LICENSE_PATH = "project.licensePath";
184
    
179
    // Properties stored in the PRIVATE.PROPERTIES
185
    // Properties stored in the PRIVATE.PROPERTIES
180
    public static final String JAVADOC_PREVIEW="javadoc.preview"; // NOI18N
186
    public static final String JAVADOC_PREVIEW="javadoc.preview"; // NOI18N
181
    // Main build.xml location
187
    // Main build.xml location
Lines 254-259 Link Here
254
    Document APPLICATION_HOMEPAGE_DOC;
260
    Document APPLICATION_HOMEPAGE_DOC;
255
    Document APPLICATION_SPLASH_DOC;
261
    Document APPLICATION_SPLASH_DOC;
256
    
262
    
263
    //customizer license headers
264
    Document LICENSE_PATH_DOC;
265
    Document LICENSE_NAME_DOC;
266
    String CHANGED_LICENSE_PATH_CONTENT;
267
    
257
    // CustomizerRunTest
268
    // CustomizerRunTest
258
269
259
    // Private fields ----------------------------------------------------------    
270
    // Private fields ----------------------------------------------------------    
Lines 292-297 Link Here
292
        init(); // Load known properties        
303
        init(); // Load known properties        
293
    }
304
    }
294
305
306
307
    public PropertyEvaluator getEvaluator() {
308
        return evaluator;
309
    }
310
    
311
295
    /** Initializes the visual models 
312
    /** Initializes the visual models 
296
     */
313
     */
297
    private void init() {
314
    private void init() {
Lines 428-433 Link Here
428
        APPLICATION_HOMEPAGE_DOC = projectGroup.createStringDocument(evaluator, APPLICATION_HOMEPAGE);
445
        APPLICATION_HOMEPAGE_DOC = projectGroup.createStringDocument(evaluator, APPLICATION_HOMEPAGE);
429
        APPLICATION_SPLASH_DOC = projectGroup.createStringDocument(evaluator, APPLICATION_SPLASH);
446
        APPLICATION_SPLASH_DOC = projectGroup.createStringDocument(evaluator, APPLICATION_SPLASH);
430
        
447
        
448
        LICENSE_NAME_DOC = projectGroup.createStringDocument(evaluator, LICENSE_NAME);
449
        LICENSE_PATH_DOC = projectGroup.createStringDocument(evaluator, LICENSE_PATH);
450
        //oh well we want unresolved value, force it.
451
        String p = projectProperties.get(LICENSE_PATH);
452
        try {
453
            //we want to show the unresolved value..
454
            LICENSE_PATH_DOC.remove(0, LICENSE_PATH_DOC.getLength());
455
            LICENSE_PATH_DOC.insertString(0, p, null);
456
        } catch (BadLocationException ex) {
457
            Exceptions.printStackTrace(ex);
458
        }
459
        
460
        CHANGED_LICENSE_PATH_CONTENT = null;
461
        
431
        if(!isFXProject()) {
462
        if(!isFXProject()) {
432
            // CustomizerRun
463
            // CustomizerRun
433
            RUN_CONFIGS = readRunConfigs();
464
            RUN_CONFIGS = readRunConfigs();
Lines 439-444 Link Here
439
    public void save() {
470
    public void save() {
440
        try {                        
471
        try {                        
441
            saveLibrariesLocation();
472
            saveLibrariesLocation();
473
            if (CHANGED_LICENSE_PATH_CONTENT != null) {
474
                try {
475
                    String path = LICENSE_PATH_DOC.getText(0, LICENSE_PATH_DOC.getLength());
476
                    String evaluated = getEvaluator().evaluate(path);
477
                    File file = project.getAntProjectHelper().resolveFile(evaluated);
478
                    FileObject fo;
479
                    if (!file.exists()) {
480
                        fo = FileUtil.createData(file);
481
                    } else {
482
                        fo = FileUtil.toFileObject(file);
483
                    }
484
                    OutputStream out = fo.getOutputStream();
485
                    try {
486
                        FileUtil.copy(new ByteArrayInputStream(CHANGED_LICENSE_PATH_CONTENT.getBytes()), out);
487
                    } finally {
488
                        out.close();
489
                    }
490
                } catch (BadLocationException ex) {
491
                    Exceptions.printStackTrace(ex);
492
                }
493
            }
442
            // Store properties
494
            // Store properties
443
            ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() {
495
            ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() {
444
                public Void run() throws IOException {
496
                public Void run() throws IOException {

Return to bug 226773