Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
berry120 committed Dec 20, 2023
2 parents 04a328e + 66b0565 commit 9d5e3a7
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 59 deletions.
4 changes: 3 additions & 1 deletion Quelea/languages/gb.lang
Original file line number Diff line number Diff line change
Expand Up @@ -782,4 +782,6 @@ general.text.options=General Text Options
translation.text.options=Translation Text Options
use.default.translation.label=Use Default Translation
translation.name.label=Translation name
ccli.licence=CCLI Licence
ccli.licence=CCLI Licence
dialog.image.group.header=Image Group
dialog.image.group.title=Rename image group
122 changes: 105 additions & 17 deletions Quelea/scheduleformat.xsl
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo">
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xslt="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="fo">
<xsl:template match="*"></xsl:template>
<xsl:template match="schedule">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" font-family="Roboto">
<fo:layout-master-set>
Expand All @@ -12,24 +15,109 @@
<fo:block font-size="18pt" font-weight="bold" space-after="12pt">
<xsl:value-of select="title"/>
</fo:block>
<xsl:for-each select="song">
<fo:block space-after="10pt">
<xsl:value-of select="position()"/>.
<xsl:value-of select="title"/>
<xsl:choose>
<xsl:when test="author != ''">
- <xsl:value-of select="author"/>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="ccli != ''">
(CCLI <xsl:value-of select="ccli"/>)
</xsl:when>
</xsl:choose>
</fo:block>
</xsl:for-each>
<xsl:apply-templates select="*"/>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template name="row">
<xsl:param name = "content" />
<xsl:param name = "details" />
<fo:block space-after="24pt">
<xsl:value-of select="position() -1"/>.
<fo:inline font-size="12pt" padding-left="4mm" >
<xsl:value-of select = "$content" />
</fo:inline>
<fo:inline font-size="8pt" padding-left="22mm" font-style="italic">
<xsl:value-of select = "$details" />
</fo:inline>
</fo:block>
</xsl:template>
<xsl:template match="song">
<xsl:call-template name="row">
<xsl:with-param name="content">
<xsl:value-of select="title"/>
</xsl:with-param>
<xsl:with-param name="details">
<xsl:choose>
<xsl:when test="author != ''"><xsl:value-of select="author"/></xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="ccli != ''">(CCLI <xsl:value-of select="ccli"/>)</xsl:when>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template match="passage">
<xsl:call-template name="row">
<xsl:with-param name="content">
<xsl:value-of select="@summary"/>
</xsl:with-param>
<xsl:with-param name="details">
<xsl:choose>
<xsl:when test="@bible != ''">(<xsl:value-of select="@bible"/>) </xsl:when>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="file">
<xsl:param name = "filetype" />
<xsl:call-template name="row">
<xsl:with-param name="content">
<xsl:value-of select="$filetype"/>
</xsl:with-param>
<xsl:with-param name="details">
<fo:inline font-family="monospace"><xsl:value-of select="text()"/></fo:inline>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template match="fileaudio">
<xsl:call-template name="file">
<xsl:with-param name="filetype">
Audio
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template match="fileimage">
<xsl:call-template name="file">
<xsl:with-param name="filetype">
Image
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template match="filepdf">
<xsl:call-template name="file">
<xsl:with-param name="filetype">
PDF
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template match="filepresentation">
<xsl:call-template name="file">
<xsl:with-param name="filetype">
Presentation
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template match="filevideo">
<xsl:call-template name="file">
<xsl:with-param name="filetype">
Video
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template match="url">
<xsl:call-template name="file">
<xsl:with-param name="filetype">
Web
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template match="fileimagegroup">
<xsl:call-template name="file">
<xsl:with-param name="filetype">
Image Group
</xsl:with-param>
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,36 @@
*/
package org.quelea.data.displayable;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import org.quelea.data.imagegroup.ImageGroup;
import org.quelea.data.imagegroup.ImageGroupFactory;
import org.quelea.services.utils.LoggerUtils;
import org.quelea.services.utils.QueleaProperties;
import org.quelea.services.utils.Utils;
import org.w3c.dom.Node;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import org.quelea.data.imagegroup.ImageGroup;
import org.quelea.data.imagegroup.ImageGroupFactory;
import org.quelea.services.utils.QueleaProperties;
import org.quelea.services.utils.Utils;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

