Search in sources :

Example 1 with DescriptionInterview

use of model.DescriptionInterview in project uPMT by coco35700.

the class Main method export.

/**
 * Exports the project p into a CSV file
 */
public void export(Project p) {
    ObjectOutputStream oos = null;
    try {
        PrintWriter writer = new PrintWriter("exports/" + p.getName() + ".csv", "UTF-8");
        writer.println("\"ENTRETIEN\",\"ID\",\"NOM\",\"EXTRAIT\",\"COULEUR\",\"DEBUT\",\"FIN\",\"CLASSE\",\"PROP\",\"VALEUR\"");
        for (DescriptionInterview ent : p.getInterviews()) {
            for (int i = 0; i < ent.getMoments().size(); i++) {
                MomentExperience m = ent.getMoments().get(i);
                writeMoment(ent, m, writer, Integer.toString(i + 1));
            }
        }
        writer.close();
    } catch (final IOException ex) {
        ex.printStackTrace();
    }
}
Also used : DescriptionInterview(model.DescriptionInterview) MomentExperience(model.MomentExperience) IOException(java.io.IOException) ObjectOutputStream(java.io.ObjectOutputStream) PrintWriter(java.io.PrintWriter)

Example 2 with DescriptionInterview

use of model.DescriptionInterview in project uPMT by coco35700.

the class MainViewController method initialize.

