Gestion de la désactivation des boutons de projet + curseur grille
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
AppThinker/.idea/*
|
||||
AppThinker/out/*
|
||||
AppThinker/out/*
|
||||
AppThinker/src/img/work/*
|
||||
@@ -11,7 +11,6 @@ public class AppThinkerGrid extends JPanel {
|
||||
*/
|
||||
public AppThinkerGrid(){
|
||||
this.setBackground(new Color(192, 192, 192));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import javax.accessibility.Accessible;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/**
|
||||
* Affiche une barre de menu en entête de la fenêtre.
|
||||
@@ -8,71 +11,228 @@ import java.awt.*;
|
||||
*/
|
||||
public class AppThinkerMenuBar extends JMenuBar {
|
||||
|
||||
private JMenu _fileMenu;
|
||||
private JMenuItem _newProject;
|
||||
private JMenuItem _openProject;
|
||||
private JMenuItem _saveProject;
|
||||
private JMenuItem _saveAsProject;
|
||||
private JMenuItem _closeProject;
|
||||
private JMenuItem _quitMenu;
|
||||
|
||||
private JMenu _projectMenu;
|
||||
private JMenuItem _newClass;
|
||||
private JMenuItem _newAssociation;
|
||||
private JMenuItem _newLink;
|
||||
private JMenuItem _editElement;
|
||||
private JMenuItem _deleteElement;
|
||||
private JMenuItem _projectOptions;
|
||||
|
||||
private JMenu _appMenu;
|
||||
private JMenuItem _appSettings;
|
||||
private JMenuItem _appInfo;
|
||||
private JMenuItem _appChangelog;
|
||||
|
||||
private AppThinkerWindow _window;
|
||||
|
||||
|
||||
/**
|
||||
* Constructeur de la classe AppThinkerMenuBar
|
||||
* @param window Une instance de AppThinkerWindow.
|
||||
*/
|
||||
public AppThinkerMenuBar(){
|
||||
public AppThinkerMenuBar(AppThinkerWindow window){
|
||||
this._window = window;
|
||||
|
||||
//Création de la barre menu
|
||||
JMenu fileMenu = new JMenu("Fichier");
|
||||
fileMenu.setMnemonic( 'F' );
|
||||
_fileMenu = new JMenu("Fichier");
|
||||
_fileMenu.setMnemonic( 'F' );
|
||||
|
||||
JMenuItem newProject = new JMenuItem("Nouveau projet");
|
||||
newProject.setIcon(new ImageIcon(getClass().getResource("img/x16/newProject.png")));
|
||||
fileMenu.add(newProject);
|
||||
_newProject = new JMenuItem("Nouveau projet");
|
||||
_newProject.setIcon(new ImageIcon(getClass().getResource("img/x16/newProject.png")));
|
||||
_newProject.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
_window.newProject();
|
||||
}
|
||||
});
|
||||
_fileMenu.add(_newProject);
|
||||
|
||||
JMenuItem openProject = new JMenuItem("Ouvrir un projet existant");
|
||||
openProject.setIcon(new ImageIcon(getClass().getResource("img/x16/openProject.png")));
|
||||
fileMenu.add(openProject);
|
||||
JMenuItem saveProject = new JMenuItem("Sauvegarder le projet");
|
||||
saveProject.setIcon(new ImageIcon(getClass().getResource("img/x16/saveProject.png")));
|
||||
fileMenu.add(saveProject);
|
||||
JMenuItem saveAsProject = new JMenuItem("Sauvegarder le projet sous...");
|
||||
saveAsProject.setIcon(new ImageIcon(getClass().getResource("img/x16/saveAsProject.png")));
|
||||
fileMenu.add(saveAsProject);
|
||||
JMenuItem quitMenu = new JMenuItem("Quitter");
|
||||
quitMenu.setIcon(new ImageIcon(getClass().getResource("img/x16/quit.png")));
|
||||
fileMenu.add(quitMenu);
|
||||
_openProject = new JMenuItem("Ouvrir un projet existant");
|
||||
_openProject.setIcon(new ImageIcon(getClass().getResource("img/x16/openProject.png")));
|
||||
_openProject.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
_window.openProject();
|
||||
}
|
||||
});
|
||||
_fileMenu.add(_openProject);
|
||||
_saveProject = new JMenuItem("Sauvegarder le projet");
|
||||
_saveProject.setIcon(new ImageIcon(getClass().getResource("img/x16/saveProject.png")));
|
||||
_saveProject.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
_window.saveProject();
|
||||
}
|
||||
});
|
||||
_fileMenu.add(_saveProject);
|
||||
_saveAsProject = new JMenuItem("Sauvegarder le projet sous...");
|
||||
_saveAsProject.setIcon(new ImageIcon(getClass().getResource("img/x16/saveAsProject.png")));
|
||||
_saveAsProject.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
_window.saveAsProject();
|
||||
}
|
||||
});
|
||||
_fileMenu.add(_saveAsProject);
|
||||
_closeProject = new JMenuItem("Fermer le projet");
|
||||
_closeProject.setIcon(new ImageIcon(getClass().getResource("img/x16/closeProject.png")));
|
||||
_closeProject.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
_window.closeProject();
|
||||
}
|
||||
});
|
||||
_fileMenu.add(_closeProject);
|
||||
_quitMenu = new JMenuItem("Quitter");
|
||||
_quitMenu.setIcon(new ImageIcon(getClass().getResource("img/x16/quit.png")));
|
||||
_quitMenu.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
_fileMenu.add(_quitMenu);
|
||||
|
||||
this.add(fileMenu);
|
||||
this.add(_fileMenu);
|
||||
|
||||
JMenu projectMenu = new JMenu("Projet");
|
||||
projectMenu.setMnemonic( 'P' );
|
||||
_projectMenu = new JMenu("Projet");
|
||||
_projectMenu.setMnemonic( 'P' );
|
||||
|
||||
JMenuItem newClass = new JMenuItem("Nouvelle classe");
|
||||
newClass.setIcon(new ImageIcon(getClass().getResource("img/x16/newClass.png")));
|
||||
projectMenu.add(newClass);
|
||||
JMenuItem newAssociation = new JMenuItem("Nouvelle association");
|
||||
newAssociation.setIcon(new ImageIcon(getClass().getResource("img/x16/newAssociation.png")));
|
||||
projectMenu.add(newAssociation);
|
||||
JMenuItem newLink = new JMenuItem("Nouveau lien");
|
||||
newLink.setIcon(new ImageIcon(getClass().getResource("img/x16/newLink.png")));
|
||||
projectMenu.add(newLink);
|
||||
JMenuItem editElement = new JMenuItem("Éditer");
|
||||
editElement.setIcon(new ImageIcon(getClass().getResource("img/x16/edit.png")));
|
||||
projectMenu.add(editElement);
|
||||
JMenuItem deleteElement = new JMenuItem("Supprimer");
|
||||
deleteElement.setIcon(new ImageIcon(getClass().getResource("img/x16/delete.png")));
|
||||
projectMenu.add(deleteElement);
|
||||
JMenuItem projectOptions = new JMenuItem("Options du projet");
|
||||
projectOptions.setIcon(new ImageIcon(getClass().getResource("img/x16/settings.png")));
|
||||
projectMenu.add(projectOptions);
|
||||
_newClass = new JMenuItem("Nouvelle classe");
|
||||
_newClass.setIcon(new ImageIcon(getClass().getResource("img/x16/newClass.png")));
|
||||
_newClass.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
showEditMouse();
|
||||
}
|
||||
});
|
||||
_projectMenu.add(_newClass);
|
||||
_newAssociation = new JMenuItem("Nouvelle association");
|
||||
_newAssociation.setIcon(new ImageIcon(getClass().getResource("img/x16/newAssociation.png")));
|
||||
_newAssociation.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
showEditMouse();
|
||||
}
|
||||
});
|
||||
_projectMenu.add(_newAssociation);
|
||||
_newLink = new JMenuItem("Nouveau lien");
|
||||
_newLink.setIcon(new ImageIcon(getClass().getResource("img/x16/newLink.png")));
|
||||
_newLink.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
showEditMouse();
|
||||
}
|
||||
});
|
||||
_projectMenu.add(_newLink);
|
||||
_editElement = new JMenuItem("Éditer");
|
||||
_editElement.setIcon(new ImageIcon(getClass().getResource("img/x16/edit.png")));
|
||||
_editElement.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
showEditMouse();
|
||||
}
|
||||
});
|
||||
_projectMenu.add(_editElement);
|
||||
_deleteElement = new JMenuItem("Supprimer");
|
||||
_deleteElement.setIcon(new ImageIcon(getClass().getResource("img/x16/delete.png")));
|
||||
_deleteElement.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
showEditMouse();
|
||||
}
|
||||
});
|
||||
_projectMenu.add(_deleteElement);
|
||||
_projectOptions = new JMenuItem("Options du projet");
|
||||
_projectOptions.setIcon(new ImageIcon(getClass().getResource("img/x16/settings.png")));
|
||||
_projectMenu.add(_projectOptions);
|
||||
|
||||
this.add(projectMenu);
|
||||
this.add(_projectMenu);
|
||||
|
||||
JMenu appMenu = new JMenu("AppThinker");
|
||||
appMenu.setMnemonic( 'A' );
|
||||
_appMenu = new JMenu("AppThinker");
|
||||
_appMenu.setMnemonic( 'A' );
|
||||
|
||||
JMenuItem appSettings = new JMenuItem("Paramètres");
|
||||
appSettings.setIcon(new ImageIcon(getClass().getResource("img/x16/settings.png")));
|
||||
appMenu.add(appSettings);
|
||||
JMenuItem appInfos = new JMenuItem("Informations");
|
||||
appInfos.setIcon(new ImageIcon(getClass().getResource("img/x16/info.png")));
|
||||
appMenu.add(appInfos);
|
||||
JMenuItem appChangelog = new JMenuItem("Nouveautés");
|
||||
appChangelog.setIcon(new ImageIcon(getClass().getResource("img/x16/news.png")));
|
||||
appMenu.add(appChangelog);
|
||||
_appSettings = new JMenuItem("Paramètres");
|
||||
_appSettings.setIcon(new ImageIcon(getClass().getResource("img/x16/settings.png")));
|
||||
_appMenu.add(_appSettings);
|
||||
_appInfo = new JMenuItem("Informations");
|
||||
_appInfo.setIcon(new ImageIcon(getClass().getResource("img/x16/info.png")));
|
||||
_appMenu.add(_appInfo);
|
||||
_appChangelog = new JMenuItem("Nouveautés");
|
||||
_appChangelog.setIcon(new ImageIcon(getClass().getResource("img/x16/news.png")));
|
||||
_appMenu.add(_appChangelog);
|
||||
|
||||
this.add(appMenu);
|
||||
this.add(_appMenu);
|
||||
|
||||
this.disableEditing();
|
||||
}
|
||||
|
||||
/**
|
||||
* Active les boutons d'édition lorsqu'un projet est ouvert.
|
||||
*/
|
||||
public void enableEditing(){
|
||||
_newProject.setEnabled(true);
|
||||
_openProject.setEnabled(true);
|
||||
_saveProject.setEnabled(true);
|
||||
_saveAsProject.setEnabled(true);
|
||||
_closeProject.setEnabled(true);
|
||||
_quitMenu.setEnabled(true);
|
||||
|
||||
_newClass.setEnabled(true);
|
||||
_newAssociation.setEnabled(true);
|
||||
_newLink.setEnabled(true);
|
||||
_editElement.setEnabled(true);
|
||||
_deleteElement.setEnabled(true);
|
||||
_projectOptions.setEnabled(true);
|
||||
|
||||
_appSettings.setEnabled(true);
|
||||
_appInfo.setEnabled(true);
|
||||
_appChangelog.setEnabled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Désactive les boutons d'édition lorsqu'aucun projet n'est ouvert.
|
||||
*/
|
||||
public void disableEditing(){
|
||||
_newProject.setEnabled(true);
|
||||
_openProject.setEnabled(true);
|
||||
_saveProject.setEnabled(false);
|
||||
_saveAsProject.setEnabled(false);
|
||||
_closeProject.setEnabled(false);
|
||||
_quitMenu.setEnabled(true);
|
||||
|
||||
_newClass.setEnabled(false);
|
||||
_newAssociation.setEnabled(false);
|
||||
_newLink.setEnabled(false);
|
||||
_editElement.setEnabled(false);
|
||||
_deleteElement.setEnabled(false);
|
||||
_projectOptions.setEnabled(false);
|
||||
|
||||
_appSettings.setEnabled(true);
|
||||
_appInfo.setEnabled(true);
|
||||
_appChangelog.setEnabled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change le curseur de la grille en curseur d'édition.
|
||||
*/
|
||||
public void showEditMouse(){
|
||||
this._window.getGrid().setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
|
||||
}
|
||||
|
||||
/**
|
||||
* Change le curseur de la grille en curseur de sélection.
|
||||
*/
|
||||
public void showSelectMouse(){
|
||||
this._window.getGrid().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,14 @@ import java.awt.*;
|
||||
* @author V.BOULANGER
|
||||
*/
|
||||
public class AppThinkerStatusbar extends JPanel {
|
||||
|
||||
private JLabel _statusLabel;
|
||||
private JLabel _posXLabel;
|
||||
private JLabel _posYLabel;
|
||||
private JLabel _sizeXLabel;
|
||||
private JLabel _sizeYLabel;
|
||||
private JLabel _fileLabel;
|
||||
|
||||
/**
|
||||
* Constructeur de la classe AppThinkerStatusbar
|
||||
*/
|
||||
@@ -15,39 +23,94 @@ public class AppThinkerStatusbar extends JPanel {
|
||||
this.setBorder(new BevelBorder(BevelBorder.LOWERED));
|
||||
this.setLayout(new GridLayout(1,3));
|
||||
|
||||
JLabel statusLabel = new JLabel("Prêt");
|
||||
this.add(statusLabel);
|
||||
_statusLabel = new JLabel("Prêt.");
|
||||
this.add(_statusLabel);
|
||||
|
||||
JPanel actionBar = new JPanel();
|
||||
|
||||
JLabel posXLabel = new JLabel("PX : 0 | ");
|
||||
actionBar.add(posXLabel);
|
||||
JLabel posYLabel = new JLabel("PY : 0 | ");
|
||||
actionBar.add(posYLabel);
|
||||
JLabel sizeXLabel = new JLabel("SX : 0 | ");
|
||||
actionBar.add(sizeXLabel);
|
||||
JLabel sizeYLabel = new JLabel("SY : 0");
|
||||
actionBar.add(sizeYLabel);
|
||||
JButton editActionBtn = new JButton();
|
||||
editActionBtn.setIcon(new ImageIcon(getClass().getResource("img/x16/edit.png")));
|
||||
editActionBtn.setToolTipText("Éditer l'élément sélectionné.");
|
||||
editActionBtn.setOpaque(false);
|
||||
editActionBtn.setContentAreaFilled(false);
|
||||
editActionBtn.setBorderPainted(false);
|
||||
actionBar.add(editActionBtn);
|
||||
JButton deleteActionBtn = new JButton();
|
||||
deleteActionBtn.setIcon(new ImageIcon(getClass().getResource("img/x16/delete.png")));
|
||||
deleteActionBtn.setToolTipText("Supprimer l'élément sélectionné.");
|
||||
deleteActionBtn.setOpaque(false);
|
||||
deleteActionBtn.setContentAreaFilled(false);
|
||||
deleteActionBtn.setBorderPainted(false);
|
||||
actionBar.add(deleteActionBtn);
|
||||
|
||||
_posXLabel = new JLabel("PX : 0 |");
|
||||
actionBar.add(_posXLabel);
|
||||
_posYLabel = new JLabel("PY : 0 |");
|
||||
actionBar.add(_posYLabel);
|
||||
_sizeXLabel = new JLabel("SX : 0 |");
|
||||
actionBar.add(_sizeXLabel);
|
||||
_sizeYLabel = new JLabel("SY : 0");
|
||||
actionBar.add(_sizeYLabel);
|
||||
|
||||
this.add(actionBar);
|
||||
|
||||
JLabel fileLabel = new JLabel("Aucun projet ouvert");
|
||||
fileLabel.setHorizontalAlignment(JLabel.RIGHT);
|
||||
this.add(fileLabel);
|
||||
_fileLabel = new JLabel("Aucun projet ouvert");
|
||||
_fileLabel.setHorizontalAlignment(JLabel.RIGHT);
|
||||
this.add(_fileLabel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Met à jour le texte de statut de la barre de statut.
|
||||
* @param msg Le message à afficher.
|
||||
*/
|
||||
public void setStatusMessage(String msg){
|
||||
this._statusLabel.setText(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Met à jour le nom du fichier dans la barre de statut.
|
||||
* @param file Le nom du fichier à afficher.
|
||||
*/
|
||||
public void setFileMessage(String file){
|
||||
this._fileLabel.setText(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Met à jour le label de position X.
|
||||
* @param posX La position X.
|
||||
*/
|
||||
public void setPosXLabel(int posX){
|
||||
this._posXLabel.setText(Integer.toString(posX));
|
||||
}
|
||||
|
||||
/**
|
||||
* Met à jour le label de position Y.
|
||||
* @param posY La position Y.
|
||||
*/
|
||||
public void setPosYLabel(int posY){
|
||||
this._posYLabel.setText(Integer.toString(posY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Met à jour les labels de position.
|
||||
* @param posX La position X.
|
||||
* @param posY La position Y.
|
||||
*/
|
||||
public void setPosLabel(int posX, int posY){
|
||||
this._posXLabel.setText(Integer.toString(posX));
|
||||
this._posYLabel.setText(Integer.toString(posY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Met à jour le label de taille X.
|
||||
* @param sizeX La taille X.
|
||||
*/
|
||||
public void setSizeXLabel(int sizeX){
|
||||
this._sizeXLabel.setText(Integer.toString(sizeX));
|
||||
}
|
||||
|
||||
/**
|
||||
* Met à jour le label de taille Y.
|
||||
* @param sizeY La taille Y.
|
||||
*/
|
||||
public void setSizeYLabel(int sizeY){
|
||||
this._sizeYLabel.setText(Integer.toString(sizeY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Met à jour les labels de taille.
|
||||
* @param sizeX La taille X.
|
||||
* @param sizeY La taille Y.
|
||||
*/
|
||||
public void setSizeLabel(int sizeX, int sizeY){
|
||||
this._sizeXLabel.setText(Integer.toString(sizeX));
|
||||
this._sizeYLabel.setText(Integer.toString(sizeY));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,115 +1,197 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/**
|
||||
* Affiche une barre d'actions en haut de la fenêtre.
|
||||
* @author V.BOULANGER
|
||||
*/
|
||||
public class AppThinkerToolbar extends JPanel {
|
||||
|
||||
private JPanel _projectPanel;
|
||||
private JButton _newProject;
|
||||
private JButton _openProject;
|
||||
private JButton _saveProject;
|
||||
private JButton _saveAsProject;
|
||||
|
||||
private JPanel _editionPanel;
|
||||
private JButton _select;
|
||||
private JButton _edit;
|
||||
private JButton _delete;
|
||||
private JButton _copy;
|
||||
private JButton _paste;
|
||||
private JButton _undo;
|
||||
private JButton _redo;
|
||||
|
||||
private JPanel _modelisationPanel;
|
||||
private JButton _newClass;
|
||||
private JButton _newAssociation;
|
||||
private JButton _newLink;
|
||||
|
||||
private AppThinkerWindow _window;
|
||||
|
||||
/**
|
||||
* Constructeur de la classe AppThinkerToolbar
|
||||
* @param window Une instance de AppThinkerWindow.
|
||||
*/
|
||||
public AppThinkerToolbar(){
|
||||
public AppThinkerToolbar(AppThinkerWindow window){
|
||||
this._window = window;
|
||||
//Création de la Toolbar
|
||||
this.setLayout(new GridLayout(2,3, 10, 0));
|
||||
this.setBackground(new Color(69, 69, 72));
|
||||
|
||||
JPanel projectPanel = new JPanel();
|
||||
projectPanel.setLayout(new GridLayout(1,4));
|
||||
JButton newProject = new JButton();
|
||||
newProject.setSize(32, 32);
|
||||
newProject.setBorderPainted(false);
|
||||
newProject.setIcon(new ImageIcon(getClass().getResource("img/x32/newProject.png")));
|
||||
newProject.setToolTipText("Créer un nouveau projet.");
|
||||
projectPanel.add(newProject);
|
||||
JButton openProject = new JButton();
|
||||
openProject.setSize(32, 32);
|
||||
openProject.setBorderPainted(false);
|
||||
openProject.setIcon(new ImageIcon(getClass().getResource("img/x32/importProject.png")));
|
||||
openProject.setToolTipText("Importer un projet existant.");
|
||||
projectPanel.add(openProject);
|
||||
JButton saveProject = new JButton();
|
||||
saveProject.setSize(32, 32);
|
||||
saveProject.setBorderPainted(false);
|
||||
saveProject.setIcon(new ImageIcon(getClass().getResource("img/x32/saveProject.png")));
|
||||
saveProject.setToolTipText("Sauvegarder le projet.");
|
||||
projectPanel.add(saveProject);
|
||||
JButton saveAsProject = new JButton();
|
||||
saveAsProject.setSize(32, 32);
|
||||
saveAsProject.setBorderPainted(false);
|
||||
saveAsProject.setIcon(new ImageIcon(getClass().getResource("img/x32/saveAsProject.png")));
|
||||
saveAsProject.setToolTipText("Sauvegarder le projet à un autre endroit.");
|
||||
projectPanel.add(saveAsProject);
|
||||
_projectPanel = new JPanel();
|
||||
_projectPanel.setLayout(new GridLayout(1,4));
|
||||
//Bouton ajout d'un nouveau projet
|
||||
_newProject = new JButton();
|
||||
_newProject.setSize(32, 32);
|
||||
_newProject.setBorderPainted(false);
|
||||
_newProject.setIcon(new ImageIcon(getClass().getResource("img/x32/newProject.png")));
|
||||
_newProject.setToolTipText("Créer un nouveau projet.");
|
||||
_newProject.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
_window.newProject();
|
||||
}
|
||||
});
|
||||
_projectPanel.add(_newProject);
|
||||
_openProject = new JButton();
|
||||
_openProject.setSize(32, 32);
|
||||
_openProject.setBorderPainted(false);
|
||||
_openProject.setIcon(new ImageIcon(getClass().getResource("img/x32/importProject.png")));
|
||||
_openProject.setToolTipText("Importer un projet existant.");
|
||||
_projectPanel.add(_openProject);
|
||||
_saveProject = new JButton();
|
||||
_saveProject.setSize(32, 32);
|
||||
_saveProject.setBorderPainted(false);
|
||||
_saveProject.setIcon(new ImageIcon(getClass().getResource("img/x32/saveProject.png")));
|
||||
_saveProject.setToolTipText("Sauvegarder le projet.");
|
||||
_projectPanel.add(_saveProject);
|
||||
_saveAsProject = new JButton();
|
||||
_saveAsProject.setSize(32, 32);
|
||||
_saveAsProject.setBorderPainted(false);
|
||||
_saveAsProject.setIcon(new ImageIcon(getClass().getResource("img/x32/saveAsProject.png")));
|
||||
_saveAsProject.setToolTipText("Sauvegarder le projet à un autre endroit.");
|
||||
_projectPanel.add(_saveAsProject);
|
||||
|
||||
JPanel editionPanel = new JPanel();
|
||||
editionPanel.setLayout(new GridLayout(1,7));
|
||||
JButton select = new JButton();
|
||||
select.setSize(32, 32);
|
||||
select.setBorderPainted(false);
|
||||
select.setIcon(new ImageIcon(getClass().getResource("img/x32/select.png")));
|
||||
select.setToolTipText("Sélectionner un élément.");
|
||||
editionPanel.add(select);
|
||||
JButton edit = new JButton();
|
||||
edit.setSize(32, 32);
|
||||
edit.setBorderPainted(false);
|
||||
edit.setIcon(new ImageIcon(getClass().getResource("img/x32/edit.png")));
|
||||
edit.setToolTipText("Éditer les propriétés d'un élément.");
|
||||
editionPanel.add(edit);
|
||||
JButton delete = new JButton();
|
||||
delete.setSize(32, 32);
|
||||
delete.setBorderPainted(false);
|
||||
delete.setIcon(new ImageIcon(getClass().getResource("img/x32/delete.png")));
|
||||
delete.setToolTipText("Supprimer un élément.");
|
||||
editionPanel.add(delete);
|
||||
JButton copy = new JButton();
|
||||
copy.setSize(32, 32);
|
||||
copy.setBorderPainted(false);
|
||||
copy.setIcon(new ImageIcon(getClass().getResource("img/x32/copy.png")));
|
||||
copy.setToolTipText("Copier un élément.");
|
||||
editionPanel.add(copy);
|
||||
JButton paste = new JButton();
|
||||
paste.setSize(32, 32);
|
||||
paste.setBorderPainted(false);
|
||||
paste.setIcon(new ImageIcon(getClass().getResource("img/x32/paste.png")));
|
||||
paste.setToolTipText("Coller un élément.");
|
||||
editionPanel.add(paste);
|
||||
JButton undo = new JButton();
|
||||
undo.setSize(32, 32);
|
||||
undo.setBorderPainted(false);
|
||||
undo.setIcon(new ImageIcon(getClass().getResource("img/x32/undo.png")));
|
||||
undo.setToolTipText("Annuler le dernier changement.");
|
||||
editionPanel.add(undo);
|
||||
JButton redo = new JButton();
|
||||
redo.setSize(32, 32);
|
||||
redo.setBorderPainted(false);
|
||||
redo.setIcon(new ImageIcon(getClass().getResource("img/x32/redo.png")));
|
||||
redo.setToolTipText("Rétablir le dernier changement annulé.");
|
||||
editionPanel.add(redo);
|
||||
_editionPanel = new JPanel();
|
||||
_editionPanel.setLayout(new GridLayout(1,7));
|
||||
_select = new JButton();
|
||||
_select.setSize(32, 32);
|
||||
_select.setBorderPainted(false);
|
||||
_select.setIcon(new ImageIcon(getClass().getResource("img/x32/select.png")));
|
||||
_select.setToolTipText("Sélectionner un élément.");
|
||||
_select.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
showSelectMouse();
|
||||
}
|
||||
});
|
||||
_editionPanel.add(_select);
|
||||
_edit = new JButton();
|
||||
_edit.setSize(32, 32);
|
||||
_edit.setBorderPainted(false);
|
||||
_edit.setIcon(new ImageIcon(getClass().getResource("img/x32/edit.png")));
|
||||
_edit.setToolTipText("Éditer les propriétés d'un élément.");
|
||||
_edit.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
showEditMouse();
|
||||
}
|
||||
});
|
||||
_editionPanel.add(_edit);
|
||||
_delete = new JButton();
|
||||
_delete.setSize(32, 32);
|
||||
_delete.setBorderPainted(false);
|
||||
_delete.setIcon(new ImageIcon(getClass().getResource("img/x32/delete.png")));
|
||||
_delete.setToolTipText("Supprimer un élément.");
|
||||
_delete.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
showEditMouse();
|
||||
}
|
||||
});
|
||||
_editionPanel.add(_delete);
|
||||
_copy = new JButton();
|
||||
_copy.setSize(32, 32);
|
||||
_copy.setBorderPainted(false);
|
||||
_copy.setIcon(new ImageIcon(getClass().getResource("img/x32/copy.png")));
|
||||
_copy.setToolTipText("Copier un élément.");
|
||||
_copy.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
showEditMouse();
|
||||
}
|
||||
});
|
||||
_editionPanel.add(_copy);
|
||||
_paste = new JButton();
|
||||
_paste.setSize(32, 32);
|
||||
_paste.setBorderPainted(false);
|
||||
_paste.setIcon(new ImageIcon(getClass().getResource("img/x32/paste.png")));
|
||||
_paste.setToolTipText("Coller un élément.");
|
||||
_paste.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
showEditMouse();
|
||||
}
|
||||
});
|
||||
_editionPanel.add(_paste);
|
||||
_undo = new JButton();
|
||||
_undo.setSize(32, 32);
|
||||
_undo.setBorderPainted(false);
|
||||
_undo.setIcon(new ImageIcon(getClass().getResource("img/x32/undo.png")));
|
||||
_undo.setToolTipText("Annuler le dernier changement.");
|
||||
_editionPanel.add(_undo);
|
||||
_redo = new JButton();
|
||||
_redo.setSize(32, 32);
|
||||
_redo.setBorderPainted(false);
|
||||
_redo.setIcon(new ImageIcon(getClass().getResource("img/x32/redo.png")));
|
||||
_redo.setToolTipText("Rétablir le dernier changement annulé.");
|
||||
_editionPanel.add(_redo);
|
||||
|
||||
JPanel modelisationPanel = new JPanel();
|
||||
modelisationPanel.setLayout(new GridLayout(1,3));
|
||||
JButton newClass = new JButton();
|
||||
newClass.setSize(32, 32);
|
||||
newClass.setBorderPainted(false);
|
||||
newClass.setIcon(new ImageIcon(getClass().getResource("img/x32/newClass.png")));
|
||||
newClass.setToolTipText("Ajouter une classe.");
|
||||
modelisationPanel.add(newClass);
|
||||
JButton newAssociation = new JButton();
|
||||
newAssociation.setSize(32, 32);
|
||||
newAssociation.setBorderPainted(false);
|
||||
newAssociation.setIcon(new ImageIcon(getClass().getResource("img/x32/newAssociation.png")));
|
||||
newAssociation.setToolTipText("Ajouter une association.");
|
||||
modelisationPanel.add(newAssociation);
|
||||
JButton newLink = new JButton();
|
||||
newLink.setSize(32, 32);
|
||||
newLink.setBorderPainted(false);
|
||||
newLink.setIcon(new ImageIcon(getClass().getResource("img/x32/newLink.png")));
|
||||
newLink.setToolTipText("Ajouter un lien.");
|
||||
modelisationPanel.add(newLink);
|
||||
_modelisationPanel = new JPanel();
|
||||
_modelisationPanel.setLayout(new GridLayout(1,3));
|
||||
_newClass = new JButton();
|
||||
_newClass.setSize(32, 32);
|
||||
_newClass.setBorderPainted(false);
|
||||
_newClass.setIcon(new ImageIcon(getClass().getResource("img/x32/newClass.png")));
|
||||
_newClass.setToolTipText("Ajouter une classe.");
|
||||
_newClass.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
showEditMouse();
|
||||
}
|
||||
});
|
||||
_modelisationPanel.add(_newClass);
|
||||
_newAssociation = new JButton();
|
||||
_newAssociation.setSize(32, 32);
|
||||
_newAssociation.setBorderPainted(false);
|
||||
_newAssociation.setIcon(new ImageIcon(getClass().getResource("img/x32/newAssociation.png")));
|
||||
_newAssociation.setToolTipText("Ajouter une association.");
|
||||
_newAssociation.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
showEditMouse();
|
||||
}
|
||||
});
|
||||
_modelisationPanel.add(_newAssociation);
|
||||
_newLink = new JButton();
|
||||
_newLink.setSize(32, 32);
|
||||
_newLink.setBorderPainted(false);
|
||||
_newLink.setIcon(new ImageIcon(getClass().getResource("img/x32/newLink.png")));
|
||||
_newLink.setToolTipText("Ajouter un lien.");
|
||||
_newLink.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
showEditMouse();
|
||||
}
|
||||
});
|
||||
_modelisationPanel.add(_newLink);
|
||||
|
||||
this.add(projectPanel, BorderLayout.CENTER);
|
||||
this.add(editionPanel, BorderLayout.CENTER);
|
||||
this.add(modelisationPanel, BorderLayout.CENTER);
|
||||
this.add(_projectPanel, BorderLayout.CENTER);
|
||||
this.add(_editionPanel, BorderLayout.CENTER);
|
||||
this.add(_modelisationPanel, BorderLayout.CENTER);
|
||||
JLabel projectLabel = new JLabel("Projet");
|
||||
projectLabel.setHorizontalAlignment(JLabel.CENTER);
|
||||
projectLabel.setForeground(Color.WHITE);
|
||||
@@ -122,5 +204,95 @@ public class AppThinkerToolbar extends JPanel {
|
||||
modelisationLabel.setHorizontalAlignment(JLabel.CENTER);
|
||||
modelisationLabel.setForeground(Color.WHITE);
|
||||
this.add(modelisationLabel);
|
||||
|
||||
this.disableEditing();
|
||||
}
|
||||
|
||||
/**
|
||||
* Active les boutons d'édition lorsqu'un projet est ouvert
|
||||
*/
|
||||
public void enableEditing(){
|
||||
_newProject.setEnabled(true);
|
||||
_openProject.setEnabled(true);
|
||||
_saveProject.setEnabled(true);
|
||||
_saveAsProject.setEnabled(true);
|
||||
|
||||
_select.setEnabled(true);
|
||||
_edit.setEnabled(true);
|
||||
_delete.setEnabled(true);
|
||||
_copy.setEnabled(true);
|
||||
_paste.setEnabled(true);
|
||||
_undo.setEnabled(true);
|
||||
_redo.setEnabled(true);
|
||||
|
||||
_newClass.setEnabled(true);
|
||||
_newAssociation.setEnabled(true);
|
||||
_newLink.setEnabled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Désactive les boutons d'édition lorsqu'aucun projet n'est ouvert
|
||||
*/
|
||||
public void disableEditing(){
|
||||
_newProject.setEnabled(true);
|
||||
_openProject.setEnabled(true);
|
||||
_saveProject.setEnabled(false);
|
||||
_saveAsProject.setEnabled(false);
|
||||
|
||||
_select.setEnabled(false);
|
||||
_edit.setEnabled(false);
|
||||
_delete.setEnabled(false);
|
||||
_copy.setEnabled(false);
|
||||
_paste.setEnabled(false);
|
||||
_undo.setEnabled(false);
|
||||
_redo.setEnabled(false);
|
||||
|
||||
_newClass.setEnabled(false);
|
||||
_newAssociation.setEnabled(false);
|
||||
_newLink.setEnabled(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rafraîchit les composants de la barre d'outils.
|
||||
*/
|
||||
public void refreshTollbar(){
|
||||
this._projectPanel.updateUI();
|
||||
this._editionPanel.updateUI();
|
||||
this._modelisationPanel.updateUI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Rafraîchit les composants du panel de projet.
|
||||
*/
|
||||
public void refreshProjectPanel(){
|
||||
this._projectPanel.updateUI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Rafraîchit les composants du panel d'édition.
|
||||
*/
|
||||
public void refreshEditionPanel(){
|
||||
this._editionPanel.updateUI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Rafraîchit les composants du panel de modélisation.
|
||||
*/
|
||||
public void refreshModelisationPanel(){
|
||||
this._modelisationPanel.updateUI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change le curseur de la grille en curseur d'édition.
|
||||
*/
|
||||
public void showEditMouse(){
|
||||
this._window.getGrid().setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
|
||||
}
|
||||
|
||||
/**
|
||||
* Change le curseur de la grille en curseur de sélection.
|
||||
*/
|
||||
public void showSelectMouse(){
|
||||
this._window.getGrid().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,11 @@ import java.awt.*;
|
||||
*/
|
||||
public class AppThinkerWindow extends JFrame {
|
||||
private Project _project;
|
||||
|
||||
private AppThinkerMenuBar _menu;
|
||||
private AppThinkerToolbar _toolbar;
|
||||
private AppThinkerGrid _grid;
|
||||
private AppThinkerStatusbar _statusbar;
|
||||
|
||||
/**
|
||||
* Constructeur de la classe AppThinkerWindow
|
||||
@@ -24,21 +28,22 @@ public class AppThinkerWindow extends JFrame {
|
||||
this.setLocationRelativeTo(null);
|
||||
|
||||
//Ajout du menu à la fenêtre
|
||||
AppThinkerMenuBar menu = new AppThinkerMenuBar();
|
||||
this.setJMenuBar(menu);
|
||||
_menu = new AppThinkerMenuBar(this);
|
||||
this.setJMenuBar(_menu);
|
||||
|
||||
//Ajout de la toolbar à la fenêtre
|
||||
AppThinkerToolbar toolbar = new AppThinkerToolbar();
|
||||
this.add(toolbar, BorderLayout.NORTH);
|
||||
_toolbar = new AppThinkerToolbar(this);
|
||||
this.add(_toolbar, BorderLayout.NORTH);
|
||||
|
||||
//Ajout de la grille à la fenêtre
|
||||
_grid = new AppThinkerGrid();
|
||||
this.add(_grid, BorderLayout.CENTER);
|
||||
|
||||
//Ajout de la statusbar à la fenêtre
|
||||
AppThinkerStatusbar statusbar = new AppThinkerStatusbar();
|
||||
this.add(statusbar, BorderLayout.SOUTH);
|
||||
_statusbar = new AppThinkerStatusbar();
|
||||
this.add(_statusbar, BorderLayout.SOUTH);
|
||||
this.pack();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,13 +52,16 @@ public class AppThinkerWindow extends JFrame {
|
||||
public void newProject(){
|
||||
this._project = new Project();
|
||||
this.setTitle("AppThinker | " + _project.getName());
|
||||
this._menu.enableEditing();
|
||||
this._toolbar.enableEditing();
|
||||
this._statusbar.setStatusMessage("Le projet a été créé.");
|
||||
this._statusbar.setFileMessage(this._project.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ouvre un projet existant dans la fenêtre.
|
||||
* @param path Le chemin du projet à ouvrir.
|
||||
*/
|
||||
public void openProject(String path){
|
||||
public void openProject(){
|
||||
|
||||
}
|
||||
|
||||
@@ -62,6 +70,11 @@ public class AppThinkerWindow extends JFrame {
|
||||
*/
|
||||
public void closeProject(){
|
||||
this._project = null;
|
||||
this.setTitle("AppThinker");
|
||||
this._menu.disableEditing();
|
||||
this._toolbar.disableEditing();
|
||||
this._statusbar.setStatusMessage("Le projet a été fermé.");
|
||||
this._statusbar.setFileMessage("Aucun projet ouvert");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,9 +93,16 @@ public class AppThinkerWindow extends JFrame {
|
||||
|
||||
/**
|
||||
* Sauvegarde le projet en cours à un autre emplacement.
|
||||
* @param path Le chemin de sauvegarde du projet.
|
||||
*/
|
||||
public void saveAsProject(String path){
|
||||
public void saveAsProject(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère la grille contenue dans la fenêtre.
|
||||
* @return La grille contenue dans la fenêtre.
|
||||
*/
|
||||
public AppThinkerGrid getGrid(){
|
||||
return this._grid;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
BIN
AppThinker/src/img/x16/closeProject.png
Normal file
BIN
AppThinker/src/img/x16/closeProject.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 340 B |
BIN
AppThinker/src/img/x32/closeProject.png
Normal file
BIN
AppThinker/src/img/x32/closeProject.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 498 B |
Reference in New Issue
Block a user