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

(-)a/maven.j2ee/src/org/netbeans/modules/maven/j2ee/MavenJavaEEConstants.java (+9 lines)
Lines 69-74 Link Here
69
     * @since NetBeans 7.0
69
     * @since NetBeans 7.0
70
     */
70
     */
71
    public static final String HINT_DEPLOY_ON_SAVE = "netbeans.deploy.on.save"; //NOI18N
71
    public static final String HINT_DEPLOY_ON_SAVE = "netbeans.deploy.on.save"; //NOI18N
72
73
    /**
74
     * Optional property, if static resources should be copy to the target directory on save.
75
     * <ul>
76
     * <li>true  - copy static resources on save is enabled - default value</li>
77
     * <li>false - copy static resources on save is disabled</li>
78
     * </ul>
79
     */
80
    public static final String HINT_COPY_STATIC_RESOURCES_ON_SAVE = "netbeans.copy.static.resources.on.save"; //NOI18N
72
    
81
    
73
    /**
82
    /**
74
     * when present, will deploy the web/ejb/ear project to an app server
83
     * when present, will deploy the web/ejb/ear project to an app server
(-)a/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ui/customizer/impl/Bundle.properties (+1 lines)
Lines 50-52 Link Here
50
CustomizerRunWeb.dosDescription.text=<html>If selected, files are compiled and deployed when you save them.<br>This option saves you time when you run or debug your application in the IDE.</html>
50
CustomizerRunWeb.dosDescription.text=<html>If selected, files are compiled and deployed when you save them.<br>This option saves you time when you run or debug your application in the IDE.</html>
51
CustomizerRunWeb.dosDescriptionIfDisabled.text=<html>If selected, files are compiled and deployed when you save them.<br>This option saves you time when you run or debug your application in the IDE.<br>NOTE: If you want to enable Deploy on Save feature you will need to change Compile on Save first (you can do that in Build/Compile project properties)</html>
51
CustomizerRunWeb.dosDescriptionIfDisabled.text=<html>If selected, files are compiled and deployed when you save them.<br>This option saves you time when you run or debug your application in the IDE.<br>NOTE: If you want to enable Deploy on Save feature you will need to change Compile on Save first (you can do that in Build/Compile project properties)</html>
52
CustomizerRunWeb.browserLabel.text=B&rowser:
52
CustomizerRunWeb.browserLabel.text=B&rowser:
53
CustomizerRunWeb.jCheckBoxCopyStaticResources.text=Compile Static Resources on Save
(-)a/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ui/customizer/impl/CustomizerRunWeb.form (-3 / +15 lines)
Lines 16-22 Link Here
16
  <Layout>
16
  <Layout>
17
    <DimensionLayout dim="0">
17
    <DimensionLayout dim="0">
18
      <Group type="103" groupAlignment="0" attributes="0">
18
      <Group type="103" groupAlignment="0" attributes="0">
19
          <Group type="102" attributes="0">
19
          <Group type="102" alignment="0" attributes="0">
20
              <EmptySpace max="-2" attributes="0"/>
20
              <EmptySpace max="-2" attributes="0"/>
21
              <Group type="103" groupAlignment="0" attributes="0">
21
              <Group type="103" groupAlignment="0" attributes="0">
22
                  <Group type="102" attributes="0">
22
                  <Group type="102" attributes="0">
Lines 45-52 Link Here
45
                      <Component id="jCheckBoxDeployOnSave" min="-2" max="-2" attributes="0"/>
45
                      <Component id="jCheckBoxDeployOnSave" min="-2" max="-2" attributes="0"/>
46
                      <EmptySpace max="32767" attributes="0"/>
46
                      <EmptySpace max="32767" attributes="0"/>
47
                  </Group>
47
                  </Group>
48
                  <Group type="102" alignment="0" attributes="0">
48
                  <Group type="102" attributes="0">
49
                      <Component id="showBrowserCheckBox" min="-2" max="-2" attributes="0"/>
49
                      <Group type="103" groupAlignment="0" max="-2" attributes="0">
50
                          <Component id="showBrowserCheckBox" max="32767" attributes="0"/>
51
                          <Component id="jCheckBoxCopyStaticResources" max="32767" attributes="0"/>
52
                      </Group>
50
                      <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
53
                      <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
51
                  </Group>
54
                  </Group>
52
              </Group>
55
              </Group>
Lines 86-91 Link Here
86
              <EmptySpace type="separate" max="-2" attributes="0"/>
89
              <EmptySpace type="separate" max="-2" attributes="0"/>
87
              <Component id="showBrowserCheckBox" min="-2" max="-2" attributes="0"/>
90
              <Component id="showBrowserCheckBox" min="-2" max="-2" attributes="0"/>
88
              <EmptySpace type="unrelated" max="-2" attributes="0"/>
91
              <EmptySpace type="unrelated" max="-2" attributes="0"/>
92
              <Component id="jCheckBoxCopyStaticResources" min="-2" max="-2" attributes="0"/>
93
              <EmptySpace type="unrelated" max="-2" attributes="0"/>
89
              <Component id="jCheckBoxDeployOnSave" min="-2" max="-2" attributes="0"/>
94
              <Component id="jCheckBoxDeployOnSave" min="-2" max="-2" attributes="0"/>
90
              <EmptySpace max="-2" attributes="0"/>
95
              <EmptySpace max="-2" attributes="0"/>
91
              <Component id="dosDescription" min="-2" max="-2" attributes="0"/>
96
              <Component id="dosDescription" min="-2" max="-2" attributes="0"/>
Lines 225-229 Link Here
225
        <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="createBrowserComboBox()"/>
230
        <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="createBrowserComboBox()"/>
226
      </AuxValues>
231
      </AuxValues>
227
    </Component>
232
    </Component>
233
    <Component class="javax.swing.JCheckBox" name="jCheckBoxCopyStaticResources">
234
      <Properties>
235
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
236
          <ResourceString bundle="org/netbeans/modules/maven/j2ee/ui/customizer/impl/Bundle.properties" key="CustomizerRunWeb.jCheckBoxCopyStaticResources.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
237
        </Property>
238
      </Properties>
239
    </Component>
228
  </SubComponents>
240
  </SubComponents>
229
</Form>
241
</Form>
(-)a/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ui/customizer/impl/CustomizerRunWeb.java (-3 / +13 lines)
Lines 58-65 Link Here
58
import org.netbeans.modules.maven.j2ee.MavenJavaEEConstants;
58
import org.netbeans.modules.maven.j2ee.MavenJavaEEConstants;
59
import org.netbeans.modules.maven.j2ee.utils.Server;
59
import org.netbeans.modules.maven.j2ee.utils.Server;
60
import org.netbeans.modules.maven.j2ee.ui.customizer.BaseRunCustomizer;
60
import org.netbeans.modules.maven.j2ee.ui.customizer.BaseRunCustomizer;
61
import org.netbeans.modules.maven.j2ee.ui.util.CopyStaticResourcesOnSaveCheckBoxUpdater;
61
import org.netbeans.modules.maven.j2ee.utils.LoggingUtils;
62
import org.netbeans.modules.maven.j2ee.utils.LoggingUtils;
62
import org.netbeans.modules.maven.j2ee.utils.MavenProjectSupport;
63
import org.netbeans.modules.maven.j2ee.web.WebModuleImpl;
63
import org.netbeans.modules.maven.j2ee.web.WebModuleImpl;
64
import org.netbeans.modules.maven.j2ee.web.WebModuleProviderImpl;
64
import org.netbeans.modules.maven.j2ee.web.WebModuleProviderImpl;
65
import org.netbeans.modules.web.api.webmodule.WebModule;
65
import org.netbeans.modules.web.api.webmodule.WebModule;
Lines 108-113 Link Here
108
        initServerModel(serverCBox, serverLabel, J2eeModule.Type.WAR);
108
        initServerModel(serverCBox, serverLabel, J2eeModule.Type.WAR);
109
        initVersionModel(javaeeVersionCBox, javaeeVersionLabel, J2eeModule.Type.WAR);
109
        initVersionModel(javaeeVersionCBox, javaeeVersionLabel, J2eeModule.Type.WAR);
110
        initDeployOnSave(jCheckBoxDeployOnSave, dosDescription);
110
        initDeployOnSave(jCheckBoxDeployOnSave, dosDescription);
111
112
        CopyStaticResourcesOnSaveCheckBoxUpdater.create(project, jCheckBoxCopyStaticResources);
111
    }
113
    }
112
    
114
    
113
    @Override
115
    @Override
Lines 133-139 Link Here
133
    public void applyChanges() {
135
    public void applyChanges() {
134
        changeServer(serverCBox);
136
        changeServer(serverCBox);
135
        changeContextPath();
137
        changeContextPath();
136
        
138
137
        JavaEEProjectSettings.setBrowserID(project, browserModel.getSelectedBrowserId());
139
        JavaEEProjectSettings.setBrowserID(project, browserModel.getSelectedBrowserId());
138
    }
140
    }
139
    
141
    
Lines 277-282 Link Here
277
        javaeeVersionCBox = new javax.swing.JComboBox();
279
        javaeeVersionCBox = new javax.swing.JComboBox();
278
        browserLabel = new javax.swing.JLabel();
280
        browserLabel = new javax.swing.JLabel();
279
        browserCBox = createBrowserComboBox();
281
        browserCBox = createBrowserComboBox();
282
        jCheckBoxCopyStaticResources = new javax.swing.JCheckBox();
280
283
281
        serverLabel.setLabelFor(serverCBox);
284
        serverLabel.setLabelFor(serverCBox);
282
        org.openide.awt.Mnemonics.setLocalizedText(serverLabel, org.openide.util.NbBundle.getMessage(CustomizerRunWeb.class, "LBL_Server")); // NOI18N
285
        org.openide.awt.Mnemonics.setLocalizedText(serverLabel, org.openide.util.NbBundle.getMessage(CustomizerRunWeb.class, "LBL_Server")); // NOI18N
Lines 312-317 Link Here
312
315
313
        org.openide.awt.Mnemonics.setLocalizedText(browserLabel, org.openide.util.NbBundle.getMessage(CustomizerRunWeb.class, "CustomizerRunWeb.browserLabel.text")); // NOI18N
316
        org.openide.awt.Mnemonics.setLocalizedText(browserLabel, org.openide.util.NbBundle.getMessage(CustomizerRunWeb.class, "CustomizerRunWeb.browserLabel.text")); // NOI18N
314
317
318
        org.openide.awt.Mnemonics.setLocalizedText(jCheckBoxCopyStaticResources, org.openide.util.NbBundle.getMessage(CustomizerRunWeb.class, "CustomizerRunWeb.jCheckBoxCopyStaticResources.text")); // NOI18N
319
315
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
320
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
316
        this.setLayout(layout);
321
        this.setLayout(layout);
317
        layout.setHorizontalGroup(
322
        layout.setHorizontalGroup(
Lines 341-347 Link Here
341
                        .addComponent(jCheckBoxDeployOnSave)
346
                        .addComponent(jCheckBoxDeployOnSave)
342
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
347
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
343
                    .addGroup(layout.createSequentialGroup()
348
                    .addGroup(layout.createSequentialGroup()
344
                        .addComponent(showBrowserCheckBox)
349
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
350
                            .addComponent(showBrowserCheckBox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
351
                            .addComponent(jCheckBoxCopyStaticResources, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
345
                        .addGap(0, 0, Short.MAX_VALUE))))
352
                        .addGap(0, 0, Short.MAX_VALUE))))
346
        );
353
        );
347
        layout.setVerticalGroup(
354
        layout.setVerticalGroup(
Lines 372-377 Link Here
372
                .addGap(18, 18, 18)
379
                .addGap(18, 18, 18)
373
                .addComponent(showBrowserCheckBox)
380
                .addComponent(showBrowserCheckBox)
374
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
381
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
382
                .addComponent(jCheckBoxCopyStaticResources)
383
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
375
                .addComponent(jCheckBoxDeployOnSave)
384
                .addComponent(jCheckBoxDeployOnSave)
376
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
385
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
377
                .addComponent(dosDescription, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
386
                .addComponent(dosDescription, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
Lines 413-418 Link Here
413
    private javax.swing.JLabel contextPathLabel;
422
    private javax.swing.JLabel contextPathLabel;
414
    private javax.swing.JTextField contextPathTField;
423
    private javax.swing.JTextField contextPathTField;
415
    private javax.swing.JLabel dosDescription;
424
    private javax.swing.JLabel dosDescription;
425
    private javax.swing.JCheckBox jCheckBoxCopyStaticResources;
416
    private javax.swing.JCheckBox jCheckBoxDeployOnSave;
426
    private javax.swing.JCheckBox jCheckBoxDeployOnSave;
417
    private javax.swing.JComboBox javaeeVersionCBox;
427
    private javax.swing.JComboBox javaeeVersionCBox;
418
    private javax.swing.JLabel javaeeVersionLabel;
428
    private javax.swing.JLabel javaeeVersionLabel;
(-)a/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ui/util/CopyStaticResourcesOnSaveCheckBoxUpdater.java (+92 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.maven.j2ee.ui.util;
44
45
import javax.swing.JCheckBox;
46
import org.netbeans.api.project.Project;
47
import org.netbeans.modules.maven.api.customizer.support.CheckBoxUpdater;
48
import org.netbeans.modules.maven.j2ee.utils.MavenProjectSupport;
49
50
/**
51
 *
52
 * @author Martin Janicek <mjanicek@netbeans.org>
53
 */
