Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Ronove
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Kaj Koivunen
Ronove
Commits
d8754f4a
Commit
d8754f4a
authored
2 years ago
by
Kaj Koivunen
Browse files
Options
Downloads
Patches
Plain Diff
tiedostojen lataus ja tallennus
parent
a118bf87
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/main/kotlin/MainView.kt
+13
-11
13 additions, 11 deletions
src/main/kotlin/MainView.kt
src/main/kotlin/Project.kt
+92
-2
92 additions, 2 deletions
src/main/kotlin/Project.kt
src/main/kotlin/SplashScreen.kt
+2
-10
2 additions, 10 deletions
src/main/kotlin/SplashScreen.kt
with
107 additions
and
23 deletions
src/main/kotlin/MainView.kt
+
13
−
11
View file @
d8754f4a
...
@@ -18,11 +18,9 @@ class MainView : View("Ronove") {
...
@@ -18,11 +18,9 @@ class MainView : View("Ronove") {
top
=
menubar
{
top
=
menubar
{
menu
(
"File"
)
{
menu
(
"File"
)
{
item
(
"New project..."
)
{
action
{
TODO
()
}
}
item
(
"New project..."
)
{
action
{
TODO
()
}
}
item
(
"New empty project"
)
{
action
{
TODO
()
}
}
item
(
"New empty project"
)
{
action
{
(
app
as
Ronove
).
project
.
new
()
}
}
separator
()
separator
()
item
(
"Open..."
).
action
{
item
(
"Open..."
)
{
action
{
(
app
as
Ronove
).
project
.
open
()
}}
chooseDirectory
(
"Choose folder"
)
}
menu
(
"Open recent"
)
{
menu
(
"Open recent"
)
{
item
(
"Recent 1"
)
item
(
"Recent 1"
)
item
(
"Recent 2"
)
item
(
"Recent 2"
)
...
@@ -31,15 +29,20 @@ class MainView : View("Ronove") {
...
@@ -31,15 +29,20 @@ class MainView : View("Ronove") {
item
(
"Recent 5"
)
item
(
"Recent 5"
)
}
}
separator
()
separator
()
item
(
"Save"
)
{
action
{
TODO
(
"Save"
)
}
}
item
(
"Save"
)
{
item
(
"Save as..."
)
{
action
{
TODO
()
}
}
action
{
(
app
as
Ronove
).
project
.
save
()
}
enableWhen
{(
app
as
Ronove
).
project
.
projectFileSet
}
}
item
(
"Save as..."
)
{
action
{
(
app
as
Ronove
).
project
.
saveAs
()
}}
item
(
"Export..."
)
{
action
{
TODO
()
}
}
item
(
"Export..."
)
{
action
{
TODO
()
}
}
separator
()
separator
()
item
(
"Exit"
).
action
{
item
(
"Exit"
)
{
action
{
//TODO: Confirm unsaved changes
//TODO: Confirm unsaved changes
exitProcess
(
0
)
exitProcess
(
0
)
}
}
}
}
}
menu
(
"Edit"
)
{
menu
(
"Edit"
)
{
item
(
"Add page"
)
{
action
{
(
app
as
Ronove
).
addPage
()
}
}
item
(
"Add page"
)
{
action
{
(
app
as
Ronove
).
addPage
()
}
}
item
(
"Remove page"
)
{
action
{
TODO
()
}
}
item
(
"Remove page"
)
{
action
{
TODO
()
}
}
...
@@ -104,4 +107,3 @@ class MainView : View("Ronove") {
...
@@ -104,4 +107,3 @@ class MainView : View("Ronove") {
modality
=
Modality
.
APPLICATION_MODAL
,
owner
=
primaryStage
)
modality
=
Modality
.
APPLICATION_MODAL
,
owner
=
primaryStage
)
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/kotlin/Project.kt
+
92
−
2
View file @
d8754f4a
package
guru.kake.ronove
package
guru.kake.ronove
import
javafx.beans.property.SimpleBooleanProperty
import
javafx.stage.FileChooser
import
tornadofx.FileChooserMode
import
tornadofx.chooseFile
import
java.io.File
import
java.io.PrintWriter
import
kotlin.reflect.KProperty1
import
kotlin.reflect.KProperty1
/**
/**
* Class for holding the data of the entire translation project, which consists of pages consisting of lines.
* Class for holding the data of the entire translation project, which consists of pages consisting of lines.
*/
*/
class
Project
{
class
Project
{
/** Last used file for saving, updated on Load/Save as */
private
var
projectFile
:
File
?
=
null
/** Observable denoting if projectfile is set */
var
projectFileSet
=
SimpleBooleanProperty
(
false
)
/** Pages of the project */
/** Pages of the project */
var
pages
:
MutableList
<
Page
>
=
mutableListOf
()
var
pages
:
MutableList
<
Page
>
=
mutableListOf
(
Page
())
/** Prompts user for project file to open and loads it */
fun
open
()
{
val
file
=
chooseFile
(
"Open..."
,
arrayOf
(
FileChooser
.
ExtensionFilter
(
"Ronove project files"
,
"*.rvp"
,
"*.RVP"
),
FileChooser
.
ExtensionFilter
(
"All files"
,
"*"
)
),
mode
=
FileChooserMode
.
Single
)
if
(
file
.
isNotEmpty
())
loadFile
(
file
[
0
])
projectFile
=
file
[
0
]
projectFileSet
.
value
=
true
}
/** Prompts user for project file to open and saves to it */
fun
saveAs
()
{
val
file
=
chooseFile
(
"Save as.."
,
arrayOf
(
FileChooser
.
ExtensionFilter
(
"Ronove project files"
,
"*.rvp"
,
"*.RVP"
),
FileChooser
.
ExtensionFilter
(
"All files"
,
"*"
)
),
mode
=
FileChooserMode
.
Save
)
saveFile
(
file
[
0
])
projectFile
=
file
[
0
]
projectFileSet
.
value
=
true
}
fun
save
()
=
projectFile
?.
let
{
saveFile
(
it
)
}
fun
new
()
{
pages
=
mutableListOf
(
Page
())
projectFile
=
null
projectFileSet
.
value
=
false
}
private
fun
loadFile
(
file
:
File
)
{
if
(!
file
.
exists
())
return
new
()
file
.
bufferedReader
().
use
{
reader
->
var
line
:
String
?
while
(
reader
.
readLine
().
also
{
line
=
it
}
!=
null
)
{
println
(
line
)
if
(
line
!!
.
startsWith
(
'#'
))
{
pages
.
add
(
Page
())
}
else
{
pages
.
last
().
lines
.
add
(
Line
(
line
!!
))
}
}
}
}
private
fun
saveFile
(
file
:
File
)
{
file
.
printWriter
().
use
{
writer
->
var
pageNumber
=
1
for
(
page
in
pages
)
{
writer
.
println
(
"#${pageNumber++}"
)
page
.
save
(
writer
)
}
}
}
}
}
/**
/**
...
@@ -44,6 +118,14 @@ class Page(lines: Collection<Line> = listOf()) {
...
@@ -44,6 +118,14 @@ class Page(lines: Collection<Line> = listOf()) {
println
(
"${line.original}: ${line.machineTranslation}"
)
println
(
"${line.original}: ${line.machineTranslation}"
)
}
}
}
}
fun
save
(
writer
:
PrintWriter
)
{
for
(
line
in
lines
)
{
with
(
line
)
{
writer
.
println
(
"$original|$machineTranslation|$finalTranslation|$notes"
)
}
}
}
}
}
/**
/**
...
@@ -58,4 +140,12 @@ data class Line(
...
@@ -58,4 +140,12 @@ data class Line(
var
finalTranslation
:
String
=
""
,
var
finalTranslation
:
String
=
""
,
/** Translator notes for the line */
/** Translator notes for the line */
var
notes
:
String
=
""
var
notes
:
String
=
""
)
)
{
\ No newline at end of file
constructor
(
s
:
String
)
:
this
()
{
val
args
=
s
.
split
(
'|'
)
original
=
args
.
getOrElse
(
0
)
{
""
}
machineTranslation
=
args
.
getOrElse
(
1
)
{
""
}
finalTranslation
=
args
.
getOrElse
(
2
)
{
""
}
notes
=
args
.
getOrElse
(
3
)
{
""
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/kotlin/SplashScreen.kt
+
2
−
10
View file @
d8754f4a
package
guru.kake.ronove
package
guru.kake.ronove
import
javafx.stage.Modality
import
javafx.stage.StageStyle
import
tornadofx.*
import
tornadofx.*
import
kotlin.system.exitProcess
import
kotlin.system.exitProcess
...
@@ -71,14 +69,8 @@ class SplashScreen(project: Project) : View("Ronove") {
...
@@ -71,14 +69,8 @@ class SplashScreen(project: Project) : View("Ronove") {
progressbar
(
0.9
)
progressbar
(
0.9
)
}
}
field
{
field
{
button
(
"New project"
)
{
button
(
"New project"
)
{
action
{
project
.
new
();
close
()
}}
action
{
button
(
"Open..."
)
{
action
{
project
.
open
();
close
()
}}
ProjectSettings
().
openModal
(
stageStyle
=
StageStyle
.
UTILITY
,
block
=
true
,
modality
=
Modality
.
APPLICATION_MODAL
,
owner
=
primaryStage
)
}
}
button
(
"Open..."
)
button
(
"Exit"
)
{
action
{
exitProcess
(
0
)
}}
button
(
"Exit"
)
{
action
{
exitProcess
(
0
)
}}
}
}
}
}
...
...
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