JaroslavTulach commented on a change in pull request #3349: URL: https://github.com/apache/netbeans/pull/3349#discussion_r760393404
########## File path: java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/refactoring/ChangeMethodParametersRefactoringAction.java ########## @@ -0,0 +1,84 @@ +/* + * 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.refactoring; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.IOException; +import javax.lang.model.element.Element; +import javax.lang.model.element.ElementKind; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.TypeElement; +import org.netbeans.api.java.source.ElementHandle; +import org.netbeans.api.java.source.JavaSource; +import org.openide.awt.ActionID; +import org.openide.awt.ActionReference; +import org.openide.awt.ActionRegistration; +import org.openide.filesystems.FileObject; +import org.openide.util.NbBundle.Messages; + +@ActionID( + category = "Refactoring", + id = "org.netbeans.modules.java.lsp.server.refactoring.ChangeMethodParametersRefactoringAction" +) +@ActionRegistration( + iconBase = "org/netbeans/modules/java/lsp/server/refactoring/newHTML.png", + displayName = "#CTL_ChangeMethodParametersRefactoringAction" +) +@ActionReference(path = "Menu/Refactoring", position = 1120) +@Messages("CTL_ChangeMethodParametersRefactoringAction=Change Method Parameters Refactoring") +public final class ChangeMethodParametersRefactoringAction implements ActionListener { + private final FileObject file; + + public ChangeMethodParametersRefactoringAction(FileObject file) { + this.file = file; + } + + @Override + public void actionPerformed(ActionEvent evt) { + JavaSource js = JavaSource.forFileObject(file); + if (js != null) { + try { + js.runUserActionTask(ci -> { + ci.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED); + ExecutableElement method = null; + METHOD: for (Element type : ci.getTopLevelElements()) { + for (Element e : type.getEnclosedElements()) { + System.err.println("e: " + e); + if (e.getKind() == ElementKind.METHOD) { + method = (ExecutableElement) e; + break METHOD; + } + } + } + if (method != null) { + ElementHandle<ExecutableElement> handle = ElementHandle.create(method); + ChangeMethodParameterUI[] model = {null}; Review comment: This action displays the same VSCode UI in NetBeans IDE! The CSS isn't optimized (e.g. no screenshot to share), but it does work (if the JDK has JavaFX libraries available). While the current effort is only targeted towards VSCode, ideally we can reuse the UIs on both sides in a future - in NetBeans IDE as well as VSCode. To do so following has to happen: - the HTML has to be (almost) without CSS - CSS is applied by the "chrome" and needs to be compatible with current L&F - modules using the UI in NetBeans IDE need a "presenter" - currently we use JavaFX web view as a presenter - e.g. it is necessary to install JavaFX libraries - we could show the UI in an external browser - so called "browser" presenter. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