@Override
public void initialize(URL arg0, ResourceBundle arg1) {
    Image image = ResourceLoader.loadImage("momentIcon.png");
    this.ajoutMomentButton.setImage(image);
    if (!main.getCurrentProject().getInterviews().isEmpty()) {
        main.setCurrentDescription(main.getCurrentProject().getInterviews().getFirst());
    }
    treeViewSchema.setEditable(true);
    treeViewInterview.setEditable(true);
    treeViewSchema.setCellFactory((TreeView<TypeController> t) -> new TypeTreeView(main));
    treeViewInterview.setCellFactory((TreeView<DescriptionInterview> t) -> new InterviewTreeView(main));
    TreeItem<TypeController> Schemaroot;
    TreeItem<DescriptionInterview> Interviewroot;
    Schemaroot = new TreeItem<TypeController>();
    Interviewroot = new TreeItem<DescriptionInterview>();
    Schemaroot.getChildren().add(SchemaTransformations.SchemaToTreeView(main.getCurrentProject().getSchema()));
    Interviewroot.getChildren().add(SchemaTransformations.EntretienToTreeView(main.getCurrentProject().getInterviews()));
    treeViewSchema.setRoot(Schemaroot);
    treeViewSchema.setShowRoot(false);
    treeViewInterview.setRoot(Interviewroot);
    treeViewInterview.setShowRoot(false);
    main.setTreeViewSchema(treeViewSchema);
    main.setTreeViewInterview(treeViewInterview);
    if (main.getCurrentDescription() != null) {
        // Give time to end initializing the scheme on the left
        Platform.runLater(new Runnable() {

            @Override
            public void run() {
                for (DescriptionInterview d : main.getCurrentProject().getInterviews()) {
                    GridPane gp = new GridPane();
                    gp.setMinHeight(200);
                    gp.setPadding(new Insets(100, 0, 0, 0));
                    addLinesToGrid(gp);
                    main.setGrid(gp);
                    MainViewTransformations.loadGridData(gp, main, d);
                    interviewsPane.put(d, gp);
                }
                updateGrid();
            }
        });
    }
    ajoutMomentButton.setOnDragDetected(new EventHandler<MouseEvent>() {

        @Override
        public void handle(MouseEvent event) {
            // TODO Auto-generated method stub
            if (main.getCurrentDescription() != null) {
                Dragboard db = ajoutMomentButton.startDragAndDrop(TransferMode.ANY);
                ClipboardContent content = new ClipboardContent();
                content.putString("ajoutMoment");
                content.putRtf("Moment Vide");
                db.setContent(content);
            }
        }
    });
    if (main.getCurrentDescription() != null)
        setDroppableText(main.getCurrentDescription().getDescripteme().getTexte().trim());
    paneDragText = new Pane();
    paneDragText.setStyle("-fx-background-color:#f4f4f4;");
    paneDragText.setCursor(Cursor.MOVE);
    paneDragText.setOpacity(0.2);
    // Quand on selectionne du texte, on met un panel devant le text pour pouvoir le dragger
    droppableText.addEventFilter(MouseEvent.MOUSE_RELEASED, new EventHandler<MouseEvent>() {

        @Override
        public void handle(MouseEvent mouseEvent) {
            if (!droppableText.getSelectedText().equals("") && !droppableText.getSelectedText().equals(" ") && !droppableText.getSelectedText().equals("\n"))
                stackForDragDrop.getChildren().add(paneDragText);
        }
    });
    // Quand on clique sur la panel qui s'est mit par dessus le texte, on l'enleve pour � nouveau rendre le texte selectionnable
    paneDragText.setOnMouseClicked(new EventHandler<MouseEvent>() {

        @Override
        public void handle(MouseEvent arg0) {
            droppableText.deselect();
            stackForDragDrop.getChildren().clear();
            stackForDragDrop.getChildren().add(droppableText);
        }
    });
    // Quand on drag le panel qui s'est mit par dessus le text
    paneDragText.setOnDragDetected(new EventHandler<MouseEvent>() {

        @Override
        public void handle(MouseEvent event) {
            // TODO Auto-generated method stub
            if (main.getCurrentDescription() != null) {
                Dragboard db = ajoutMomentButton.startDragAndDrop(TransferMode.ANY);
                ClipboardContent content = new ClipboardContent();
                content.putString("ajoutMoment");
                content.put(DataFormat.HTML, droppableText.getSelectedText());
                db.setContent(content);
            }
        }
    });
    buttonTextInterview.setOnMouseClicked(new EventHandler<MouseEvent>() {

        @Override
        public void handle(MouseEvent arg0) {
            if (droppableText.isDisabled()) {
                buttonTextInterview.setImage(ResourceLoader.loadImage("closeMenuBlack.png"));
                droppableText.setDisable(false);
                mainSplitPane.setDividerPosition(1, splitPos);
                stackForDragDrop.getChildren().add(droppableText);
                topBarContainerTextInterview.setCenter(textInterviewTitle);
                paneOfTextArea.setMaxWidth(paneOfTextArea.USE_COMPUTED_SIZE);
            } else {
                buttonTextInterview.setImage(ResourceLoader.loadImage("openMenuBlack.png"));
                droppableText.deselect();
                droppableText.setDisable(true);
                splitPos = mainSplitPane.getDividers().get(1).getPosition();
                mainSplitPane.setDividerPosition(1, 1);
                stackForDragDrop.getChildren().clear();
                topBarContainerTextInterview.setCenter(null);
                paneOfTextArea.setMaxWidth(buttonTextInterview.getFitWidth());
            }
        }
    });
}
Also used : MomentAddTypeController(controller.controller.MomentAddTypeController) TypeController(controller.controller.TypeController) MomentRemoveTypeController(controller.controller.MomentRemoveTypeController) TypeTreeView(controller.typeTreeView.TypeTreeView) GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) MouseEvent(javafx.scene.input.MouseEvent) ClipboardContent(javafx.scene.input.ClipboardContent) DescriptionInterview(model.DescriptionInterview) Image(javafx.scene.image.Image) StackPane(javafx.scene.layout.StackPane) ScrollPane(javafx.scene.control.ScrollPane) Pane(javafx.scene.layout.Pane) SplitPane(javafx.scene.control.SplitPane) FlowPane(javafx.scene.layout.FlowPane) BorderPane(javafx.scene.layout.BorderPane) GridPane(javafx.scene.layout.GridPane) InterviewTreeView(controller.interviewTreeView.InterviewTreeView) InterviewTreeView(controller.interviewTreeView.InterviewTreeView) TreeView(javafx.scene.control.TreeView) TypeTreeView(controller.typeTreeView.TypeTreeView) Dragboard(javafx.scene.input.Dragboard)

Example 3 with DescriptionInterview

use of model.DescriptionInterview in project uPMT by coco35700.

the class NewInterviewDialogController method validerClick.

public void validerClick() {
    LocalDate d = dateEntretien.getValue();
    String text = "";
    try {
        File fileDir = fichierChoisi;
        BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(fileDir), "UTF8"));
        String line = br.readLine();
        while (line != null || !line.equals(null)) {
            text = text + line + "\n";
            line = br.readLine();
        }
        br.close();
    } catch (Exception e) {
    // System.out.println(e.getMessage());
    }
    // System.out.println(text);
    DescriptionInterview de = new DescriptionInterview(new Descripteme(text), nomEntretien.getText());
    de.setDateInterview(d);
    if (!participantEntretien.getText().replaceAll(" ", "").equals(""))
        de.setParticipant(participantEntretien.getText());
    if (!commentaireEntretien.getText().replaceAll(" ", "").equals(""))
        de.setComment(commentaireEntretien.getText());
    if (main.getProjectInCreation() != null) {
        main.getProjects().add(main.getProjectInCreation());
        main.setCurrentProject(main.getProjectInCreation());
        main.getCurrentProject().save();
        main.setProjectInCreation(null);
        main.launchMainView();
    }
    main.getCurrentProject().addEntretiens(de);
    main.setCurrentDescription(de);
    main.refreshDataTreeView();
    main.getMainViewController().addGridPaneInterview(de);
    main.getMainViewController().updateGrid();
    // in case the center was set to null because of automatic interview Creation
    if (main.getRootLayout().getCenter() == null) {
        main.launchMainView();
    }
    main.getCurrentProject().save();
    main.launchMainView();
    main.refreshDataTreeView();
    main.needToSave();
    window.close();
}
Also used : InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) DescriptionInterview(model.DescriptionInterview) LocalDate(java.time.LocalDate) File(java.io.File) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) Descripteme(model.Descripteme)

