Search in sources :

Example 1 with MomentExperience

use of model.MomentExperience in project uPMT by coco35700.

the class Main method writeMoment.

/**
 * Recursive method used to recursively transform a Moment and its sub Moments into CSV compatible DATAZ
 */
private void writeMoment(DescriptionInterview ent, MomentExperience m, PrintWriter writer, String hierarchy) {
    LinkedList<String> classes = new LinkedList<String>();
    for (Type t : m.getTypes()) {
        for (Type prop : t.getTypes()) {
            Property p = (Property) prop;
            classes.add(format(t.getName()) + "," + format(p.getName()) + "," + format(p.getValue()));
        }
    }
    if (!classes.isEmpty()) {
        for (String s : classes) {
            writer.println(format(ent.getName()) + ",\"" + hierarchy + "\"" + "," + format(m.getName()) + "," + format(m.getDescripteme()) + "," + format(m.getColor()) + "," + format(m.getDuration()) + "," + s);
        }
    } else {
        writer.println(format(ent.getName()) + ",\"" + hierarchy + "\"" + "," + format(m.getName()) + "," + format(m.getDescripteme()) + "," + format(m.getColor()) + "," + format(m.getDuration()) + ",\"\",\"\",\"\"");
    }
    for (int i = 0; i < m.getSubMoments().size(); i++) {
        MomentExperience sub = m.getSubMoments().get(i);
        writeMoment(ent, sub, writer, hierarchy + "." + (i + 1));
    }
}
Also used : AlertType(javafx.scene.control.Alert.AlertType) ButtonType(javafx.scene.control.ButtonType) Type(model.Type) MomentExperience(model.MomentExperience) Property(model.Property) LinkedList(java.util.LinkedList)

Example 2 with MomentExperience

use of model.MomentExperience 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 3 with MomentExperience

use of model.MomentExperience in project uPMT by coco35700.

the class MainViewTransformations method addPaneOnDragListener.

/*
	 * Listener du panel qu'il y a entre plusieurs moment
	 * */
public static void addPaneOnDragListener(DropPane p, Main main) {
    p.setOnDragExited(new EventHandler<DragEvent>() {

        @Override
        public void handle(DragEvent event) {
            p.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));
        }
    });
    p.setOnDragOver(new EventHandler<DragEvent>() {

        public void handle(DragEvent event) {
            // setting the drag autorizations
            boolean cond = true;
            MomentExperience draggedMoment = null;
            try {
                draggedMoment = (MomentExperience) Serializer.deserialize((byte[]) event.getDragboard().getContent(MomentExpVBox.df));
                int pos = p.getCol();
                int i = ((Integer) event.getDragboard().getContent(MomentExpVBox.realCol));
                if (draggedMoment != null) {
                    if (!draggedMoment.hasParent()) {
                        // int pos = main.getGrid().getChildren().indexOf(p)/2;
                        if (p.hasMomentParent()) {
                            if (p.getMomentParent().getMoment().equals(draggedMoment))
                                cond = false;
                            else if (p.getMomentParent().isAChildOf(draggedMoment))
                                cond = false;
                        } else
                            cond = ((pos - i) > 1) || ((pos - i) < 0);
                    // System.out.println("pos-i="+(pos-i)+" -- 1 < "+(pos-i)+" < 0 ?"+cond);
                    } else {
                        if (p.hasMomentParent()) {
                            if (p.getMomentParent().getMoment().getID() == draggedMoment.getParentID()) {
                                cond = ((pos - i) > 1) || ((pos - i) < 0);
                            }
                        } else
                            cond = true;
                    }
                } else
                    cond = false;
            } catch (Exception e) {
            // System.out.println("null");
            }
            // System.out.println(Math.abs(i - pos));
            if ((event.getDragboard().getString().equals("ajoutMoment")) || (event.getDragboard().getString().equals("moveMoment") && cond)) {
                event.acceptTransferModes(TransferMode.ANY);
                // p.setBackground(new Background(new BackgroundFill(Color.GRAY, CornerRadii.EMPTY, Insets.EMPTY)));
                p.onDragOver(event.getDragboard().getString());
            }
            event.consume();
        }
    });
    p.setOnDragDropped(new EventHandler<DragEvent>() {

        public void handle(DragEvent event) {
            p.onDragExited();
            if (main.getCurrentDescription().getNumberOfMoments() == 0) {
                p.emptyProjectPane();
            }
            // int pos = main.getGrid().getColumnIndex(p)/2;
            int pos = p.getCol();
            if (event.getDragboard().getString().equals("ajoutMoment")) {
                AddMomentCommand cmd = null;
                MomentExperience moment = moment = new MomentExperience();
                if (event.getDragboard().getContent(DataFormat.HTML) != null) {
                    moment.setDescripteme((String) event.getDragboard().getContent(DataFormat.HTML));
                }
                if (p.hasMomentParent())
                    cmd = new AddMomentCommand(pos, moment, p.getMomentParent().getMoment(), main);
                else
                    cmd = new AddMomentCommand(pos, moment, main);
                cmd.execute();
                UndoCollector.INSTANCE.add(cmd);
            }
            if (event.getDragboard().getString().equals("moveMoment")) {
                // System.out.println("Panel, move a moment in index "+pos);
                MomentExperience serial = null;
                try {
                    serial = (MomentExperience) Serializer.deserialize((byte[]) event.getDragboard().getContent(MomentExpVBox.df));
                } catch (ClassNotFoundException | IOException e) {
                    e.printStackTrace();
                }
                if (p.hasMomentParent()) {
                    MoveMomentToMomentCommand cmd = new MoveMomentToMomentCommand(serial, p.getMomentParent().getMoment(), pos, main);
                    cmd.execute();
                    UndoCollector.INSTANCE.add(cmd);
                } else {
                    MoveMomentCommand cmd = new MoveMomentCommand(serial, pos, main);
                    cmd.execute();
                    UndoCollector.INSTANCE.add(cmd);
                }
            }
            // p.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));
            event.consume();
        }
    });
    p.setOnDragExited(new EventHandler<DragEvent>() {

        @Override
        public void handle(DragEvent arg0) {
            p.onDragExited();
            if (main.getCurrentDescription().getNumberOfMoments() == 0) {
                p.emptyProjectPane();
            }
        }
    });
}
Also used : DragEvent(javafx.scene.input.DragEvent) AddMomentCommand(controller.command.AddMomentCommand) Background(javafx.scene.layout.Background) BackgroundFill(javafx.scene.layout.BackgroundFill) MoveMomentCommand(controller.command.MoveMomentCommand) MomentExperience(model.MomentExperience) MoveMomentToMomentCommand(controller.command.MoveMomentToMomentCommand) IOException(java.io.IOException)

Example 4 with MomentExperience

use of model.MomentExperience in project uPMT by coco35700.

the class MainViewTransformations method loadSousMoment.

public static void loadSousMoment(MomentExpVBox mev, Main main) {
    if (mev.getChildren().size() == 1) {
        mev.getChildren().add(mev.getSousMomentPane());
    }
    // Ajout >
    if (mev.getMoment().getSubMoments().size() > 0) {
        ColumnConstraints cP = new ColumnConstraints();
        /*cP.setMinWidth(PANELSIZE);
			cP.setPrefWidth(PANELSIZE);
			cP.setMaxWidth(PANELSIZE);*/
        cP.setPrefWidth(Control.USE_COMPUTED_SIZE);
        cP.setMaxWidth(Control.USE_COMPUTED_SIZE);
        mev.getSousMomentPane().getColumnConstraints().add(cP);
        DropPane p = new DropPane(mev, 0, DropPane.PANELSIZE, main);
        addPaneOnDragListener(p, main);
        mev.getSousMomentPane().add(p, mev.getSousMomentPane().getColumnConstraints().size() - 1, 0);
    }
    int i = 0;
    for (MomentExperience m : mev.getMoment().getSubMoments()) {
        i++;
        MomentExpVBox tmp = new MomentExpVBox(main);
        tmp.setMoment(m);
        tmp.setVBoxParent(mev);
        tmp.showMoment();
        tmp.LoadMomentData();
        ColumnConstraints c = new ColumnConstraints();
        mev.getSousMomentPane().getColumnConstraints().add(c);
        mev.getSousMomentPane().add(tmp, mev.getSousMomentPane().getColumnConstraints().size() - 1, 0);
        // Ajout>
        ColumnConstraints cP = new ColumnConstraints();
        /*cP.setMinWidth(PANELSIZE);
			cP.setPrefWidth(PANELSIZE);
			cP.setMaxWidth(PANELSIZE);*/
        cP.setPrefWidth(Control.USE_COMPUTED_SIZE);
        cP.setMaxWidth(Control.USE_COMPUTED_SIZE);
        mev.getSousMomentPane().getColumnConstraints().add(cP);
        // <
        DropPane p = new DropPane(mev, i, DropPane.PANELSIZE, main);
        addPaneOnDragListener(p, main);
        mev.getSousMomentPane().add(p, mev.getSousMomentPane().getColumnConstraints().size() - 1, 0);
        MainViewTransformations.addBorderPaneMomentListener(tmp, main);
        loadTypes(tmp, main);
        loadSousMoment(tmp, main);
    }
}
Also used : ColumnConstraints(javafx.scene.layout.ColumnConstraints) DropPane(controller.DropPane) MomentExperience(model.MomentExperience) MomentExpVBox(controller.MomentExpVBox)

Example 5 with MomentExperience

use of model.MomentExperience in project uPMT by coco35700.

the class MainViewTransformations method loadGridData.

