19 package org.turro.elephant.web.actions;
21 import org.turro.i18n.I_;
22 import org.turro.icon.Icons;
23 import org.turro.string.Strings;
32 private final String caption, url, icon;
35 this(type, caption, url,
null);
40 this.caption = caption;
50 if(Strings.isBlank(caption))
return switch(type) {
51 case NAVIGATE, ACTION, TAG, URL -> url;
52 case MAIL ->
I_.
get(
"Email");
53 case TEL ->
I_.
get(
"Call");
54 case WHATS ->
"Whatsapp";
55 case TGRAM ->
"Telegram";
56 case WRONG ->
"Wrong";
66 if(Strings.isBlank(icon))
return switch(type) {
67 case NAVIGATE, URL, TAG ->
"globe";
68 case MAIL ->
"envelope";
70 case ACTION ->
switch(url) {
71 case "singup" ->
"sign in alternate";
72 case "tellsomeone" ->
"satellite dish";
75 case WHATS ->
"whatsapp";
76 case TGRAM ->
"telegram";
77 case WRONG ->
"warning";
84 case NAVIGATE, TAG, ACTION, URL -> url;
85 case MAIL, TEL -> Strings.pastFirst(url,
":");
86 case WHATS -> Strings.pastLast(url,
"=");
87 case TGRAM -> Strings.pastLast(url,
"/");
88 case WRONG ->
"Wrong action found";
97 return url.matches(
"(http|https|ftp|sftp|ftps):.+");
101 return type ==
null || Strings.isBlank(caption) || Strings.isBlank(url);
104 private String pastProtocol() {
105 if(url.contains(
":")) {
106 return url.substring(url.indexOf(
":") + 1);
WebLink(WebActionType type, String caption, String url, String icon)
WebLink(WebActionType type, String caption, String url)
static WebLink from(WebLink webLink, String newCaption)
static String get(String msg)