Example 4 with DescriptionInterview

use of model.DescriptionInterview in project uPMT by coco35700.

the class SchemaTransformations method EntretienToTreeView.

public static TreeItem<DescriptionInterview> EntretienToTreeView(LinkedList<DescriptionInterview> entretiens) {
    TreeItem<DescriptionInterview> entres;
    entres = new TreeItem<DescriptionInterview>(new DescriptionInterview(null, "Interviews"));
    // entres = new TreeItem<DescriptionEntretien>(new DescriptionEntretien(null,main._langBundle.getString("interview")));
    entres.setExpanded(true);
    for (DescriptionInterview d : entretiens) {
        entres.getChildren().add(new TreeItem<DescriptionInterview>(d));
    }
    return entres;
}
Also used : DescriptionInterview(model.DescriptionInterview)

Example 5 with DescriptionInterview

use of model.DescriptionInterview in project uPMT by coco35700.

the class InterviewTreeView method updateItem.

@Override
protected void updateItem(DescriptionInterview elem, boolean empty) {
    super.updateItem(elem, empty);
    if (empty || elem == null) {
        setText(null);
        setGraphic(null);
    } else {
        // if elem is an interview of the project
        DescriptionInterview desc = ((DescriptionInterview) elem);
        try {
            FXMLLoader loader = new FXMLLoader();
            loader.setLocation(getClass().getResource("/view/EntretienTreeView.fxml"));
            InterviewTreeViewController controller = new InterviewTreeViewController(desc, this);
            this.controller = controller;
            loader.setController(controller);
            BorderPane elementPane = (BorderPane) loader.load();
            this.setGraphic(elementPane);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (desc.getName().equals("Interviews")) {
            try {
                FXMLLoader loader = new FXMLLoader();
                loader.setLocation(getClass().getResource("/view/RootEntretienTreeView.fxml"));
                RootInterviewTreeViewController controller = new RootInterviewTreeViewController(desc, main);
                this.controller = controller;
                loader.setController(controller);
                BorderPane elementPane;
                elementPane = (BorderPane) loader.load();
                this.setGraphic(elementPane);
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            this.setOnMouseClicked(new EventHandler<MouseEvent>() {

                @Override
                public void handle(MouseEvent event) {
                    main.setCurrentDescription(desc);
                    main.getTreeViewInterview().refresh();
                    main.getMainViewController().updateGrid();
                }
            });
            if ((!main.getCurrentProject().getInterviews().isEmpty()) && desc.equals(main.getCurrentDescription())) {
                ((InterviewTreeViewController) controller).setSelected("blue");
            } else {
                ((InterviewTreeViewController) controller).setSelected("black");
            }
        }
    }
}
Also used : BorderPane(javafx.scene.layout.BorderPane) MouseEvent(javafx.scene.input.MouseEvent) DescriptionInterview(model.DescriptionInterview) IOException(java.io.IOException) FXMLLoader(javafx.fxml.FXMLLoader)

Aggregations

DescriptionInterview (model.DescriptionInterview)6 IOException (java.io.IOException)3 MouseEvent (javafx.scene.input.MouseEvent)2 BorderPane (javafx.scene.layout.BorderPane)2 MomentAddTypeController (controller.controller.MomentAddTypeController)1 MomentRemoveTypeController (controller.controller.MomentRemoveTypeController)1 TypeController (controller.controller.TypeController)1 InterviewTreeView (controller.interviewTreeView.InterviewTreeView)1 TypeTreeView (controller.typeTreeView.TypeTreeView)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStreamReader (java.io.InputStreamReader)1 ObjectOutputStream (java.io.ObjectOutputStream)1 PrintWriter (java.io.PrintWriter)1 LocalDate (java.time.LocalDate)1 FXMLLoader (javafx.fxml.FXMLLoader)1 Insets (javafx.geometry.Insets)1 ScrollPane (javafx.scene.control.ScrollPane)1 SplitPane (javafx.scene.control.SplitPane)1