Skip to content

Commit

Permalink
Merge pull request #416 from HemanshuGandhi/feature-block-content-edi…
Browse files Browse the repository at this point in the history
…t-view

Feature block content edit view [View]
  • Loading branch information
HemanshuGandhi authored Apr 10, 2020
2 parents 08a9401 + 962adaa commit 498bc28
Show file tree
Hide file tree
Showing 8 changed files with 325 additions and 40 deletions.
4 changes: 1 addition & 3 deletions src/main/java/com/notably/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static java.util.Objects.requireNonNull;

import com.notably.logic.commands.exceptions.CommandException;
import com.notably.model.Model;

/**
Expand All @@ -15,10 +14,9 @@ public class EditCommand extends Command {
/**
* Edit the Block body of the current directory.
* @param notablyModel used to access the tree structure.
* @throws CommandException
*/
public void execute(Model notablyModel) {
requireNonNull(notablyModel);
notablyModel.setBlockEditable(true);
}
}

28 changes: 24 additions & 4 deletions src/main/java/com/notably/view/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import javafx.fxml.FXML;
import javafx.scene.control.MenuItem;
import javafx.scene.control.TextInputControl;
import javafx.scene.effect.ColorAdjust;
import javafx.scene.input.KeyCombination;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.StackPane;
Expand Down Expand Up @@ -47,6 +48,9 @@ public class MainWindow extends ViewPart<Stage> {
@FXML
private MenuItem helpMenuItem;

@FXML
private VBox mainWindow;

@FXML
private StackPane sideBarPlaceholder;

Expand All @@ -62,14 +66,12 @@ public class MainWindow extends ViewPart<Stage> {
public MainWindow(Stage primaryStage, Logic logic, Model model) {
super(FXML, primaryStage);

// Set dependencies
this.primaryStage = primaryStage;
this.logic = logic;
this.model = model;

// Configure the VIEW
setWindowDefaultSize(logic.getGuiSettings());

//setWindowSettings(primaryStage);
setAccelerators();

initializeHelpWindow(model);
Expand All @@ -79,6 +81,24 @@ public Stage getPrimaryStage() {
return primaryStage;
}

/**
* Provides an alternative way to set the settings of the main window, as an alternative
* to doing so via fxml tags.
*
* @param primaryStage the stage corresponding to the main app window.
*/
private void setWindowSettings(Stage primaryStage) {
primaryStage.focusedProperty().addListener(((observable, unused, isFocused) -> {
if (isFocused) {
mainWindow.setEffect(null);
} else {
ColorAdjust colorAdjust = new ColorAdjust();
colorAdjust.setBrightness(-0.4);
mainWindow.setEffect(colorAdjust);
}
}));
}

private void setAccelerators() {
setAccelerator(helpMenuItem, KeyCombination.valueOf("F1"));
}
Expand Down Expand Up @@ -125,7 +145,7 @@ void fillInnerParts() {
sidebarTreeView = new SideBarTreeView(model.getBlockTree(), model.currentlyOpenPathProperty());
sideBarPlaceholder.getChildren().add(sidebarTreeView.getRoot());

blockContent = new BlockContent(blockContentPlaceholder, model);
blockContent = new BlockContent(blockContentPlaceholder, logic, model);

suggestionsWindowView = new SuggestionsWindowView(model.getSuggestions(), model.responseTextProperty());
suggestionsWindow.getChildren().add(suggestionsWindowView.getRoot());
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/com/notably/view/blockcontent/BlockContent.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.notably.view.blockcontent;

import java.util.Objects;
import static com.notably.commons.util.CollectionUtil.requireAllNonNull;

import com.notably.logic.Logic;
import com.notably.model.Model;

import javafx.scene.layout.StackPane;
Expand All @@ -10,15 +11,15 @@
* View of the currently open block's content.
*/
public class BlockContent {

private final BlockContentDisplayView blockContentDisplayView;
private final BlockContentEditView blockContentEditView;

public BlockContent(StackPane blockContentPlaceholder, Model model) {
Objects.requireNonNull(blockContentPlaceholder);
Objects.requireNonNull(model);
public BlockContent(StackPane blockContentPlaceholder, Logic logic, Model model) {
requireAllNonNull(blockContentPlaceholder, model, logic);

blockContentDisplayView = new BlockContentDisplayView(model);
blockContentEditView = new BlockContentEditView(model);
blockContentEditView = new BlockContentEditView(logic, model);

// TODO: Integrate BlockContentEditView
blockContentPlaceholder.getChildren().addAll(blockContentDisplayView.getRoot());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* Read-only and rendered view of the currently open block's content.
*/
public class BlockContentDisplayView extends ViewPart<WebView> {
private static final String FXML = "blockcontent/BlockContentDisplayView.fxml";

private static final String FXML = "blockcontent/BlockContentDisplayView.fxml";
private final Model model;

@FXML
Expand Down
Loading

0 comments on commit 498bc28

Please sign in to comment.