Skip to content

Commit 119c3ef

Browse files
author
SeTSeR
committed
Added notice opening by mouse-click
1 parent 5274da6 commit 119c3ef

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

src/com/temporaryteam/noticeditor/view/EditNoticeTreeCell.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import javafx.scene.control.TreeCell;
1212
import javafx.scene.input.KeyCode;
1313
import javafx.scene.input.KeyEvent;
14+
import javafx.scene.input.MouseEvent;
1415

1516
import com.temporaryteam.noticeditor.model.NoticeCategory;
1617

@@ -28,9 +29,8 @@ public EditNoticeTreeCell() {
2829
MenuItem addNoticeItem = new MenuItem("Add notice");
2930
MenuItem deleteItem = new MenuItem("Delete");
3031
MenuItem deleteItem2 = new MenuItem("Delete");
31-
MenuItem openItem = new MenuItem("Open notice");
3232
branchMenu.getItems().addAll(addBranchItem, addNoticeItem, deleteItem);
33-
noticeMenu.getItems().addAll(openItem, deleteItem2);
33+
noticeMenu.getItems().add(deleteItem2);
3434
addBranchItem.setOnAction(new EventHandler<ActionEvent>() {
3535
public void handle(ActionEvent t) {
3636
ArrayList<NoticeCategory> list = new ArrayList<NoticeCategory>();
@@ -60,10 +60,12 @@ public void handle(ActionEvent t) {
6060
};
6161
deleteItem.setOnAction(handler);
6262
deleteItem2.setOnAction(handler);
63-
openItem.setOnAction(new EventHandler<ActionEvent>() {
64-
public void handle(ActionEvent t) {
65-
controller.setCurrentTreeItem(getNoticeTreeItem());
66-
controller.open(getNoticeTreeItem().getNotice().getContent());
63+
setOnMouseReleased(new EventHandler<MouseEvent>() {
64+
public void handle(MouseEvent t) {
65+
if(getNoticeTreeItem().getNotice().getContent()!=null) {
66+
controller.setCurrentTreeItem(getNoticeTreeItem());
67+
controller.open(getNoticeTreeItem().getNotice().getContent());
68+
}
6769
}
6870
});
6971
}

src/com/temporaryteam/noticeditor/view/NoticeController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ public void writeNode(NoticeCategory node, String name) throws IOException {
120120
*/
121121
public void rebuild(String str) {
122122
ArrayList<NoticeCategory> list = new ArrayList<NoticeCategory>();
123-
list.add(new NoticeCategory("", str));
124-
currentNotice = new NoticeCategory("", list);
123+
list.add(new NoticeCategory("Default notice", str));
124+
currentNotice = new NoticeCategory("Default notice", list);
125125
noticeTree.setRoot(createNode(currentNotice));
126126
}
127127

0 commit comments

Comments
 (0)