/**
/**
* A displayable that's an image group.
* <p/>
* @author Arvid, based on PresentationDisplayable
*/
public class ImageGroupDisplayable implements Displayable {

private static final Logger LOGGER = LoggerUtils.getLogger();
private final File[] files;
private final ImageGroup presentation;
private final String title;

/**
* Create a new image group displayable
* <p/>
* @param file the file to create the PDF presentation from.
*/
public ImageGroupDisplayable(File[] file) throws IOException {
public ImageGroupDisplayable(File[] file, String groupTitle) throws IOException {
this.files = file;
this.title = groupTitle;
presentation = new ImageGroupFactory().getPresentation(file);
if (presentation == null) {
throw new IOException("Error with image group, couldn't open " + Arrays.toString(file));
Expand All @@ -79,6 +73,10 @@ public boolean supportClear() {
public String getXML() {
StringBuilder ret = new StringBuilder();
ret.append("<fileimagegroup>");
ret.append("<title>");
ret.append(Utils.escapeXML(title));
ret.append("</title>");
ret.append("<files>");
for (File f : files) {
String loc;
if (QueleaProperties.get().getEmbedMediaInScheduleFile()) {
Expand All @@ -88,6 +86,7 @@ public String getXML() {
}
ret.append(Utils.escapeXML(loc)).append(";");
}
ret.append("</files>");
ret.append("</fileimagegroup>");
return ret.toString();
}
Expand All @@ -100,15 +99,35 @@ public String getXML() {
* @return the object as defined by the XML.
*/
public static ImageGroupDisplayable parseXML(Node node, Map<String, String> fileChanges) throws IOException {
String[] files = node.getTextContent().split(";");
ArrayList<File> tmp = new ArrayList<>();
for (String f : files) {
tmp.add(Utils.getChangedFile(f, fileChanges));
// Check for the title node. Since title is a later update, we want to maintain compatibility with older exports.
String title = null;
NodeList childNodes = node.getChildNodes();
if (childNodes.getLength() > 0) {
for (int i = 0; i < childNodes.getLength(); i++) {
Node childNode = childNodes.item(i);
if ("title".equals(childNode.getNodeName())) {
title = childNode.getTextContent();
} else if ("files".equals(childNode.getNodeName())) {
node = childNode;
}
}
}
return new ImageGroupDisplayable(tmp.toArray(new File[tmp.size()]));
return imageGroupFromXml(node, fileChanges, title);
}

/**

private static ImageGroupDisplayable imageGroupFromXml(Node node, Map<String, String> fileChanges, String title) throws IOException {
String[] files = node.getTextContent().split(";");
ArrayList<File> tmp = new ArrayList<>();
for (String f : files) {
tmp.add(Utils.getChangedFile(f, fileChanges));
}
File[] fileArray = tmp.toArray(new File[0]);
if (title == null) title = concatenatedFileNames(fileArray);
return new ImageGroupDisplayable(fileArray, title);
}

/**
* Get the preview icon of this image group.
* <p/>
* @return the imagegroup preview icon.
Expand All @@ -125,11 +144,15 @@ public ImageView getPreviewIcon() {
*/
@Override
public String getPreviewText() {
StringBuilder sb = new StringBuilder("");
return this.title;
}

public static String concatenatedFileNames(File[] files) {
StringBuilder sb = new StringBuilder();
for (File f : files) {
sb.append(f.getName()).append(", ");
}
return "Image Group: " + sb.toString().substring(0, sb.toString().lastIndexOf(","));
return "Image Group: " + sb.substring(0, sb.toString().lastIndexOf(","));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@
*/
package org.quelea.windows.main.actionhandlers;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.TextInputDialog;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.stage.FileChooser;
import org.javafx.dialog.Dialog;
import org.quelea.data.displayable.ImageDisplayable;
Expand All @@ -37,6 +35,13 @@
import org.quelea.windows.main.QueleaApp;
import org.quelea.windows.main.StatusPanel;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
* The action handler for adding images.
*
Expand Down Expand Up @@ -72,13 +77,24 @@ public void run() {
try {
if (!halt) {
Platform.runLater(() -> {
File[] filesArray = files.toArray(new File[0]);

TextInputDialog dialog = new TextInputDialog();
dialog.setTitle(LabelGrabber.INSTANCE.getLabel("dialog.image.group.title"));
dialog.setHeaderText(LabelGrabber.INSTANCE.getLabel("dialog.image.group.header"));
dialog.setGraphic(new ImageView(new Image("file:icons/image-group-schedule.png")));

String fallbackTitle = ImageGroupDisplayable.concatenatedFileNames(filesArray);
dialog.getEditor().setText(fallbackTitle);
Optional<String> result = dialog.showAndWait();
String imageGroupTitle = result.orElse(fallbackTitle);
try {
ImageGroupDisplayable displayable = new ImageGroupDisplayable(files.toArray(new File[files.size()]));
ImageGroupDisplayable displayable = new ImageGroupDisplayable(filesArray, imageGroupTitle);
QueleaApp.get().getMainWindow().getMainPanel().getSchedulePanel().getScheduleList().add(displayable);
} catch (IOException ex) {
System.err.println("IO " + ex);
if (!halt) {
Platform.runLater(() -> Dialog.showError(LabelGrabber.INSTANCE.getLabel("adding.presentation.error.title"), LabelGrabber.INSTANCE.getLabel("adding.presentation.error.message")));
Platform.runLater(() -> Dialog.showError(LabelGrabber.INSTANCE.getLabel("adding.presentation.error.imageGroupTitle"), LabelGrabber.INSTANCE.getLabel("adding.presentation.error.message")));
}
}
});
Expand Down

0 comments on commit 9d5e3a7

Please sign in to comment.