# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: /home/mkozeny/NetBeans_workspace/core-main # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: api.java/apichanges.xml --- api.java/apichanges.xml Base (BASE) +++ api.java/apichanges.xml Locally Modified (Based On LOCAL) @@ -76,6 +76,23 @@ + + + New API ProjectModificationImplementation + + + + + +

+ Added new API ProjectModificationImplementation, which provides methods + getPackagesToExport, exportPackageAction and isExportSelectedPackages. + This API is used by ExportPackageAction located in non-public package org.netbeans.spi.java.queries.impl + which is action implemented for exporting package(s) from NetBeans Module Project. +

+
+ +
The SourceLevelQuery supports JDK 8 profiles Index: api.java/manifest.mf --- api.java/manifest.mf Base (BASE) +++ api.java/manifest.mf Locally Modified (Based On LOCAL) @@ -1,6 +1,6 @@ Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.api.java/1 -OpenIDE-Module-Specification-Version: 1.46 +OpenIDE-Module-Specification-Version: 1.47 OpenIDE-Module-Localizing-Bundle: org/netbeans/api/java/queries/Bundle.properties AutoUpdate-Show-In-Client: false Index: api.java/nbproject/project.xml --- api.java/nbproject/project.xml Base (BASE) +++ api.java/nbproject/project.xml Locally Modified (Based On LOCAL) @@ -68,6 +68,23 @@ + org.netbeans.modules.projectapi + + + + 1 + 1.53 + + + + org.openide.awt + + + + 7.58 + + + org.openide.filesystems Index: api.java/src/org/netbeans/spi/java/queries/ProjectModifierImplementation.java --- api.java/src/org/netbeans/spi/java/queries/ProjectModifierImplementation.java Base (BASE) +++ api.java/src/org/netbeans/spi/java/queries/ProjectModifierImplementation.java Locally New @@ -0,0 +1,77 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2013 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2013 Sun Microsystems, Inc. + */ +package org.netbeans.spi.java.queries; + +import java.util.Collection; +import org.netbeans.api.annotations.common.NonNull; +import org.openide.filesystems.FileObject; + +/** + * Provide API for manipulating with project packages. + * @author mkozeny + * @since 1.47 + */ +public interface ProjectModifierImplementation { + + /** + * Returns collection of packages to export or unexport + * @param selectedPackages set of selected packages + * @return collection of packages which are able to export or unexport + */ + public @NonNull Collection getPackagesToExport(Collection selectedPackages); + + /** + * Check whether passed set of packages should be exported or unexported + * @param packagesToExport set of packages to export or to unexport + * @return true or false according to whether collection of packages + * passed as parameter contains at least one non-public package + */ + public boolean isExportSelectedPackages(Collection packagesToExport); + + /** + * Do the export or unexport of passed set of packages + * @param packagesToExport set of packages to export or to unexport + * @param export whether passed set of packages should be export or unexport + */ + public void exportPackageAction(@NonNull Collection packagesToExport, boolean export); + +} Index: api.java/src/org/netbeans/spi/java/queries/impl/ExportPackageAction.java --- api.java/src/org/netbeans/spi/java/queries/impl/ExportPackageAction.java Base (BASE) +++ api.java/src/org/netbeans/spi/java/queries/impl/ExportPackageAction.java Locally New @@ -0,0 +1,126 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2013 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2013 Sun Microsystems, Inc. + */ +package org.netbeans.spi.java.queries.impl; + +import java.awt.event.ActionEvent; +import java.util.Collection; +import javax.swing.AbstractAction; +import javax.swing.Action; +import org.netbeans.api.project.FileOwnerQuery; +import org.netbeans.api.project.Project; +import org.netbeans.spi.java.queries.ProjectModifierImplementation; +import org.openide.awt.ActionID; +import org.openide.awt.ActionReference; +import org.openide.awt.ActionReferences; +import org.openide.awt.ActionRegistration; +import org.openide.awt.DynamicMenuContent; +import org.openide.filesystems.FileObject; +import org.openide.util.ContextAwareAction; +import org.openide.util.Lookup; +import org.openide.util.NbBundle.Messages; + +/** + * Submenu which permits the user to export or unexport appropriate package. + * Must be locate in NetBeans Module Project. + */ +@ActionID( + category = "Project", + id = "org.netbeans.modules.apisupport.project.ExportPackageAction") +@ActionRegistration( + displayName = "#CTL_ExportPackageAction", lazy = false) +@ActionReferences({ + @ActionReference(path = "Projects/package/Actions", position = 100), +}) +@Messages({"CTL_UnexportPackageAction=Unexport Package","CTL_ExportPackageAction=Export Package"}) +public final class ExportPackageAction extends AbstractAction implements ContextAwareAction{ + + @Override + public void actionPerformed(ActionEvent ev) { + //well, since someone can assign a shortcut ti the action, the invokation is unvaiodable, make it noop + //assert false : "Action should never be called without a context"; + } + + @Override + public Action createContextAwareInstance(Lookup actionContext) { + Collection selectedPackages = (Collection) actionContext.lookupAll(FileObject.class); + Project project = FileOwnerQuery.getOwner(selectedPackages.iterator().hasNext()?selectedPackages.iterator().next():null); + ProjectModifierImplementation pmi = null; + if((pmi = project.getLookup().lookup(ProjectModifierImplementation.class)) != null) { + Collection packagesToExport = pmi.getPackagesToExport(selectedPackages); + return new ExportPackageAction.ContextAction(pmi, packagesToExport, pmi.isExportSelectedPackages(packagesToExport)); + } + return new ExportPackageAction.ContextAction(); + } + + /** + * The particular instance of this action for a given package(s). + */ + private static final class ContextAction extends AbstractAction { + + private Collection packagesToExport; + private boolean export; + private ProjectModifierImplementation pmi; + + public ContextAction() { + this(true, false); + } + + public ContextAction(ProjectModifierImplementation pmi, Collection packagesToExport, boolean export) { + this(export, packagesToExport!=null && !packagesToExport.isEmpty()); + this.pmi = pmi; + this.packagesToExport = packagesToExport; + this.export = export; + } + + private ContextAction(boolean export, boolean enable) { + super(export?Bundle.CTL_ExportPackageAction():Bundle.CTL_UnexportPackageAction()); + this.putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true); + this.setEnabled(enable); + } + + @Override + public void actionPerformed(ActionEvent evt) { + pmi.exportPackageAction(packagesToExport, export); + } + + } +} \ No newline at end of file