Skip to content

Commit

Permalink
Merge 601a889 into aecf912
Browse files Browse the repository at this point in the history
  • Loading branch information
JeridiOmar authored Feb 5, 2023
2 parents aecf912 + 601a889 commit 3beaf17
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import components.interviewSelector.appCommands.InterviewSelectorCommandFactory;
import components.interviewSelector.controllers.InterviewSelectorCellController;
import components.modelisationSpace.category.appCommands.RemoveConcreteCategoryCommand;
import components.schemaTree.Section;
import javafx.application.Platform;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
Expand Down Expand Up @@ -49,19 +50,19 @@ public void updateItem(Interview item, boolean empty) {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("/views/InterviewSelector/InterviewSelectorCell.fxml"));
//Cell Controller
InterviewSelectorCellController newController = new InterviewSelectorCellController(item, this ,commandFactory);
InterviewSelectorCellController newController = new InterviewSelectorCellController(item, this, commandFactory);
loader.setController(newController);
controller = newController;

//Mouse click event
setOnMouseClicked(event -> {
commandFactory.selectCurrentInterview(item, true).execute();
selectedInterviewIndex=this.getListView().getItems().indexOf(item);
selectedInterviewIndex = this.getListView().getItems().indexOf(item);
});
this.getListView().getStyleClass().add("list-cell");


newController.updateColor();
// newController.updateColor();
this.addDragAndDrop(newController);

try {
Expand All @@ -72,7 +73,8 @@ public void updateItem(Interview item, boolean empty) {
}
}
}
private void addDragAndDrop(InterviewSelectorCellController newController){

private void addDragAndDrop(InterviewSelectorCellController newController) {
this.setOnDragDetected(mouseEvent -> {
selectedItem.set(this.getListView().getSelectionModel().getSelectedItem());
Dragboard db = this.startDragAndDrop(TransferMode.MOVE);
Expand All @@ -84,14 +86,23 @@ private void addDragAndDrop(InterviewSelectorCellController newController){
});

this.setOnDragOver(event -> {
this.setStyle("-fx-opacity: 1;");
boolean success = false;
if (event.getGestureSource() != this &&
DragStore.getDraggable().getDataFormat() == Interview.format) {
this.setStyle("-fx-opacity: 0.5;");
event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
Section section = this.mouseIsDraggingOn(event.getY());
if (section == Section.bottom) {
this.setStyle("-fx-background-color: #999;-fx-font-weight: bold;-fx-border-color: #777;-fx-border-width: 0 0 4;");
success = true;
} else if (section == Section.top) {
this.setStyle("-fx-background-color: #999;-fx-font-weight: bold;-fx-border-color: #777;-fx-border-width: 4 0 0 ;");
success = true;
}
if (success) {
event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
}
}
event.consume();
newController.updateColor();
// newController.updateColor();
});
this.setOnDragDropped(event -> {
Dragboard db = event.getDragboard();
Expand All @@ -100,17 +111,26 @@ private void addDragAndDrop(InterviewSelectorCellController newController){
ObservableList<Interview> items = this.getListView().getItems();
int draggedIdx = items.indexOf(DragStore.getDraggable());
int thisIdx = items.indexOf(getItem());
items.set(draggedIdx, getItem());
items.set(thisIdx, DragStore.getDraggable());
this.getListView().setItems(items);
if(selectedInterviewIndex==draggedIdx){
this.getListView().getSelectionModel().select(thisIdx);
selectedInterviewIndex=thisIdx;
}else{
int newPosition;
Section section = this.mouseIsDraggingOn(event.getY());
if (section == Section.top && thisIdx != 0) {
newPosition = thisIdx - 1;
} else {
newPosition = thisIdx;
}
// items.set(draggedIdx, getItem());
// items.set(thisIdx, DragStore.getDraggable());
// this.getListView().setItems(items);
Interview selectedInterview = items.remove(draggedIdx);
items.add(newPosition, selectedInterview);
if (selectedInterviewIndex == draggedIdx) {
this.getListView().getSelectionModel().select(newPosition);
selectedInterviewIndex = newPosition;
} else {
this.getListView().getSelectionModel().select(selectedInterviewIndex);
}
success = true;
newController.updateColor();
// newController.updateColor();
}

event.setDropCompleted(success);
Expand All @@ -120,7 +140,8 @@ private void addDragAndDrop(InterviewSelectorCellController newController){

this.setOnDragExited(dragEvent -> {
this.setStyle("-fx-opacity: 1;");
newController.updateColor();
this.getListView().getSelectionModel().select(selectedInterviewIndex);
// newController.updateColor();
});

this.setOnDragEntered(dragEvent -> {
Expand All @@ -129,6 +150,16 @@ private void addDragAndDrop(InterviewSelectorCellController newController){
});
}

public Section mouseIsDraggingOn(double y) {
if (y < 10) {
return Section.top;
} else if (y > 20) {
return Section.bottom;
} else {
return Section.middle;
}
}

private void removeGraphics() {
this.setGraphic(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ public InterviewSelectorCellController(Interview interview, InterviewSelectorCel

@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
pictureView.setImage(ResourceLoader.loadImage("category.png"));
pictureView.setImage(ResourceLoader.loadImage("interview-"+interview.getColor()+".png"));
name.setText(interview.getTitle());

interview.titleProperty().addListener((observableValue, s, t1) -> name.setText(t1));

MenuItem deleteButton = new MenuItem(Configuration.langBundle.getString("delete"));
MenuItem editButton = new MenuItem(Configuration.langBundle.getString("edit"));
updateColor();
// updateColor();
//ADDING COLOR
Menu changeColor = new Menu(Configuration.langBundle.getString("change_color"));

Expand Down Expand Up @@ -109,7 +109,7 @@ public void initialize(URL url, ResourceBundle resourceBundle) {

}
public void updateColor() {
this.interviewSelectorCell.setStyle("-fx-background-color: #" + interview.getColor() + ";\n"+"-fx-text-fill: black;\n"+"-fx-text-inner-color:black;\n");
this.pictureView.setImage(ResourceLoader.loadImage("interview-"+interview.getColor()+".png"));
// this.interviewSelectorCell.setStyle("-fx-text-fill: black;\n");

}
Expand Down
19 changes: 15 additions & 4 deletions src/main/resources/css/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
/*#nameDisplayer{*/
/* -fx-text-fill: black;*/
/*}*/
.list-cell:filled:selected:focused .text , .list-cell:filled:selected .text{
-fx-text-fill: #360909;
-fx-font-weight: bold;
}

/*#name {*/
/* !*-fx-background-color: linear-gradient(#328BDB 0%, #207BCF 25%, #1973C9 75%, #0A65BF 100%);*!*/
/* -fx-text-fill: black;*/
Expand All @@ -24,6 +21,20 @@

/*}*/

/*
--Interviews panel--
*/
.list-cell:filled:selected:focused .text , .list-cell:filled:selected .text{
/*-fx-text-fill: #360909;*/
-fx-font-weight: bold;
}
/*.list-cell:filled:selected:focused , .list-cell:filled:selected {*/
/*!*#697dd7;*!*/
/* -fx-background-color: rgba(74, 95, 175, 0.78);*/

/*}*/


/* --------------------------------------
* --------------------------------------
* --------------SCROLLBAR---------------
Expand Down
Binary file added src/main/resources/images/interview-7092be.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/images/interview-8671cd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/images/interview-b5e61d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/images/interview-b97a57.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/images/interview-f15252.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/images/interview-ffaec9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/images/interview-ffc90e.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/images/interview-ffffff.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3beaf17

Please sign in to comment.