Skip to content

Commit

Permalink
Merge pull request apache#2694 from sdedic/lsp/source-attacher-brandi…
Browse files Browse the repository at this point in the history
…ng-api

Allow "Attach sources/javadoc" UIs to be branded out.
  • Loading branch information
sdedic authored Jan 22, 2021
2 parents f78623f + 572079a commit 2db694e
Show file tree
Hide file tree
Showing 18 changed files with 824 additions and 69 deletions.
121 changes: 121 additions & 0 deletions java/java.j2seplatform/apichanges.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<?xml-stylesheet type="text/xml" href="../../nbbuild/javadoctools/apichanges.xsl"?>
<!DOCTYPE apichanges PUBLIC "-//NetBeans//DTD API changes list 1.0//EN" "../../nbbuild/javadoctools/apichanges.dtd">

<!--
INFO FOR PEOPLE ADDING CHANGES:
Check the DTD (apichanges.dtd) for details on the syntax. You do not
need to regenerate the HTML, as this is part of Javadoc generation; just
change the XML. Rough syntax of a change (several parts optional):
<change>
<api name="compiler"/>
<summary>Some brief description here, can use <b>XHTML</b></summary>
<version major="1" minor="99"/>
<date day="13" month="6" year="2001"/>
<author login="jrhacker"/>
<compatibility addition="yes"/>
<description>
The main description of the change here.
Again can use full <b>XHTML</b> as needed.
</description>
<class package="org.openide.compiler" name="DoWhatIWantCompiler"/>
<issue number="14309"/>
</change>
Also permitted elements: <package>, <branch>. <version> is API spec
version, recommended for all new changes. <compatibility> should say
if things were added/modified/deprecated/etc. and give all information
related to upgrading old code. List affected top-level classes and
link to issue numbers if applicable. See the DTD for more details.
Changes need not be in any particular order, they are sorted in various
ways by the stylesheet anyway.
Dates are assumed to mean "on the trunk". If you *also* make the same
change on a stabilization branch, use the <branch> tag to indicate this
and explain why the change was made on a branch in the <description>.
Please only change this file on the trunk! Rather: you can change it
on branches if you want, but these changes will be ignored; only the
trunk version of this file is important.
Deprecations do not count as incompatible, assuming that code using the
deprecated calls continues to see their documented behavior. But do
specify deprecation="yes" in <compatibility>.
This file is not a replacement for Javadoc: it is intended to list changes,
not describe the complete current behavior, for which ordinary documentation
is the proper place.
-->

<apichanges>

<!-- First, a list of API names you may use: -->
<apidefs>
<apidef name="j2selibraries">Java SE Platforms and Libraries</apidef>
</apidefs>

<!-- ACTUAL CHANGES BEGIN HERE: -->

<changes>
<change id="ask.on.volume.attach">
<api name="j2selibraries"/>
<summary>Rebrand defaults for attach source and javaddoc user questions</summary>
<version major="1" minor="54"/>
<date day="20" month="1" year="2021"/>
<author login="sdedic"/>
<compatibility modification="yes" binary="compatible" source="compatible"/>
<description>
A branding API to disable showing on source and javadoc attachment dialogs
- <a href="architecture-summary.html#group-branding">API_Ask_attachJavadocQuestion &amp; API_Ask_attachSourcesQuestion</a>.
</description>
</change>
</changes>

<!-- Now the surrounding HTML text and document structure: -->

<htmlcontents>

<!-- Generated from apichanges.xml -->
<head>
<title>Change History for the Java SE Platforms and Libraries</title>
<link rel="stylesheet" href="prose.css" type="text/css"/>
</head>
<body>
<p class="overviewlink"><a href="@TOP@/overview-summary.html">Overview</a></p>
<h1>Introduction</h1>
<p>This document lists changes made to the <a href="@TOP@/overview-summary.html">Java SE Platforms and Libraries</a>.</p>
<!-- The actual lists of changes, as summaries and details: -->
<hr/>
<standard-changelists module-code-name="org.netbeans.modules.java.j2seplatform/1"/>
<hr/>
<p>@FOOTER@</p>
</body>

</htmlcontents>

</apichanges>
49 changes: 47 additions & 2 deletions java/java.j2seplatform/arch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,55 @@
</api>
</li>
</ul>

<api name="org.netbeans.modules.java.j2seplatform.api.API_Ask_attachSourcesQuestion" group="branding" type="export" category="stable">
<p>
Controls interaction when <b>sources</b> are about to be attached to a Classpath root, in
<a href="@org-netbeans-api-java@/org/netbeans/spi/java/queries/SourceJavadocAttacherImplementation.html">SourceJavadocAttacherImplementation</a>
provided by this module. By setting <code>API_Ask_attachSourcesQuestion</code> key in
<code>org/netbeans/modules/java/j2seplatform/api/Bundle.properties</code> one can control the function:
</p>
<ul>
<li>
<b>no</b> will disable the attachers. No source/javadoc will be attached, and no user interaction will be started.
</li>
<li>
<b>yes</b> will permit the registered <a href="@org-netbeans-api-java@/org/netbeans/spi/java/queries/SourceJavadocAttacherImplementation#Definer.html">
SourceJavadocAttacherImplementation.Definer</a> to attach an appropriate resource(s). <b>User interaction will be skipped</b>
</li>
<li>
<b>ask</b> (the default) will ask the user to supply the resources.
</li>
</ul>
<p>
The key can be set by a branding file in your application build.
</p>
</api>
<api name="org.netbeans.modules.java.j2seplatform.api.API_Ask_attachJavadocQuestion" group="branding" type="export" category="stable">
<p>
Controls interaction when <b>javadocs</b> are about to be attached to a Classpath root, in
<a href="@org-netbeans-api-java@/org/netbeans/spi/java/queries/SourceJavadocAttacherImplementation.html">SourceJavadocAttacherImplementation</a>
provided by this module. By setting <code>API_Ask_attachJavadocQuestion</code> key in
<code>org/netbeans/modules/java/j2seplatform/api/Bundle.properties</code> one can control the function:
</p>
<ul>
<li>
<b>no</b> will disable the attachers. No source/javadoc will be attached, and no user interaction will be started.
</li>
<li>
<b>yes</b> will permit the registered <a href="@org-netbeans-api-java@/org/netbeans/spi/java/queries/SourceJavadocAttacherImplementation#Definer.html">
SourceJavadocAttacherImplementation.Definer</a> to attach an appropriate resource(s). <b>User interaction will be skipped</b>
</li>
<li>
<b>ask</b> (the default) will ask the user to supply the resources.
</li>
</ul>
<p>
The key can be set by a branding file in your application build.
</p>
</api>
</answer>



<!--
<question id="dep-non-nb" when="init">
What other projects outside NetBeans does this one depend on?
Expand Down
2 changes: 1 addition & 1 deletion java/java.j2seplatform/manifest.mf
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/j2seplatform/Bundle.
OpenIDE-Module-Layer: org/netbeans/modules/java/j2seplatform/resources/layer.xml
OpenIDE-Module-Install: org/netbeans/modules/java/j2seplatform/J2SEPlatformModule.class
AutoUpdate-Show-In-Client: false
OpenIDE-Module-Specification-Version: 1.53
OpenIDE-Module-Specification-Version: 1.54
OpenIDE-Module-Provides: j2seplatform
1 change: 1 addition & 0 deletions java/java.j2seplatform/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ extra.module.files=modules/ext/org-netbeans-modules-java-j2seplatform-probe.jar
jnlp.indirect.jars=modules/ext/org-netbeans-modules-java-j2seplatform-probe.jar

javadoc.arch=${basedir}/arch.xml
javadoc.apichanges=${basedir}/apichanges.xml

#requires nb javac for unit tests
requires.nb.javac=true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# Select sources to attach to JAR files: yes/no/ask
API_Ask_attachSourcesQuestion=ask
API_Ask_attachJavadocQuestion=ask
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package org.netbeans.modules.java.j2seplatform.queries;

import java.awt.GraphicsEnvironment;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URI;
Expand All @@ -35,6 +34,8 @@
import org.netbeans.api.annotations.common.NonNull;
import org.netbeans.api.annotations.common.NullAllowed;
import org.netbeans.api.java.queries.SourceJavadocAttacher.AttachmentListener;
import org.netbeans.modules.java.j2seplatform.api.J2SEPlatformCreator;
import org.netbeans.modules.java.j2seplatform.spi.J2SEPlatformDefaultJavadoc;
import org.netbeans.spi.java.project.support.JavadocAndSourceRootDetection;
import org.netbeans.spi.java.queries.SourceJavadocAttacherImplementation;
import org.openide.DialogDescriptor;
Expand Down Expand Up @@ -77,23 +78,40 @@ public static List<? extends URI> selectJavadoc(
assert root != null;
assert browseCall != null;
assert convertor != null;
final SelectRootsPanel selectJavadoc = new SelectRootsPanel(
SelectRootsPanel.JAVADOC,
root,
attachedRoots,
browseCall,
convertor,
plugin);
final DialogDescriptor dd = new DialogDescriptor(selectJavadoc, Bundle.TXT_SelectJavadoc());
dd.setButtonListener(selectJavadoc);
if (DialogDisplayer.getDefault().notify(dd) == DialogDescriptor.OK_OPTION) {
try {
return selectJavadoc.getRoots();
} catch (Exception e) {
DialogDisplayer.getDefault().notify(
new NotifyDescriptor.Message(
Bundle.TXT_InvalidJavadocRoot(),
NotifyDescriptor.ERROR_MESSAGE));
String action = NbBundle.getMessage(J2SEPlatformCreator.class, "API_Ask_attachJavadocQuestion");
if ("yes".equalsIgnoreCase(action)) { // NOI18N
if (plugin == null) {
return null;
}
List<? extends URI> sources = plugin.getSources(root, () -> false).stream().map(url -> {
try {
return url.toURI();
} catch (URISyntaxException ex) {
}
return null;
}).filter(uri -> uri != null).collect(Collectors.toList());
if (!sources.isEmpty()) {
return sources;
}
} else if ("ask".equalsIgnoreCase(action)) { // NOI18N
final SelectRootsPanel selectJavadoc = new SelectRootsPanel(
SelectRootsPanel.JAVADOC,
root,
attachedRoots,
browseCall,
convertor,
plugin);
final DialogDescriptor dd = new DialogDescriptor(selectJavadoc, Bundle.TXT_SelectJavadoc());
dd.setButtonListener(selectJavadoc);
if (DialogDisplayer.getDefault().notify(dd) == DialogDescriptor.OK_OPTION) {
try {
return selectJavadoc.getRoots();
} catch (Exception e) {
DialogDisplayer.getDefault().notify(
new NotifyDescriptor.Message(
Bundle.TXT_InvalidJavadocRoot(),
NotifyDescriptor.ERROR_MESSAGE));
}
}
}
return null;
Expand All @@ -113,7 +131,11 @@ public static List<? extends URI> selectSources(
assert root != null;
assert browseCall != null;
assert convertor != null;
if (GraphicsEnvironment.isHeadless()) {
String action = NbBundle.getMessage(J2SEPlatformCreator.class, "API_Ask_attachSourcesQuestion");
if ("yes".equalsIgnoreCase(action)) { // NOI18N
if (plugin == null) {
return null;
}
List<? extends URI> sources = plugin.getSources(root, () -> false).stream().map(url -> {
try {
return url.toURI();
Expand All @@ -124,7 +146,7 @@ public static List<? extends URI> selectSources(
if (!sources.isEmpty()) {
return sources;
}
} else {
} else if ("ask".equalsIgnoreCase(action)) { // NOI18N
final SelectRootsPanel selectSources = new SelectRootsPanel(
SelectRootsPanel.SOURCES,
root,
Expand Down
Loading

0 comments on commit 2db694e

Please sign in to comment.