Skip to content

Commit

Permalink
Merge pull request #6275 from apache/delivery
Browse files Browse the repository at this point in the history
Sync delivery to release190 for 19-rc4
  • Loading branch information
neilcsmith-net authored Aug 4, 2023
2 parents 9e004a0 + 5d6c0c0 commit f1f01f0
Show file tree
Hide file tree
Showing 32 changed files with 221 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.netbeans.modules.j2ee.metadata.model.api.support.annotation.ObjectProvider;
import org.netbeans.modules.j2ee.metadata.model.api.support.annotation.PersistentObjectManager;

// @todo: Support JakartaEE
public class EnterpriseBeansImpl implements EnterpriseBeans {

private final AnnotationModelHelper helper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
/**
* @author Petr Slechta
*/
// @todo: Support JakartaEE
public class AnnotationHelpers {

private AnnotationModelHelper helper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
*
* @author Martin Adamek
*/
// @todo: Support JakartaEE
public final class SendJMSGenerator {

private static final Logger LOG = Logger.getLogger(SendJMSGenerator.class.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public EjbType run(EjbJarMetadata metadata) throws Exception {
Project project = FileOwnerQuery.getOwner(ejbClassFO);
if (project != null){
J2eeProjectCapabilities projectCap = J2eeProjectCapabilities.forProject(project);
allowsNoInterface = projectCap != null ? projectCap.isEjb31LiteSupported() : false;
allowsNoInterface = (projectCap != null && (projectCap.isEjb31LiteSupported() || projectCap.isEjb40LiteSupported()));
}

controller = new SessionMethodController(className, model, allowsNoInterface);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,9 @@ private void inProjectComboActionPerformed(java.awt.event.ActionEvent evt) {//GE
// End of variables declaration//GEN-END:variables

private void updateCheckboxes() {
J2eeProjectCapabilities projectCap = J2eeProjectCapabilities.forProject(project);
//by default for ejb 3.1 no interfaces will be created
localCheckBox.setSelected(!J2eeProjectCapabilities.forProject(project).isEjb31LiteSupported());
localCheckBox.setSelected(!(projectCap.isEjb31LiteSupported() || projectCap.isEjb40LiteSupported()));
changeSupport.fireChange();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ public boolean isValid() {
return false;
}
if (!(component.isRemote() || component.isLocal())) {
if(J2eeProjectCapabilities.forProject(project).isEjb31LiteSupported()) {
J2eeProjectCapabilities projectCap = J2eeProjectCapabilities.forProject(project);
if(projectCap.isEjb31LiteSupported() || projectCap.isEjb40LiteSupported()) {
//if it's jee6 project, ejb 3.1 allow to omit any interfaces
} else {
wizardDescriptor.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, NbBundle.getMessage(EjbFacadeWizardPanel2.class, "ERR_ChooseInterface")); // NOI18N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
*
* @author Martin Fousek <marfous@netbeans.org>
*/
// @todo: Support JakartaEE
@SuppressWarnings("serial") // not used to be serialized
public class MdbPropertiesPanelVisual extends javax.swing.JPanel {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
* This class contains only static methods.
* @author Tomas Mysik
*/
// @todo: Support JakartaEE
public abstract class MessageDestinationUiSupport {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public boolean isValid() {
}
boolean isLocal = wizardPanel.isLocal();
boolean isRemote = wizardPanel.isRemote();
if (!isLocal && !isRemote && !J2eeProjectCapabilities.forProject(project).isEjb31LiteSupported()) {
J2eeProjectCapabilities projectCap = J2eeProjectCapabilities.forProject(project);
if (!isLocal && !isRemote && !projectCap.isEjb31LiteSupported() && !projectCap.isEjb40LiteSupported()) {
wizardDescriptor.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, NbBundle.getMessage(SessionEJBWizardDescriptor.class,"ERR_RemoteOrLocal_MustBeSelected")); //NOI18N
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,15 +476,15 @@ public Project getRemoteInterfaceProject() {
}

private boolean isSingletonSupported(J2eeProjectCapabilities projectCap) {
return projectCap.isEjb31LiteSupported();
return projectCap.isEjb31LiteSupported() || projectCap.isEjb40LiteSupported();
}

private boolean isNoInterfaceViewSupported(J2eeProjectCapabilities projectCap) {
return projectCap.isEjb31LiteSupported();
return projectCap.isEjb31LiteSupported() || projectCap.isEjb40LiteSupported();
}

private boolean isTimerSupported(J2eeProjectCapabilities projectCap) {
return projectCap.isEjb31Supported() || projectCap.isEjb32LiteSupported();
return projectCap.isEjb31Supported() || projectCap.isEjb32LiteSupported() || projectCap.isEjb40LiteSupported();
}

private boolean isRemoteInterfaceSupported() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"AsynchronousMethodInvocation.description=Checks usage of @Asynchronous. Tests whether it's used within supported project and interface type.",
"AsynchronousMethodInvocation.err.asynchronous.in.ejb31=Asynchronous method invocation is not allowed in project targeting JavaEE 6 Lite profile"
})
// @todo: Support JakartaEE
public final class AsynchronousMethodInvocation {

private AsynchronousMethodInvocation() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
* @author ads
*
*/
// @todo: Support JakartaEE
class ObjectProviders {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,18 @@ public final class SQLCloneableEditor extends CloneableEditor implements MultiVi
private MultiViewElementCallback callback;

public SQLCloneableEditor() {
// Constructor used for deserialization/persistence
super(null);
putClientProperty("oldInitialize", Boolean.TRUE); // NOI18N
}

public SQLCloneableEditor(Lookup context) {
// Normally used constructor
super(context.lookup(SQLEditorSupport.class));
SQLEditorSupport support = context.lookup(SQLEditorSupport.class);
setActivatedNodes(new Node[] {support.getDataObject().getNodeDelegate()});
putClientProperty("oldInitialize", Boolean.TRUE); // NOI18N
initialize();
SQLEditorSupport support = context.lookup(SQLEditorSupport.class);
setActivatedNodes(new Node[]{support.getDataObject().getNodeDelegate()});
support.initializeCloneableEditor(this);
}

void setResults(List<Component> results) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ protected boolean notifyModified () {

@Override
protected void initializeCloneableEditor(CloneableEditor editor) {
// Invoked when SQLCloneableEditor is deserialized and from the
// SQLCloneableEditor(Lookup) constructor.
super.initializeCloneableEditor(editor);
((SQLCloneableEditor) editor).initialize();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,15 @@ public void connect(OutputStream pin, InputStream pout, InputStream perr, String
updateTtySize();

if (pin != null) {
outputStreamWriter = new OutputStreamWriter(pin);
if(charSet == null) {
outputStreamWriter = new OutputStreamWriter(pin);
} else {
try {
outputStreamWriter = new OutputStreamWriter(pin, charSet);
} catch (UnsupportedEncodingException ex) {
outputStreamWriter = new OutputStreamWriter(pin);
}
}
stdinMonitor = new InputMonitor(outputStreamWriter);
addInputListener(stdinMonitor);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.netbeans.modules.j2ee.metadata.model.api.support.annotation.PersistentObjectManager;
import org.netbeans.modules.j2ee.persistence.api.metadata.orm.*;

// @todo: Support JakartaEE
public class EntityMappingsImpl implements EntityMappings {

private final AnnotationModelHelper helper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import javax.lang.model.type.ArrayType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.swing.text.BadLocationException;
import javax.swing.text.StyledDocument;
import org.eclipse.lsp4j.Position;
import org.eclipse.lsp4j.Range;
Expand Down Expand Up @@ -399,24 +398,34 @@ public static String encode2JSON(String value) {

/**
* Simple conversion from HTML to plaintext. Removes all html tags incl. attributes,
* replaces BR, P and HR tags with newlines.
* replaces BR, P and HR tags with newlines. The method optionally collapses whitespaces:
* all whitespace characters are replaced by spaces, adjacent spaces collapsed to single one, leading
* and trailing spaces removed.
* @param s html text
* @param collapseWhitespaces to collapse
* @return plaintext
*/
public static String html2plain(String s) {
public static String html2plain(String s, boolean collapseWhitespaces) {
if (s == null) {
return null;
}
boolean inTag = false;
boolean whitespace = false;

int tagStart = -1;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
if (inTag) {
T: if (inTag) {
boolean alpha = Character.isAlphabetic(ch);
if (tagStart > 0 && !alpha) {
String t = s.substring(tagStart, i).toLowerCase(Locale.ENGLISH);
switch (t) {
case "br": case "p": case "hr": // NOI1N
sb.append("\n");
break;
ch ='\n'; // NOI18N
// continues to process 'ch' as if it came from the string, but `inTag` remains
// the same.
break T;
}
// prevent entering tagstart state again
tagStart = -2;
Expand All @@ -426,16 +435,40 @@ public static String html2plain(String s) {
} else if (tagStart == -1 && alpha) {
tagStart = i;
}
continue;
} else {
if (ch == '<') { // NOI18N
tagStart = -1;
inTag = true;
continue;
}
sb.append(ch);
}
if (collapseWhitespaces) {
if (ch == '\n') {
ch = ' ';
}
if (Character.isWhitespace(ch)) {
if (whitespace) {
continue;
}
ch = ' '; // NOI18N
whitespace = true;
} else {
whitespace = false;
}
}
sb.append(ch);
}
return sb.toString();
return collapseWhitespaces ? sb.toString().trim() : sb.toString();
}

/**
* Simple conversion from HTML to plaintext. Removes all html tags incl. attributes,
* replaces BR, P and HR tags with newlines.
* @param s html text
* @return plaintext
*/
public static String html2plain(String s) {
return html2plain(s, false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import org.netbeans.api.project.SourceGroupModifier;
import org.netbeans.api.templates.CreateDescriptor;
import org.netbeans.api.templates.FileBuilder;
import org.netbeans.modules.java.lsp.server.Utils;
import org.netbeans.modules.java.lsp.server.input.QuickPickItem;
import org.netbeans.modules.java.lsp.server.input.ShowQuickPickParams;
import org.netbeans.modules.java.lsp.server.input.ShowInputBoxParams;
Expand Down Expand Up @@ -459,23 +460,7 @@ private static String findDetail(DataObject obj) {
}

static String stripHtml(String s) {
boolean inTag = false;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
if (inTag) {
if (ch == '>') {
inTag = false;
}
} else {
if (ch == '<') {
inTag = true;
continue;
}
sb.append(ch);
}
}
return sb.toString();
return Utils.html2plain(s, true);
}

private static <T extends Exception> T raise(Class<T> clazz, Exception ex) throws T {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import org.eclipse.lsp4j.ApplyWorkspaceEditParams;
import org.eclipse.lsp4j.ApplyWorkspaceEditResponse;
import org.eclipse.lsp4j.ConfigurationParams;
Expand All @@ -37,6 +38,7 @@
import org.eclipse.lsp4j.WorkDoneProgressCreateParams;
import org.eclipse.lsp4j.WorkspaceFolder;
import org.eclipse.lsp4j.jsonrpc.messages.Either;
import org.netbeans.modules.java.lsp.server.Utils;
import org.netbeans.modules.java.lsp.server.input.QuickPickItem;
import org.netbeans.modules.java.lsp.server.input.ShowQuickPickParams;
import org.netbeans.modules.java.lsp.server.input.ShowMutliStepInputParams;
Expand Down Expand Up @@ -86,7 +88,16 @@ public CompletableFuture<String> execInHtmlPage(HtmlPageParams params) {

@Override
public CompletableFuture<List<QuickPickItem>> showQuickPick(ShowQuickPickParams params) {
return remote.showQuickPick(params);
// vscode from version 1.80.2 displays control characters in quickpicks. Let's strip them:
ShowQuickPickParams copy = new ShowQuickPickParams(
params.getTitle(), params.getPlaceHolder(), params.getCanPickMany(),
params.getItems().stream().map(
i -> new QuickPickItem(
i.getLabel(), Utils.html2plain(i.getDescription(), true), Utils.html2plain(i.getDetail(), true),
i.isPicked(), i.getUserData())
).collect(Collectors.toList())
);
return remote.showQuickPick(copy);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.eclipse.lsp4j.MessageType;
import org.eclipse.lsp4j.ShowMessageRequestParams;
import org.eclipse.lsp4j.jsonrpc.messages.Either;
import org.netbeans.modules.java.lsp.server.Utils;
import org.netbeans.modules.java.lsp.server.input.InputBoxStep;
import org.netbeans.modules.java.lsp.server.input.InputCallbackParams;
import org.netbeans.modules.java.lsp.server.input.InputService;
Expand Down Expand Up @@ -372,7 +373,7 @@ public <T extends NotifyDescriptor> CompletableFuture<T> clientNotifyCompletion(
List<QuickPickItem> items = new ArrayList<>(qpItems.size());
for (int i = 0; i < qpItems.size(); i++) {
NotifyDescriptor.QuickPick.Item item = qpItems.get(i);
items.add(new QuickPickItem(item.getLabel(), item.getDescription(), null, item.isSelected(), Integer.toString(i)));
items.add(new QuickPickItem(item.getLabel(), Utils.html2plain(item.getDescription(), true), null, item.isSelected(), Integer.toString(i)));
}
ShowQuickPickParams params = new ShowQuickPickParams(qp.getLabel(), qp.getTitle(), qp.isMultipleSelection(), items);
CompletableFuture<List<QuickPickItem>> qpF = client.showQuickPick(params);
Expand Down Expand Up @@ -431,7 +432,8 @@ public CompletableFuture<Either<QuickPickStep, InputBoxStep>> step(InputCallback
List<QuickPickItem> items = new ArrayList<>();
for (int i = 0; i < qpItems.size(); i++) {
NotifyDescriptor.QuickPick.Item item = qpItems.get(i);
items.add(new QuickPickItem(item.getLabel(), item.getDescription(), null, item.isSelected(), Integer.toString(i)));
items.add(new QuickPickItem(item.getLabel(),
Utils.html2plain(item.getDescription(), true), null, item.isSelected(), Integer.toString(i)));
}
QuickPickStep step = new QuickPickStep(ci.getEstimatedNumberOfInputs(), stepId,
null, input.getTitle(), ((NotifyDescriptor.QuickPick) input).isMultipleSelection(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,36 @@ public void testEncode2JSON() {
assertEquals("abcd", Utils.encode2JSON("abcd"));
assertEquals("'\\\"\\b\\t\\n\\r\\\\", Utils.encode2JSON("'\"\b\t\n\r\\"));
}

@Test
public void testStripHtml() {
String s = "<div>Pre <span>Text</span> Post</div>";
String expResult = "Pre Text Post";
String result = Utils.html2plain(s);
assertEquals(expResult, result);
}

/**
* All newlines should be removed
*/
@Test
public void testStripNewlines() {
String s = "\n<div>Pre <span\n>\nText</span> Post\n</div>";
String expResult = "Pre Text Post";
String result = Utils.html2plain(s, true);
assertEquals(expResult, result);
}


/**
* Consecutive whitespaces should be collapsed to a single space. Leading/trailing whitespaces
* removed.
*/
@Test
public void testStripConsecutiveWhitespces() {
String s = "\t <div> Pre <span> Text\t </span>\t\t Post </div>\t";
String expResult = "Pre Text Post";
String result = Utils.html2plain(s, true);
assertEquals(expResult, result);
}
}
Loading

0 comments on commit f1f01f0

Please sign in to comment.