1.1 --- a/web.clientproject/src/org/netbeans/modules/web/clientproject/ant/AntServices.java Mon Oct 20 12:43:21 2014 +0200
1.2 +++ b/web.clientproject/src/org/netbeans/modules/web/clientproject/ant/AntServices.java Mon Oct 20 13:28:45 2014 +0200
1.3 @@ -54,9 +54,9 @@
1.4 import org.netbeans.modules.web.clientproject.api.WebClientProjectConstants;
1.5 import org.netbeans.modules.web.clientproject.indirect.AntProjectHelper;
1.6 import org.netbeans.modules.web.clientproject.indirect.IndirectServices;
1.7 +import org.netbeans.modules.web.clientproject.indirect.LicensePanelSupport;
1.8 import org.netbeans.modules.web.clientproject.indirect.PropertyEvaluator;
1.9 import org.netbeans.modules.web.clientproject.indirect.ReferenceHelper;
1.10 -import org.netbeans.modules.web.clientproject.ui.customizer.LicensePanelSupport;
1.11 import org.netbeans.spi.project.AuxiliaryConfiguration;
1.12 import org.netbeans.spi.project.support.ant.AntBasedProjectRegistration;
1.13 import org.netbeans.spi.project.support.ant.ProjectGenerator;
1.14 @@ -107,11 +107,6 @@
1.15 }
1.16
1.17 @Override
1.18 - public JComponent createLicenseHeaderCustomizerPanel(ProjectCustomizer.Category category, LicensePanelSupport licenseSupport) {
1.19 - return CustomizerUtilities.createLicenseHeaderCustomizerPanel(category, licenseSupport);
1.20 - }
1.21 -
1.22 - @Override
1.23 public String relativizeFile(File base, File relative) {
1.24 return PropertyUtils.relativizeFile(base, relative);
1.25 }
1.26 @@ -150,6 +145,19 @@
1.27 return new ReferenceHelperImpl(orig);
1.28 }
1.29
1.30 + @Override
1.31 + public JComponent createLicenseHeaderCustomizerPanel(ProjectCustomizer.Category category, LicensePanelSupport licenseSupport) {
1.32 + LicensePanelSupportImpl li = (LicensePanelSupportImpl) licenseSupport;
1.33 + return CustomizerUtilities.createLicenseHeaderCustomizerPanel(category, li);
1.34 + }
1.35 +
1.36 + @Override
1.37 + public LicensePanelSupport newLicensePanelSupport(
1.38 + PropertyEvaluator evaluator, AntProjectHelper projectHelper, String p1, String p2
1.39 + ) {
1.40 + return new LicensePanelSupportImpl(evaluator, projectHelper, p1, p2);
1.41 + }
1.42 +
1.43 public static IndirectServices newServices() {
1.44 return new AntServices();
1.45 }
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/web.clientproject/src/org/netbeans/modules/web/clientproject/ant/LicensePanelSupportImpl.java Mon Oct 20 13:28:45 2014 +0200
2.3 @@ -0,0 +1,152 @@
2.4 +/*
2.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2.6 + *
2.7 + * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
2.8 + *
2.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
2.10 + * Other names may be trademarks of their respective owners.
2.11 + *
2.12 + * The contents of this file are subject to the terms of either the GNU
2.13 + * General Public License Version 2 only ("GPL") or the Common
2.14 + * Development and Distribution License("CDDL") (collectively, the
2.15 + * "License"). You may not use this file except in compliance with the
2.16 + * License. You can obtain a copy of the License at
2.17 + * http://www.netbeans.org/cddl-gplv2.html
2.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
2.19 + * specific language governing permissions and limitations under the
2.20 + * License. When distributing the software, include this License Header
2.21 + * Notice in each file and include the License file at
2.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
2.23 + * particular file as subject to the "Classpath" exception as provided
2.24 + * by Oracle in the GPL Version 2 section of the License file that
2.25 + * accompanied this code. If applicable, add the following below the
2.26 + * License Header, with the fields enclosed by brackets [] replaced by
2.27 + * your own identifying information:
2.28 + * "Portions Copyrighted [year] [name of copyright owner]"
2.29 + *
2.30 + * If you wish your version of this file to be governed by only the CDDL
2.31 + * or only the GPL Version 2, indicate your decision by adding
2.32 + * "[Contributor] elects to include this software in this distribution
2.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
2.34 + * single choice of license, a recipient has the option to distribute
2.35 + * your version of this file under either the CDDL, the GPL Version 2 or
2.36 + * to extend the choice of license to its licensees as provided above.
2.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
2.38 + * Version 2 license, then the option applies only if the new code is
2.39 + * made subject to such option by the copyright holder.
2.40 + *
2.41 + * Contributor(s):
2.42 + *
2.43 + * Portions Copyrighted 2013 Sun Microsystems, Inc.
2.44 + */
2.45 +package org.netbeans.modules.web.clientproject.ant;
2.46 +
2.47 +import java.io.ByteArrayInputStream;
2.48 +import java.io.File;
2.49 +import java.io.IOException;
2.50 +import java.io.OutputStream;
2.51 +import org.netbeans.api.annotations.common.NonNull;
2.52 +import org.netbeans.api.annotations.common.NullAllowed;
2.53 +import org.netbeans.modules.web.clientproject.indirect.AntProjectHelper;
2.54 +import org.netbeans.modules.web.clientproject.indirect.LicensePanelSupport;
2.55 +import org.netbeans.modules.web.clientproject.indirect.PropertyEvaluator;
2.56 +import org.netbeans.spi.project.support.ant.ui.CustomizerUtilities;
2.57 +import org.openide.filesystems.FileObject;
2.58 +import org.openide.filesystems.FileUtil;
2.59 +import org.openide.util.EditableProperties;
2.60 +
2.61 +// copied from web.common
2.62 +final class LicensePanelSupportImpl
2.63 +extends LicensePanelSupport implements CustomizerUtilities.LicensePanelContentHandler {
2.64 + private String licenseName;
2.65 + private String licensePath;
2.66 + private String licenseContent;
2.67 +
2.68 + private PropertyEvaluator evaluator;
2.69 + private AntProjectHelper antHelper;
2.70 +
2.71 + public LicensePanelSupportImpl(PropertyEvaluator evaluator, AntProjectHelper antHelper,
2.72 + String licensePath, String licenseName) {
2.73 + this.evaluator = evaluator;
2.74 + this.antHelper = antHelper;
2.75 + this.licensePath = licensePath;
2.76 + this.licenseName = licenseName;
2.77 + this.licenseContent = null;
2.78 + }
2.79 +
2.80 + @Override
2.81 + public String getProjectLicenseLocation() {
2.82 + return licensePath;
2.83 + }
2.84 +
2.85 + @Override
2.86 + public String getGlobalLicenseName() {
2.87 + return licenseName;
2.88 + }
2.89 +
2.90 + @Override
2.91 + public FileObject resolveProjectLocation(@NonNull String path) {
2.92 + String evaluated = evaluator.evaluate(path);
2.93 + if (evaluated != null) {
2.94 + return antHelper.resolveFileObject(evaluated);
2.95 + } else {
2.96 + return null;
2.97 + }
2.98 + }
2.99 +
2.100 + @Override
2.101 + public void setProjectLicenseLocation(@NullAllowed String newLocation) {
2.102 + licensePath = newLocation;
2.103 + }
2.104 +
2.105 + @Override
2.106 + public void setGlobalLicenseName(@NullAllowed String newName) {
2.107 + licenseName = newName;
2.108 + }
2.109 +
2.110 + @Override
2.111 + public String getDefaultProjectLicenseLocation() {
2.112 + return "./nbproject/licenseheader.txt";
2.113 + }
2.114 +
2.115 + @Override
2.116 + public void setProjectLicenseContent(@NullAllowed String text) {
2.117 + licenseContent = text;
2.118 + }
2.119 +
2.120 + @Override
2.121 + public void saveLicenseFile() throws IOException {
2.122 + if (licenseContent != null) {
2.123 + assert licensePath != null; //path needs to exist once we have content?
2.124 + String evaluated = evaluator.evaluate(licensePath);
2.125 + assert evaluated != null;
2.126 + File file = antHelper.resolveFile(evaluated);
2.127 + FileObject fo;
2.128 + if (!file.exists()) {
2.129 + fo = FileUtil.createData(file);
2.130 + } else {
2.131 + fo = FileUtil.toFileObject(file);
2.132 + }
2.133 + OutputStream out = fo.getOutputStream();
2.134 + try {
2.135 + FileUtil.copy(new ByteArrayInputStream(licenseContent.getBytes()), out);
2.136 + } finally {
2.137 + out.close();
2.138 + }
2.139 + }
2.140 + }
2.141 +
2.142 + @Override
2.143 + public void updateProperties(EditableProperties projectProperties) {
2.144 + if (licensePath != null) {
2.145 + projectProperties.setProperty(LICENSE_PATH, licensePath);
2.146 + } else {
2.147 + projectProperties.remove(LICENSE_PATH);
2.148 + }
2.149 + if (licenseName != null) {
2.150 + projectProperties.setProperty(LICENSE_NAME, licenseName);
2.151 + } else {
2.152 + projectProperties.remove(LICENSE_NAME);
2.153 + }
2.154 + }
2.155 +}
3.1 --- a/web.clientproject/src/org/netbeans/modules/web/clientproject/indirect/IndirectServices.java Mon Oct 20 12:43:21 2014 +0200
3.2 +++ b/web.clientproject/src/org/netbeans/modules/web/clientproject/indirect/IndirectServices.java Mon Oct 20 13:28:45 2014 +0200
3.3 @@ -46,7 +46,6 @@
3.4 import javax.swing.JComponent;
3.5 import org.netbeans.api.project.Project;
3.6 import org.netbeans.api.project.Sources;
3.7 -import org.netbeans.modules.web.clientproject.ui.customizer.LicensePanelSupport;
3.8 import org.netbeans.spi.project.AuxiliaryConfiguration;
3.9 import org.netbeans.spi.project.ui.support.ProjectCustomizer;
3.10 import org.openide.filesystems.FileObject;
3.11 @@ -66,4 +65,9 @@
3.12 public abstract ReferenceHelper newReferenceHelper(AntProjectHelper helper, AuxiliaryConfiguration configuration, PropertyEvaluator eval);
3.13
3.14 public abstract Sources initSources(Project project, AntProjectHelper h, PropertyEvaluator e);
3.15 +
3.16 + public abstract LicensePanelSupport newLicensePanelSupport(
3.17 + PropertyEvaluator evaluator, AntProjectHelper projectHelper,
3.18 + String p1, String p2
3.19 + );
3.20 }
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/web.clientproject/src/org/netbeans/modules/web/clientproject/indirect/LicensePanelSupport.java Mon Oct 20 13:28:45 2014 +0200
4.3 @@ -0,0 +1,53 @@
4.4 +/*
4.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4.6 + *
4.7 + * Copyright 2014 Oracle and/or its affiliates. All rights reserved.
4.8 + *
4.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
4.10 + * Other names may be trademarks of their respective owners.
4.11 + *
4.12 + * The contents of this file are subject to the terms of either the GNU
4.13 + * General Public License Version 2 only ("GPL") or the Common
4.14 + * Development and Distribution License("CDDL") (collectively, the
4.15 + * "License"). You may not use this file except in compliance with the
4.16 + * License. You can obtain a copy of the License at
4.17 + * http://www.netbeans.org/cddl-gplv2.html
4.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
4.19 + * specific language governing permissions and limitations under the
4.20 + * License. When distributing the software, include this License Header
4.21 + * Notice in each file and include the License file at
4.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
4.23 + * particular file as subject to the "Classpath" exception as provided
4.24 + * by Oracle in the GPL Version 2 section of the License file that
4.25 + * accompanied this code. If applicable, add the following below the
4.26 + * License Header, with the fields enclosed by brackets [] replaced by
4.27 + * your own identifying information:
4.28 + * "Portions Copyrighted [year] [name of copyright owner]"
4.29 + *
4.30 + * If you wish your version of this file to be governed by only the CDDL
4.31 + * or only the GPL Version 2, indicate your decision by adding
4.32 + * "[Contributor] elects to include this software in this distribution
4.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
4.34 + * single choice of license, a recipient has the option to distribute
4.35 + * your version of this file under either the CDDL, the GPL Version 2 or
4.36 + * to extend the choice of license to its licensees as provided above.
4.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
4.38 + * Version 2 license, then the option applies only if the new code is
4.39 + * made subject to such option by the copyright holder.
4.40 + *
4.41 + * Contributor(s):
4.42 + *
4.43 + * Portions Copyrighted 2014 Sun Microsystems, Inc.
4.44 + */
4.45 +package org.netbeans.modules.web.clientproject.indirect;
4.46 +
4.47 +import java.io.IOException;
4.48 +import org.openide.util.EditableProperties;
4.49 +
4.50 +public abstract class LicensePanelSupport {
4.51 + public static final String LICENSE_NAME = "project.license";
4.52 + public static final String LICENSE_PATH = "project.licensePath";
4.53 +
4.54 + public abstract void updateProperties(EditableProperties projectProperties);
4.55 + public abstract void saveLicenseFile() throws IOException;
4.56 +}
5.1 --- a/web.clientproject/src/org/netbeans/modules/web/clientproject/ui/customizer/ClientSideProjectProperties.java Mon Oct 20 12:43:21 2014 +0200
5.2 +++ b/web.clientproject/src/org/netbeans/modules/web/clientproject/ui/customizer/ClientSideProjectProperties.java Mon Oct 20 13:28:45 2014 +0200
5.3 @@ -41,6 +41,7 @@
5.4 */
5.5 package org.netbeans.modules.web.clientproject.ui.customizer;
5.6
5.7 +import org.netbeans.modules.web.clientproject.indirect.LicensePanelSupport;
5.8 import java.awt.EventQueue;
5.9 import java.beans.PropertyChangeEvent;
5.10 import java.io.File;
5.11 @@ -60,6 +61,7 @@
5.12 import org.netbeans.modules.web.clientproject.api.platform.PlatformProvider;
5.13 import org.netbeans.modules.web.clientproject.api.platform.PlatformProviders;
5.14 import org.netbeans.modules.web.clientproject.indirect.AntProjectHelper;
5.15 +import org.netbeans.modules.web.clientproject.indirect.IndirectServices;
5.16 import org.netbeans.modules.web.clientproject.spi.platform.ClientProjectEnhancedBrowserImplementation;
5.17 import org.netbeans.modules.web.clientproject.util.ClientSideProjectUtilities;
5.18 import org.openide.filesystems.FileUtil;
5.19 @@ -452,7 +454,8 @@
5.20
5.21 public LicensePanelSupport getLicenseSupport() {
5.22 if (licenseSupport == null) {
5.23 - licenseSupport = new LicensePanelSupport(project.getEvaluator(), project.getProjectHelper(),
5.24 + IndirectServices is = project.is;
5.25 + licenseSupport = is.newLicensePanelSupport(project.getEvaluator(), project.getProjectHelper(),
5.26 getProjectProperty(LicensePanelSupport.LICENSE_PATH, null),
5.27 getProjectProperty(LicensePanelSupport.LICENSE_NAME, null));
5.28 }
6.1 --- a/web.clientproject/src/org/netbeans/modules/web/clientproject/ui/customizer/LicensePanelSupport.java Mon Oct 20 12:43:21 2014 +0200
6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
6.3 @@ -1,152 +0,0 @@
6.4 -/*
6.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
6.6 - *
6.7 - * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
6.8 - *
6.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
6.10 - * Other names may be trademarks of their respective owners.
6.11 - *
6.12 - * The contents of this file are subject to the terms of either the GNU
6.13 - * General Public License Version 2 only ("GPL") or the Common
6.14 - * Development and Distribution License("CDDL") (collectively, the
6.15 - * "License"). You may not use this file except in compliance with the
6.16 - * License. You can obtain a copy of the License at
6.17 - * http://www.netbeans.org/cddl-gplv2.html
6.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
6.19 - * specific language governing permissions and limitations under the
6.20 - * License. When distributing the software, include this License Header
6.21 - * Notice in each file and include the License file at
6.22 - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
6.23 - * particular file as subject to the "Classpath" exception as provided
6.24 - * by Oracle in the GPL Version 2 section of the License file that
6.25 - * accompanied this code. If applicable, add the following below the
6.26 - * License Header, with the fields enclosed by brackets [] replaced by
6.27 - * your own identifying information:
6.28 - * "Portions Copyrighted [year] [name of copyright owner]"
6.29 - *
6.30 - * If you wish your version of this file to be governed by only the CDDL
6.31 - * or only the GPL Version 2, indicate your decision by adding
6.32 - * "[Contributor] elects to include this software in this distribution
6.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
6.34 - * single choice of license, a recipient has the option to distribute
6.35 - * your version of this file under either the CDDL, the GPL Version 2 or
6.36 - * to extend the choice of license to its licensees as provided above.
6.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
6.38 - * Version 2 license, then the option applies only if the new code is
6.39 - * made subject to such option by the copyright holder.
6.40 - *
6.41 - * Contributor(s):
6.42 - *
6.43 - * Portions Copyrighted 2013 Sun Microsystems, Inc.
6.44 - */
6.45 -package org.netbeans.modules.web.clientproject.ui.customizer;
6.46 -
6.47 -import java.io.ByteArrayInputStream;
6.48 -import java.io.File;
6.49 -import java.io.IOException;
6.50 -import java.io.OutputStream;
6.51 -import org.netbeans.api.annotations.common.NonNull;
6.52 -import org.netbeans.api.annotations.common.NullAllowed;
6.53 -import org.netbeans.modules.web.clientproject.indirect.AntProjectHelper;
6.54 -import org.netbeans.modules.web.clientproject.indirect.PropertyEvaluator;
6.55 -import org.netbeans.spi.project.support.ant.ui.CustomizerUtilities;
6.56 -import org.openide.filesystems.FileObject;
6.57 -import org.openide.filesystems.FileUtil;
6.58 -import org.openide.util.EditableProperties;
6.59 -
6.60 -// copied from web.common
6.61 -public final class LicensePanelSupport implements CustomizerUtilities.LicensePanelContentHandler {
6.62 -
6.63 - public static final String LICENSE_NAME = "project.license";
6.64 - public static final String LICENSE_PATH = "project.licensePath";
6.65 -
6.66 - private String licenseName;
6.67 - private String licensePath;
6.68 - private String licenseContent;
6.69 -
6.70 - private PropertyEvaluator evaluator;
6.71 - private AntProjectHelper antHelper;
6.72 -
6.73 - public LicensePanelSupport(PropertyEvaluator evaluator, AntProjectHelper antHelper,
6.74 - String licensePath, String licenseName) {
6.75 - this.evaluator = evaluator;
6.76 - this.antHelper = antHelper;
6.77 - this.licensePath = licensePath;
6.78 - this.licenseName = licenseName;
6.79 - this.licenseContent = null;
6.80 - }
6.81 -
6.82 - @Override
6.83 - public String getProjectLicenseLocation() {
6.84 - return licensePath;
6.85 - }
6.86 -
6.87 - @Override
6.88 - public String getGlobalLicenseName() {
6.89 - return licenseName;
6.90 - }
6.91 -
6.92 - @Override
6.93 - public FileObject resolveProjectLocation(@NonNull String path) {
6.94 - String evaluated = evaluator.evaluate(path);
6.95 - if (evaluated != null) {
6.96 - return antHelper.resolveFileObject(evaluated);
6.97 - } else {
6.98 - return null;
6.99 - }
6.100 - }
6.101 -
6.102 - @Override
6.103 - public void setProjectLicenseLocation(@NullAllowed String newLocation) {
6.104 - licensePath = newLocation;
6.105 - }
6.106 -
6.107 - @Override
6.108 - public void setGlobalLicenseName(@NullAllowed String newName) {
6.109 - licenseName = newName;
6.110 - }
6.111 -
6.112 - @Override
6.113 - public String getDefaultProjectLicenseLocation() {
6.114 - return "./nbproject/licenseheader.txt";
6.115 - }
6.116 -
6.117 - @Override
6.118 - public void setProjectLicenseContent(@NullAllowed String text) {
6.119 - licenseContent = text;
6.120 - }
6.121 -
6.122 - public void saveLicenseFile() throws IOException {
6.123 - if (licenseContent != null) {
6.124 - assert licensePath != null; //path needs to exist once we have content?
6.125 - String evaluated = evaluator.evaluate(licensePath);
6.126 - assert evaluated != null;
6.127 - File file = antHelper.resolveFile(evaluated);
6.128 - FileObject fo;
6.129 - if (!file.exists()) {
6.130 - fo = FileUtil.createData(file);
6.131 - } else {
6.132 - fo = FileUtil.toFileObject(file);
6.133 - }
6.134 - OutputStream out = fo.getOutputStream();
6.135 - try {
6.136 - FileUtil.copy(new ByteArrayInputStream(licenseContent.getBytes()), out);
6.137 - } finally {
6.138 - out.close();
6.139 - }
6.140 - }
6.141 - }
6.142 -
6.143 - public void updateProperties(EditableProperties projectProperties) {
6.144 - if (licensePath != null) {
6.145 - projectProperties.setProperty(LICENSE_PATH, licensePath);
6.146 - } else {
6.147 - projectProperties.remove(LICENSE_PATH);
6.148 - }
6.149 - if (licenseName != null) {
6.150 - projectProperties.setProperty(LICENSE_NAME, licenseName);
6.151 - } else {
6.152 - projectProperties.remove(LICENSE_NAME);
6.153 - }
6.154 - }
6.155 -}