You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2021/12/09 08:59:47 UTC

[GitHub] [netbeans] JaroslavTulach opened a new pull request #3361: Using HTML based UI for Change method parameters refactoring

JaroslavTulach opened a new pull request #3361:
URL: https://github.com/apache/netbeans/pull/3361


   This PR builds on top of #3357 and 9e27e191c829978a9dbdcdaeee774d4208412348 (accidentally integrated into `master`) to deliver the final vision of #3349 - e.g. to display _rich HTML user interface_ for change method parameters refactoring.
   
   ![obrazek](https://user-images.githubusercontent.com/26887752/144278716-8bf683a7-ae65-42bd-a12b-14a0e1b414d9.png)
   
   Should there be any problems with 9e27e191c829978a9dbdcdaeee774d4208412348 I am ready to resolve it as part of this PR as soon as possible.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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

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


[GitHub] [netbeans] JaroslavTulach commented on a change in pull request #3361: Using HTML based UI for Change method parameters refactoring

Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3361:
URL: https://github.com/apache/netbeans/pull/3361#discussion_r765734298



##########
File path: java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/htmlui/Buttons.java
##########
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+package org.netbeans.modules.java.lsp.server.htmlui;
+
+import net.java.html.js.JavaScriptBody;
+import org.netbeans.spi.htmlui.HTMLViewerSpi;
+
+/**
+ * Helper utilities to deal with HTML buttons.
+ */
+public final class Buttons {
+    private Buttons() {
+    }
+
+    @JavaScriptBody(args = {}, body = "\n"
+        + "const vscode = acquireVsCodeApi();\n" // this method can be called only once per WebView existance
+        + "window.close = function() {\n"
+        + "  vscode.postMessage({\n"
+        + "    command: 'dispose',\n"
+        + "  });\n"
+        + "};\n"
+    )
+    public static native void registerCloseWindow();
+
+    @JavaScriptBody(args = { "id", "callback" }, javacall = true, body = "\n"
+            + "var first = false;\n"
+            + "var footer = document.getElementById('dialog-buttons');\n"
+            + "if (!footer) {\n"
+            + "  first = true\n"
+            + "  footer = document.createElement('div');\n"
+            + "  footer.id = 'dialog-buttons';\n"
+            + "  footer.classList.add('flex');\n"
+            + "  footer.classList.add('section');\n"
+            + "  document.body.appendChild(footer);\n"
+            + "}\n"
+            + "var button = document.createElement('button');\n"
+            + "button.id = id;\n"
+            + "button.onclick = function() {;\n"
+            + "  @org.netbeans.modules.java.lsp.server.htmlui.Buttons::clickButton0(Ljava/lang/String;Ljava/lang/Object;)(id, callback);\n"

Review comment:
       The HTML/Java API infrastructure generates a callback class `$JsCallbacks$` in the same package to be able to call from JavaScript to JVM. We don't want that class in the API - as such I am introducing new `Buttons` class and moving all `@JavaScriptBody` methods in here.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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

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


[GitHub] [netbeans] JaroslavTulach commented on a change in pull request #3361: Using HTML based UI for Change method parameters refactoring

Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3361:
URL: https://github.com/apache/netbeans/pull/3361#discussion_r765734828



##########
File path: java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/ui/AbstractLspHtmlViewer.java
##########
@@ -44,51 +52,12 @@ public View newView(Context context) {
         return view;
     }
 
-    @JavaScriptBody(args = {}, body = "\n"
-        + "const vscode = acquireVsCodeApi();\n" // this method can be called only once per WebView existance
-        + "window.close = function() {\n"
-        + "  vscode.postMessage({\n"
-        + "    command: 'dispose',\n"
-        + "  });\n"
-        + "};\n"
-    )
-    private static native void registerCloseWindow();
 
     @Override
     public Object createButton(View view, String id) {
-        return createButton0(id, view.ctx);
+        return Buttons.createButton0(id, view.ctx);
     }
 
-    @JavaScriptBody(args = { "id", "callback" }, javacall = true, body = "\n"
-            + "var first = false;\n"
-            + "var footer = document.getElementById('dialog-buttons');\n"
-            + "if (!footer) {\n"
-            + "  first = true\n"
-            + "  footer = document.createElement('div');\n"
-            + "  footer.id = 'dialog-buttons';\n"
-            + "  footer.classList.add('flex');\n"
-            + "  footer.classList.add('section');\n"
-            + "  document.body.appendChild(footer);\n"
-            + "}\n"
-            + "var button = document.createElement('button');\n"
-            + "button.id = id;\n"
-            + "button.onclick = function() {;\n"
-            + "  @org.netbeans.modules.java.lsp.server.ui.AbstractLspHtmlViewer::clickButton0(Ljava/lang/String;Ljava/lang/Object;)(id, callback);\n"

Review comment:
       Moved into `Buttons` class in non-API package.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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

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


[GitHub] [netbeans] JaroslavTulach commented on a change in pull request #3361: Using HTML based UI for Change method parameters refactoring

Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3361:
URL: https://github.com/apache/netbeans/pull/3361#discussion_r765733079



##########
File path: java/java.lsp.server/nbproject/org-netbeans-modules-java-lsp-server.sig
##########
@@ -23,6 +23,35 @@ meth public void notifyLater(org.openide.NotifyDescriptor)
 supr org.openide.DialogDisplayer
 hfds context
 
+CLSS public org.netbeans.modules.java.lsp.server.ui.AbstractGlobalActionContext
+cons public init()
+intf org.openide.util.ContextGlobalProvider
+intf org.openide.util.Lookup$Provider
+meth public org.openide.util.Lookup createGlobalContext()
+meth public org.openide.util.Lookup getLookup()
+meth public static <%0 extends java.lang.Object> {%%0} withActionContext(org.openide.util.Lookup,java.util.concurrent.Callable<{%%0}>)
+supr java.lang.Object
+hcls ContextHolder
+
+CLSS public org.netbeans.modules.java.lsp.server.ui.AbstractLspHtmlViewer
+cons protected init()
+innr protected final View
+intf org.netbeans.spi.htmlui.HTMLViewerSpi<org.netbeans.modules.java.lsp.server.ui.AbstractLspHtmlViewer$View,java.lang.Object>
+meth public <%0 extends java.lang.Object> {%%0} component(org.netbeans.modules.java.lsp.server.ui.AbstractLspHtmlViewer$View,java.lang.Class<{%%0}>)
+meth public java.lang.Object createButton(org.netbeans.modules.java.lsp.server.ui.AbstractLspHtmlViewer$View,java.lang.String)
+meth public java.lang.String getId(org.netbeans.modules.java.lsp.server.ui.AbstractLspHtmlViewer$View,java.lang.Object)
+meth public org.netbeans.modules.java.lsp.server.ui.AbstractLspHtmlViewer$View newView(org.netbeans.spi.htmlui.HTMLViewerSpi$Context)
+meth public void runLater(org.netbeans.modules.java.lsp.server.ui.AbstractLspHtmlViewer$View,java.lang.Runnable)
+meth public void setEnabled(org.netbeans.modules.java.lsp.server.ui.AbstractLspHtmlViewer$View,java.lang.Object,boolean)
+meth public void setText(org.netbeans.modules.java.lsp.server.ui.AbstractLspHtmlViewer$View,java.lang.Object,java.lang.String)
+supr java.lang.Object
+hfds initial
+
+CLSS protected final org.netbeans.modules.java.lsp.server.ui.AbstractLspHtmlViewer$View

Review comment:
       sigtest doesn't like private `View` - making it `protected` to fix `ant gen-sigtests-release` problem introduced in 9e27e191c829978a9dbdcdaeee774d4208412348




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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

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


[GitHub] [netbeans] JaroslavTulach commented on a change in pull request #3361: Using HTML based UI for Change method parameters refactoring

Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3361:
URL: https://github.com/apache/netbeans/pull/3361#discussion_r765731456



##########
File path: java/java.lsp.server/licenseinfo.xml
##########
@@ -27,6 +27,11 @@
         <file>vscode/src/extension.ts</file>
         <license ref="MIT-vscode-ext" />
     </fileset>
+    <fileset>
+        <file>src/org/netbeans/modules/java/lsp/server/refactoring/ui/codicon.ttf</file>
+        <file>src/org/netbeans/modules/java/lsp/server/refactoring/ui/codicon.css</file>

Review comment:
       These files are taken from [Microsoft codicons](https://github.com/microsoft/vscode-codicons) project. Readme mentions it is MIT licensed and points to [standard MIT license](https://opensource.org/licenses/MIT).




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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

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


[GitHub] [netbeans] JaroslavTulach commented on a change in pull request #3361: Using HTML based UI for Change method parameters refactoring

Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3361:
URL: https://github.com/apache/netbeans/pull/3361#discussion_r765973515



##########
File path: java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/ui/MockHtmlViewer.java
##########
@@ -74,6 +73,15 @@ private void load(View view, ClassLoader loader, URL pageUrl, Callable<Object> i
         return clazz.cast(v);
     }
 
+    @Override
+    public <C> C component(View view, Class<C> type) {
+        if (type == Void.class) {
+            load(view);

Review comment:
       Thanks, @dbalek , loading the view after `newView` is finished was one of recent changes. Previously the initialization started sooner then reference to `View` was returned and that lead to various races. Sometimes it worked, sometimes it deadlocked depending on the order of threads execution. Creating the instance first and initializing later when `component(Void.class)` is called fixes these races. I have probably forgotten to update the test - but it actually passed fine this morning (probably too positive order of execution).




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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

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


[GitHub] [netbeans] JaroslavTulach merged pull request #3361: Using HTML based UI for Change method parameters refactoring

Posted by GitBox <gi...@apache.org>.
JaroslavTulach merged pull request #3361:
URL: https://github.com/apache/netbeans/pull/3361


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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

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