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
49d5b6fe
Commit
49d5b6fe
authored
5 years ago
by
PECHOUX Romain
Browse files
Options
Downloads
Patches
Plain Diff
MainFrame.java reformat
parent
65476545
No related branches found
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
+2
-15
2 additions, 15 deletions
src/main/java/view/EditorView.java
src/main/java/view/MainFrame.java
+3
-8
3 additions, 8 deletions
src/main/java/view/MainFrame.java
with
5 additions
and
23 deletions
src/main/java/view/EditorView.java
+
2
−
15
View file @
49d5b6fe
...
...
@@ -17,7 +17,6 @@ limitations under the License.
package
view
;
import
complexityparser.Model
;
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.event.ActionEvent
;
...
...
@@ -29,33 +28,27 @@ import java.nio.charset.StandardCharsets;
import
java.nio.file.Files
;
/**
*
a
basic view to display a text editor containing the code that is analysed and displayed by the ANTLR tree
*
A
basic view to display a text editor containing the code that is analysed and displayed by the ANTLR tree
.
*/
public
class
EditorView
extends
JPanel
{
private
JScrollPane
panel
;
private
JTextArea
area
;
private
JButton
updateButton
;
private
MainFrame
parent
;
private
Model
m
;
public
EditorView
(
Model
m
,
MainFrame
parent
)
{
this
.
parent
=
parent
;
this
.
m
=
m
;
InputMap
inputMap
=
getInputMap
(
JComponent
.
WHEN_IN_FOCUSED_WINDOW
);
area
=
new
JTextArea
(
m
.
getCode
());
area
.
setCaretColor
(
area
.
getForeground
());
area
.
getCaret
().
setBlinkRate
(
0
);
area
.
setTabSize
(
4
);
area
.
setFont
(
new
Font
(
"monospaced"
,
Font
.
PLAIN
,
12
));
panel
=
new
JScrollPane
(
area
);
panel
.
setWheelScrollingEnabled
(
true
);
updateButton
=
new
JButton
(
"update"
);
Action
action
=
new
AbstractAction
()
{
@Override
...
...
@@ -67,20 +60,16 @@ public class EditorView extends JPanel {
updateButton
.
addActionListener
(
action
);
inputMap
.
put
(
KeyStroke
.
getKeyStroke
(
"F6"
),
"F6"
);
getActionMap
().
put
(
"F6"
,
action
);
BorderLayout
layout
=
new
BorderLayout
();
setLayout
(
layout
);
add
(
panel
,
BorderLayout
.
CENTER
);
add
(
updateButton
,
BorderLayout
.
SOUTH
);
inputMap
.
put
(
KeyStroke
.
getKeyStroke
(
KeyEvent
.
VK_O
,
InputEvent
.
CTRL_DOWN_MASK
),
"o"
);
getActionMap
().
put
(
"o"
,
new
AbstractAction
()
{
@Override
public
void
actionPerformed
(
ActionEvent
actionEvent
)
{
JFileChooser
fc
=
new
JFileChooser
();
fc
.
setCurrentDirectory
(
new
File
(
System
.
getProperty
(
"user.dir"
)));
if
(
JFileChooser
.
APPROVE_OPTION
==
fc
.
showOpenDialog
(
parent
))
{
File
f
=
fc
.
getSelectedFile
();
try
{
...
...
@@ -96,9 +85,7 @@ 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
...
...
@@ -107,4 +94,4 @@ public class EditorView extends JPanel {
}
});
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/java/view/MainFrame.java
+
3
−
8
View file @
49d5b6fe
...
...
@@ -17,34 +17,29 @@ limitations under the License.
package
view
;
import
complexityparser.Model
;
import
javax.swing.*
;
import
java.awt.*
;
/**
*
just t
he main window
*
T
he main window
.
*/
public
class
MainFrame
extends
JFrame
{
public
MainFrame
(
Model
m
)
{
setTheme
();
setVisible
(
true
);
setDefaultCloseOperation
(
WindowConstants
.
EXIT_ON_CLOSE
);
setTitle
(
"ComplexityParser"
);
BorderLayout
layout
=
new
BorderLayout
();
setLayout
(
layout
);
add
(
new
EditorView
(
m
,
this
),
BorderLayout
.
WEST
);
add
(
new
TreePanel
(
m
),
BorderLayout
.
CENTER
);
add
(
new
MessageView
(
m
),
BorderLayout
.
EAST
);
pack
();
//setSize(600,600);
}
/**
*
c
hanges the look and feel of java swing to the OS theme
*
C
hanges the look and feel of java swing to the OS theme
.
*/
private
static
void
setTheme
()
{
try
{
...
...
@@ -53,4 +48,4 @@ public class MainFrame extends JFrame {
e
.
printStackTrace
();
}
}
}
}
\ No newline at end of file
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