Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
ProofScriptParser
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
24
Issues
24
List
Boards
Labels
Service Desk
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sarah.grebing
ProofScriptParser
Commits
0efab96a
Commit
0efab96a
authored
Jun 19, 2017
by
Sarah Grebing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
line highlighting preparation
parent
89d49cfb
Pipeline
#11253
failed with stage
in 2 minutes and 21 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
94 additions
and
8 deletions
+94
-8
src/main/java/edu/kit/formal/gui/controls/ScriptArea.java
src/main/java/edu/kit/formal/gui/controls/ScriptArea.java
+83
-2
src/main/java/edu/kit/formal/gui/controls/ScriptAreaTab.java
src/main/java/edu/kit/formal/gui/controls/ScriptAreaTab.java
+1
-2
src/main/java/edu/kit/formal/gui/model/RootModel.java
src/main/java/edu/kit/formal/gui/model/RootModel.java
+6
-4
src/main/resources/edu/kit/formal/gui/debugger-ui.less
src/main/resources/edu/kit/formal/gui/debugger-ui.less
+4
-0
No files found.
src/main/java/edu/kit/formal/gui/controls/ScriptArea.java
View file @
0efab96a
...
...
@@ -12,10 +12,14 @@ import javafx.beans.property.SimpleObjectProperty;
import
javafx.collections.FXCollections
;
import
javafx.collections.ObservableList
;
import
javafx.collections.ObservableSet
;
import
javafx.event.ActionEvent
;
import
javafx.geometry.Insets
;
import
javafx.geometry.Point2D
;
import
javafx.scene.Node
;
import
javafx.scene.control.ContextMenu
;
import
javafx.scene.control.Label
;
import
javafx.scene.control.MenuItem
;
import
javafx.scene.input.MouseEvent
;
import
javafx.scene.layout.Background
;
import
javafx.scene.layout.BackgroundFill
;
import
javafx.scene.layout.HBox
;
...
...
@@ -26,29 +30,43 @@ import javafx.scene.text.Font;
import
javafx.scene.text.FontPosture
;
import
org.antlr.v4.runtime.CharStreams
;
import
org.antlr.v4.runtime.Token
;
import
org.fxmisc.richtext.CharacterHit
;
import
org.fxmisc.richtext.CodeArea
;
import
org.fxmisc.richtext.MouseOverTextEvent
;
import
org.fxmisc.richtext.model.NavigationActions
;
import
org.fxmisc.richtext.model.Paragraph
;
import
org.fxmisc.richtext.model.StyledText
;
import
org.reactfx.collection.LiveList
;
import
org.reactfx.value.Val
;
import
java.time.Duration
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.function.IntFunction
;
/**
* ScriptArea is the textarea on the left side of the GUI. It displays the script code and allows highlighting of lines and setting of breakpoints
* ScriptArea is the textarea on the left side of the GUI.
* It displays the script code and allows highlighting of lines and setting of breakpoints
*
*/
public
class
ScriptArea
extends
CodeArea
{
/**
* Lines to highlight?
*/
private
ObservableSet
<
Integer
>
markedLines
=
FXCollections
.
observableSet
();
private
GutterFactory
gutter
;
private
ANTLR4LexerHighlighter
highlighter
;
private
ListProperty
<
LintProblem
>
problems
=
new
SimpleListProperty
<>(
FXCollections
.
observableArrayList
());
private
SimpleObjectProperty
<
CharacterHit
>
currentMouseOver
=
new
SimpleObjectProperty
<>();
public
ScriptArea
()
{
init
();
}
public
void
setCurrentMouseOver
(
CharacterHit
i
)
{
currentMouseOver
.
set
(
i
);
}
private
void
init
()
{
this
.
setWrapText
(
true
);
gutter
=
new
GutterFactory
();
...
...
@@ -77,6 +95,21 @@ public class ScriptArea extends CodeArea {
}).subscribe(s -> setStyleSpans(0, s));*/
getStyleClass
().
add
(
"script-area"
);
installPopup
();
this
.
addEventHandler
(
MouseEvent
.
MOUSE_PRESSED
,
(
MouseEvent
e
)
->
{
CharacterHit
hit
=
this
.
hit
(
e
.
getX
(),
e
.
getY
());
currentMouseOver
.
set
(
this
.
hit
(
e
.
getX
(),
e
.
getY
()));
int
characterPosition
=
hit
.
getInsertionIndex
();
//System.out.println("characterPosition = " + characterPosition);
// move the caret to that character's position
this
.
moveTo
(
characterPosition
,
NavigationActions
.
SelectionPolicy
.
CLEAR
);
});
ScriptAreaContextMenu
cm
=
new
ScriptAreaContextMenu
(
currentMouseOver
);
this
.
setContextMenu
(
cm
);
}
private
void
installPopup
()
{
...
...
@@ -152,6 +185,25 @@ public class ScriptArea extends CodeArea {
}
}
/**
* Highlight line given by the characterindex
*
* @param chrIdx
*/
public
void
highlightLine
(
int
chrIdx
)
{
//calculate line number from characterindex
int
lineNumber
=
this
.
offsetToPosition
(
chrIdx
,
Bias
.
Forward
).
getMajor
();
Paragraph
<
Collection
<
String
>,
StyledText
<
Collection
<
String
>>,
Collection
<
String
>>
paragraph
=
this
.
getParagraph
(
lineNumber
);
//calculate start and endposition
int
startPos
=
getAbsolutePosition
(
this
.
offsetToPosition
(
chrIdx
,
Bias
.
Forward
).
getMajor
(),
0
);
int
length
=
paragraph
.
length
();
//highlight line
this
.
setStyle
(
startPos
,
startPos
+
length
,
Collections
.
singleton
(
"line-highlight-postmortem"
));
}
public
class
GutterFactory
implements
IntFunction
<
Node
>
{
private
final
Background
defaultBackground
=
new
Background
(
new
BackgroundFill
(
Color
.
web
(
"#ddd"
),
null
,
null
));
...
...
@@ -232,4 +284,33 @@ public class ScriptArea extends CodeArea {
}
}
private
class
ScriptAreaContextMenu
extends
ContextMenu
{
MenuItem
showPostmortemTab
=
new
MenuItem
(
"Show this State"
);
//MenuItem showPostmortemTab = new MenuItem("Show this State");
SimpleObjectProperty
<
CharacterHit
>
currentIdx
=
new
SimpleObjectProperty
<>();
public
ScriptAreaContextMenu
(
SimpleObjectProperty
<
CharacterHit
>
currentMouseOver
)
{
super
();
this
.
addEventHandler
(
ActionEvent
.
ACTION
,
e
->
{
ScriptAreaContextMenu
cm
=
(
ScriptAreaContextMenu
)
e
.
getSource
();
ScriptArea
area
=
(
ScriptArea
)
cm
.
getOwnerNode
();
int
chrIdx
=
currentIdx
.
get
().
getCharacterIndex
().
orElse
(
0
);
if
(
chrIdx
!=
0
)
{
area
.
highlightLine
(
chrIdx
);
}
});
currentIdx
.
bind
(
currentMouseOver
);
showPostmortemTab
.
addEventHandler
(
ActionEvent
.
ACTION
,
e
->
{
System
.
out
.
println
(
currentIdx
.
get
());
});
this
.
getItems
().
add
(
showPostmortemTab
);
}
}
}
\ No newline at end of file
src/main/java/edu/kit/formal/gui/controls/ScriptAreaTab.java
View file @
0efab96a
...
...
@@ -24,9 +24,8 @@ public class ScriptAreaTab extends Tab {
try
{
loader
.
load
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
public
ScriptArea
getScriptArea
()
{
...
...
src/main/java/edu/kit/formal/gui/model/RootModel.java
View file @
0efab96a
...
...
@@ -35,10 +35,6 @@ public class RootModel {
*/
private
final
SimpleObjectProperty
<
File
>
keYFile
=
new
SimpleObjectProperty
<>();
/**
* Property: current loaded script string
*/
//private ObservableValue<String> currentScript;
/**
* ListProperty: list of goal nodes in the current state (depending on interpreter state)
...
...
@@ -50,8 +46,14 @@ public class RootModel {
*/
private
final
SimpleObjectProperty
<
GoalNode
<
KeyData
>>
currentSelectedGoalNode
=
new
SimpleObjectProperty
<>();
/**
* Loaded contracts
*/
private
final
SimpleListProperty
<
Contract
>
loadedContracts
=
new
SimpleListProperty
<>(
FXCollections
.
observableArrayList
());
/**
* Chosen contract for problem
*/
private
final
SimpleObjectProperty
<
Contract
>
chosenContract
=
new
SimpleObjectProperty
<>();
public
RootModel
()
{
...
...
src/main/resources/edu/kit/formal/gui/debugger-ui.less
View file @
0efab96a
...
...
@@ -79,6 +79,10 @@
-rtfx-background-color: @magenta;
-fx-underline: true;
}
.line-highlight-postmortem{
-rtfx-background-color: @blue;
}
}
/**********************************************************************************************************************/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment