Skip to content

Commit 8afab70

Browse files
author
Jaroslav Tulach
authored
Merge pull request #3361 from JaroslavTulach/jtulach/ChangeMethodRefactoringHtmlUI
Using HTML based UI for Change method parameters refactoring
2 parents b5329ca + 22dd80e commit 8afab70

20 files changed

Lines changed: 1341 additions & 356 deletions

java/java.lsp.server/licenseinfo.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
<file>vscode/src/extension.ts</file>
2828
<license ref="MIT-vscode-ext" />
2929
</fileset>
30+
<fileset>
31+
<file>src/org/netbeans/modules/java/lsp/server/refactoring/ui/codicon.ttf</file>
32+
<file>src/org/netbeans/modules/java/lsp/server/refactoring/ui/codicon.css</file>
33+
<license ref="MIT" />
34+
</fileset>
3035
<fileset>
3136
<file>vscode/.vscodeignore</file>
3237
<file>vscode/.eslintrc.json</file>

java/java.lsp.server/nbproject/org-netbeans-modules-java-lsp-server.sig

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Signature file v4.1
2-
#Version 1.10.0
2+
#Version 1.14.0
33

44
CLSS public java.lang.Object
55
cons public init()
@@ -23,6 +23,35 @@ meth public void notifyLater(org.openide.NotifyDescriptor)
2323
supr org.openide.DialogDisplayer
2424
hfds context
2525

26+
CLSS public org.netbeans.modules.java.lsp.server.ui.AbstractGlobalActionContext
27+
cons public init()
28+
intf org.openide.util.ContextGlobalProvider
29+
intf org.openide.util.Lookup$Provider
30+
meth public org.openide.util.Lookup createGlobalContext()
31+
meth public org.openide.util.Lookup getLookup()
32+
meth public static <%0 extends java.lang.Object> {%%0} withActionContext(org.openide.util.Lookup,java.util.concurrent.Callable<{%%0}>)
33+
supr java.lang.Object
34+
hcls ContextHolder
35+
36+
CLSS public org.netbeans.modules.java.lsp.server.ui.AbstractLspHtmlViewer
37+
cons protected init()
38+
innr protected final View
39+
intf org.netbeans.spi.htmlui.HTMLViewerSpi<org.netbeans.modules.java.lsp.server.ui.AbstractLspHtmlViewer$View,java.lang.Object>
40+
meth public <%0 extends java.lang.Object> {%%0} component(org.netbeans.modules.java.lsp.server.ui.AbstractLspHtmlViewer$View,java.lang.Class<{%%0}>)
41+
meth public java.lang.Object createButton(org.netbeans.modules.java.lsp.server.ui.AbstractLspHtmlViewer$View,java.lang.String)
42+
meth public java.lang.String getId(org.netbeans.modules.java.lsp.server.ui.AbstractLspHtmlViewer$View,java.lang.Object)
43+
meth public org.netbeans.modules.java.lsp.server.ui.AbstractLspHtmlViewer$View newView(org.netbeans.spi.htmlui.HTMLViewerSpi$Context)
44+
meth public void runLater(org.netbeans.modules.java.lsp.server.ui.AbstractLspHtmlViewer$View,java.lang.Runnable)
45+
meth public void setEnabled(org.netbeans.modules.java.lsp.server.ui.AbstractLspHtmlViewer$View,java.lang.Object,boolean)
46+
meth public void setText(org.netbeans.modules.java.lsp.server.ui.AbstractLspHtmlViewer$View,java.lang.Object,java.lang.String)
47+
supr java.lang.Object
48+
hfds initial
49+
50+
CLSS protected final org.netbeans.modules.java.lsp.server.ui.AbstractLspHtmlViewer$View
51+
outer org.netbeans.modules.java.lsp.server.ui.AbstractLspHtmlViewer
52+
supr java.lang.Object
53+
hfds ctx,presenter,ui
54+
2655
CLSS public abstract org.netbeans.modules.java.lsp.server.ui.AbstractLspInputOutputProvider
2756
cons protected init()
2857
innr public final static LspIO
@@ -92,6 +121,7 @@ meth protected abstract java.util.concurrent.CompletableFuture<org.eclipse.lsp4j
92121
meth protected abstract org.openide.awt.StatusDisplayer$Message showStatusMessage(org.netbeans.modules.java.lsp.server.protocol.ShowStatusMessageParams)
93122
meth protected abstract void logMessage(org.eclipse.lsp4j.MessageParams)
94123
meth protected abstract void showMessage(org.eclipse.lsp4j.MessageParams)
124+
meth protected java.util.concurrent.CompletableFuture<java.lang.String> showHtmlPage(org.netbeans.modules.java.lsp.server.protocol.HtmlPageParams)
95125
meth public static org.netbeans.modules.java.lsp.server.ui.UIContext find()
96126
anno 0 org.netbeans.api.annotations.common.NonNull()
97127
meth public static org.netbeans.modules.java.lsp.server.ui.UIContext find(org.openide.util.Lookup)
@@ -104,6 +134,16 @@ CLSS public abstract interface org.netbeans.modules.progress.spi.ProgressEnviron
104134
meth public abstract org.netbeans.api.progress.ProgressHandle createHandle(java.lang.String,org.openide.util.Cancellable,boolean)
105135
meth public abstract org.netbeans.modules.progress.spi.Controller getController()
106136

137+
CLSS public abstract interface org.netbeans.spi.htmlui.HTMLViewerSpi<%0 extends java.lang.Object, %1 extends java.lang.Object>
138+
innr public final static Context
139+
meth public abstract <%0 extends java.lang.Object> {%%0} component({org.netbeans.spi.htmlui.HTMLViewerSpi%0},java.lang.Class<{%%0}>)
140+
meth public abstract java.lang.String getId({org.netbeans.spi.htmlui.HTMLViewerSpi%0},{org.netbeans.spi.htmlui.HTMLViewerSpi%1})
141+
meth public abstract void runLater({org.netbeans.spi.htmlui.HTMLViewerSpi%0},java.lang.Runnable)
142+
meth public abstract void setEnabled({org.netbeans.spi.htmlui.HTMLViewerSpi%0},{org.netbeans.spi.htmlui.HTMLViewerSpi%1},boolean)
143+
meth public abstract void setText({org.netbeans.spi.htmlui.HTMLViewerSpi%0},{org.netbeans.spi.htmlui.HTMLViewerSpi%1},java.lang.String)
144+
meth public abstract {org.netbeans.spi.htmlui.HTMLViewerSpi%0} newView(org.netbeans.spi.htmlui.HTMLViewerSpi$Context)
145+
meth public abstract {org.netbeans.spi.htmlui.HTMLViewerSpi%1} createButton({org.netbeans.spi.htmlui.HTMLViewerSpi%0},java.lang.String)
146+
107147
CLSS public abstract interface org.netbeans.spi.io.InputOutputProvider<%0 extends java.lang.Object, %1 extends java.io.PrintWriter, %2 extends java.lang.Object, %3 extends java.lang.Object>
108148
meth public abstract boolean isIOClosed({org.netbeans.spi.io.InputOutputProvider%0})
109149
anno 1 org.netbeans.api.annotations.common.NonNull()
@@ -190,3 +230,27 @@ supr java.lang.Object
190230
hfds INSTANCE
191231
hcls Trivial
192232

