forked from nus-cs2103-AY2324S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from Nixx162/improve-ui
Improve UI
- Loading branch information
Showing
18 changed files
with
322 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package seedu.address.ui; | ||
|
||
import javafx.fxml.FXML; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.layout.FlowPane; | ||
import javafx.scene.layout.HBox; | ||
import javafx.scene.layout.Region; | ||
import seedu.address.model.person.Person; | ||
|
||
/** | ||
* An UI component that displays information of a {@code Person}. | ||
*/ | ||
public class ContactCard extends UiPart<Region> { | ||
|
||
private static final String FXML = "ContactCard.fxml"; | ||
|
||
/** | ||
* Note: Certain keywords such as "location" and "resources" are reserved keywords in JavaFX. | ||
* As a consequence, UI elements' variable names cannot be set to such keywords | ||
* or an exception will be thrown by JavaFX during runtime. | ||
* | ||
* @see <a href="https://github.com/se-edu/addressbook-level4/issues/336">The issue on AddressBook level 4</a> | ||
*/ | ||
|
||
public final Person person; | ||
|
||
@FXML | ||
private HBox cardPane; | ||
@FXML | ||
private Label name; | ||
@FXML | ||
private Label email; | ||
@FXML | ||
private Label mobile; | ||
@FXML | ||
private Label address; | ||
@FXML | ||
private FlowPane tags; | ||
|
||
/** | ||
* Creates a {@code PersonCode} with the given {@code Person} and index to display. | ||
*/ | ||
public ContactCard(Person person) { | ||
super(FXML); | ||
this.person = person; | ||
name.setText(person.getName().fullName); | ||
mobile.setText("Phone: " + person.getPhone().value); | ||
address.setText(person.getAddress().value); | ||
email.setText(person.getEmail().value); | ||
person.getTags().stream() | ||
.forEach(tag -> tags.getChildren().add(new Label(tag.tagName))); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package seedu.address.ui; | ||
|
||
import java.util.logging.Logger; | ||
|
||
import javafx.beans.property.SimpleStringProperty; | ||
import javafx.collections.ObservableList; | ||
import javafx.fxml.FXML; | ||
import javafx.scene.control.TableCell; | ||
import javafx.scene.control.TableColumn; | ||
import javafx.scene.control.TableView; | ||
import javafx.stage.Stage; | ||
import seedu.address.commons.core.LogsCenter; | ||
import seedu.address.model.event.Event; | ||
|
||
/** | ||
* Controller for a help page | ||
*/ | ||
public class EventListWindow extends UiPart<Stage> { | ||
private static final Logger logger = LogsCenter.getLogger(EventListWindow.class); | ||
private static final String FXML = "EventListWindow.fxml"; | ||
|
||
@FXML private TableView<Event> table; | ||
@FXML private TableColumn<Event, Void> indexCol; | ||
@FXML private TableColumn<Event, String> nameCol; | ||
@FXML private TableColumn<Event, String> startCol; | ||
@FXML private TableColumn<Event, String> endCol; | ||
@FXML private TableColumn<Event, String> locCol; | ||
@FXML private TableColumn<Event, String> infoCol; | ||
|
||
/** | ||
* Creates a new EventListWindow. | ||
* | ||
* @param root Stage to use as the root of the EventListWindow. | ||
*/ | ||
public EventListWindow(Stage root) { | ||
super(FXML, root); | ||
} | ||
|
||
/** | ||
* Creates a new EventListWindow. | ||
*/ | ||
public EventListWindow() { | ||
this(new Stage()); | ||
} | ||
|
||
/** | ||
* Shows the help window. | ||
* @throws IllegalStateException | ||
* <ul> | ||
* <li> | ||
* if this method is called on a thread other than the JavaFX Application Thread. | ||
* </li> | ||
* <li> | ||
* if this method is called during animation or layout processing. | ||
* </li> | ||
* <li> | ||
* if this method is called on the primary stage. | ||
* </li> | ||
* <li> | ||
* if {@code dialogStage} is already showing. | ||
* </li> | ||
* </ul> | ||
*/ | ||
public void show(ObservableList<Event> events) { | ||
logger.fine("Showing help page about the application."); | ||
|
||
indexCol.setCellFactory(col -> new TableIndexCell()); | ||
nameCol.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getName())); | ||
startCol.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getStartString())); | ||
endCol.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getEndString())); | ||
locCol.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getLocationStr())); | ||
infoCol.setCellValueFactory(data -> new SimpleStringProperty(data.getValue().getInformationStr())); | ||
|
||
table.setItems(events); | ||
|
||
getRoot().show(); | ||
getRoot().centerOnScreen(); | ||
} | ||
|
||
/** | ||
* Returns true if the help window is currently being shown. | ||
*/ | ||
public boolean isShowing() { | ||
return getRoot().isShowing(); | ||
} | ||
|
||
/** | ||
* Hides the help window. | ||
*/ | ||
public void hide() { | ||
getRoot().hide(); | ||
} | ||
|
||
/** | ||
* Focuses on the help window. | ||
*/ | ||
public void focus() { | ||
getRoot().requestFocus(); | ||
} | ||
|
||
class TableIndexCell extends TableCell<Event, Void> { | ||
@Override | ||
public void updateIndex(int index) { | ||
super.updateIndex(index); | ||
if (isEmpty() || index < 0) { | ||
setText(null); | ||
} else { | ||
setText(Integer.toString(index + 1)); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.