From b170de527b7a3b7f3fc56f0c7d0abcae24127480 Mon Sep 17 00:00:00 2001 From: hades Date: Thu, 6 Aug 2020 15:51:42 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-36404=20=E8=BF=9C=E7=A8=8B-=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=99=A8=E6=96=AD=E5=BC=80=E5=90=8E=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E6=9C=AA=E5=BC=B9=E5=87=BA=E5=B7=A5=E4=BD=9C=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E9=80=89=E6=8B=A9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/env/RemoteEnvPane.java | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java index 3c481ba303..37c4cd41a1 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java @@ -44,6 +44,7 @@ import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.File; +import java.util.function.Supplier; import static com.fr.design.layout.TableLayout.FILL; import static com.fr.design.layout.TableLayout.PREFERRED; @@ -439,20 +440,29 @@ public class RemoteEnvPane extends BasicBeanPane { * 设置 app 和 servlet 默认值 */ private void setDefaultAppAndServlet() { - String appName; - String servletName; - try { - appName = FRContext.getCommonOperator().getAppName(); - } catch (Exception ignored) { - appName = RemoteWorkspaceURL.DEFAULT_WEB_APP_NAME; - } - try { - servletName = ServerConfig.getInstance().getServletName(); - } catch (Exception ignored) { - servletName = RemoteWorkspaceURL.DEFAULT_SERVLET_NAME; - } - webAppNameInput.setText(appName); - servletNameInput.setText(servletName); + setWrap(webAppNameInput, () -> FRContext.getCommonOperator().getAppName(), RemoteWorkspaceURL.DEFAULT_WEB_APP_NAME); + setWrap(servletNameInput, () -> ServerConfig.getInstance().getServletName(), RemoteWorkspaceURL.DEFAULT_SERVLET_NAME); + } + + private void setWrap(final UITextField textField, final Supplier supplier, final String defaultName) { + new SwingWorker() { + + @Override + protected String doInBackground() throws Exception { + return supplier.get(); + } + + @Override + protected void done() { + String name = defaultName; + try { + name = get(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage() , e); + } + textField.setText(name); + } + }.execute(); }