@ -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<RemoteDesignerWorkspaceInfo> {
* 设置 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 < String > supplier , final String defaultName ) {
new SwingWorker < String , Void > ( ) {
@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 ( ) ;
}