You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by lk...@apache.org on 2022/02/03 17:16:32 UTC

[netbeans] branch master updated (44ea743 -> b15b5d6)

This is an automated email from the ASF dual-hosted git repository.

lkishalmi pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git.


    from 44ea743  [NETBEANS-6410] - Upgrade JAXB from 2.3.3 to 2.3.5 (#3545)
     new 9b9d3ff  Form a single problem from the exception.
     new 73fe197  Retain project problems from gradle execution.
     new b15b5d6  Respect HTML formatting. Display "Resolve problems" actions for projects.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../gradle/GradleProjectProblemProvider.java       | 10 ++-
 .../modules/gradle/NbGradleProjectImpl.java        | 17 ++++-
 .../src/org/netbeans/modules/gradle/layer.xml      |  4 ++
 .../gradle/loaders/GradleProjectLoaderImpl.java    |  6 +-
 .../gradle/loaders/LegacyProjectLoader.java        | 84 ++++++++++++++++++++--
 .../ui/problems/BrokenReferencesCustomizer.form    |  4 +-
 .../ui/problems/BrokenReferencesCustomizer.java    | 18 +++--
 .../maven/src/org/netbeans/modules/maven/layer.xml |  4 ++
 8 files changed, 127 insertions(+), 20 deletions(-)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[netbeans] 02/03: Retain project problems from gradle execution.

Posted by lk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lkishalmi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git

commit 73fe19791595c29d5b0a8e763d0bffe604eeaf33
Author: Svata Dedic <sv...@oracle.com>
AuthorDate: Wed Feb 2 11:28:31 2022 +0100

    Retain project problems from gradle execution.
---
 .../netbeans/modules/gradle/NbGradleProjectImpl.java    | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/extide/gradle/src/org/netbeans/modules/gradle/NbGradleProjectImpl.java b/extide/gradle/src/org/netbeans/modules/gradle/NbGradleProjectImpl.java
index 7901ef2..a09b799 100644
--- a/extide/gradle/src/org/netbeans/modules/gradle/NbGradleProjectImpl.java
+++ b/extide/gradle/src/org/netbeans/modules/gradle/NbGradleProjectImpl.java
@@ -402,7 +402,20 @@ public final class NbGradleProjectImpl implements Project {
             }
             loadedProjectSerial = s;
             this.attemptedQuality = aim;
-            if (project != null && !force && project.getQuality().atLeast(prj.getQuality())) {
+            
+            boolean replace = project == null;
+            if (project != null) {
+                if (prj.getQuality().betterThan(project.getQuality())) {
+                    replace = true;
+                } else if (
+                        project.getQuality().equals(prj.getQuality()) && 
+                        !project.getProblems().equals(prj.getProblems()) &&
+                        !prj.getProblems().isEmpty()) {
+                    // exception: if the new project is the same quality fallback, but contains (different) problem info, use it
+                    replace = true;
+                }
+            }
+            if (!replace) {
                 // avoid replacing a project when nothing has changed.
                 LOG.log(Level.FINER, "Current project {1} sufficient for attempted quality {0}", new Object[] { this.project, aim });
                 return CompletableFuture.completedFuture(this.project);
@@ -495,7 +508,7 @@ public final class NbGradleProjectImpl implements Project {
 
     GradleProject getPrimedProject() {
         GradleProject gp = projectWithQuality(null, EVALUATED, false, false);
-        return !(gp.getQuality().notBetterThan(EVALUATED) || !gp.getProblems().isEmpty()) ? gp : null;
+        return gp.getQuality().betterThan(EVALUATED) ? gp : null;
     }
     
     /**

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[netbeans] 01/03: Form a single problem from the exception.

Posted by lk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lkishalmi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git

commit 9b9d3fff59dcd0c6df493e78673b315dc860fc88
Author: Svata Dedic <sv...@oracle.com>
AuthorDate: Wed Feb 2 11:27:35 2022 +0100

    Form a single problem from the exception.
---
 .../gradle/GradleProjectProblemProvider.java       | 10 ++-
 .../gradle/loaders/GradleProjectLoaderImpl.java    |  6 +-
 .../gradle/loaders/LegacyProjectLoader.java        | 84 ++++++++++++++++++++--
 3 files changed, 90 insertions(+), 10 deletions(-)

diff --git a/extide/gradle/src/org/netbeans/modules/gradle/GradleProjectProblemProvider.java b/extide/gradle/src/org/netbeans/modules/gradle/GradleProjectProblemProvider.java
index 2b53729..b12edc8 100644
--- a/extide/gradle/src/org/netbeans/modules/gradle/GradleProjectProblemProvider.java
+++ b/extide/gradle/src/org/netbeans/modules/gradle/GradleProjectProblemProvider.java
@@ -80,12 +80,16 @@ public class GradleProjectProblemProvider implements ProjectProblemsProvider {
     public Collection<? extends ProjectProblem> getProblems() {
         List<ProjectProblem> ret = new ArrayList<>();
         GradleProject gp = project.getLookup().lookup(NbGradleProjectImpl.class).getGradleProject();
-        if (gp.getQuality().notBetterThan(EVALUATED)) {
-            ret.add(ProjectProblem.createError(Bundle.LBL_PrimingRequired(), Bundle.TXT_PrimingRequired(), resolver));
+        // untrusted project can't have 'real' problems: the execution could not happen
+        boolean trusted = ProjectTrust.getDefault().isTrusted(project);
+        if (!trusted || gp.getProblems().isEmpty()) {
+            if (gp.getQuality().notBetterThan(EVALUATED)) {
+                ret.add(ProjectProblem.createError(Bundle.LBL_PrimingRequired(), Bundle.TXT_PrimingRequired(), resolver));
+            }
         } else {
             for (String problem : gp.getProblems()) {
                 String[] lines = problem.split("\\n"); //NOI18N
-                ret.add(ProjectProblem.createWarning(lines[0], problem.replaceAll("\\n", "<br/>"), resolver)); //NOI18N
+                ret.add(ProjectProblem.createWarning(lines[0], problem.replaceAll("\\n", "<br/>"), null)); //NOI18N
             }
         }
         return ret;
diff --git a/extide/gradle/src/org/netbeans/modules/gradle/loaders/GradleProjectLoaderImpl.java b/extide/gradle/src/org/netbeans/modules/gradle/loaders/GradleProjectLoaderImpl.java
index 070bf2a..833ee1c 100644
--- a/extide/gradle/src/org/netbeans/modules/gradle/loaders/GradleProjectLoaderImpl.java
+++ b/extide/gradle/src/org/netbeans/modules/gradle/loaders/GradleProjectLoaderImpl.java
@@ -30,6 +30,7 @@ import org.netbeans.modules.gradle.api.NbGradleProject;
 import org.netbeans.modules.gradle.api.execute.GradleCommandLine;
 import org.netbeans.modules.gradle.api.execute.RunUtils;
 import org.netbeans.modules.gradle.options.GradleExperimentalSettings;
+import org.openide.util.NbBundle;
 
 /**
  *
@@ -45,6 +46,9 @@ public class GradleProjectLoaderImpl implements GradleProjectLoader {
     }
 
     @Override
+    @NbBundle.Messages({
+        "ERR_ProjectNotTrusted=Gradle execution is not trusted on this project."
+    })
     public GradleProject loadProject(NbGradleProject.Quality aim, String descriptionOpt, boolean ignoreCache, boolean interactive, String... args) {
         LOGGER.info("Load aiming " +aim + " for "+ project);
         GradleCommandLine cmd = new GradleCommandLine(args);
@@ -76,7 +80,7 @@ public class GradleProjectLoaderImpl implements GradleProjectLoader {
                     } else {
                         ret = ctx.getPrevious();
                         if (ret != null) {
-                            ret = ret.invalidate("Gradle execution is not trusted on this project.");
+                            ret = ret.invalidate(Bundle.ERR_ProjectNotTrusted());
                         }
                         LOGGER.log(Level.FINER, "Execution not allowed, invalidated {0}", ret);
                     }
diff --git a/extide/gradle/src/org/netbeans/modules/gradle/loaders/LegacyProjectLoader.java b/extide/gradle/src/org/netbeans/modules/gradle/loaders/LegacyProjectLoader.java
index 488b94d..2520aa7 100644
--- a/extide/gradle/src/org/netbeans/modules/gradle/loaders/LegacyProjectLoader.java
+++ b/extide/gradle/src/org/netbeans/modules/gradle/loaders/LegacyProjectLoader.java
@@ -20,6 +20,7 @@ package org.netbeans.modules.gradle.loaders;
 
 import java.io.Serializable;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
@@ -174,12 +175,7 @@ public class LegacyProjectLoader extends AbstractProjectLoader {
             }
         } catch (GradleConnectionException | IllegalStateException ex) {
             LOG.log(FINE, "Failed to retrieve project information for: " + base.getProjectDir(), ex);
-            List<String> problems = new ArrayList<>();
-            Throwable th = ex;
-            while (th != null) {
-                problems.add(th.getMessage());
-                th = th.getCause();
-            }
+            List<String> problems = exceptionsToProblems(ex);
             errors.openNotification(TIT_LOAD_FAILED(base.getProjectDir()), ex.getMessage(), GradleProjectErrorNotifications.bulletedList(problems));
             return ctx.previous.invalidate(problems.toArray(new String[0]));
         } finally {
@@ -201,6 +197,82 @@ public class LegacyProjectLoader extends AbstractProjectLoader {
         }
         return ret;
     }
+    
+    private static List<String> causesToProblems(Throwable ex) {
+        List<String> problems = new ArrayList<>();
+        Throwable th = ex;
+        while (th != null) {
+            problems.add(th.getMessage());
+        }
+        return problems;
+    }
+    
+    @NbBundle.Messages({
+        "# {0} - previous part",
+        "# {1} - appended part",
+        "FMT_AppendMessage={0} {1}",
+        "# {0} - the error message",
+        "# {1} - the file / line",
+        "FMT_MessageWithLocation={0} ({1})"
+    })
+    /**
+     * Rearranges the exception stack messages to be more readable. A typical Gradle build exception is a 
+     * {@link GradleConnectionException} that wraps the actual exception. The message of this exception
+     * is completely useless except possibly for gradle wrapper/distribution path.
+     * 
+     * The next to rearrange is the positional information - the message should come first as it
+     * often appears in the title. The positional information holder is not a part of oficial tooling API
+     * so a little hack is used to extract the information from the exception chain.
+     * 
+     * The rest of messages is coalesced into one text. Location, if present, is appended at the end.
+     */
+    private static List<String> exceptionsToProblems(Throwable t) {
+        if (!(t instanceof GradleConnectionException)) {
+            return causesToProblems(t);
+        }
+        // skip Connection exception no useful info there.
+        Throwable cause = t.getCause();
+        if (cause == null || cause == t) {
+            // no cause - use exception message.
+            return Collections.singletonList(t.getMessage());
+        }
+        String msg = "";
+        String appendLocation = null;
+        // LocationAwareException is not part of APIs:
+        if (cause.getClass().getName().endsWith("LocationAwareException")) { // NOI18N
+            Throwable next = cause.getCause();
+            appendLocation = cause.getMessage();
+            if (next != null) {
+                String m = next.getMessage();
+                int i = appendLocation.indexOf(m);
+                if (i >= 0) {
+                    // the LocationAwareException may include the immediately nested exception's message.
+                    appendLocation = appendLocation.substring(0, i).trim();
+                }
+            }
+            cause = next;
+        }
+        while (cause != null) {
+            if (!msg.isEmpty()) {
+                msg = Bundle.FMT_AppendMessage(msg, cause.getMessage());
+            } else {
+                msg = cause.getMessage();
+            }
+            Throwable next = cause.getCause();
+            if (next == cause) {
+                break;
+            }
+            cause = next;
+        }
+        if (appendLocation != null) {
+            // if the message itself is multi-line, add the location info on a separate line:
+            if (msg.contains("\n")) { // NOI18N
+                msg = msg + "\n"; // NOI18N
+            }
+            msg = Bundle.FMT_MessageWithLocation(msg, appendLocation);
+        }
+        return Collections.singletonList(msg);
+    }
 
     private static BuildActionExecuter<NbProjectInfo> createInfoAction(ProjectConnection pconn, GradleCommandLine cmd, CancellationToken token, ProgressListener pl) {
         BuildActionExecuter<NbProjectInfo> ret = pconn.action(new NbProjectInfoAction());

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[netbeans] 03/03: Respect HTML formatting. Display "Resolve problems" actions for projects.

Posted by lk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lkishalmi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git

commit b15b5d6f6521ba7b550d757607188deb62894dbe
Author: Svata Dedic <sv...@oracle.com>
AuthorDate: Wed Feb 2 11:29:06 2022 +0100

    Respect HTML formatting. Display "Resolve problems" actions for projects.
---
 .../gradle/src/org/netbeans/modules/gradle/layer.xml   |  4 ++++
 .../ui/problems/BrokenReferencesCustomizer.form        |  4 +---
 .../ui/problems/BrokenReferencesCustomizer.java        | 18 +++++++++++++-----
 java/maven/src/org/netbeans/modules/maven/layer.xml    |  4 ++++
 4 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/extide/gradle/src/org/netbeans/modules/gradle/layer.xml b/extide/gradle/src/org/netbeans/modules/gradle/layer.xml
index c3d049e..6c866a2 100644
--- a/extide/gradle/src/org/netbeans/modules/gradle/layer.xml
+++ b/extide/gradle/src/org/netbeans/modules/gradle/layer.xml
@@ -81,6 +81,10 @@
                     <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
                     <attr name="position" intvalue="1300"/>
                 </file>
+                <file name="org-netbeans-modules-project-ui-problems-BrokenProjectActionFactory.shadow">
+                    <attr name="originalFile" stringvalue="Actions/Project/org-netbeans-modules-project-ui-problems-BrokenProjectActionFactory.instance"/>
+                    <attr name="position" intvalue="1770"/>
+                </file>
                 <file name="org-netbeans-modules-project-ui-SetMainProject.shadow">
                     <attr name="originalFile" stringvalue="Actions/Project/org-netbeans-modules-project-ui-SetMainProject.instance"/>
                     <attr name="position" intvalue="1800"/>
diff --git a/ide/projectui/src/org/netbeans/modules/project/ui/problems/BrokenReferencesCustomizer.form b/ide/projectui/src/org/netbeans/modules/project/ui/problems/BrokenReferencesCustomizer.form
index 2d895e1..d46fa54 100644
--- a/ide/projectui/src/org/netbeans/modules/project/ui/problems/BrokenReferencesCustomizer.form
+++ b/ide/projectui/src/org/netbeans/modules/project/ui/problems/BrokenReferencesCustomizer.form
@@ -146,11 +146,9 @@
 
       <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
       <SubComponents>
-        <Component class="javax.swing.JTextArea" name="description">
+        <Component class="javax.swing.JTextPane" name="description">
           <Properties>
             <Property name="editable" type="boolean" value="false"/>
-            <Property name="lineWrap" type="boolean" value="true"/>
-            <Property name="wrapStyleWord" type="boolean" value="true"/>
           </Properties>
         </Component>
       </SubComponents>
diff --git a/ide/projectui/src/org/netbeans/modules/project/ui/problems/BrokenReferencesCustomizer.java b/ide/projectui/src/org/netbeans/modules/project/ui/problems/BrokenReferencesCustomizer.java
index 29f34b3..d742a8b 100644
--- a/ide/projectui/src/org/netbeans/modules/project/ui/problems/BrokenReferencesCustomizer.java
+++ b/ide/projectui/src/org/netbeans/modules/project/ui/problems/BrokenReferencesCustomizer.java
@@ -89,7 +89,7 @@ public class BrokenReferencesCustomizer extends javax.swing.JPanel {
         fix = new javax.swing.JButton();
         descriptionLabel = new javax.swing.JLabel();
         jScrollPane2 = new javax.swing.JScrollPane();
-        description = new javax.swing.JTextArea();
+        description = new javax.swing.JTextPane();
 
         setPreferredSize(new java.awt.Dimension(550, 350));
         setLayout(new java.awt.GridBagLayout());
@@ -146,8 +146,6 @@ public class BrokenReferencesCustomizer extends javax.swing.JPanel {
         descriptionLabel.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BrokenReferencesCustomizer.class, "ACSD_BrokenLinksCustomizer_Description")); // NOI18N
 
         description.setEditable(false);
-        description.setLineWrap(true);
-        description.setWrapStyleWord(true);
         jScrollPane2.setViewportView(description);
 
         gridBagConstraints = new java.awt.GridBagConstraints();
@@ -249,7 +247,16 @@ public class BrokenReferencesCustomizer extends javax.swing.JPanel {
         if (value instanceof BrokenReferencesModel.ProblemReference) {
             final BrokenReferencesModel.ProblemReference reference = (BrokenReferencesModel.ProblemReference) value;
             if (!reference.resolved) {
-                description.setText(reference.problem.getDescription());                
+                String s = reference.problem.getDescription();
+                // attempt to autodetect HTML tags in the description, switch content type appropriately.
+                if (s.contains("/>") || (s.contains("<") && s.contains(">"))) {
+                    description.setContentType("text/html");
+                } else {
+                    description.setContentType("text/plain");
+                }
+                description.setText(s);       
+                // avoid possible scroll down/left if the text does not fit in the default window
+                description.getCaret().setDot(0);
                 fix.setEnabled(reference.problem.isResolvable());
                 javax.swing.SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
@@ -272,13 +279,14 @@ public class BrokenReferencesCustomizer extends javax.swing.JPanel {
     
     
     // Variables declaration - do not modify//GEN-BEGIN:variables
-    private javax.swing.JTextArea description;
+    private javax.swing.JTextPane description;
     private javax.swing.JLabel descriptionLabel;
     private javax.swing.JList errorList;
     private javax.swing.JLabel errorListLabel;
     private javax.swing.JButton fix;
     private javax.swing.JScrollPane jScrollPane1;
     private javax.swing.JScrollPane jScrollPane2;
+    private javax.swing.JScrollPane jScrollPane3;
     // End of variables declaration//GEN-END:variables
 
     private static final @StaticResource String BROKEN_REF = "org/netbeans/modules/project/ui/resources/broken-reference.gif";
diff --git a/java/maven/src/org/netbeans/modules/maven/layer.xml b/java/maven/src/org/netbeans/modules/maven/layer.xml
index 268d98e..013037a 100644
--- a/java/maven/src/org/netbeans/modules/maven/layer.xml
+++ b/java/maven/src/org/netbeans/modules/maven/layer.xml
@@ -113,6 +113,10 @@
                     <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
                     <attr name="position" intvalue="1600"/>
                 </file>
+                <file name="org-netbeans-modules-project-ui-problems-BrokenProjectActionFactory.shadow">
+                    <attr name="originalFile" stringvalue="Actions/Project/org-netbeans-modules-project-ui-problems-BrokenProjectActionFactory.instance"/>
+                    <attr name="position" intvalue="1770"/>
+                </file>
                 <file name="org-netbeans-modules-project-ui-SetMainProject.shadow">
                     <attr name="originalFile" stringvalue="Actions/Project/org-netbeans-modules-project-ui-SetMainProject.instance"/>
                     <attr name="position" intvalue="1800"/>

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists