Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
sarah.grebing
ProofScriptParser
Commits
385d3f9a
Commit
385d3f9a
authored
Aug 10, 2017
by
Sarah Grebing
Browse files
save script file
parent
2e37effe
Pipeline
#12744
failed with stage
in 1 minute and 27 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/edu/kit/formal/gui/controller/DebuggerMainWindowController.java
View file @
385d3f9a
...
...
@@ -300,9 +300,12 @@ public class DebuggerMainWindowController implements Initializable {
}
@FXML
public
void
saveAsScript
()
{
File
f
=
openFileChooserSaveDialog
(
"Save script"
,
""
,
"kps"
);
public
void
saveAsScript
()
throws
IOException
{
File
f
=
openFileChooserSaveDialog
(
"Save script"
,
"
Save Script files
"
,
"kps"
);
if
(
f
!=
null
)
{
/* if(!f.exists()){
f.createNewFile();
}*/
saveScript
(
f
);
}
}
...
...
src/main/java/edu/kit/formal/gui/controls/ScriptController.java
View file @
385d3f9a
...
...
@@ -18,7 +18,6 @@ import javafx.collections.ObservableMap;
import
org.antlr.v4.runtime.CharStream
;
import
org.antlr.v4.runtime.CharStreams
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.lang.NotImplementedException
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.dockfx.DockNode
;
...
...
@@ -71,6 +70,13 @@ public class ScriptController {
return
openScripts
.
get
(
editor
);
}
/**
* Create a new Tab in the ScriptTabPane containing the contents of the file given as argument
*
* @param filePath to file that should be loaded to new tab
* @return refernce to new scriptArea in new tab
* @throws IOException if an Exception occurs while loading file
*/
public
ScriptArea
createNewTab
(
File
filePath
)
throws
IOException
{
filePath
=
filePath
.
getAbsoluteFile
();
if
(
findEditor
(
filePath
)
==
null
)
{
...
...
@@ -129,6 +135,10 @@ public class ScriptController {
return
dockNode
;
}
/**
* Get all breakpoints in the current area
* @return set of all breakpoints in tab
*/
public
Set
<
Breakpoint
>
getBreakpoints
()
{
HashSet
<
Breakpoint
>
breakpoints
=
new
HashSet
<>();
openScripts
.
keySet
().
forEach
(
tab
->
...
...
@@ -137,6 +147,11 @@ public class ScriptController {
return
breakpoints
;
}
/**
* Find the scriptarea for the requested file
* @param filePath
* @return
*/
public
ScriptArea
findEditor
(
File
filePath
)
{
return
openScripts
.
keySet
().
stream
()
.
filter
(
scriptArea
->
...
...
@@ -146,9 +161,17 @@ public class ScriptController {
.
orElse
(
null
);
}
/**
* Save the script currently in focus to the specified file
* @param scriptFile
* @throws IOException
*/
public
void
saveCurrentScriptAs
(
File
scriptFile
)
throws
IOException
{
for
(
ScriptArea
area
:
openScripts
.
keySet
())
{
if
(
area
.
isFocused
())
{
if
(
openScripts
.
size
()
==
1
||
area
.
isFocused
())
{
System
.
out
.
println
(
area
.
getText
());
FileUtils
.
write
(
scriptFile
,
area
.
getText
(),
Charset
.
defaultCharset
());
area
.
setFilePath
(
scriptFile
);
area
.
setDirty
(
false
);
...
...
@@ -166,6 +189,10 @@ public class ScriptController {
return
all
;
}
/**
* Open a new script with a random file name and load it into scriptarea
* @return reference to ScriptArea for new script
*/
public
ScriptArea
newScript
()
{
ScriptArea
area
=
new
ScriptArea
();
area
.
setFilePath
(
new
File
(
Utils
.
getRandomName
()));
...
...
@@ -177,8 +204,17 @@ public class ScriptController {
return
postMortemHighlighter
;
}
public
void
saveCurrentScript
()
{
throw
new
NotImplementedException
();
/**
* Save the current content of the script area
*/
public
void
saveCurrentScript
()
throws
IOException
{
for
(
ScriptArea
scriptArea
:
openScripts
.
keySet
())
{
if
(
scriptArea
.
isFocused
())
{
saveCurrentScriptAs
(
scriptArea
.
getFilePath
());
}
}
// throw new NotImplementedException();
}
public
MainScriptIdentifier
getMainScript
()
{
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment