From d3eac32ce7c9cb7f231324c411ec8ffb6963e435 Mon Sep 17 00:00:00 2001 From: zephyr Date: Mon, 28 Oct 2019 15:21:55 +0800 Subject: [PATCH] Fix wrapText --- .../java/seedu/algobase/ui/FindRuleCard.java | 17 +++++++++++++++++ src/main/java/seedu/algobase/ui/PlanCard.java | 11 +++++++++++ .../java/seedu/algobase/ui/ProblemCard.java | 17 +++++++++++++++++ src/main/java/seedu/algobase/ui/TagCard.java | 5 +++++ src/main/java/seedu/algobase/ui/TaskCard.java | 19 +++++++++++++++++++ .../seedu/algobase/ui/TaskManagementPane.java | 4 ++-- 6 files changed, 71 insertions(+), 2 deletions(-) diff --git a/src/main/java/seedu/algobase/ui/FindRuleCard.java b/src/main/java/seedu/algobase/ui/FindRuleCard.java index f08272ed321..d12ff2c36f4 100644 --- a/src/main/java/seedu/algobase/ui/FindRuleCard.java +++ b/src/main/java/seedu/algobase/ui/FindRuleCard.java @@ -7,6 +7,7 @@ import javafx.scene.control.Label; import javafx.scene.layout.HBox; import javafx.scene.layout.Region; +import javafx.scene.text.TextAlignment; import seedu.algobase.model.searchrule.problemsearchrule.DifficultyIsInRangePredicate; import seedu.algobase.model.searchrule.problemsearchrule.ProblemSearchRule; @@ -47,25 +48,35 @@ public FindRuleCard(ProblemSearchRule findRule, int displayedIndex) { super(FXML); this.findRule = findRule; id.setText(displayedIndex + ". "); + id.setWrapText(true); + id.setTextAlignment(TextAlignment.JUSTIFY); ruleName.setText(findRule.getName().name); + ruleName.setWrapText(true); + ruleName.setTextAlignment(TextAlignment.JUSTIFY); if (findRule.getNamePredicate().isEmpty()) { problemName.setText(DEFAULT_PREDICATE); } else { problemName.setText(findRule.getNamePredicate().get().getKeywords().toString()); } + problemName.setWrapText(true); + problemName.setTextAlignment(TextAlignment.JUSTIFY); if (findRule.getAuthorPredicate().isEmpty()) { author.setText(DEFAULT_PREDICATE); } else { author.setText(findRule.getAuthorPredicate().get().getKeyword().keyword); } + author.setWrapText(true); + author.setTextAlignment(TextAlignment.JUSTIFY); if (findRule.getDescriptionPredicate().isEmpty()) { description.setText(DEFAULT_PREDICATE); } else { description.setText(findRule.getDescriptionPredicate().get().getKeywords().toString()); } + description.setWrapText(true); + description.setTextAlignment(TextAlignment.JUSTIFY); if (findRule.getDifficultyPredicate().isEmpty()) { difficulty.setText(DEFAULT_PREDICATE); @@ -76,18 +87,24 @@ public FindRuleCard(ProblemSearchRule findRule, int displayedIndex) { String difficultyString = String.format("%f - %f", lowerBound, upperBound); difficulty.setText(difficultyString); } + difficulty.setWrapText(true); + difficulty.setTextAlignment(TextAlignment.JUSTIFY); if (findRule.getSourcePredicate().isEmpty()) { source.setText(DEFAULT_PREDICATE); } else { source.setText(findRule.getSourcePredicate().get().getKeyword().keyword); } + source.setWrapText(true); + source.setTextAlignment(TextAlignment.JUSTIFY); if (findRule.getTagPredicate().isEmpty()) { tag.setText(DEFAULT_PREDICATE); } else { tag.setText(findRule.getTagPredicate().get().getKeywords().toString()); } + tag.setWrapText(true); + tag.setTextAlignment(TextAlignment.JUSTIFY); } diff --git a/src/main/java/seedu/algobase/ui/PlanCard.java b/src/main/java/seedu/algobase/ui/PlanCard.java index 6cb0175ef94..2c6a56e3f5c 100644 --- a/src/main/java/seedu/algobase/ui/PlanCard.java +++ b/src/main/java/seedu/algobase/ui/PlanCard.java @@ -10,6 +10,7 @@ import javafx.scene.input.MouseEvent; import javafx.scene.layout.HBox; import javafx.scene.layout.Region; +import javafx.scene.text.TextAlignment; import seedu.algobase.commons.core.LogsCenter; import seedu.algobase.logic.parser.ParserUtil; import seedu.algobase.model.Id; @@ -45,10 +46,20 @@ public PlanCard(Plan plan, int displayedIndex, WriteOnlyTabManager writeOnlyTabM super(FXML); this.plan = plan; id.setText(displayedIndex + ". "); + id.setWrapText(true); + id.setTextAlignment(TextAlignment.JUSTIFY); planName.setText(plan.getPlanName().fullName + " (" + plan.getTasks().size() + " tasks)"); + planName.setWrapText(true); + planName.setTextAlignment(TextAlignment.JUSTIFY); planDescription.setText(plan.getPlanDescription().value); + planDescription.setWrapText(true); + planDescription.setTextAlignment(TextAlignment.JUSTIFY); startDate.setText(plan.getStartDate().format(ParserUtil.FORMATTER)); + startDate.setWrapText(true); + startDate.setTextAlignment(TextAlignment.JUSTIFY); endDate.setText(plan.getEndDate().format(ParserUtil.FORMATTER)); + endDate.setWrapText(true); + endDate.setTextAlignment(TextAlignment.JUSTIFY); addMouseClickListener(writeOnlyTabManager.addDetailsTabConsumer(ModelType.PLAN)); } diff --git a/src/main/java/seedu/algobase/ui/ProblemCard.java b/src/main/java/seedu/algobase/ui/ProblemCard.java index 355f44f151a..80b557dddac 100644 --- a/src/main/java/seedu/algobase/ui/ProblemCard.java +++ b/src/main/java/seedu/algobase/ui/ProblemCard.java @@ -12,6 +12,7 @@ import javafx.scene.layout.FlowPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Region; +import javafx.scene.text.TextAlignment; import seedu.algobase.commons.core.LogsCenter; import seedu.algobase.model.Id; import seedu.algobase.model.ModelType; @@ -62,13 +63,29 @@ public ProblemCard(Problem problem, int displayedIndex, WriteOnlyTabManager writ super(FXML); this.problem = problem; id.setText(displayedIndex + ". "); + id.setWrapText(true); + id.setTextAlignment(TextAlignment.JUSTIFY); name.setText(problem.getName().fullName); + name.setWrapText(true); + name.setTextAlignment(TextAlignment.JUSTIFY); author.setText(problem.getAuthor().value); + author.setWrapText(true); + author.setTextAlignment(TextAlignment.JUSTIFY); description.setText(problem.getDescription().value); + description.setWrapText(true); + description.setTextAlignment(TextAlignment.JUSTIFY); weblink.setText(problem.getWebLink().value); + weblink.setWrapText(true); + weblink.setTextAlignment(TextAlignment.JUSTIFY); difficulty.setText(problem.getDifficulty().toString()); + difficulty.setWrapText(true); + difficulty.setTextAlignment(TextAlignment.JUSTIFY); remark.setText(problem.getRemark().value); + remark.setWrapText(true); + remark.setTextAlignment(TextAlignment.JUSTIFY); source.setText(problem.getSource().value); + source.setWrapText(true); + source.setTextAlignment(TextAlignment.JUSTIFY); problem.getTags().stream() .sorted(Comparator.comparing(tag -> tag.tagName)) .forEach(tag -> tags.getChildren().add(new Label(tag.tagName))); diff --git a/src/main/java/seedu/algobase/ui/TagCard.java b/src/main/java/seedu/algobase/ui/TagCard.java index 297b47c15e2..d7da3de28f3 100644 --- a/src/main/java/seedu/algobase/ui/TagCard.java +++ b/src/main/java/seedu/algobase/ui/TagCard.java @@ -4,6 +4,7 @@ import javafx.scene.control.Label; import javafx.scene.layout.HBox; import javafx.scene.layout.Region; +import javafx.scene.text.TextAlignment; import seedu.algobase.model.tag.Tag; @@ -27,7 +28,11 @@ public TagCard(Tag tag, int displayedIndex) { super(FXML); this.tag = tag; id.setText(displayedIndex + ". "); + id.setWrapText(true); + id.setTextAlignment(TextAlignment.JUSTIFY); tagName.setText(tag.getName()); + tagName.setWrapText(true); + tagName.setTextAlignment(TextAlignment.JUSTIFY); } @Override diff --git a/src/main/java/seedu/algobase/ui/TaskCard.java b/src/main/java/seedu/algobase/ui/TaskCard.java index 4ba637b456c..5e54447a9c4 100644 --- a/src/main/java/seedu/algobase/ui/TaskCard.java +++ b/src/main/java/seedu/algobase/ui/TaskCard.java @@ -7,6 +7,7 @@ import javafx.scene.layout.FlowPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Region; +import javafx.scene.text.TextAlignment; import seedu.algobase.logic.parser.ParserUtil; import seedu.algobase.model.task.Task; @@ -54,14 +55,32 @@ public TaskCard(Task task, int displayedIndex) { super(FXML); this.task = task; id.setText(displayedIndex + ". "); + id.setWrapText(true); + id.setTextAlignment(TextAlignment.JUSTIFY); name.setText(task.getName().fullName + task.getStatusIcon()); + name.setWrapText(true); + name.setTextAlignment(TextAlignment.JUSTIFY); targetDate.setText(task.getTargetDate().format(ParserUtil.FORMATTER)); + targetDate.setWrapText(true); + targetDate.setTextAlignment(TextAlignment.JUSTIFY); author.setText(task.getAuthor().value); + author.setWrapText(true); + author.setTextAlignment(TextAlignment.JUSTIFY); description.setText(task.getDescription().value); + description.setWrapText(true); + description.setTextAlignment(TextAlignment.JUSTIFY); weblink.setText(task.getWebLink().value); + weblink.setWrapText(true); + weblink.setTextAlignment(TextAlignment.JUSTIFY); difficulty.setText(task.getDifficulty().toString()); + difficulty.setWrapText(true); + difficulty.setTextAlignment(TextAlignment.JUSTIFY); remark.setText(task.getRemark().value); + remark.setWrapText(true); + remark.setTextAlignment(TextAlignment.JUSTIFY); source.setText(task.getSource().value); + source.setWrapText(true); + source.setTextAlignment(TextAlignment.JUSTIFY); task.getTags().stream() .sorted(Comparator.comparing(tag -> tag.tagName)) .forEach(tag -> tags.getChildren().add(new Label(tag.tagName))); diff --git a/src/main/java/seedu/algobase/ui/TaskManagementPane.java b/src/main/java/seedu/algobase/ui/TaskManagementPane.java index 149f359788f..e91709c0aeb 100644 --- a/src/main/java/seedu/algobase/ui/TaskManagementPane.java +++ b/src/main/java/seedu/algobase/ui/TaskManagementPane.java @@ -34,7 +34,7 @@ public class TaskManagementPane extends UiPart { public TaskManagementPane(ObservableList taskList, ObservableStringValue plan, ObservableIntegerValue solvedCount, ObservableIntegerValue unsolvedCount) { super(FXML); - currentPlan.setText(plan.getValue()); + currentPlan.setText("Current Plan: " + plan.getValue()); taskListView.setItems(taskList); taskListView.setCellFactory(listView -> new TaskListViewCell()); taskProgressChart.setData(getChartData((int) solvedCount.getValue(), (int) unsolvedCount.getValue())); @@ -78,7 +78,7 @@ private ObservableList getChartData(int solvedCount, int unsolvedCount) { */ private void addListenerForPlanName(ObservableStringValue s) { s.addListener((observable, oldValue, newValue) -> { - currentPlan.setText(newValue); + currentPlan.setText("Current Plan: " + newValue); }); }