AntOSDK first working version, now application can be built from browser

This commit is contained in:
Xuan Sang LE
2018-03-20 13:07:23 +01:00
parent 09f72fd436
commit f89c71e2b3
13 changed files with 187 additions and 43 deletions

View File

@ -1,4 +1,4 @@
coffee_files = main.coffee
coffee_files = main.coffee dialog.coffee
jsfiles = coffeescript.js

View File

@ -0,0 +1,109 @@
class BuildDialog extends this.OS.GUI.BasicDialog
constructor: () ->
super "BuildDialog", {
tags: [
{ tag: "afx-label", att: 'text="__(Coffees)" data-height="23" class="header"' },
{ tag: "afx-list-view" }
{ tag: "afx-label", att: 'text="__(Javascripts)" data-height="23" class="header"' },
{ tag: "afx-list-view" }
{ tag: "afx-label", att: 'text="__(Css)" data-height="23" class="header"' },
{ tag: "afx-list-view" }
{ tag: "afx-label", att: 'text="__(Copied files)" data-height="23" class="header"' },
{ tag: "afx-list-view" }
{ tag: "div", att: ' data-height="5"' }
],
width: 350,
height: 450,
resizable: true,
buttons: [
{
label: "__(Save)", onclick: (d) ->
data =
coffees: (v.text for v in (d.find "content1").get "items")
javascripts: (v.text for v in (d.find "content3").get "items")
css: (v.text for v in (d.find "content5").get "items")
copies: (v.text for v in (d.find "content7").get "items")
d.handler data if d.handler
d.quit()
},
{ label: "__(Cancel)", onclick: (d) -> d.quit() }
],
filldata: (d) ->
lv = d.find "content1"
lv.set "items", ({ text: v } for v in d.parent.prjfile.cache.coffees)
lv.set "buttons", [
{
text: "+",
onbtclick: (e) ->
d.selectFile ["text/coffeescript"], (f) ->
lv.push { text: f }, true if f
},
{
text: "-",
onbtclick: (e) ->
sel = lv.get "selected"
return unless sel
lv.remove sel, true
}
]
lv1 = d.find "content3"
lv1.set "items", ({ text: v } for v in d.parent.prjfile.cache.javascripts)
lv1.set "buttons", [
{
text: "+",
onbtclick: (e) ->
d.selectFile ["application/javascript"], (f) ->
lv1.push { text: f }, true if f
},
{
text: "-",
onbtclick: (e) ->
sel = lv1.get "selected"
return unless sel
lv1.remove sel, true
}
]
lv2 = d.find "content5"
lv2.set "items", ({ text: v } for v in d.parent.prjfile.cache.css)
lv2.set "buttons", [
{
text: "+",
onbtclick: (e) ->
d.selectFile ["text/css"], (f) ->
lv2.push { text: f }, true if f
},
{
text: "-",
onbtclick: (e) ->
sel = lv2.get "selected"
return unless sel
lv2.remove sel, true
}
]
lv3 = d.find "content7"
lv3.set "items", ({ text: v } for v in d.parent.prjfile.cache.copies)
lv3.set "buttons", [
{
text: "+",
onbtclick: (e) ->
d.selectFile [".*"], (f) ->
lv3.push { text: f }, true if f
},
{
text: "-",
onbtclick: (e) ->
sel = lv3.get "selected"
return unless sel
lv3.remove sel, true
}
]
}
selectFile: (mimes, f) ->
me = @
@openDialog "FileDiaLog", (d, n, p) ->
f p.replace me.parent.prjfile.cache.root + "/", ""
, "__(Select a file)", { mimes: mimes, type: "file", root: @parent.prjfile.cache.root }

View File

@ -145,8 +145,10 @@ class AntOSDK extends this.OS.GUI.BaseApplication
@bindKey "CTRL-S", () -> me.actionFile "#{me.name}-Save"
@bindKey "ALT-W", () -> me.actionFile "#{me.name}-Saveas"
@bindKey "CTRL-R", () -> me.bnR()
@bindKey "ALT-B", () -> me.actionBuild "#{me.name}-Build"
@bindKey "ALT-C", () -> me.actionBuild "#{me.name}-Build"
@bindKey "ALT-P", () -> me.buildAndRelease()
@bindKey "ALT-Y", () ->
me.actionBuild "#{me.name}-Options"
@openProject @prjfile if @prjfile
@trigger "calibrate"
@ -428,8 +430,8 @@ class AntOSDK extends this.OS.GUI.BaseApplication
child: [
{ text: "__(Build and Run)", dataid: "#{@name}-Run", shortcut: "C-R" },
{ text: "__(Build release)", dataid: "#{@name}-Release", shortcut: "A-P" },
{ text: "__(Build)", dataid: "#{@name}-Build", shortcut: "A-B" },
{ text: "__(Build Options)", dataid: "#{@name}-Options", shortcut: "A-C" }
{ text: "__(Build)", dataid: "#{@name}-Build", shortcut: "A-C" },
{ text: "__(Build Options)", dataid: "#{@name}-Options", shortcut: "A-Y" }
],
onmenuselect: (e) -> me.actionBuild e.item.data.dataid
}
@ -438,6 +440,7 @@ class AntOSDK extends this.OS.GUI.BaseApplication
actionFile: (e) ->
me = @
return unless @prjfile
saveas = () ->
me.openDialog "FileDiaLog", (d, n) ->
file = "#{d}/#{n}".asFileHandler()
@ -487,10 +490,17 @@ class AntOSDK extends this.OS.GUI.BaseApplication
return fn() unless @isDirty()
@ask "__(Unsaved project)", "__(Ignore unsaved project ?)", () ->
fn()
when "#{@name}-Save"
return unless @prjfile
@prjfile.write "object", (r) ->
return me.error __("Cannot save project: {0}", r.error) if r.error
me.notify __("project saved")
me.prjfile.dirty = false
actionBuild: (e) ->
me = @
return unless @prjfile
switch e
when "#{@name}-Run" then me.bnR()
when "#{@name}-Build"
@ -498,7 +508,11 @@ class AntOSDK extends this.OS.GUI.BaseApplication
me.log "ERROR", ex.toString()
when "#{@name}-Release"
me.buildAndRelease()
when "#{@name}-Options"
me.openDialog new BuildDialog(), (d) ->
me.prjfile.cache[k] = v for k, v of d
me.prjfile.dirty = true
, "__(Add files to build target)"
isDirty: () ->
return false unless @tabarea
@ -512,9 +526,10 @@ class AntOSDK extends this.OS.GUI.BaseApplication
me = @
evt.preventDefault()
dirties = ( v for v in @tabarea.get "items" when v.dirty )
@ask "__(Quit)", __("Ignore all {0} unsaved files ?", dirties.length), () ->
m = __("Ignore: {0} unsaved files {1}?", dirties.length, if @prjfile.dirty then "__(and unsaved project)" else "")
@ask "__(Quit)", m, () ->
v.dirty = false for v in dirties
@prjfile.dirty = false
me.prjfile.dirty = false
me.quit()
log: (t, m) ->

View File

@ -110,4 +110,11 @@ afx-tab-bar[data-id="tabarea"] afx-list-view{
afx-tab-bar[data-id="tabarea"] afx-list-view > div.list-container > ul > li.selected {
background-color: #f6F6F6;
border-radius: 0;
}
afx-app-window[data-id="BuildDialog"] afx-label.header {
font-weight: bold;
margin: 0;
}
afx-app-window[data-id="BuildDialog"] afx-list-view {
border: 1px solid #a6A6A6;
}