233+
CLSS public abstract interface org.openide.util.ContextGlobalProvider
234+
meth public abstract org.openide.util.Lookup createGlobalContext()
235+
236+
CLSS public abstract org.openide.util.Lookup
237+
cons public init()
238+
fld public final static org.openide.util.Lookup EMPTY
239+
innr public abstract interface static Provider
240+
innr public abstract static Item
241+
innr public abstract static Result
242+
innr public final static Template
243+
meth public <%0 extends java.lang.Object> java.util.Collection<? extends {%%0}> lookupAll(java.lang.Class<{%%0}>)
244+
meth public <%0 extends java.lang.Object> org.openide.util.Lookup$Item<{%%0}> lookupItem(org.openide.util.Lookup$Template<{%%0}>)
245+
meth public <%0 extends java.lang.Object> org.openide.util.Lookup$Result<{%%0}> lookupResult(java.lang.Class<{%%0}>)
246+
meth public abstract <%0 extends java.lang.Object> org.openide.util.Lookup$Result<{%%0}> lookup(org.openide.util.Lookup$Template<{%%0}>)
247+
meth public abstract <%0 extends java.lang.Object> {%%0} lookup(java.lang.Class<{%%0}>)
248+
meth public static org.openide.util.Lookup getDefault()
249+
supr java.lang.Object
250+
hfds LOG,defaultLookup,defaultLookupProvider
251+
hcls DefLookup,Empty
252+
253+
CLSS public abstract interface static org.openide.util.Lookup$Provider
254+
outer org.openide.util.Lookup
255+
meth public abstract org.openide.util.Lookup getLookup()
256+

java/java.lsp.server/nbproject/project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
javac.source=1.8
1919
javac.compilerargs=-Xlint -Xlint:-serial
20-
spec.version.base=1.13.0
20+
spec.version.base=1.14.0
2121
requires.nb.javac=true
2222
lsp.build.dir=vscode/nbcode
2323
test.unit.run.cp.extra=
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.netbeans.modules.java.lsp.server.htmlui;
20+
21+
import net.java.html.js.JavaScriptBody;
22+
import org.netbeans.spi.htmlui.HTMLViewerSpi;
23+
24+
/**
25+
* Helper utilities to deal with HTML buttons.
26+
*/
27+
public final class Buttons {
28+
private Buttons() {
29+
}
30+
31+
@JavaScriptBody(args = {}, body = "\n"
32+
+ "const vscode = acquireVsCodeApi();\n" // this method can be called only once per WebView existance
33+
+ "window.close = function() {\n"
34+
+ " vscode.postMessage({\n"
35+
+ " command: 'dispose',\n"
36+
+ " });\n"
37+
+ "};\n"
38+
)
39+
public static native void registerCloseWindow();
40+
41+
@JavaScriptBody(args = { "id", "callback" }, javacall = true, body = "\n"
42+
+ "var first = false;\n"
43+
+ "var footer = document.getElementById('dialog-buttons');\n"
44+
+ "if (!footer) {\n"
45+
+ " first = true\n"
46+
+ " footer = document.createElement('div');\n"
47+
+ " footer.id = 'dialog-buttons';\n"
48+
+ " footer.classList.add('flex');\n"
49+
+ " footer.classList.add('section');\n"
50+
+ " document.body.appendChild(footer);\n"
51+
+ "}\n"
52+
+ "var button = document.createElement('button');\n"
53+
+ "button.id = id;\n"
54+
+ "button.onclick = function() {;\n"
55+
+ " @org.netbeans.modules.java.lsp.server.htmlui.Buttons::clickButton0(Ljava/lang/String;Ljava/lang/Object;)(id, callback);\n"
56+
+ "};\n"
57+
+ "button.classList.add('regular-button');\n"
58+
+ "button.classList.add('vscode-font');\n"
59+
+ "if (first) {\n"
60+
+ " button.classList.add('align-right');\n"
61+
+ "}\n"
62+
+ "footer.appendChild(button);\n"
63+
+ "return button;\n"
64+
)
65+
public native static Object createButton0(String id, HTMLViewerSpi.Context callback);
66+
67+
static void clickButton0(String id, Object callback) {
68+
HTMLViewerSpi.Context ctx = (HTMLViewerSpi.Context) callback;
69+
ctx.onSubmit(id);
70+
}
71+
72+
@JavaScriptBody(args = { "b" }, body = "return b.id;")
73+
public native static String buttonName0(Object b);
74+
75+
@JavaScriptBody(args = { "b", "text" }, body = "b.innerHTML = text;")
76+
public native static void buttonText0(Object b, String text);
77+
78+
@JavaScriptBody(args = { "b", "disabled" }, body = "return b.disabled = disabled;")
79+
public native static String buttonDisabled0(Object b, boolean disabled);
80+
81+
}

0 commit comments

Comments
 (0)