54
public class CopyStaticResourcesOnSaveCheckBoxUpdater extends CheckBoxUpdater {
55
56
    private final Project project;
57
    private final boolean defaultValue;
58
59
    private CopyStaticResourcesOnSaveCheckBoxUpdater(Project project, JCheckBox compileStaticResourcesCheckBox) {
60
        super(compileStaticResourcesCheckBox);
61
        this.project = project;
62
        this.defaultValue = getValue();
63
    }
64
65
66
    /**
67
     * Factory method encapsulating CheckBoxUpdater creation. Typically client don't
68
     * want to do anything with a new instance so this makes more sense than creating
69
     * it using "new" keyword.
70
     *
71
     * @param project project for which we want to change DoS
72
     * @param deployOnSaveCheckBox Deploy on Save check box for which we want to create updater
73
     */
74
    public static void create(Project project, JCheckBox deployOnSaveCheckBox) {
75
        new CopyStaticResourcesOnSaveCheckBoxUpdater(project, deployOnSaveCheckBox);
76
    }
77
78
    @Override
79
    public Boolean getValue() {
80
        return MavenProjectSupport.isCopyStaticResourcesOnSave(project);
81
    }
82
83
    @Override
84
    public void setValue(Boolean value) {
85
        MavenProjectSupport.setCopyStaticResourcesOnSave(project, value);
86
    }
87
88
    @Override
89
    public boolean getDefaultValue() {
90
        return defaultValue;
91
    }
92
}
(-)a/maven.j2ee/src/org/netbeans/modules/maven/j2ee/utils/MavenProjectSupport.java (-8 / +11 lines)
Lines 454-467 Link Here
454
        } else {
454
        } else {
455
            getPreferences(project, true).putBoolean(MavenJavaEEConstants.HINT_DEPLOY_ON_SAVE, value);
455
            getPreferences(project, true).putBoolean(MavenJavaEEConstants.HINT_DEPLOY_ON_SAVE, value);
456
        }
