6c88b6b3b4
Préparation pour nouvelle version avec gestion de la base des évaluations. La méthode analyseStyle peut être appliqué au niveau des styles de page dans les en-têtes ou les pied de page.
785 lines
26 KiB
Java
785 lines
26 KiB
Java
package fenetres;
|
|
|
|
import java.awt.BorderLayout;
|
|
import java.awt.Color;
|
|
import java.awt.Dimension;
|
|
import java.awt.Font;
|
|
import java.awt.GridLayout;
|
|
import java.awt.event.ActionEvent;
|
|
import java.awt.event.InputEvent;
|
|
import java.awt.event.KeyEvent;
|
|
import java.awt.event.MouseAdapter;
|
|
import java.awt.event.MouseEvent;
|
|
import java.util.Enumeration;
|
|
|
|
import javax.swing.AbstractAction;
|
|
import javax.swing.Action;
|
|
import javax.swing.ImageIcon;
|
|
import javax.swing.JButton;
|
|
import javax.swing.JFrame;
|
|
import javax.swing.JLabel;
|
|
import javax.swing.JMenu;
|
|
import javax.swing.JMenuBar;
|
|
import javax.swing.JMenuItem;
|
|
import javax.swing.JOptionPane;
|
|
import javax.swing.JPanel;
|
|
import javax.swing.JScrollPane;
|
|
import javax.swing.JSplitPane;
|
|
import javax.swing.JToggleButton;
|
|
import javax.swing.JToolBar;
|
|
import javax.swing.JTree;
|
|
import javax.swing.KeyStroke;
|
|
import javax.swing.UnsupportedLookAndFeelException;
|
|
import javax.swing.event.TreeSelectionEvent;
|
|
import javax.swing.event.TreeSelectionListener;
|
|
import javax.swing.tree.DefaultMutableTreeNode;
|
|
import javax.swing.tree.TreeModel;
|
|
import javax.swing.tree.TreeNode;
|
|
import javax.swing.tree.TreePath;
|
|
import javax.swing.tree.TreeSelectionModel;
|
|
|
|
import MEPTL.commandes;
|
|
import action.actAPropos;
|
|
import action.actAbout;
|
|
import action.actAfficheInformationFichierAnalyse;
|
|
import action.actAttribut;
|
|
import action.actCollapseAll;
|
|
import action.actCollapseNode;
|
|
import action.actCopy;
|
|
import action.actDeleteNode;
|
|
import action.actDocumentation;
|
|
import action.actDownNode;
|
|
import action.actEvalueFalse;
|
|
import action.actEvalueTrue;
|
|
import action.actEvaluer;
|
|
import action.actEvaluerTousEnfantsFalse;
|
|
import action.actEvaluerTousEnfantsTrue;
|
|
import action.actExit;
|
|
import action.actExpandAll;
|
|
import action.actExpandNode;
|
|
import action.actLicence;
|
|
import action.actNewFichierAnalyse;
|
|
import action.actNodeFichier;
|
|
import action.actOpenBaseEvaluation;
|
|
import action.actPaste;
|
|
import action.actSaveEvaluation;
|
|
import action.actSetting;
|
|
import action.actTotalPoint;
|
|
import action.actTotalPointNode;
|
|
import action.actTousLesNodesEvaluer;
|
|
import action.actTutoriels;
|
|
import action.actUpNode;
|
|
import cXML.Run;
|
|
import cXML.node;
|
|
import menucontextuel.CreatePopupMenu;
|
|
|
|
|
|
|
|
/**
|
|
*
|
|
* @author pablo rodriguez
|
|
*
|
|
*/
|
|
public final class create extends JFrame {
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
// les éléments de create
|
|
private static JTree tree = new JTree();
|
|
private static DefaultMutableTreeNode selectNode;
|
|
private static afficheText textNodeSelect = new afficheText();
|
|
private JToolBar toolBarPrincipal;
|
|
private JMenuBar menuBar = new JMenuBar();
|
|
private static JButton buttonEvaluate;
|
|
private static JToggleButton tglbtnTousLesNodes;
|
|
private JPanel panelPrincipal;
|
|
private static create instance;
|
|
public static boolean isDispose = true;
|
|
private static JLabel lblInfo = new JLabel("Fichier d'analyse");
|
|
/**
|
|
* Création de la fenêtre.</br>
|
|
*/
|
|
public create() {
|
|
setBackground(new Color(255, 255, 255));
|
|
try {
|
|
initialize();
|
|
} catch (UnsupportedLookAndFeelException e) {
|
|
e.printStackTrace();
|
|
}
|
|
setVisible(true);
|
|
}
|
|
|
|
/**
|
|
* Obtient l'instance encours.</br>
|
|
* @return l'instance de la fenêtre.</br>
|
|
*/
|
|
public static create getInstance() {
|
|
if (isDispose) {
|
|
instance = new create();
|
|
}
|
|
instance.setVisible(true);
|
|
lectureFichierDejaCharger();
|
|
refreshLabelInfo();
|
|
isDispose=false;
|
|
return instance;
|
|
}
|
|
|
|
/**
|
|
* Ferme la fenêtre et quitte.
|
|
*/
|
|
public static void fermeCreate() {
|
|
if(!isDispose) {
|
|
isDispose=true;
|
|
instance.dispose();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Initialize the contents of the frame.
|
|
* @throws UnsupportedLookAndFeelException
|
|
*/
|
|
private void initialize() throws UnsupportedLookAndFeelException {
|
|
|
|
setSize(1200,800);
|
|
int screenWidth = (int) java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getWidth();
|
|
int screenHeight = (int) java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getHeight();
|
|
setLocation(( (screenWidth) - getWidth()) / 2, (screenHeight - getHeight()) / 2);
|
|
|
|
ImageIcon img = new ImageIcon(getClass().getResource("/evalwriter.png") );
|
|
setTitle(commandes.Titre + " " + commandes.version + " " + commandes.branch);
|
|
setIconImage(img.getImage());
|
|
|
|
setLocationRelativeTo( null );
|
|
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
|
|
|
// Construction et injection de la barre de menu
|
|
setJMenuBar( this.createMenuBar() );
|
|
tree.setBackground(new Color(255, 255, 255));
|
|
tree.setVisibleRowCount(30);
|
|
|
|
// Ajoute le menu contextuel de la tree
|
|
tree.setComponentPopupMenu(null);
|
|
|
|
this.createToolBar();
|
|
|
|
panelPrincipal = new JPanel();
|
|
getContentPane().add(panelPrincipal, BorderLayout.NORTH);
|
|
|
|
|
|
// The content of the window
|
|
if(commandes.fichierAnalyseValide) tree = commandes.tree;
|
|
|
|
JPanel panelLeft = new JPanel();
|
|
panelLeft.setLayout(new BorderLayout());
|
|
|
|
JPanel panelNorth = new JPanel();
|
|
panelNorth.setLayout(new GridLayout(2,1,0,0));
|
|
|
|
|
|
JScrollPane leftScrollPane = new JScrollPane( );
|
|
leftScrollPane.setPreferredSize( new Dimension(400, 0) );
|
|
|
|
JLabel lblNewLabel = new JLabel("");
|
|
lblNewLabel.setIcon(new ImageIcon(create.class.getResource("/resources/accueil fichier anlyse.png")));
|
|
panelNorth.add(lblNewLabel);
|
|
lblInfo.setFont(new Font("Tahoma", Font.BOLD, 12));
|
|
|
|
panelNorth.add(lblInfo);
|
|
|
|
panelLeft.add(panelNorth,BorderLayout.NORTH);
|
|
|
|
panelLeft.add(leftScrollPane,BorderLayout.CENTER);
|
|
|
|
JScrollPane rightScrollPane = new JScrollPane( );
|
|
|
|
// JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftScrollPane, rightScrollPane );
|
|
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panelLeft, rightScrollPane );
|
|
splitPane.setBounds(10, 10, 1364, 783); //10, 10, 1364, 783
|
|
splitPane.setDividerLocation(0.25);
|
|
|
|
textNodeSelect.setBackground(new Color(255, 242, 155));
|
|
rightScrollPane.setViewportView(textNodeSelect);
|
|
textNodeSelect.setFont(new Font("Monospaced", Font.PLAIN, 15));
|
|
|
|
leftScrollPane.setViewportView(tree);
|
|
tree.setFont(new Font("Tahoma", Font.PLAIN, 16));
|
|
|
|
getContentPane().add(splitPane, BorderLayout.CENTER);
|
|
panelPrincipal.setLayout(new GridLayout(1, 1, 0, 0));
|
|
panelPrincipal.add(toolBarPrincipal);
|
|
|
|
if(commandes.fichierAnalyseValide) {
|
|
tree.setVisible(true);
|
|
constructionTree();
|
|
}else {
|
|
tree.setVisible(false);
|
|
}
|
|
|
|
this.setExtendedState(MAXIMIZED_BOTH);
|
|
rightScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
|
// orig = (Point) rightScrollPane.getViewport().getViewPosition().clone();
|
|
|
|
ListenerAction();
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* Selection du node du tree et d'un node CXML.</br>
|
|
* Fermeture de la fenêtre.<br>
|
|
*/
|
|
private void ListenerAction() {
|
|
|
|
/**
|
|
* Selection d'un node dans le JTree.</br>
|
|
*/
|
|
tree.addMouseListener(new MouseAdapter() {
|
|
@Override
|
|
public void mouseClicked(MouseEvent e) {
|
|
if(tree.getSelectionPath()!=null) {
|
|
selectNode = (DefaultMutableTreeNode) tree.getSelectionPath().getLastPathComponent();
|
|
node nod = (node) selectNode.getUserObject(); //node sélectionné.
|
|
new CreatePopupMenu(nod); // création du popup menu.
|
|
textNodeSelect.refreshAffichage(nod); //affiche des informations sur le node.
|
|
// refreshTree(); //repaint l'arbre.
|
|
if(tree.isCollapsed(tree.getSelectionPath())){
|
|
tree.expandPath(tree.getSelectionPath()); //Etend le node sélectionné.
|
|
}else {
|
|
tree.collapsePath(tree.getSelectionPath());
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
/**
|
|
* Selection d'un node sans la souris.
|
|
*/
|
|
tree.addTreeSelectionListener(new TreeSelectionListener() {
|
|
@Override
|
|
public void valueChanged(TreeSelectionEvent e) {
|
|
if(tree.getSelectionPath()!=null) {
|
|
selectNode = (DefaultMutableTreeNode) tree.getSelectionPath().getLastPathComponent();
|
|
node nod = (node) selectNode.getUserObject(); //node sélectionné.
|
|
new CreatePopupMenu(nod); // création du popup menu.
|
|
textNodeSelect.refreshAffichage(nod); //affiche des informations sur le node.
|
|
}
|
|
}
|
|
});
|
|
|
|
/**
|
|
* Fermeture de la fenêtre.</br>
|
|
*/
|
|
addWindowListener(new java.awt.event.WindowAdapter() {
|
|
@Override
|
|
public void windowClosing(java.awt.event.WindowEvent windowEvent) {
|
|
if(JOptionPane.showConfirmDialog(null,"Voulez-vous quitter analyseWriter?", "Quitter", JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE)==JOptionPane.YES_OPTION) {
|
|
baseDonneesEvaluations.ferme();
|
|
evaluate.ferme();
|
|
fermeCreate();
|
|
};
|
|
}
|
|
});
|
|
|
|
|
|
}
|
|
|
|
/**
|
|
* Repaint l'arbre.</br>
|
|
*/
|
|
@SuppressWarnings("unused")
|
|
private void refreshTree() {
|
|
tree.repaint();
|
|
}
|
|
|
|
|
|
/**
|
|
* Methode de construction de la barre de menu.</br>
|
|
* */
|
|
private JMenuBar createMenuBar() {
|
|
|
|
// La barre de menu à proprement parler
|
|
menuBar = new JMenuBar();
|
|
|
|
// Définition du menu déroulant "File" et de son contenu
|
|
JMenu mnuFile = new JMenu( "Base des évaluations" );
|
|
mnuFile.setMnemonic( 'F' );
|
|
JMenuItem menuItem_3 = mnuFile.add( new actOpenBaseEvaluation() );
|
|
menuItem_3.setText("Base des évaluations");
|
|
mnuFile.addSeparator();
|
|
JMenuItem menuItem_4 = mnuFile.add( new actSaveEvaluation());
|
|
menuItem_4.setText("Enregistrer l'évaluation");
|
|
// mnuFile.addSeparator();
|
|
// /*JMenuItem mnuNewFile =*/
|
|
// mnuFile.add( new actOpen() );
|
|
// mnuFile.add( new actNewFichierAnalyse() );
|
|
//
|
|
//// mnuFile.add( new actPathBaseEvaluations() );
|
|
//
|
|
// mnuFile.addSeparator();
|
|
// mnuFile.add( new actSaveFileAnalysis() );
|
|
// mnuFile.add( new actSaveAs() );
|
|
mnuFile.addSeparator();
|
|
JMenuItem menuItem_5 = mnuFile.add( new actExit());
|
|
menuItem_5.setText("Quitter");
|
|
|
|
|
|
menuBar.add(mnuFile);
|
|
|
|
// Définition du menu déroulant "Edit" et de son contenu
|
|
JMenu mnuEdit = new JMenu( "Edition" );
|
|
mnuEdit.setMnemonic( 'E' );
|
|
|
|
mnuEdit.add( actUndo );
|
|
mnuEdit.add( actRedo );
|
|
mnuEdit.addSeparator();
|
|
mnuEdit.add( new actCopy() );
|
|
mnuEdit.add( actCut );
|
|
mnuEdit.add( new actPaste() );
|
|
|
|
menuBar.add(mnuEdit);
|
|
|
|
|
|
// Définition du menu Node
|
|
JMenu mnNode = new JMenu("Modifier");
|
|
mnNode.add( new actNodeFichier() );
|
|
mnNode.addSeparator();
|
|
menuBar.add(mnNode);
|
|
|
|
//Menu arbre
|
|
JMenu mnManageTree = new JMenu("Arbre");
|
|
JMenuItem menuItem = mnManageTree.add(new actUpNode());
|
|
menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.SHIFT_DOWN_MASK));
|
|
JMenuItem menuItem_2 = mnManageTree.add(new actDownNode());
|
|
menuItem_2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.SHIFT_DOWN_MASK));
|
|
mnManageTree.addSeparator();
|
|
mnManageTree.add(new actExpandAll());
|
|
mnManageTree.add(new actExpandNode());
|
|
mnManageTree.addSeparator();
|
|
mnManageTree.add(new actCollapseAll());
|
|
mnManageTree.add(new actCollapseNode());
|
|
mnManageTree.addSeparator();
|
|
JMenuItem menuItem_1 = mnManageTree.add(new actDeleteNode());
|
|
menuItem_1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK));
|
|
mnNode.add(mnManageTree);
|
|
mnNode.addSeparator();
|
|
|
|
//Définition Evaluer
|
|
JMenu mnEvaluer = new JMenu("Evaluer");
|
|
mnEvaluer.add(new actEvalueTrue());
|
|
mnEvaluer.add(new actEvalueFalse());
|
|
mnNode.add(mnEvaluer);
|
|
|
|
|
|
|
|
// Définition du menu déroulant "Création évaluation" et de son contenu
|
|
JMenu mnuExercice = new JMenu( "Création évaluation" );
|
|
mnuExercice.setMnemonic( 'N' );
|
|
mnuExercice.add(new actEvaluer());
|
|
|
|
menuBar.add(mnuExercice);
|
|
|
|
// Définition du menu déroulant "Help" et de son contenu
|
|
JMenu mnuHelp = new JMenu( "Aides" );
|
|
mnuHelp.setMnemonic( 'H' );
|
|
mnuHelp.add( new actAPropos());
|
|
mnuHelp.addSeparator();
|
|
mnuHelp.add( new actDocumentation());
|
|
mnuHelp.addSeparator();
|
|
mnuHelp.add( new actTutoriels());
|
|
mnuHelp.addSeparator();
|
|
mnuHelp.add( new actLicence());
|
|
|
|
menuBar.add( mnuHelp );
|
|
|
|
return menuBar;
|
|
}
|
|
|
|
/**
|
|
* Methode de construction de la barre d'outils/</br>
|
|
*/
|
|
private void createToolBar() {
|
|
toolBarPrincipal = new JToolBar();
|
|
toolBarPrincipal.setFloatable(false);
|
|
toolBarPrincipal.setRollover(true);
|
|
|
|
toolBarPrincipal.setName("outils principaux");
|
|
|
|
JButton btnChargeEvaluation = toolBarPrincipal.add( new actOpenBaseEvaluation() );
|
|
btnChargeEvaluation.setIcon(new ImageIcon(create.class.getResource("/resources/chargehistoriqueevaluation.png")));
|
|
btnChargeEvaluation.setHideActionText(true);
|
|
toolBarPrincipal.add(btnChargeEvaluation);
|
|
|
|
// JButton btnSaveEvluation = toolBarPrincipal.add( new actSaveHistoriqueEvaluation() );
|
|
// btnSaveEvluation.addActionListener(new ActionListener() {
|
|
// public void actionPerformed(ActionEvent e) {
|
|
// }
|
|
// });
|
|
// btnSaveEvluation.setIcon(new ImageIcon(create.class.getResource("/resources/sauvegardehistoriqueevaluation.png")));
|
|
// btnSaveEvluation.setHideActionText(true);
|
|
// toolBarPrincipal.add(btnSaveEvluation);
|
|
|
|
toolBarPrincipal.addSeparator();
|
|
|
|
JButton btnSaveEvaluation = toolBarPrincipal.add( new actSaveEvaluation() );
|
|
btnSaveEvaluation.setIcon(new ImageIcon(create.class.getResource("/resources/saveEvaluation.png")));
|
|
btnSaveEvaluation.setHideActionText(true);
|
|
toolBarPrincipal.add(btnSaveEvaluation);
|
|
|
|
JButton btnNewFichierAnalyse = toolBarPrincipal.add( new actNewFichierAnalyse() );
|
|
|
|
btnNewFichierAnalyse.setIcon(new ImageIcon(create.class.getResource("/resources/fichierODF.png")));
|
|
btnNewFichierAnalyse.setHideActionText(true);
|
|
toolBarPrincipal.add(btnNewFichierAnalyse);
|
|
|
|
toolBarPrincipal.addSeparator();
|
|
|
|
buttonEvaluate = toolBarPrincipal.add( new actEvaluer() );
|
|
buttonEvaluate.setIcon(new ImageIcon(create.class.getResource("/resources/versevaluate.png")));
|
|
|
|
toolBarPrincipal.addSeparator();
|
|
|
|
JButton btnAfficheInformationFichierAnalyse = toolBarPrincipal.add( new actAfficheInformationFichierAnalyse() );
|
|
|
|
btnAfficheInformationFichierAnalyse.setIcon(new ImageIcon(create.class.getResource("/resources/fichierAnalyseInfo.png")));
|
|
btnAfficheInformationFichierAnalyse.setHideActionText(true);
|
|
toolBarPrincipal.add(btnAfficheInformationFichierAnalyse);
|
|
|
|
JButton btnNodeFichier = toolBarPrincipal.add( new actNodeFichier() );
|
|
|
|
btnNodeFichier.setIcon(new ImageIcon(create.class.getResource("/resources/nodeFichier.png")));
|
|
btnNodeFichier.setHideActionText(true);
|
|
toolBarPrincipal.add(btnNodeFichier);
|
|
|
|
JButton btnSetting = toolBarPrincipal.add( new actSetting());
|
|
btnSetting.setIcon(new ImageIcon(create.class.getResource("/resources/setting.png")));
|
|
toolBarPrincipal.add(btnSetting);
|
|
|
|
toolBarPrincipal.addSeparator();
|
|
|
|
JButton btnEvaluerTrue = toolBarPrincipal.add( new actEvalueTrue() );
|
|
|
|
btnEvaluerTrue.setIcon(new ImageIcon(create.class.getResource("/resources/evaluertrue.png")));
|
|
btnEvaluerTrue.setHideActionText(true);
|
|
toolBarPrincipal.add(btnEvaluerTrue);
|
|
|
|
JButton btnEvaluerFalse = toolBarPrincipal.add(new actEvalueFalse() );
|
|
|
|
btnEvaluerFalse.setIcon(new ImageIcon(create.class.getResource("/resources/evaluerfalse.png")));
|
|
btnEvaluerFalse.setHideActionText(true);
|
|
toolBarPrincipal.add(btnEvaluerFalse);
|
|
|
|
JButton btnEvaluerTouteLaBrancheEtLesEnfantTrue = toolBarPrincipal.add( new actEvaluerTousEnfantsTrue() );
|
|
|
|
btnEvaluerTouteLaBrancheEtLesEnfantTrue.setIcon(new ImageIcon(create.class.getResource("/resources/evaluertouslesenfants.png")));
|
|
btnEvaluerTouteLaBrancheEtLesEnfantTrue.setHideActionText(true);
|
|
toolBarPrincipal.add(btnEvaluerTouteLaBrancheEtLesEnfantTrue);
|
|
|
|
JButton btnEvaluerTouteLaBrancheEtLesEnfantFalse = toolBarPrincipal.add( new actEvaluerTousEnfantsFalse() );
|
|
|
|
btnEvaluerTouteLaBrancheEtLesEnfantFalse.setIcon(new ImageIcon(create.class.getResource("/resources/evaluertouslesenfantsfaux.png")));
|
|
btnEvaluerTouteLaBrancheEtLesEnfantTrue.setHideActionText(true);
|
|
toolBarPrincipal.add(btnEvaluerTouteLaBrancheEtLesEnfantFalse);
|
|
|
|
toolBarPrincipal.addSeparator();
|
|
|
|
|
|
JButton btnAttribut = new JButton(new actAttribut());
|
|
|
|
btnAttribut.setText("");
|
|
btnAttribut.setIcon(new ImageIcon(create.class.getResource("/resources/attribut.png")));
|
|
toolBarPrincipal.add(btnAttribut);
|
|
|
|
toolBarPrincipal.addSeparator();
|
|
|
|
JButton btnTotalPoint = new JButton(new actTotalPoint());
|
|
|
|
btnTotalPoint.setToolTipText("Nombre de point total dans l'exercice.");
|
|
btnTotalPoint.setText("");
|
|
btnTotalPoint.setIcon(new ImageIcon(create.class.getResource("/resources/totalpoint.png")));
|
|
toolBarPrincipal.add(btnTotalPoint);
|
|
|
|
JButton btnTotalPointNode = toolBarPrincipal.add( new actTotalPointNode() );
|
|
btnTotalPointNode.setIcon(new ImageIcon(create.class.getResource("/resources/totalpointnode.png")));
|
|
btnTotalPointNode.setHideActionText(true);
|
|
toolBarPrincipal.add(btnTotalPointNode);
|
|
|
|
toolBarPrincipal.addSeparator();
|
|
|
|
|
|
tglbtnTousLesNodes = new JToggleButton("");
|
|
tglbtnTousLesNodes.setAction(new actTousLesNodesEvaluer());
|
|
tglbtnTousLesNodes.setIcon(new ImageIcon(create.class.getResource("/resources/lesnodesevaluer.png")));
|
|
toolBarPrincipal.add(tglbtnTousLesNodes);
|
|
|
|
toolBarPrincipal.addSeparator();
|
|
|
|
JButton btnAbout = toolBarPrincipal.add( new actAbout() );
|
|
btnAbout.setIcon(new ImageIcon(create.class.getResource("/resources/apropos.png")));
|
|
btnAbout.setHideActionText( true );
|
|
toolBarPrincipal.add(btnAbout);
|
|
|
|
|
|
JButton btnNewButton = toolBarPrincipal.add( new actDocumentation());
|
|
btnNewButton.setIcon(new ImageIcon(create.class.getResource("/resources/documentation.png")));
|
|
btnNewButton.setHideActionText(true);
|
|
toolBarPrincipal.add(btnNewButton);
|
|
|
|
toolBarPrincipal.addSeparator();
|
|
|
|
JButton buttonExit = toolBarPrincipal.add( new actExit() );
|
|
|
|
buttonExit.setHideActionText( true );
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Annule une action.</br>
|
|
*/
|
|
private AbstractAction actUndo = new AbstractAction() {
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
{
|
|
putValue( Action.NAME, "Annuler" );
|
|
putValue( Action.SMALL_ICON, new ImageIcon( getClass().getResource("/undo.png") ) );
|
|
putValue( Action.MNEMONIC_KEY, KeyEvent.VK_U );
|
|
putValue( Action.SHORT_DESCRIPTION, "Annuler (CTRL+Z)" );
|
|
putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_Z, KeyEvent.CTRL_DOWN_MASK ) );
|
|
}
|
|
|
|
@Override public void actionPerformed( ActionEvent e ) {
|
|
System.out.println( "Undo" );
|
|
}
|
|
};
|
|
|
|
/**
|
|
*
|
|
*/
|
|
private AbstractAction actRedo = new AbstractAction() {
|
|
|
|
/**
|
|
*
|
|
*/
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
{
|
|
putValue( Action.NAME, "Refaire" );
|
|
putValue( Action.SMALL_ICON, new ImageIcon( getClass().getResource("/redo.png") ) );
|
|
putValue( Action.MNEMONIC_KEY, KeyEvent.VK_R );
|
|
putValue( Action.SHORT_DESCRIPTION, "Refaire (CTRL+U)" );
|
|
putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_U, KeyEvent.CTRL_DOWN_MASK ) );
|
|
}
|
|
|
|
@Override public void actionPerformed( ActionEvent e ) {
|
|
System.out.println( "Redo" );
|
|
}
|
|
};
|
|
|
|
/**
|
|
*
|
|
*/
|
|
private AbstractAction actCut = new AbstractAction() {
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
{
|
|
putValue( Action.NAME, "Couper" );
|
|
putValue( Action.SMALL_ICON, new ImageIcon( getClass().getResource("/cut.png") ) );
|
|
putValue( Action.MNEMONIC_KEY, KeyEvent.VK_T );
|
|
putValue( Action.SHORT_DESCRIPTION, "Couper (CTRL+X)" );
|
|
putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.CTRL_DOWN_MASK ) );
|
|
}
|
|
|
|
@Override public void actionPerformed( ActionEvent e ) {
|
|
System.out.println( "Cut" );
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Ferme l'application.</br>
|
|
*/
|
|
public void closeWindows() {
|
|
if(JOptionPane.showConfirmDialog(null,"Voulez-vous quitter analyseWriter?", "Quitter", JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE)==JOptionPane.YES_OPTION) {
|
|
isDispose=true;
|
|
dispose();
|
|
}
|
|
}
|
|
|
|
public void closeDirectlyWindows() {
|
|
isDispose=true;
|
|
this.dispose();
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Construction du Tree avec le node sujet.
|
|
*/
|
|
public static void constructionTree() {
|
|
|
|
Run.parentAndLevel(commandes.sujet, commandes.sujet, 0);
|
|
|
|
DefaultMutableTreeNode root = null;
|
|
|
|
commandes.tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
|
|
commandes.tree.setExpandsSelectedPaths(true);
|
|
commandes.tree.setInvokesStopCellEditing(true);
|
|
|
|
tree.setExpandsSelectedPaths(true);
|
|
tree.setInvokesStopCellEditing(true);
|
|
|
|
//Construction si c'est un fichier d'analyse
|
|
if(commandes.sujet.getNomElt().equals("fichier")) {
|
|
|
|
root = new DefaultMutableTreeNode(commandes.sujet,true);
|
|
|
|
root = addNodeMutable(commandes.sujet, root);
|
|
|
|
|
|
commandes.tree = new JTree(root);
|
|
|
|
|
|
tree.setCellRenderer(new MyTreeCellRenderer());
|
|
// tree.setCellRenderer(new MyCellRenderer());
|
|
|
|
tree.setModel(commandes.tree.getModel()) ;
|
|
|
|
refreshLabelInfo();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* Rafraichi le label info contenant le nm du fichier d'analyse.
|
|
*/
|
|
private static void refreshLabelInfo() {
|
|
//Mise à jour du label info
|
|
if(commandes.sujet.getAttributs().get("analysis_filename")!=null) {
|
|
lblInfo.setText(commandes.sujet.getAttributs().get("analysis_filename"));
|
|
}else {
|
|
lblInfo.setText("fichier d'analyse");
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Permet la construction du tree.
|
|
* @param nod
|
|
* @param parent
|
|
* @return
|
|
*/
|
|
private static DefaultMutableTreeNode addNodeMutable(node nod, DefaultMutableTreeNode parent) {
|
|
if(nod!=null) {
|
|
DefaultMutableTreeNode node1 = null;
|
|
|
|
for(int i = 0 ; i < nod.getNodes().size(); i++) {
|
|
// Le node setting ne doit pas s'afficher dans le JTree
|
|
if(!nod.getNodes().get(i).getNomElt().equals("setting")) {
|
|
|
|
node1 = new DefaultMutableTreeNode(nod.getNodes().get(i));
|
|
addNodeMutable(nod.getNodes().get(i), node1);
|
|
parent.add(node1);
|
|
}
|
|
}
|
|
}
|
|
return parent;
|
|
}
|
|
|
|
/**
|
|
* Lecture du fichier déjà chargé.</br>
|
|
*/
|
|
private static void lectureFichierDejaCharger() {
|
|
if(commandes.fichierAnalyseValide) {
|
|
tree.setVisible(true);
|
|
fenetres.create.constructionTree();
|
|
fenetres.create.getTextNodeSelect().afficheChargementFichierAnalyse();
|
|
fenetres.create.getTglbtnTousLesNodes().setSelected(false);
|
|
fenetres.create.getButtonEvaluate().setEnabled(true);
|
|
fenetres.create.getTextNodeSelect().afficheChargementFichierAnalyse();
|
|
}else {
|
|
fenetres.create.getTextNodeSelect().setContentType("text/plain");
|
|
}
|
|
}
|
|
|
|
|
|
public static JTree getTree() {
|
|
return tree;
|
|
}
|
|
|
|
|
|
public static void setTree(TreeModel newModel) {
|
|
tree.setModel(newModel);
|
|
}
|
|
|
|
|
|
public static DefaultMutableTreeNode getSelectNode() {
|
|
return selectNode;
|
|
}
|
|
|
|
|
|
|
|
public static afficheText getTextNodeSelect() {
|
|
return textNodeSelect;
|
|
}
|
|
|
|
|
|
|
|
public static JToggleButton getTglbtnTousLesNodes() {
|
|
return tglbtnTousLesNodes;
|
|
}
|
|
|
|
public static JButton getButtonEvaluate() {
|
|
return buttonEvaluate;
|
|
}
|
|
|
|
public static void expandAll() {
|
|
Enumeration<?> topLevelNodes = ((TreeNode) tree.getModel().getRoot()).children();
|
|
while(topLevelNodes.hasMoreElements()) {
|
|
DefaultMutableTreeNode N = (DefaultMutableTreeNode) topLevelNodes.nextElement();
|
|
tree.expandPath(new TreePath(N.getPath()));
|
|
expandNode( N);
|
|
}
|
|
}
|
|
|
|
public static void collapseAll() {
|
|
Enumeration<?> topLevelNodes = ((TreeNode) tree.getModel().getRoot()).children();
|
|
while(topLevelNodes.hasMoreElements()) {
|
|
DefaultMutableTreeNode N = (DefaultMutableTreeNode) topLevelNodes.nextElement();
|
|
tree.collapsePath(new TreePath(N.getPath()));
|
|
collapseNode(N);
|
|
}
|
|
}
|
|
|
|
public static void expandNode(DefaultMutableTreeNode N) {
|
|
Enumeration<?> topLevelNodes = ((TreeNode) N).children();
|
|
while(topLevelNodes.hasMoreElements()) {
|
|
DefaultMutableTreeNode N1 = (DefaultMutableTreeNode) topLevelNodes.nextElement();
|
|
tree.expandPath(new TreePath(N1.getPath()));
|
|
expandNode(N1);
|
|
}
|
|
}
|
|
|
|
public static void collapseNode(DefaultMutableTreeNode N) {
|
|
Enumeration<?> topLevelNodes = ((TreeNode) N).children();
|
|
while(topLevelNodes.hasMoreElements()) {
|
|
DefaultMutableTreeNode N1 = (DefaultMutableTreeNode) topLevelNodes.nextElement();
|
|
tree.collapsePath(new TreePath(N1.getPath()));
|
|
collapseNode( N1 );
|
|
}
|
|
tree.collapsePath(new TreePath(N.getPath()));
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|