Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,32 @@
* Additional information for (and around) the free field of the pdf export.
*
* @author Schaefer
* @param significantInformation
* the {@link SignificantInformation}
*
*/
public class FreeFieldInfo {

private String significantInformation;

public record FreeFieldInfo(SignificantInformation significantInformation) {
/**
* @return the significant information
* @param mainPlan
* the main {@link LoadedPlanInformation}
* @param comparePlan
* the compare {@link LoadedPlanInformation}
*/
public String getSignificantInformation() {
return significantInformation;
public record SignificantInformation(LoadedPlanInformation mainPlan,
LoadedPlanInformation comparePlan) {

}

/**
* @param significantInformation
* the significant information to set
* @param name
* the plan name
* @param checksum
* the checksum
* @param timestamp
* the timestamp
*/
public void setSignificantInformation(final String significantInformation) {
this.significantInformation = significantInformation;
public record LoadedPlanInformation(String name, String checksum,
String timestamp) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import javax.imageio.ImageIO
import javax.xml.parsers.DocumentBuilderFactory
import javax.xml.parsers.ParserConfigurationException
import org.eclipse.set.basis.FreeFieldInfo
import org.eclipse.set.basis.FreeFieldInfo.LoadedPlanInformation
import org.eclipse.set.basis.FreeFieldInfo.SignificantInformation
import org.eclipse.set.basis.constants.ToolboxConstants
import org.eclipse.set.model.tablemodel.CellContent
import org.eclipse.set.model.tablemodel.CompareFootnoteContainer
Expand Down Expand Up @@ -555,10 +557,20 @@ class TableToTableDocument {
}

private def Element create doc.createElement("SignificantInformation") transformToSignificantInformation(
String significantInformation) {
textContent = significantInformation
return
SignificantInformation significantInformation) {
appendChild(transformLoadedPlanInformation("MainPlan", significantInformation.mainPlan))
if (significantInformation.comparePlan !== null) {
appendChild(transformLoadedPlanInformation("ComparePlan", significantInformation.comparePlan))
}
}

private def Element create doc.createElement("LoadedPlan") transformLoadedPlanInformation(String id, LoadedPlanInformation info) {
val idAttr = doc.createAttribute("id")
idAttr.value = id
attributeNode = idAttr
textContent = '''«info.name» «info.timestamp» MD5: «info.checksum»'''
}


private def Element create doc.createElement("Footnotes")
transformToFootnotes(Table table) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ private void sheetcutImageHandle(final String url, final int sheetcutcount,
exportImages.add(bufferedImage);
if (exportImages.size() >= sheetcutcount) {
final PlanProToFreeFieldTransformation planProToFreeField = PlanProToFreeFieldTransformation
.create();
.create(sessionService);
final FreeFieldInfo freeFieldInfo = planProToFreeField
.transform(modelSession);
.transform();
dialogService.showProgressUISync(shell,
message.WebSiteplanPart_Export, () -> {
exportService.exportSiteplanPdf(exportImages,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ public TableType getTableType() {

private FreeFieldInfo getFreeFieldInfo() {
final PlanProToFreeFieldTransformation planProToFreeField = PlanProToFreeFieldTransformation
.create();
return planProToFreeField.transform(getModelSession());
.create(getSessionService());
return planProToFreeField.transform();
}

private Path getAttachmentPath(final String guid) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,8 @@ && getTreeDataModel() instanceof TableCheckboxTreeModel) {
this::getAttachmentPath);
updateTitlebox(titlebox);
final PlanProToFreeFieldTransformation planProToFreeField = PlanProToFreeFieldTransformation
.create();
final FreeFieldInfo freeFieldInfo = planProToFreeField
.transform(modelSession);
.create(getSessionService());
final FreeFieldInfo freeFieldInfo = planProToFreeField.transform();
getExportService().exportPdf(tables, getExportType(), titlebox,
freeFieldInfo, id, getSelectedDirectory().toString(),
modelSession.getToolboxPaths(), getTableType(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,17 @@ http://www.eclipse.org/legal/epl-v20.html
</fo:table>
</xsl:template>

<xsl:template match="SignificantInformation">
<xsl:template match="SignificantInformation[LoadedPlan]">
<fo:block xsl:use-attribute-sets="significant-information-style">
<xsl:apply-templates select="LoadedPlan" />
</fo:block>
</xsl:template>

<xsl:template match="LoadedPlan">
<fo:block>
<xsl:if test="@id = 'ComparePlan'">
<xsl:text>Vergleich mit: </xsl:text>
</xsl:if>
<xsl:value-of select="." />
</fo:block>
</xsl:template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,57 @@ package org.eclipse.set.ppmodel.extensions.utils
import org.eclipse.set.model.planpro.PlanPro.PlanPro_Schnittstelle
import org.eclipse.set.basis.FreeFieldInfo
import org.eclipse.set.basis.IModelSession
import org.eclipse.set.core.services.session.SessionService
import org.eclipse.set.basis.files.ToolboxFileRole
import org.eclipse.set.basis.FreeFieldInfo.SignificantInformation
import org.eclipse.set.basis.FreeFieldInfo.LoadedPlanInformation

/**
* Transformation from {@link IModelSession} to {@link FreeFieldInfo}.
*
* @author Schaefer
*/
class PlanProToFreeFieldTransformation {
SessionService sessionService

private new() {
private new(SessionService sessionService) {
this.sessionService = sessionService
}

private def IModelSession mainSession() {
return sessionService.getLoadedSession(ToolboxFileRole.SESSION)
}

private def IModelSession compareSession() {
return sessionService.getLoadedSession(ToolboxFileRole.COMPARE_PLANNING)
}

/**
* Creates a new transformation.
*/
def static PlanProToFreeFieldTransformation create() {
return new PlanProToFreeFieldTransformation
def static PlanProToFreeFieldTransformation create(
SessionService sessionService) {
return new PlanProToFreeFieldTransformation(sessionService)
}

/**
* Transforms a PlanPro Schnittstelle to a FreeFieldInfo.
*/
def FreeFieldInfo create new FreeFieldInfo transform(
IModelSession session) {
val filename = session.toolboxFile.path.fileName.toString
def FreeFieldInfo transform() {

return new FreeFieldInfo(
new SignificantInformation(mainSession.transformLoadedPlan,
compareSession.transformLoadedPlan))
}

def LoadedPlanInformation transformLoadedPlan(IModelSession session) {
if (session === null) {
return null
}
val name = session?.toolboxFile?.path?.fileName?.toString
val timestamp = session.planProSchnittstelle.timestamp
val checksum = session.toolboxFile.checksum
significantInformation = '''«filename» «timestamp» MD5: «checksum»'''
return
return new LoadedPlanInformation(name, checksum, timestamp)
}

private def String getTimestamp(PlanPro_Schnittstelle schnittstelle) {
Expand Down
Loading