Ajout de la fonction de sélection d'outils
This commit is contained in:
@@ -9,6 +9,17 @@ import java.awt.event.ActionListener;
|
||||
*/
|
||||
public class AppThinkerToolbar extends JPanel {
|
||||
|
||||
public static final int SELECT_TOOL = 0;
|
||||
public static final int EDIT_TOOL = 1;
|
||||
public static final int DELETE_TOOL = 2;
|
||||
public static final int COPY_TOOL = 3;
|
||||
public static final int PASTE_TOOL = 4;
|
||||
public static final int CLASS_TOOL = 5;
|
||||
public static final int ASSOCIATION_TOOL = 6;
|
||||
public static final int LINK_TOOL = 7;
|
||||
|
||||
private int _currentTool = 0;
|
||||
|
||||
private JPanel _projectPanel;
|
||||
private JButton _newProject;
|
||||
private JButton _openProject;
|
||||
@@ -85,7 +96,7 @@ public class AppThinkerToolbar extends JPanel {
|
||||
_select.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
showSelectMouse();
|
||||
changeTool(AppThinkerToolbar.SELECT_TOOL);
|
||||
}
|
||||
});
|
||||
_editionPanel.add(_select);
|
||||
@@ -97,7 +108,7 @@ public class AppThinkerToolbar extends JPanel {
|
||||
_edit.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
showEditMouse();
|
||||
changeTool(AppThinkerToolbar.EDIT_TOOL);
|
||||
}
|
||||
});
|
||||
_editionPanel.add(_edit);
|
||||
@@ -109,7 +120,7 @@ public class AppThinkerToolbar extends JPanel {
|
||||
_delete.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
showEditMouse();
|
||||
changeTool(AppThinkerToolbar.DELETE_TOOL);
|
||||
}
|
||||
});
|
||||
_editionPanel.add(_delete);
|
||||
@@ -121,7 +132,7 @@ public class AppThinkerToolbar extends JPanel {
|
||||
_copy.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
showEditMouse();
|
||||
changeTool(AppThinkerToolbar.COPY_TOOL);
|
||||
}
|
||||
});
|
||||
_editionPanel.add(_copy);
|
||||
@@ -133,7 +144,7 @@ public class AppThinkerToolbar extends JPanel {
|
||||
_paste.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
showEditMouse();
|
||||
changeTool(AppThinkerToolbar.PASTE_TOOL);
|
||||
}
|
||||
});
|
||||
_editionPanel.add(_paste);
|
||||
@@ -160,7 +171,7 @@ public class AppThinkerToolbar extends JPanel {
|
||||
_newClass.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
showEditMouse();
|
||||
changeTool(AppThinkerToolbar.CLASS_TOOL);
|
||||
}
|
||||
});
|
||||
_modelisationPanel.add(_newClass);
|
||||
@@ -172,7 +183,7 @@ public class AppThinkerToolbar extends JPanel {
|
||||
_newAssociation.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
showEditMouse();
|
||||
changeTool(AppThinkerToolbar.ASSOCIATION_TOOL);
|
||||
}
|
||||
});
|
||||
_modelisationPanel.add(_newAssociation);
|
||||
@@ -184,7 +195,7 @@ public class AppThinkerToolbar extends JPanel {
|
||||
_newLink.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
showEditMouse();
|
||||
changeTool(AppThinkerToolbar.LINK_TOOL);
|
||||
}
|
||||
});
|
||||
_modelisationPanel.add(_newLink);
|
||||
@@ -211,6 +222,7 @@ public class AppThinkerToolbar extends JPanel {
|
||||
/**
|
||||
* Active les boutons d'édition lorsqu'un projet est ouvert
|
||||
*/
|
||||
|
||||
public void enableEditing(){
|
||||
_newProject.setEnabled(true);
|
||||
_openProject.setEnabled(true);
|
||||
@@ -255,7 +267,7 @@ public class AppThinkerToolbar extends JPanel {
|
||||
/**
|
||||
* Rafraîchit les composants de la barre d'outils.
|
||||
*/
|
||||
public void refreshTollbar(){
|
||||
public void refreshToolbar(){
|
||||
this._projectPanel.updateUI();
|
||||
this._editionPanel.updateUI();
|
||||
this._modelisationPanel.updateUI();
|
||||
@@ -283,16 +295,38 @@ public class AppThinkerToolbar extends JPanel {
|
||||
}
|
||||
|
||||
/**
|
||||
* Change le curseur de la grille en curseur d'édition.
|
||||
* Change d'outil pour l'édition du diagramme.
|
||||
* @param tool L'outil cible.
|
||||
*/
|
||||
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));
|
||||
public void changeTool(int tool){
|
||||
this._currentTool = tool;
|
||||
if(this._currentTool == AppThinkerToolbar.SELECT_TOOL) this._window.getGrid().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
else this._window.getGrid().setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
|
||||
switch(tool){
|
||||
case 1:
|
||||
_window.getStatusbar().setStatusMessage("Outil édition - Cliquez sur un élément pour l'éditer.");
|
||||
break;
|
||||
case 2:
|
||||
_window.getStatusbar().setStatusMessage("Outil suppression - Cliquez sur un élément pour le supprimer.");
|
||||
break;
|
||||
case 3:
|
||||
_window.getStatusbar().setStatusMessage("Outil copie - Cliquez sur un élément pour le copier.");
|
||||
break;
|
||||
case 4:
|
||||
_window.getStatusbar().setStatusMessage("Outil coller - Cliquez à un endroit pour coller l'élément.");
|
||||
break;
|
||||
case 5:
|
||||
_window.getStatusbar().setStatusMessage("Outil classe - Cliquez à un endroit pour ajouter une classe.");
|
||||
break;
|
||||
case 6:
|
||||
_window.getStatusbar().setStatusMessage("Outil association - Cliquez à un endroit pour ajouter une association.");
|
||||
break;
|
||||
case 7:
|
||||
_window.getStatusbar().setStatusMessage("Outil lien - Cliquez sur une classe, maintenez, puis relachez sur une autre.");
|
||||
break;
|
||||
default:
|
||||
_window.getStatusbar().setStatusMessage("Outil sélection - Cliquez sur un élément pour le sélectionner.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user