Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SAE2.01 - Developpement application
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PIQUEREZ Corentin
SAE2.01 - Developpement application
Commits
e2dd3bd9
Commit
e2dd3bd9
authored
1 year ago
by
Victor Peyrade-Mathon
Browse files
Options
Downloads
Patches
Plain Diff
Claire CAUSSE [
Ajout CTRL+Z (et bouton retour)]
parent
4e19236a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
shukan/ShukanController.java
+55
-8
55 additions, 8 deletions
shukan/ShukanController.java
with
55 additions
and
8 deletions
shukan/ShukanController.java
+
55
−
8
View file @
e2dd3bd9
...
...
@@ -2,6 +2,7 @@ package shukan;
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.event.*
;
import
java.util.Stack
;
/** Shukan controller
...
...
@@ -15,6 +16,7 @@ public class ShukanController
private
ShukanViewBar
bar
;
/** Controlled application data. */
private
ShukanData
data
;
private
Stack
<
Integer
>
actionStack
;
/** Constructs a event handler.
* @param canvas display area.
...
...
@@ -23,6 +25,7 @@ public class ShukanController
this
.
canvas
=
canvas
;
this
.
bar
=
bar
;
this
.
data
=
data
;
this
.
actionStack
=
new
Stack
<>();
}
...
...
@@ -53,6 +56,13 @@ public class ShukanController
{
switch
(
e
.
getKeyCode
())
{
case
KeyEvent
.
VK_Z
:
if
(
pressed
&&
e
.
isControlDown
())
{
int
lastAction
=
actionStack
.
pop
();
revertAction
(
lastAction
);
}
break
;
case
KeyEvent
.
VK_Q
:
case
KeyEvent
.
VK_ESCAPE
:
if
(!
pressed
)
...
...
@@ -90,7 +100,34 @@ public class ShukanController
}
}
private
void
revertAction
(
int
action
)
{
switch
(
action
)
{
case
0
:
canvas
.
deleteActivity
();
canvas
.
repaint
();
break
;
case
1
:
System
.
out
.
println
(
"revert delete activity"
);
break
;
case
2
:
data
.
followRight
();
canvas
.
repaint
();
break
;
case
3
:
data
.
followLeft
();
canvas
.
repaint
();
break
;
case
4
:
data
.
exchangeExtremes
();
canvas
.
repaint
();
break
;
case
5
:
data
.
toggleCursus
(
false
);
canvas
.
repaint
();
}
}
/** Invoked when a key has been typed.
* Implementation from KeyListener.
...
...
@@ -199,37 +236,47 @@ public class ShukanController
* @param e detected action event
* */
public
void
actionPerformed
(
ActionEvent
e
){
if
(
e
.
getSource
()==
bar
.
buttons
[
0
])
if
(
e
.
getSource
()==
bar
.
buttons
[
0
])
{
canvas
.
saveData
();
else
if
(
e
.
getSource
()==
bar
.
buttons
[
1
])
System
.
out
.
println
(
"back"
);
}
else
if
(
e
.
getSource
()==
bar
.
buttons
[
1
])
{
int
lastAction
=
actionStack
.
pop
();
revertAction
(
lastAction
);
}
else
if
(
e
.
getSource
()==
bar
.
buttons
[
2
])
{
canvas
.
newActivity
();
canvas
.
repaint
();
actionStack
.
push
(
0
);
}
else
if
(
e
.
getSource
()==
bar
.
buttons
[
3
])
{
canvas
.
deleteActivity
();
actionStack
.
push
(
1
);
}
else
if
(
e
.
getSource
()==
bar
.
buttons
[
3
])
canvas
.
deleteActivity
();
else
if
(
e
.
getSource
()==
bar
.
buttons
[
4
])
{
if
(
data
.
followLeft
())
canvas
.
repaint
();}
else
if
(
e
.
getSource
()==
bar
.
buttons
[
4
])
{
if
(
data
.
followLeft
())
{
canvas
.
repaint
();
actionStack
.
push
(
2
);}
}
else
if
(
e
.
getSource
()==
bar
.
buttons
[
5
])
{
if
(
data
.
followRight
())
canvas
.
repaint
();}
else
if
(
e
.
getSource
()==
bar
.
buttons
[
5
])
{
if
(
data
.
followRight
())
{
canvas
.
repaint
();
actionStack
.
push
(
3
);}
}
else
if
(
e
.
getSource
()==
bar
.
buttons
[
6
])
{
data
.
exchangeExtremes
();
canvas
.
repaint
();
actionStack
.
push
(
4
);
}
else
if
(
e
.
getSource
()==
bar
.
buttons
[
7
])
{
data
.
toggleCursus
(
false
);
canvas
.
repaint
();
actionStack
.
push
(
5
);
}
//if (data.followRight ()) canvas.repaint ();
else
if
(
e
.
getSource
()==
bar
.
buttons
[
8
])
new
ShukanTex
(
data
);
else
if
(
e
.
getSource
()==
bar
.
buttons
[
9
]){
EventQueue
.
invokeLater
(()
->
{
ShukanParameters
myParameters
=
new
ShukanParameters
(
"Changer de thème"
,
canvas
);
myParameters
.
setSize
(
300
,
300
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment