You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
2.8 KiB
87 lines
2.8 KiB
package com.fr.design.actions.help; |
|
|
|
import com.fr.design.i18n.LocaleLinkProvide; |
|
import com.fr.design.i18n.Toolkit; |
|
import com.fr.design.login.AbstractDesignerSSO; |
|
import com.fr.design.menu.MenuKeySet; |
|
import com.fr.general.GeneralContext; |
|
import com.fr.general.http.HttpToolbox; |
|
import com.fr.stable.CommonUtils; |
|
import com.fr.stable.ProductConstants; |
|
import com.fr.stable.StringUtils; |
|
import com.fr.third.org.apache.http.HttpStatus; |
|
import com.fr.third.org.apache.http.StatusLine; |
|
import com.fr.third.org.apache.http.client.methods.HttpGet; |
|
|
|
import javax.swing.KeyStroke; |
|
import java.awt.event.KeyEvent; |
|
|
|
public class TutorialAction extends AbstractDesignerSSO { |
|
|
|
/** |
|
* 云中心社区帮助文档在配置文件中对应的配置文件key |
|
*/ |
|
private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Help"; |
|
|
|
/** |
|
* 云中心社区帮助文档默认链接在配置文件中对应的配置文件key |
|
*/ |
|
private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Help_Default"; |
|
|
|
public TutorialAction() { |
|
this.setMenuKeySet(HELP_TUTORIAL); |
|
this.setName(getMenuKeySet().getMenuName()); |
|
this.setMnemonic(getMenuKeySet().getMnemonic()); |
|
this.setSmallIcon("/com/fr/design/images/bbs/help"); |
|
this.setAccelerator(getMenuKeySet().getKeyStroke()); |
|
} |
|
|
|
@Override |
|
public String getJumpUrl() { |
|
return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); |
|
} |
|
|
|
// 生成帮助文档 sitecenter key, help.zh_CN.10 |
|
protected String createDocKey() { |
|
String locale = GeneralContext.getLocale().toString(); |
|
return CommonUtils.join(new String[]{"help", locale, ProductConstants.MAIN_VERSION}, "."); |
|
} |
|
|
|
// 判断是否可以访问在线文档 |
|
protected boolean isServerOnline(String url) { |
|
if (StringUtils.isEmpty(url)) { |
|
return false; |
|
} |
|
|
|
HttpGet getHelp = new HttpGet(url); |
|
try { |
|
StatusLine statusLine = HttpToolbox.getHttpClient(url).execute(getHelp).getStatusLine(); |
|
return statusLine.getStatusCode() == HttpStatus.SC_OK; |
|
} catch (Exception ignore) { |
|
// 网络异常 |
|
return false; |
|
} |
|
} |
|
|
|
public String getOffLineWarnMessage() { |
|
return Toolkit.i18nText("Fine-Design_Offline_Helptutorial_Msg"); |
|
} |
|
|
|
public static final MenuKeySet HELP_TUTORIAL = new MenuKeySet() { |
|
@Override |
|
public char getMnemonic() { |
|
return 'T'; |
|
} |
|
|
|
@Override |
|
public String getMenuName() { |
|
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help"); |
|
} |
|
|
|
@Override |
|
public KeyStroke getKeyStroke() { |
|
return KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0); |
|
} |
|
}; |
|
|
|
}
|
|
|