Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
ComplexityParser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Emmanuel Hainry
ComplexityParser
Commits
05b7c7f7
Commit
05b7c7f7
authored
6 years ago
by
zyno1
Browse files
Options
Downloads
Patches
Plain Diff
gui keyboard events
parent
25ef4d7c
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/view/EditorView.java
+9
-0
9 additions, 0 deletions
src/main/java/view/EditorView.java
src/main/java/view/TreePanel.java
+18
-1
18 additions, 1 deletion
src/main/java/view/TreePanel.java
with
27 additions
and
1 deletion
src/main/java/view/EditorView.java
+
9
−
0
View file @
05b7c7f7
...
...
@@ -82,5 +82,14 @@ public class EditorView extends JPanel {
});
setPreferredSize
(
new
Dimension
(
400
,
600
));
inputMap
.
put
(
KeyStroke
.
getKeyStroke
(
KeyEvent
.
VK_ESCAPE
,
0
),
"escape"
);
getActionMap
().
put
(
"escape"
,
new
AbstractAction
()
{
@Override
public
void
actionPerformed
(
ActionEvent
actionEvent
)
{
System
.
out
.
println
(
"transfer focus"
);
area
.
transferFocus
();
}
});
}
}
This diff is collapsed.
Click to expand it.
src/main/java/view/TreePanel.java
+
18
−
1
View file @
05b7c7f7
...
...
@@ -3,15 +3,20 @@ package view;
import
complexityparser.Model
;
import
lib.Observable
;
import
lib.Observer
;
import
org.antlr.v4.gui.TreeViewer
;
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.KeyEvent
;
/**
* a basic pannel displaying the ANTLR tree
*/
public
class
TreePanel
extends
JScrollPane
implements
Observer
{
private
TreeViewer
viewr
;
public
TreePanel
(
Model
m
)
{
super
(
m
.
getTreeComponent
());
m
.
add
(
this
);
...
...
@@ -19,12 +24,24 @@ public class TreePanel extends JScrollPane implements Observer {
setPreferredSize
(
new
Dimension
(
600
,
600
));
getVerticalScrollBar
().
setUnitIncrement
(
10
);
getHorizontalScrollBar
().
setUnitIncrement
(
10
);
JScrollBar
vertical
=
getVerticalScrollBar
();
InputMap
im
=
vertical
.
getInputMap
(
JComponent
.
WHEN_IN_FOCUSED_WINDOW
);
im
.
put
(
KeyStroke
.
getKeyStroke
(
"DOWN"
),
"positiveUnitIncrement"
);
im
.
put
(
KeyStroke
.
getKeyStroke
(
"UP"
),
"negativeUnitIncrement"
);
JScrollBar
horizontal
=
getHorizontalScrollBar
();
im
=
horizontal
.
getInputMap
(
JComponent
.
WHEN_IN_FOCUSED_WINDOW
);
im
.
put
(
KeyStroke
.
getKeyStroke
(
"RIGHT"
),
"positiveUnitIncrement"
);
im
.
put
(
KeyStroke
.
getKeyStroke
(
"LEFT"
),
"negativeUnitIncrement"
);
}
@Override
public
void
update
(
Observable
m
)
{
Model
model
=
(
Model
)
m
;
setViewportView
(
model
.
getTreeComponent
());
viewr
=
model
.
getTreeComponent
();
setViewportView
(
viewr
);
}
}
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