456
        }
457
        
457
    }
458
        CopyOnSave copyOnSave = project.getLookup().lookup(CopyOnSave.class);
458
459
        if (copyOnSave != null) {
459
    public static boolean isCopyStaticResourcesOnSave(Project project) {
460
            if (isDeployOnSave(project)) {
460
        return getPreferences(project, true).getBoolean(MavenJavaEEConstants.HINT_COPY_STATIC_RESOURCES_ON_SAVE, true);
461
                copyOnSave.initialize();
461
    }
462
            } else {
462
463
                copyOnSave.cleanup();
463
    public static void setCopyStaticResourcesOnSave(Project project, boolean value) {
464
            }
464
        if (value) {
465
            getPreferences(project, true).remove(MavenJavaEEConstants.HINT_COPY_STATIC_RESOURCES_ON_SAVE);
466
        } else {
467
            getPreferences(project, true).putBoolean(MavenJavaEEConstants.HINT_COPY_STATIC_RESOURCES_ON_SAVE, value);
465
        }
468
        }
466
    }
469
    }
467
470
(-)a/maven.j2ee/src/org/netbeans/modules/maven/j2ee/web/WebCopyOnSave.java (-1 / +23 lines)
Lines 55-60 Link Here
55
import org.netbeans.modules.javaee.project.api.ClientSideDevelopmentSupport;
55
import org.netbeans.modules.javaee.project.api.ClientSideDevelopmentSupport;
56
import org.netbeans.modules.maven.api.NbMavenProject;
56
import org.netbeans.modules.maven.api.NbMavenProject;
57
import org.netbeans.modules.maven.j2ee.CopyOnSave;
57
import org.netbeans.modules.maven.j2ee.CopyOnSave;
58
import org.netbeans.modules.maven.j2ee.MavenJavaEEConstants;
59
import org.netbeans.modules.maven.j2ee.utils.MavenProjectSupport;
58
import org.netbeans.modules.web.api.webmodule.WebModule;
60
import org.netbeans.modules.web.api.webmodule.WebModule;
59
import org.netbeans.modules.web.common.api.CssPreprocessors;
61
import org.netbeans.modules.web.common.api.CssPreprocessors;
60
import org.netbeans.spi.project.ProjectServiceProvider;
62
import org.netbeans.spi.project.ProjectServiceProvider;
Lines 257-269 Link Here
257
                checkPreprocessors(fe.getFile());
259
                checkPreprocessors(fe.getFile());
258
                
260
                
259
                if (!isInPlace()) {
261
                if (!isInPlace()) {
260
                    handleCopyFileToDestDir(fe.getFile());
262
                    boolean deployOnSave = MavenProjectSupport.isDeployOnSave(project);
263
                    boolean copyStaticResourcesOnSave = MavenProjectSupport.isCopyStaticResourcesOnSave(project);
264
265
                    // DoS is enabled and copy static resource too --> handle all files
266
                    if (deployOnSave && copyStaticResourcesOnSave) {
267
                        handleCopyFileToDestDir(fe.getFile());
268
                    }
269
270
                    if (!deployOnSave && copyStaticResourcesOnSave) {
271
                        // DoS is disabled --> handle only static resources
272
                        if (isStaticResource(fe.getFile().getExt())) {
273
                            handleCopyFileToDestDir(fe.getFile());
274
                        }
275
                    }
261
                }
276
                }
262
            } catch (IOException e) {
277
            } catch (IOException e) {
263
                ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
278
                ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
264
            }
279
            }
265
        }
280
        }
266
281
282
        private boolean isStaticResource(String fileExt) {
283
            if ("html".equals(fileExt) || "jsp".equals(fileExt) || "xhtml".equals(fileExt)) {
284
                return true;
285
            }
286
            return false;
287
        }
288
267
        @Override
289
        @Override
268
        public void fileDataCreated(final FileEvent fe) {
290
        public void fileDataCreated(final FileEvent fe) {
269
            if (SwingUtilities.isEventDispatchThread()) {//#167740
291
            if (SwingUtilities.isEventDispatchThread()) {//#167740

Return to bug 218345