Javafx: Support HTML template for web deployment. Save in config system-independent paths to template and properties. Test added (IDEA-104030)

This commit is contained in:
Pavel Dolgov
2016-04-15 17:22:37 +03:00
parent 526744bff5
commit a9e8f0b496
11 changed files with 269 additions and 89 deletions
@@ -65,6 +65,10 @@ public abstract class AbstractJavaFxPackager {
protected abstract String getHeight();
protected abstract String getHtmlTemplateFile();
protected abstract String getHtmlPlaceholderId();
protected abstract String getHtmlParamFile();
protected abstract String getParamFile();
@@ -106,7 +110,7 @@ public abstract class AbstractJavaFxPackager {
buf.append("<target name=\"build artifact\" xmlns:fx=\"javafx:com.sun.javafx.tools.ant\">");
final String artifactFileName = getArtifactRootName();
final List<JavaFxAntGenerator.SimpleTag> tags =
JavaFxAntGenerator.createJarAndDeployTasks(this, artifactFileName, getArtifactName(), tempUnzippedArtifactOutput.getPath(), false);
JavaFxAntGenerator.createJarAndDeployTasks(this, artifactFileName, getArtifactName(), tempUnzippedArtifactOutput.getPath(), tempDirectory.getPath(), null);
for (JavaFxAntGenerator.SimpleTag tag : tags) {
tag.generate(buf);
}
@@ -34,7 +34,8 @@ public class JavaFxAntGenerator {
String artifactFileName,
String artifactName,
String tempDirPath,
boolean isRelativeIconPath) {
String tempDirDeployPath,
String relativeToBaseDirPath) {
final String artifactFileNameWithoutExtension = FileUtil.getNameWithoutExtension(artifactFileName);
final List<SimpleTag> topLevelTagsCollector = new ArrayList<SimpleTag>();
final String preloaderJar = packager.getPreloaderJar();
@@ -100,7 +101,7 @@ public class JavaFxAntGenerator {
//create jar task
final SimpleTag createJarTag = new SimpleTag("fx:jar",
Couple.of("destfile", tempDirPath + File.separator + artifactFileName));
Couple.of("destfile", tempDirPath + "/" + artifactFileName));
createJarTag.add(new SimpleTag("fx:application", Couple.of("refid", appId)));
final List<Pair> fileset2Jar = new ArrayList<Pair>();
@@ -124,18 +125,21 @@ public class JavaFxAntGenerator {
topLevelTagsCollector.add(createJarTag);
final JavaFxPackagerConstants.NativeBundles bundle = packager.getNativeBundle();
final SimpleTag iconTag = appendApplicationIconPath(topLevelTagsCollector, bundle, packager.getIcons(), isRelativeIconPath);
final SimpleTag iconTag = appendApplicationIconPath(topLevelTagsCollector, bundle, packager.getIcons(), relativeToBaseDirPath);
//deploy task
final SimpleTag deployTag = new SimpleTag("fx:deploy",
Couple.of("width", packager.getWidth()),
Couple.of("height", packager.getHeight()),
Couple.of("updatemode", packager.getUpdateMode()),
Couple.of("outdir", tempDirPath + File.separator + "deploy"),
Couple.of("outdir", tempDirDeployPath),
Couple.of("outfile", artifactFileNameWithoutExtension));
if (bundle != JavaFxPackagerConstants.NativeBundles.none) {
if (bundle != null && bundle != JavaFxPackagerConstants.NativeBundles.none) {
deployTag.addAttribute(Couple.of("nativeBundles", bundle.name()));
}
if (!StringUtil.isEmpty(packager.getHtmlPlaceholderId())) {
deployTag.addAttribute(Couple.of("placeholderId", packager.getHtmlPlaceholderId()));
}
if (packager.isEnabledSigning()) {
deployTag.add(new SimpleTag("fx:permissions", Couple.of("elevated", "true")));
@@ -153,6 +157,8 @@ public class JavaFxAntGenerator {
if (iconTag != null) infoTag.add(iconTag);
}
deployTag.add(createResourcesTag(preloaderFiles, true, allButPreloader, allButSelf, all));
final SimpleTag templateTag = createTemplateTag(packager, tempDirDeployPath, relativeToBaseDirPath);
if (templateTag != null) deployTag.add(templateTag);
topLevelTagsCollector.add(deployTag);
return topLevelTagsCollector;
@@ -161,32 +167,32 @@ public class JavaFxAntGenerator {
private static SimpleTag appendApplicationIconPath(List<SimpleTag> topLevelTagsCollector,
JavaFxPackagerConstants.NativeBundles bundle,
JavaFxApplicationIcons appIcons,
boolean isRelativeIconPath) {
String relativeToPath) {
boolean haveAppIcon = false;
if (appIcons == null || bundle == null || appIcons.isEmpty()) return null;
if (bundle.isOnLinux()) {
String iconPath = appIcons.getLinuxIcon(isRelativeIconPath);
String iconPath = appIcons.getLinuxIcon(relativeToPath);
if (!StringUtil.isEmpty(iconPath)) {
final SimpleTag and = new SimpleTag("and");
and.add(new SimpleTag("os", Couple.of("family", "unix")));
final SimpleTag not = new SimpleTag("not");
not.add(new SimpleTag("os", Couple.of("family", "mac")));
and.add(not);
appendIconPropertyTag(topLevelTagsCollector, iconPath, isRelativeIconPath, and);
appendIconPropertyTag(topLevelTagsCollector, iconPath, relativeToPath != null, and);
haveAppIcon = true;
}
}
if (bundle.isOnMac()) {
String iconPath = appIcons.getMacIcon(isRelativeIconPath);
String iconPath = appIcons.getMacIcon(relativeToPath);
if (!StringUtil.isEmpty(iconPath)) {
appendIconPropertyTag(topLevelTagsCollector, iconPath, isRelativeIconPath, new SimpleTag("os", Couple.of("family", "mac")));
appendIconPropertyTag(topLevelTagsCollector, iconPath, relativeToPath != null, new SimpleTag("os", Couple.of("family", "mac")));
haveAppIcon = true;
}
}
if (bundle.isOnWindows()) {
String iconPath = appIcons.getWindowsIcon(isRelativeIconPath);
String iconPath = appIcons.getWindowsIcon(relativeToPath);
if (!StringUtil.isEmpty(iconPath)) {
appendIconPropertyTag(topLevelTagsCollector, iconPath, isRelativeIconPath, new SimpleTag("os", Couple.of("family", "windows")));
appendIconPropertyTag(topLevelTagsCollector, iconPath, relativeToPath != null, new SimpleTag("os", Couple.of("family", "windows")));
haveAppIcon = true;
}
}
@@ -221,6 +227,20 @@ public class JavaFxAntGenerator {
return resourcesTag;
}
private static SimpleTag createTemplateTag(AbstractJavaFxPackager packager, String deployOutDir, String relativeToBaseDirPath) {
String htmlTemplate = packager.getHtmlTemplateFile();
if (!StringUtil.isEmpty(htmlTemplate)) {
final String shortName = new File(htmlTemplate).getName();
if (!StringUtil.isEmpty(relativeToBaseDirPath)) {
htmlTemplate = "${basedir}/" + FileUtil.getRelativePath(relativeToBaseDirPath, htmlTemplate, '/');
}
return new SimpleTag("fx:template",
Couple.of("file", htmlTemplate),
Couple.of("tofile", deployOutDir + "/" + shortName));
}
return null;
}
private static void appendIfNotEmpty(final List<Pair> pairs, final String propertyName, final String propValue) {
if (!StringUtil.isEmptyOrSpaces(propValue)) {
pairs.add(Couple.of(propertyName, propValue));
@@ -11,14 +11,13 @@ public class JavaFxApplicationIcons {
private String myLinuxIcon;
private String myMacIcon;
private String myWindowsIcon;
private String myBaseDir;
public String getLinuxIcon() {
return myLinuxIcon;
}
public String getLinuxIcon(boolean isRelative) {
return isRelative ? getRelativeIcon(myLinuxIcon) : myLinuxIcon;
public String getLinuxIcon(String relativeToPath) {
return getRelativeIcon(relativeToPath, myLinuxIcon);
}
public void setLinuxIcon(String linuxIcon) {
@@ -29,8 +28,8 @@ public class JavaFxApplicationIcons {
return myMacIcon;
}
public String getMacIcon(boolean isRelative) {
return isRelative ? getRelativeIcon(myMacIcon) : myMacIcon;
public String getMacIcon(String relativeToPath) {
return getRelativeIcon(relativeToPath, myMacIcon);
}
public void setMacIcon(String macIcon) {
@@ -41,22 +40,14 @@ public class JavaFxApplicationIcons {
return myWindowsIcon;
}
public String getWindowsIcon(boolean isRelative) {
return isRelative ? getRelativeIcon(myWindowsIcon) : myWindowsIcon;
public String getWindowsIcon(String relativeToPath) {
return getRelativeIcon(relativeToPath, myWindowsIcon);
}
public void setWindowsIcon(String windowsIcon) {
myWindowsIcon = windowsIcon;
}
public String getBaseDir() {
return myBaseDir;
}
public void setBaseDir(String baseDir) {
myBaseDir = baseDir;
}
public boolean isEmpty() {
return StringUtil.isEmpty(myLinuxIcon) && StringUtil.isEmpty(myMacIcon) && StringUtil.isEmpty(myWindowsIcon);
}
@@ -71,7 +62,6 @@ public class JavaFxApplicationIcons {
if (myLinuxIcon != null ? !myLinuxIcon.equals(icons.myLinuxIcon) : icons.myLinuxIcon != null) return false;
if (myMacIcon != null ? !myMacIcon.equals(icons.myMacIcon) : icons.myMacIcon != null) return false;
if (myWindowsIcon != null ? !myWindowsIcon.equals(icons.myWindowsIcon) : icons.myWindowsIcon != null) return false;
if (myBaseDir != null ? !myBaseDir.equals(icons.myBaseDir) : icons.myBaseDir != null) return false;
return true;
}
@@ -81,14 +71,13 @@ public class JavaFxApplicationIcons {
int result = myLinuxIcon != null ? myLinuxIcon.hashCode() : 0;
result = 31 * result + (myMacIcon != null ? myMacIcon.hashCode() : 0);
result = 31 * result + (myWindowsIcon != null ? myWindowsIcon.hashCode() : 0);
result = 31 * result + (myBaseDir != null ? myBaseDir.hashCode() : 0);
return result;
}
@Nullable
private String getRelativeIcon(String icon) {
if (!StringUtil.isEmpty(icon) && !StringUtil.isEmpty(myBaseDir)) {
return FileUtil.getRelativePath(myBaseDir, icon, '/');
private static String getRelativeIcon(String relativeToPath, String icon) {
if (!StringUtil.isEmpty(icon) && !StringUtil.isEmpty(relativeToPath)) {
return FileUtil.getRelativePath(relativeToPath, icon, '/');
}
return icon;
}
@@ -34,7 +34,9 @@ public class JavaFxAntTaskTest extends UsefulTestCase{
private static final String TITLE = "title";
private static final String VERSION = "version";
private static final String ICONS = "icons";
private static final String RELATIVE_PATH = "relativePath";
private static final String BASE_DIR_PATH = "baseDirPath";
private static final String TEMPLATE = "template";
private static final String PLACEHOLDER = "placeholder";
private static final String PRELOADER_JAR = "preloaderJar";
private static final String SIGNED = "signed";
@@ -147,8 +149,8 @@ public class JavaFxAntTaskTest extends UsefulTestCase{
"</fx:fileset>\n" +
"</fx:resources>\n" +
"</fx:deploy>\n", new ContainerUtil.ImmutableMapBuilder<String, String>()
.put(ICONS, "/project_dir/app_icon.png,/project_dir/app_icon.icns,/project_dir/app_icon.ico,/project_dir")
.put(RELATIVE_PATH, "true")
.put(ICONS, "/project_dir/app_icon.png,/project_dir/app_icon.icns,/project_dir/app_icon.ico")
.put(BASE_DIR_PATH, "/project_dir")
.build());
}
@@ -200,10 +202,8 @@ public class JavaFxAntTaskTest extends UsefulTestCase{
"<fx:fileset refid=\"all_jarDeployIconAbsolute\">\n" +
"</fx:fileset>\n" +
"</fx:resources>\n" +
"</fx:deploy>\n", new ContainerUtil.ImmutableMapBuilder<String, String>()
.put(ICONS, "/project_dir/app_icon.png,/project_dir/app_icon.icns,/project_dir/app_icon.ico,/project_dir")
.put(RELATIVE_PATH, "false")
.build());
"</fx:deploy>\n",
Collections.singletonMap(ICONS, "/project_dir/app_icon.png,/project_dir/app_icon.icns,/project_dir/app_icon.ico"));
}
public void testJarDeployVersion() throws Exception {
@@ -235,6 +235,41 @@ public class JavaFxAntTaskTest extends UsefulTestCase{
"</fx:deploy>\n", Collections.singletonMap(VERSION, "4.2"));
}
public void testJarDeployTemplate() throws Exception {
doTest("<fx:fileset id=\"all_but_jarDeployTemplate\" dir=\"temp\" includes=\"**/*.jar\">\n" +
"<exclude name=\"jarDeployTemplate.jar\">\n" +
"</exclude>\n" +
"</fx:fileset>\n" +
"<fx:fileset id=\"all_jarDeployTemplate\" dir=\"temp\" includes=\"**/*.jar\">\n" +
"</fx:fileset>\n" +
"<fx:application id=\"jarDeployTemplate_id\" name=\"jarDeployTemplate\" mainClass=\"Main\">\n" +
"</fx:application>\n" +
"<fx:jar destfile=\"temp/jarDeployTemplate.jar\">\n" +
"<fx:application refid=\"jarDeployTemplate_id\">\n" +
"</fx:application>\n" +
"<fileset dir=\"temp\" excludes=\"**/*.jar\">\n" +
"</fileset>\n" +
"<fx:resources>\n" +
"<fx:fileset refid=\"all_but_jarDeployTemplate\">\n" +
"</fx:fileset>\n" +
"</fx:resources>\n" +
"</fx:jar>\n" +
"<fx:deploy width=\"800\" height=\"400\" updatemode=\"background\" outdir=\"temp/deploy\" outfile=\"jarDeployTemplate\" placeholderId=\"app-placeholder-id\">\n" +
"<fx:application refid=\"jarDeployTemplate_id\">\n" +
"</fx:application>\n" +
"<fx:resources>\n" +
"<fx:fileset refid=\"all_jarDeployTemplate\">\n" +
"</fx:fileset>\n" +
"</fx:resources>\n" +
"<fx:template file=\"${basedir}/app_template.html\" tofile=\"temp/deploy/app_template.html\">\n" +
"</fx:template>\n" +
"</fx:deploy>\n", new ContainerUtil.ImmutableMapBuilder<String, String>()
.put(TEMPLATE, "/project_dir/app_template.html")
.put(PLACEHOLDER, "app-placeholder-id")
.put(BASE_DIR_PATH, "/project_dir")
.build());
}
public void testJarDeploySigned() throws Exception {
doTest("<fx:fileset id=\"all_but_jarDeploySigned\" dir=\"temp\" includes=\"**/*.jar\">\n" +
"<exclude name=\"jarDeploySigned.jar\">\n" +
@@ -323,7 +358,7 @@ public class JavaFxAntTaskTest extends UsefulTestCase{
packager.setVersion(version);
}
boolean isRelativeIconPath = Boolean.valueOf(options.get(RELATIVE_PATH));
String relativeToBaseDirPath = options.get(BASE_DIR_PATH);
final String icon = options.get(ICONS);
if (icon != null) {
final String[] icons = icon.split(",");
@@ -331,11 +366,19 @@ public class JavaFxAntTaskTest extends UsefulTestCase{
appIcons.setLinuxIcon(icons[0]);
appIcons.setMacIcon(icons[1]);
appIcons.setWindowsIcon(icons[2]);
appIcons.setBaseDir(icons[3]);
packager.setIcons(appIcons);
packager.setNativeBundle(JavaFxPackagerConstants.NativeBundles.all);
}
final String template = options.get(TEMPLATE);
if (template != null) {
packager.setHtmlTemplate(template);
}
final String placeholder = options.get(PLACEHOLDER);
if (placeholder != null) {
packager.setHtmlPlaceholderId(placeholder);
}
final String preloaderClass = options.get(PRELOADER_CLASS);
if (preloaderClass != null) {
packager.setPreloaderClass(preloaderClass);
@@ -351,7 +394,7 @@ public class JavaFxAntTaskTest extends UsefulTestCase{
}
final List<JavaFxAntGenerator.SimpleTag> temp = JavaFxAntGenerator
.createJarAndDeployTasks(packager, artifactFileName, artifactName, "temp", isRelativeIconPath);
.createJarAndDeployTasks(packager, artifactFileName, artifactName, "temp", "temp" + File.separator + "deploy", relativeToBaseDirPath);
final StringBuilder buf = new StringBuilder();
for (JavaFxAntGenerator.SimpleTag tag : temp) {
tag.generate(buf);
@@ -369,6 +412,8 @@ public class JavaFxAntTaskTest extends UsefulTestCase{
private String myVendor;
private String myDescription;
private String myVersion;
private String myHtmlTemplate;
private String myHtmlPlaceholderId;
private String myHtmlParams;
private String myParams;
private String myPreloaderClass;
@@ -400,6 +445,14 @@ public class JavaFxAntTaskTest extends UsefulTestCase{
myVersion = version;
}
private void setHtmlTemplate(String htmlTemplate) {
myHtmlTemplate = htmlTemplate;
}
private void setHtmlPlaceholderId(String htmlPlaceholderId) {
myHtmlPlaceholderId = htmlPlaceholderId;
}
private void setHtmlParams(String htmlParams) {
myHtmlParams = htmlParams;
}
@@ -478,6 +531,16 @@ public class JavaFxAntTaskTest extends UsefulTestCase{
return "400";
}
@Override
public String getHtmlTemplateFile() {
return myHtmlTemplate;
}
@Override
public String getHtmlPlaceholderId() {
return myHtmlPlaceholderId;
}
@Override
protected String getHtmlParamFile() {
return myHtmlParams;
@@ -175,6 +175,16 @@ public class JpsJavaFxArtifactBuildTaskProvider extends ArtifactBuildTaskProvide
myCompileContext.processMessage(new CompilerMessage(COMPILER_NAME, BuildMessage.Kind.ERROR, message));
}
@Override
protected String getHtmlTemplateFile() {
return myProperties.myState.getHtmlTemplateFile();
}
@Override
protected String getHtmlPlaceholderId() {
return myProperties.myState.getHtmlPlaceholderId();
}
@Override
protected String getHtmlParamFile() {
return myProperties.myState.getHtmlParamFile();
@@ -31,6 +31,8 @@ public class JpsJavaFxArtifactProperties extends JpsElementBase<JpsJavaFxArtifac
myState.setVersion(state.myVersion);
myState.setWidth(state.myWidth);
myState.setHeight(state.myHeight);
myState.setHtmlTemplateFile(state.myHtmlTemplateFile);
myState.setHtmlPlaceholderId(state.myHtmlPlaceholderId);
myState.setHtmlParamFile(state.myHtmlParamFile);
myState.setParamFile(state.myParamFile);
myState.setUpdateMode(state.myUpdateMode);
@@ -65,6 +67,8 @@ public class JpsJavaFxArtifactProperties extends JpsElementBase<JpsJavaFxArtifac
private String myVersion;
private String myWidth = JavaFxPackagerConstants.DEFAULT_WEIGHT;
private String myHeight = JavaFxPackagerConstants.DEFAULT_HEIGHT;
private String myHtmlTemplateFile;
private String myHtmlPlaceholderId;
private String myHtmlParamFile;
private String myParamFile;
private String myUpdateMode = JavaFxPackagerConstants.UPDATE_MODE_BACKGROUND;
@@ -143,6 +147,22 @@ public class JpsJavaFxArtifactProperties extends JpsElementBase<JpsJavaFxArtifac
myHeight = height;
}
public String getHtmlTemplateFile() {
return myHtmlTemplateFile;
}
public void setHtmlTemplateFile(String htmlTemplateFile) {
myHtmlTemplateFile = htmlTemplateFile;
}
public String getHtmlPlaceholderId() {
return myHtmlPlaceholderId;
}
public void setHtmlPlaceholderId(String htmlPlaceholderId) {
myHtmlPlaceholderId = htmlPlaceholderId;
}
public String getHtmlParamFile() {
return myHtmlParamFile;
}
@@ -7,7 +7,6 @@ import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
@@ -28,9 +27,9 @@ public class JavaFxApplicationIconsDialog extends DialogWrapper {
init();
if (icons != null) {
setSystemDependentPath(myPanel.myLinuxIconPath, icons.getLinuxIcon());
setSystemDependentPath(myPanel.myMacIconPath, icons.getMacIcon());
setSystemDependentPath(myPanel.myWindowsIconPath, icons.getWindowsIcon());
JavaFxArtifactPropertiesEditor.setSystemDependentPath(myPanel.myLinuxIconPath, icons.getLinuxIcon());
JavaFxArtifactPropertiesEditor.setSystemDependentPath(myPanel.myMacIconPath, icons.getMacIcon());
JavaFxArtifactPropertiesEditor.setSystemDependentPath(myPanel.myWindowsIconPath, icons.getWindowsIcon());
}
addBrowseListener(myPanel.myLinuxIconPath, "png", project);
@@ -58,23 +57,12 @@ public class JavaFxApplicationIconsDialog extends DialogWrapper {
@NotNull
public JavaFxApplicationIcons getIcons() {
JavaFxApplicationIcons icons = new JavaFxApplicationIcons();
icons.setLinuxIcon(getSystemIndependentPath(myPanel.myLinuxIconPath));
icons.setMacIcon(getSystemIndependentPath(myPanel.myMacIconPath));
icons.setWindowsIcon(getSystemIndependentPath(myPanel.myWindowsIconPath));
icons.setBaseDir(myProject.getBasePath());
icons.setLinuxIcon(JavaFxArtifactPropertiesEditor.getSystemIndependentPath(myPanel.myLinuxIconPath));
icons.setMacIcon(JavaFxArtifactPropertiesEditor.getSystemIndependentPath(myPanel.myMacIconPath));
icons.setWindowsIcon(JavaFxArtifactPropertiesEditor.getSystemIndependentPath(myPanel.myWindowsIconPath));
return icons;
}
private static String getSystemIndependentPath(TextFieldWithBrowseButton withBrowseButton) {
final String text = withBrowseButton.getText();
if (StringUtil.isEmptyOrSpaces(text)) return null;
return FileUtil.toSystemIndependentName(text.trim());
}
private static void setSystemDependentPath(TextFieldWithBrowseButton withBrowseButton, String path) {
withBrowseButton.setText(!StringUtil.isEmptyOrSpaces(path) ? FileUtil.toSystemDependentName(path) : "");
}
private boolean isValidPath(TextFieldWithBrowseButton withBrowseButton, ProjectFileIndex index, String osName) {
final String text = withBrowseButton.getText();
if (StringUtil.isEmptyOrSpaces(text)) return true;
@@ -60,6 +60,8 @@ public class JavaFxArtifactProperties extends ArtifactProperties<JavaFxArtifactP
private String myVersion;
private String myWidth = JavaFxPackagerConstants.DEFAULT_WEIGHT;
private String myHeight = JavaFxPackagerConstants.DEFAULT_HEIGHT;
private String myHtmlTemplateFile;
private String myHtmlPlaceholderId;
private String myHtmlParamFile;
private String myParamFile;
private String myUpdateMode = JavaFxPackagerConstants.UPDATE_MODE_BACKGROUND;
@@ -191,6 +193,22 @@ public class JavaFxArtifactProperties extends ArtifactProperties<JavaFxArtifactP
myHeight = height;
}
public String getHtmlTemplateFile() {
return myHtmlTemplateFile;
}
public void setHtmlTemplateFile(String htmlTemplateFile) {
myHtmlTemplateFile = htmlTemplateFile;
}
public String getHtmlPlaceholderId() {
return myHtmlPlaceholderId;
}
public void setHtmlPlaceholderId(String htmlPlaceholderId) {
myHtmlPlaceholderId = htmlPlaceholderId;
}
public String getHtmlParamFile() {
return myHtmlParamFile;
}
@@ -413,6 +431,16 @@ public class JavaFxArtifactProperties extends ArtifactProperties<JavaFxArtifactP
return myProperties.isConvertCss2Bin();
}
@Override
protected String getHtmlTemplateFile() {
return myProperties.getHtmlTemplateFile();
}
@Override
protected String getHtmlPlaceholderId() {
return myProperties.getHtmlPlaceholderId();
}
@Override
protected String getHtmlParamFile() {
return myProperties.getHtmlParamFile();
@@ -8,7 +8,7 @@
<properties/>
<border type="none"/>
<children>
<grid id="ca833" layout-manager="GridLayoutManager" row-count="15" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="ca833" layout-manager="GridLayoutManager" row-count="17" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -123,10 +123,42 @@
</constraints>
<properties/>
</component>
<component id="d5f8c" class="javax.swing.JLabel">
<component id="74232" class="javax.swing.JLabel">
<constraints>
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="26da8"/>
<text value="HT&amp;ML Template:"/>
</properties>
</component>
<component id="26da8" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myHtmlTemplate">
<constraints>
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="665bb" class="javax.swing.JLabel">
<constraints>
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="a217c"/>
<text value="HTML Placeh&amp;older Id:"/>
</properties>
</component>
<component id="a217c" class="javax.swing.JTextField" binding="myHtmlPlaceholderIdTF">
<constraints>
<grid row="8" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="d5f8c" class="javax.swing.JLabel">
<constraints>
<grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="b2b7a"/>
<text value="HTM&amp;L Parameters:"/>
@@ -134,13 +166,13 @@
</component>
<component id="b2b7a" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myHtmlParams">
<constraints>
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="9" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="db3d4" class="javax.swing.JLabel">
<constraints>
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="10" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="be63e"/>
@@ -149,13 +181,13 @@
</component>
<component id="be63e" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myParams">
<constraints>
<grid row="8" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="10" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="4a8b2" class="javax.swing.JCheckBox" binding="myUpdateInBackgroundCB">
<constraints>
<grid row="9" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="11" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Update in &amp;background"/>
@@ -163,7 +195,7 @@
</component>
<component id="b03bd" class="javax.swing.JCheckBox" binding="myEnableSigningCB">
<constraints>
<grid row="12" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="14" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Enable &amp;signing"/>
@@ -172,7 +204,7 @@
<grid id="506ce" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="12" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="14" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -194,7 +226,7 @@
</grid>
<component id="8bb5f" class="javax.swing.JCheckBox" binding="myConvertCssToBinCheckBox" default-binding="true">
<constraints>
<grid row="11" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="13" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Convert css to bin"/>
@@ -202,7 +234,7 @@
</component>
<component id="9164e" class="javax.swing.JLabel">
<constraints>
<grid row="10" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="12" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="2acc4"/>
@@ -211,13 +243,13 @@
</component>
<component id="2acc4" class="javax.swing.JComboBox" binding="myNativeBundleCB">
<constraints>
<grid row="10" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
<grid row="12" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="7d6a7" class="javax.swing.JLabel">
<constraints>
<grid row="13" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="15" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Custom manifest attributes"/>
@@ -226,7 +258,7 @@
<grid id="cd6c2" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="13" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="15" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -236,7 +268,7 @@
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Edit Attributes"/>
<text value="Edit &amp;Attributes"/>
</properties>
</component>
<hspacer id="20f71">
@@ -249,7 +281,7 @@
<grid id="9d065" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="14" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="16" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -259,7 +291,7 @@
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Edit Icons"/>
<text value="Edit Ico&amp;ns"/>
</properties>
</component>
<hspacer id="3a5bd">
@@ -271,7 +303,7 @@
</grid>
<component id="b08ee" class="javax.swing.JLabel">
<constraints>
<grid row="14" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="16" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Application icon"/>
@@ -283,7 +315,7 @@
</constraints>
<properties>
<labelFor value="78c4b"/>
<text value="V&amp;ersion"/>
<text value="V&amp;ersion:"/>
</properties>
</component>
<component id="78c4b" class="javax.swing.JTextField" binding="myVersionTF">
@@ -23,6 +23,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.packaging.artifacts.Artifact;
import com.intellij.packaging.ui.ArtifactPropertiesEditor;
@@ -55,6 +56,8 @@ public class JavaFxArtifactPropertiesEditor extends ArtifactPropertiesEditor {
private JTextField myVersionTF;
private JTextField myWidthTF;
private JTextField myHeightTF;
private TextFieldWithBrowseButton myHtmlTemplate;
private JTextField myHtmlPlaceholderIdTF;
private TextFieldWithBrowseButton myHtmlParams;
private TextFieldWithBrowseButton myParams;
private JCheckBox myUpdateInBackgroundCB;
@@ -75,6 +78,8 @@ public class JavaFxArtifactPropertiesEditor extends ArtifactPropertiesEditor {
final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileDescriptor(StdFileTypes.PROPERTIES);
myHtmlParams.addBrowseFolderListener("Choose Properties File", "Parameters for the resulting application to run standalone.", project, descriptor);
myParams.addBrowseFolderListener("Choose Properties File", "Parameters for the resulting application to run in the browser.", project, descriptor);
myHtmlTemplate.addBrowseFolderListener("Choose HTML File", "HTML template for application entry point to run in browser", project,
FileChooserDescriptorFactory.createSingleFileDescriptor(StdFileTypes.HTML));
myEditSignCertificateButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@@ -130,8 +135,10 @@ public class JavaFxArtifactPropertiesEditor extends ArtifactPropertiesEditor {
if (isModified(myProperties.getHeight(), myHeightTF)) return true;
if (isModified(myProperties.getAppClass(), myAppClass)) return true;
if (isModified(myProperties.getVersion(), myVersionTF)) return true;
if (isModified(myProperties.getHtmlParamFile(), myHtmlParams)) return true;
if (isModified(myProperties.getParamFile(), myParams)) return true;
if (isModified(myProperties.getHtmlTemplateFile(), getSystemIndependentPath(myHtmlTemplate))) return true;
if (isModified(myProperties.getHtmlPlaceholderId(), myHtmlPlaceholderIdTF)) return true;
if (isModified(myProperties.getHtmlParamFile(), getSystemIndependentPath(myHtmlParams))) return true;
if (isModified(myProperties.getParamFile(), getSystemIndependentPath(myParams))) return true;
if (!Comparing.equal(myNativeBundleCB.getSelectedItem(), myProperties.getNativeBundle())) return true;
final boolean inBackground = Comparing.strEqual(myProperties.getUpdateMode(), JavaFxPackagerConstants.UPDATE_MODE_BACKGROUND);
if (inBackground != myUpdateInBackgroundCB.isSelected()) return true;
@@ -160,6 +167,10 @@ public class JavaFxArtifactPropertiesEditor extends ArtifactPropertiesEditor {
return !Comparing.strEqual(title, tf.getText().trim());
}
private static boolean isModified(final String title, String value) {
return !Comparing.strEqual(title, value);
}
@Override
public void apply() {
myProperties.setTitle(myTitleTF.getText());
@@ -169,8 +180,10 @@ public class JavaFxArtifactPropertiesEditor extends ArtifactPropertiesEditor {
myProperties.setVersion(myVersionTF.getText());
myProperties.setWidth(myWidthTF.getText());
myProperties.setHeight(myHeightTF.getText());
myProperties.setHtmlParamFile(myHtmlParams.getText());
myProperties.setParamFile(myParams.getText());
myProperties.setHtmlTemplateFile(getSystemIndependentPath(myHtmlTemplate));
myProperties.setHtmlPlaceholderId(myHtmlPlaceholderIdTF.getText());
myProperties.setHtmlParamFile(getSystemIndependentPath(myHtmlParams));
myProperties.setParamFile(getSystemIndependentPath(myParams));
myProperties.setUpdateMode(myUpdateInBackgroundCB.isSelected() ? JavaFxPackagerConstants.UPDATE_MODE_BACKGROUND
: JavaFxPackagerConstants.UPDATE_MODE_ALWAYS);
myProperties.setEnabledSigning(myEnableSigningCB.isSelected());
@@ -205,8 +218,10 @@ public class JavaFxArtifactPropertiesEditor extends ArtifactPropertiesEditor {
setText(myHeightTF, myProperties.getHeight());
setText(myAppClass, myProperties.getAppClass());
setText(myVersionTF, myProperties.getVersion());
setText(myHtmlParams, myProperties.getHtmlParamFile());
setText(myParams, myProperties.getParamFile());
setSystemDependentPath(myHtmlTemplate, myProperties.getHtmlTemplateFile());
setText(myHtmlPlaceholderIdTF, myProperties.getHtmlPlaceholderId());
setSystemDependentPath(myHtmlParams, myProperties.getHtmlParamFile());
setSystemDependentPath(myParams, myProperties.getParamFile());
myNativeBundleCB.setSelectedItem(myProperties.getNativeBundle());
myUpdateInBackgroundCB.setSelected(Comparing.strEqual(myProperties.getUpdateMode(), JavaFxPackagerConstants.UPDATE_MODE_BACKGROUND));
myEnableSigningCB.setSelected(myProperties.isEnabledSigning());
@@ -235,6 +250,16 @@ public class JavaFxArtifactPropertiesEditor extends ArtifactPropertiesEditor {
}
}
static String getSystemIndependentPath(TextFieldWithBrowseButton withBrowseButton) {
final String text = withBrowseButton.getText();
if (StringUtil.isEmptyOrSpaces(text)) return null;
return FileUtil.toSystemIndependentName(text.trim());
}
static void setSystemDependentPath(TextFieldWithBrowseButton withBrowseButton, String path) {
withBrowseButton.setText(path != null ? FileUtil.toSystemDependentName(path.trim()) : "");
}
private static class CustomManifestAttributesDialog extends DialogWrapper {
private final JPanel myWholePanel = new JPanel(new BorderLayout());
private final AttributesTable myTable;
@@ -145,8 +145,9 @@ public class JavaFxChunkBuildExtension extends ChunkBuildExtension {
@Override
protected void registerJavaFxPackagerError(String message) {}
};
final List<JavaFxAntGenerator.SimpleTag> tags =
JavaFxAntGenerator.createJarAndDeployTasks(javaFxPackager, artifactFileName, artifact.getName(), tempDirPath, true);
final String tempDirDeployPath = tempDirPath + "/deploy";
final List<JavaFxAntGenerator.SimpleTag> tags =
JavaFxAntGenerator.createJarAndDeployTasks(javaFxPackager, artifactFileName, artifact.getName(), tempDirPath, tempDirDeployPath, context.getProject().getBasePath());
for (JavaFxAntGenerator.SimpleTag tag : tags) {
buildTags(generator, tag);
}
@@ -181,14 +182,14 @@ public class JavaFxChunkBuildExtension extends ChunkBuildExtension {
}
final Tag signjar = new Tag("signjar", keysDescriptions);
final Tag fileset = new Tag("fileset", Couple.of("dir", tempDirPath + "/deploy"));
final Tag fileset = new Tag("fileset", Couple.of("dir", tempDirDeployPath));
fileset.add(new Tag("include", Couple.of("name", "*.jar")));
signjar.add(fileset);
generator.add(signjar);
}
final DirectoryAntCopyInstructionCreator creator = new DirectoryAntCopyInstructionCreator(BuildProperties.propertyRef(context.getConfiguredArtifactOutputProperty(artifact)));
generator.add(creator.createDirectoryContentCopyInstruction(tempDirPath + "/deploy"));
generator.add(creator.createDirectoryContentCopyInstruction(tempDirDeployPath));
final Tag deleteTag = new Tag("delete", Couple.of("includeemptydirs", "true"));
deleteTag.add(new Tag("fileset", Couple.of("dir", tempDirPath)));
generator.add(deleteTag);