|
|
|
package com.fr.startup.ui;
|
|
|
|
|
|
|
|
import com.fr.base.svg.SVGIcon;
|
|
|
|
import com.fr.design.env.DesignerWorkspaceType;
|
|
|
|
import com.fr.log.FineLoggerFactory;
|
|
|
|
|
|
|
|
import javax.swing.Icon;
|
|
|
|
import java.net.URL;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* created by Harrison on 2022/07/11
|
|
|
|
**/
|
|
|
|
public class StartupPageUtil {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取最近区域的 ICON
|
|
|
|
*
|
|
|
|
* @param workspaceBean 工作目录
|
|
|
|
* @return 图标
|
|
|
|
*/
|
|
|
|
public static Icon getIcon4RecentAreaByWorkspace(StartupWorkspaceBean workspaceBean) {
|
|
|
|
|
|
|
|
if (workspaceBean.getType() == DesignerWorkspaceType.Local) {
|
|
|
|
return SVGIcon.readSVGIcon("/com/fr/design/startup/local_server_background_36.svg", 36, 36);
|
|
|
|
}
|
|
|
|
return SVGIcon.readSVGIcon("/com/fr/design/startup/remote_server_background_36.svg", 36, 36);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取工作目录描述区域的 ICON
|
|
|
|
*
|
|
|
|
* @param workspaceBean 工作目录
|
|
|
|
* @return 图标
|
|
|
|
*/
|
|
|
|
public static Icon getIcon4DescAreaByWorkspace(StartupWorkspaceBean workspaceBean) {
|
|
|
|
|
|
|
|
if (workspaceBean.getType() == DesignerWorkspaceType.Local) {
|
|
|
|
return SVGIcon.readSVGIcon("/com/fr/design/startup/local_server_background_28.svg", 28, 28);
|
|
|
|
}
|
|
|
|
return SVGIcon.readSVGIcon("/com/fr/design/startup/remote_server_background_28.svg", 28, 28);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 返回 ip : port
|
|
|
|
*
|
|
|
|
* @param urlStr 完整的 url 值,例如 https://localhost:3090/xxx
|
|
|
|
* @return localhost:3090
|
|
|
|
*/
|
|
|
|
public static String getRemoteAddress(String urlStr) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
URL url = new URL(urlStr);
|
|
|
|
String host = url.getHost();
|
|
|
|
int port = url.getPort();
|
|
|
|
return host + ":" + port;
|
|
|
|
} catch (Exception e) {
|
|
|
|
FineLoggerFactory.getLogger().debug(e.getMessage(), e);
|
|
|
|
return urlStr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|