// private static int PANELSIZE = 20;
// Method used to load the grid related to a certain Interview
public static void loadGridData(GridPane grid, Main main, DescriptionInterview d) {
    // Grid initialisation ( reset )
    grid.getChildren().clear();
    grid.getColumnConstraints().clear();
    for (int j = 0; j < d.getNumberOfMoments(); j++) {
        // System.out.println("On ajoute deux colonnes, "+d.getNumberOfMoments());
        ColumnConstraints c = new ColumnConstraints();
        // c.setMinWidth(PANELSIZE);
        // c.setPrefWidth(PANELSIZE);
        // c.setMaxWidth(PANELSIZE);
        c.setPrefWidth(Control.USE_COMPUTED_SIZE);
        c.setMaxWidth(Control.USE_COMPUTED_SIZE);
        grid.getColumnConstraints().add(c);
        ColumnConstraints c2 = new ColumnConstraints();
        c2.setMinWidth(180);
        c2.setPrefWidth(Control.USE_COMPUTED_SIZE);
        c2.setMaxWidth(Control.USE_COMPUTED_SIZE);
        grid.getColumnConstraints().add(c2);
    }
    // Ajout de la colonne de fin
    ColumnConstraints c = new ColumnConstraints();
    c.setMinWidth(180);
    c.setPrefWidth(180);
    c.setMaxWidth(180);
    grid.getColumnConstraints().add(c);
    for (int i = 0; i < 1; i++) {
        for (int j = 0; j < d.getNumberOfMoments(); j++) {
            // System.out.println("On ajoute un panel");
            // Creation of the Moment box
            // if(j>=d.getNumberOfMoments()-1)width=180;
            DropPane p = new DropPane(j, DropPane.PANELSIZE, main);
            /*p.setPrefWidth(PANELSIZE);
				p.setMaxWidth(PANELSIZE);
				p.setMinWidth(PANELSIZE);*/
            p.setPrefWidth(Control.USE_COMPUTED_SIZE);
            p.setMaxWidth(Control.USE_COMPUTED_SIZE);
            p.setPrefHeight(200);
            p.setMinHeight(200);
            // p.setStyle("-fx-background-color:black;");
            addPaneOnDragListener(p, main);
            grid.add(p, j * 2, i);
            // System.out.println("On ajoute un moment");
            // System.out.println("J'ajoute un moment � "+j);
            MomentExpVBox mp = new MomentExpVBox(main);
            addBorderPaneMomentListener(mp, main);
            MomentExperience mom;
            boolean hasMoment = false;
            if (main.getCurrentDescription() != null) {
                for (MomentExperience m : d.getMoments()) {
                    // System.out.println(m.getNom()+" est � "+m.getGridCol()+" et j est � "+j);
                    if (m.getGridCol() == j) {
                        mom = m;
                        mp.setMoment(mom);
                        hasMoment = true;
                    }
                }
            }
            if (hasMoment) {
                mp.showMoment();
                mp.LoadMomentData();
                loadTypes(mp, main);
                loadSousMoment(mp, main);
            }
            grid.add(mp, (j * 2) + 1, i);
        }
    }
    DropPane p = new DropPane(d.getNumberOfMoments(), DropPane.DRAGGEDPANELSIZE, main);
    /*p.setPrefWidth(180);
		p.setMaxWidth(180);
		p.setMinWidth(180);*/
    p.setPrefHeight(200);
    p.setMinHeight(200);
    // p.setStyle("-fx-background-color:black;");
    addPaneOnDragListener(p, main);
    grid.add(p, d.getNumberOfMoments() * 2, 0);
    if (d.getNumberOfMoments() == 0) {
        p.emptyProjectPane();
    }
}
Also used : ColumnConstraints(javafx.scene.layout.ColumnConstraints) DropPane(controller.DropPane) MomentExperience(model.MomentExperience) MomentExpVBox(controller.MomentExpVBox)

Aggregations

MomentExperience (model.MomentExperience)7 IOException (java.io.IOException)3 DropPane (controller.DropPane)2 MomentExpVBox (controller.MomentExpVBox)2 AddMomentCommand (controller.command.AddMomentCommand)2 MoveMomentToMomentCommand (controller.command.MoveMomentToMomentCommand)2 DragEvent (javafx.scene.input.DragEvent)2 Background (javafx.scene.layout.Background)2 BackgroundFill (javafx.scene.layout.BackgroundFill)2 ColumnConstraints (javafx.scene.layout.ColumnConstraints)2 TypeClassRepresentationController (controller.TypeClassRepresentationController)1 AddTypeCommand (controller.command.AddTypeCommand)1 MoveMomentCommand (controller.command.MoveMomentCommand)1 ObjectOutputStream (java.io.ObjectOutputStream)1 PrintWriter (java.io.PrintWriter)1 LinkedList (java.util.LinkedList)1 Node (javafx.scene.Node)1 AlertType (javafx.scene.control.Alert.AlertType)1 ButtonType (javafx.scene.control.ButtonType)1 MouseEvent (javafx.scene.input.MouseEvent)1