allow products to customize default script name for 'Create Launcher Script' dialog (IDEA-CR-13319)

This commit is contained in:
nik
2016-11-24 15:13:06 +03:00
parent 8c5e438505
commit 174a12fae2
2 changed files with 10 additions and 1 deletions
@@ -38,6 +38,7 @@ public class ApplicationNamesInfo {
private String myFullProductName;
private String myLowercaseProductName;
private String myScriptName;
private String myDefaultLauncherName;
private static class ApplicationNamesInfoHolder {
private static final ApplicationNamesInfo ourInstance = new ApplicationNamesInfo();
@@ -66,6 +67,7 @@ public class ApplicationNamesInfo {
myFullProductName = names.getAttributeValue(ATTRIBUTE_FULL_NAME);
myLowercaseProductName = StringUtil.capitalize(myProductName.toLowerCase(Locale.US));
myScriptName = names.getAttributeValue(ATTRIBUTE_SCRIPT);
myDefaultLauncherName = names.getAttributeValue("default-launcher-name", myScriptName);
}
/**
@@ -99,6 +101,13 @@ public class ApplicationNamesInfo {
return myScriptName;
}
/**
* @return default name of the command-line launcher to be suggested in 'Create Launcher Script' dialog
*/
public String getDefaultLauncherName() {
return myDefaultLauncherName;
}
public static String getComponentName() {
String prefix = System.getProperty(PlatformUtils.PLATFORM_PREFIX_KEY);
return prefix != null ? prefix + COMPONENT_NAME : COMPONENT_NAME;
@@ -164,7 +164,7 @@ public class CreateLauncherScriptAction extends DumbAwareAction {
}
public static String defaultScriptPath() {
String scriptName = ApplicationNamesInfo.getInstance().getScriptName();
String scriptName = ApplicationNamesInfo.getInstance().getDefaultLauncherName();
if (StringUtil.isEmptyOrSpaces(scriptName)) scriptName = ApplicationNamesInfo.getInstance().getProductName().toLowerCase(Locale.US);
return "/usr/local/bin/" + scriptName;
}