diff --git a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/ShareDialog.java b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/ShareDialog.java index dc835c7..5b5df8a 100644 --- a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/ShareDialog.java +++ b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/ShareDialog.java @@ -25,7 +25,7 @@ public class ShareDialog extends Dialog implements LocaleChangeObserver { private static final String CLOSE_ICON_ID = "closeIcon"; private final TextField urlField; - private final TextField packageField; + private final TextArea packageArea; private final TextArea latexArea; private final H3 heading; @@ -34,11 +34,9 @@ public class ShareDialog extends Dialog implements LocaleChangeObserver { * to the String that is passed as corresponding parameter. * * @param url a permalink to share with other users - * @param latexPackages the needed LaTeX-packages to use the displayed mathematics - * in other LaTeX documents. Should be in the form „\\usepackage<package>“ * @param latexCode LaTeX code for users to copy into their own LaTeX document(s) */ - public ShareDialog(String url, String latexPackages, String latexCode) { + public ShareDialog(String url, String latexCode) { HorizontalLayout headingLayout = new HorizontalLayout(); headingLayout.setId(HEADING_LAYOUT_ID); @@ -55,17 +53,17 @@ public class ShareDialog extends Dialog implements LocaleChangeObserver { setId(SHARE_DIALOG_ID); urlField = new TextField(); - packageField = new TextField(); + packageArea = new TextArea(); latexArea = new TextArea(); urlField.setValue(url); urlField.setClassName(FIELD_CLASS); - packageField.setValue(latexPackages); - packageField.setClassName(FIELD_CLASS); + packageArea.setValue(getTranslation("share.neededPackages")); + packageArea.setClassName(FIELD_CLASS); latexArea.setValue(latexCode); latexArea.setClassName(FIELD_CLASS); - layout.add(urlField, packageField, latexArea); + layout.add(urlField, packageArea, latexArea); add(headingLayout, layout); } @@ -75,7 +73,7 @@ public class ShareDialog extends Dialog implements LocaleChangeObserver { public void localeChange(LocaleChangeEvent localeChangeEvent) { heading.setText(getTranslation("share.heading")); urlField.setLabel(getTranslation("share.url.label")); - packageField.setLabel(getTranslation("share.packages.label")); + packageArea.setLabel(getTranslation("share.packages.label")); latexArea.setLabel(getTranslation("share.latex.label")); } } diff --git a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/TypeInferenceView.java b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/TypeInferenceView.java index f189547..5136e5a 100644 --- a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/TypeInferenceView.java +++ b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/TypeInferenceView.java @@ -82,7 +82,7 @@ public class TypeInferenceView extends VerticalLayout @Override public void shareButton() { UI.getCurrent().getPage().executeJs("return decodeURI(window.location.href)").then(url -> - new ShareDialog(url.asString(), lc.getLatexPackages(), lc.getTree()).open() + new ShareDialog(url.asString(), lc.getTree()).open() ); } diff --git a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreator.java b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreator.java index 0027bca..e841c98 100644 --- a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreator.java +++ b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreator.java @@ -77,16 +77,6 @@ public class LatexCreator implements StepVisitor { return constraintsCreator.getTreeNumbers(); } - /** - * Returns needed LaTeX packages - * - * @return the packages needed for the LaTeX-code from getTree() to work - */ - public String getLatexPackages() { - return BUSSPROOFS; - } - - private String conclusionToLatex(Conclusion conclusion) { String typeAssumptions = typeAssumptionsToLatex(conclusion.getTypeAssumptions()); String term = new LatexCreatorTerm(conclusion.getLambdaTerm()).getLatex(); @@ -155,8 +145,7 @@ public class LatexCreator implements StepVisitor { tree.insert(0, generateConclusion(varL, LABEL_VAR, UIC)); String typeAbstraction = generateTypeAbstraction(varL.getTypeAbsInPremise()); String instantiatedType = new LatexCreatorType(varL.getInstantiatedTypeAbs()).getLatex(); - String premiseRight = DOLLAR_SIGN + typeAbstraction + INSTANTIATE_SIGN + instantiatedType - + DOLLAR_SIGN + NEW_LINE; + String premiseRight = DOLLAR_SIGN + typeAbstraction + INSTANTIATE_SIGN + instantiatedType + DOLLAR_SIGN; String premiseLeft = AXC + CURLY_LEFT + DOLLAR_SIGN + ALIGN_BEGIN + generateVarStepPremise(varL).replace(DOLLAR_SIGN, "") + SPACE + LATEX_NEW_LINE + SPACE // todo less replacement fixups diff --git a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreatorConstants.java b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreatorConstants.java index a24e587..0a1e65c 100644 --- a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreatorConstants.java +++ b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreatorConstants.java @@ -74,6 +74,4 @@ public final class LatexCreatorConstants { protected static final String ALIGN_END = "\\end{aligned}"; protected static final String SPLIT_BEGIN = "\\begin{split}"; protected static final String SPLIT_END = "\\end{split}"; - - protected static final String BUSSPROOFS = "\\usepackage{bussproofs}"; } diff --git a/src/main/resources/language/general.properties b/src/main/resources/language/general.properties index 10da464..b7df9bd 100644 --- a/src/main/resources/language/general.properties +++ b/src/main/resources/language/general.properties @@ -79,4 +79,8 @@ root.varLetLatex=\ \ \\LeftLabel{\\textrm V{\\small AR}}\ \\BinaryInfC{$\\Gamma \\vdash \\texttt{x} : \\tau$}\ -\\end{prooftree} \ No newline at end of file +\\end{prooftree} + +share.neededPackages=\ +\\usepackage{bussproofs}\n\ +\\usepackage{amsmath} \ No newline at end of file