gvcsfx 0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,50 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <!--
4
+ Copyright (C) 2020 Chris Liaw <chrisliaw@antrapol.com>
5
+ Author: Chris Liaw <chrisliaw@antrapol.com>
6
+
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+ -->
20
+
21
+ <?import javafx.geometry.Insets?>
22
+ <?import javafx.scene.control.Button?>
23
+ <?import javafx.scene.control.Label?>
24
+ <?import javafx.scene.control.TextArea?>
25
+ <?import javafx.scene.layout.HBox?>
26
+ <?import javafx.scene.layout.VBox?>
27
+ <?import javafx.scene.text.Font?>
28
+
29
+ <VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="353.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1">
30
+ <children>
31
+ <Label fx:id="lblHeader" text="Diff Result">
32
+ <font>
33
+ <Font name="System Bold" size="13.0" />
34
+ </font>
35
+ </Label>
36
+ <TextArea fx:id="txtContent" editable="false" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="280.0" minWidth="-Infinity" wrapText="true" VBox.vgrow="ALWAYS">
37
+ <VBox.margin>
38
+ <Insets bottom="5.0" top="5.0" />
39
+ </VBox.margin>
40
+ </TextArea>
41
+ <HBox alignment="CENTER_RIGHT" maxHeight="38.0" maxWidth="1.7976931348623157E308" minHeight="38.0" prefHeight="38.0" VBox.vgrow="ALWAYS">
42
+ <children>
43
+ <Button fx:id="butClose" maxWidth="80.0" minWidth="80.0" mnemonicParsing="false" onAction="#win_close" prefWidth="80.0" text="Close" />
44
+ </children>
45
+ </HBox>
46
+ </children>
47
+ <padding>
48
+ <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
49
+ </padding>
50
+ </VBox>
@@ -0,0 +1,59 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <!--
4
+ Copyright (C) 2020 Chris Liaw <chrisliaw@antrapol.com>
5
+ Author: Chris Liaw <chrisliaw@antrapol.com>
6
+
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+ -->
20
+
21
+ <?import javafx.geometry.Insets?>
22
+ <?import javafx.scene.control.Button?>
23
+ <?import javafx.scene.control.ComboBox?>
24
+ <?import javafx.scene.control.Label?>
25
+ <?import javafx.scene.control.TextField?>
26
+ <?import javafx.scene.layout.HBox?>
27
+ <?import javafx.scene.layout.VBox?>
28
+ <?import javafx.scene.text.Font?>
29
+
30
+
31
+ <VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="178.0" prefWidth="507.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1">
32
+ <children>
33
+ <Label fx:id="lblTitle" text="Restore Stash To New Branch" wrapText="true">
34
+ <font>
35
+ <Font name="System Bold" size="14.0" />
36
+ </font>
37
+ </Label>
38
+ <Label fx:id="lblContent" text="Please select one of the stash record in the combox below to restore:" wrapText="true" />
39
+ <HBox alignment="CENTER" maxHeight="-Infinity" maxWidth="1.7976931348623157E308" minHeight="-Infinity" prefHeight="48.0" VBox.vgrow="NEVER">
40
+ <children>
41
+ <ComboBox fx:id="cmbOptions" />
42
+ </children>
43
+ </HBox>
44
+ <TextField fx:id="txtNewBranch" alignment="CENTER" promptText="New branch name" />
45
+ <HBox alignment="CENTER_RIGHT" prefHeight="48.0" prefWidth="470.0" VBox.vgrow="NEVER">
46
+ <children>
47
+ <Button fx:id="butOk" defaultButton="true" maxWidth="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#butOk_onAction" prefWidth="80.0" text="OK">
48
+ <HBox.margin>
49
+ <Insets right="5.0" />
50
+ </HBox.margin>
51
+ </Button>
52
+ <Button fx:id="butCancel" cancelButton="true" maxWidth="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#win_close" prefWidth="80.0" text="Cancel" />
53
+ </children>
54
+ </HBox>
55
+ </children>
56
+ <padding>
57
+ <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
58
+ </padding>
59
+ </VBox>
@@ -0,0 +1,85 @@
1
+ # Copyright (C) 2020 Chris Liaw <chrisliaw@antrapol.com>
2
+ # Author: Chris Liaw <chrisliaw@antrapol.com>
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+
18
+ require 'jrubyfx'
19
+
20
+ require_relative "lib/version"
21
+
22
+ fxml_root File.join(File.dirname(__FILE__),"fx")
23
+
24
+ require_relative 'handlers/main_win_controller'
25
+ require_relative 'handlers/tray'
26
+ require_relative 'handlers/float_win_controller'
27
+
28
+ module GvcsFx
29
+ class MainWin < JRubyFX::Application
30
+ include GvcsFx::Tray
31
+
32
+ attr_reader :stage
33
+ def start(stage)
34
+
35
+ @stage = stage
36
+ #@stage.always_on_top = true
37
+ #@stage.init_style = javafx.stage.StageStyle::UNDECORATED
38
+ #javafx.application.Platform.implicit_exit = false
39
+
40
+ # temporary disable for direct testing
41
+ #with(stage, title: "G-VCS Float") do
42
+ # fxml FloatWinController
43
+ # show
44
+ #end
45
+
46
+ MainWinController.load_into(@stage)
47
+ @stage.show
48
+
49
+ # this is correct can show tray
50
+ # but hide/show javafx stage doesn't work
51
+ #javax.swing.SwingUtilities.invokeLater do
52
+ # start_tray(self)
53
+ #end
54
+
55
+ end # start
56
+
57
+ def show_stage
58
+ javafx.application.Platform.run_later do
59
+ puts "insite run_later #{@stage}"
60
+ if not @stage.nil?
61
+ @stage.show
62
+ @stage.toFront
63
+ end
64
+ end
65
+ end
66
+
67
+ def hide_stage
68
+ javafx.application.Platform.run_later do
69
+ @stage.hide
70
+ end
71
+ end
72
+
73
+ end
74
+ end
75
+
76
+ if $0 == __FILE__
77
+ #puts "Launching"
78
+ GvcsFx::MainWin.launch
79
+
80
+ ## put swing code in its own event loop or the right click menu and the icon itself won't show
81
+ #event_thread = nil
82
+ #javax.swing.SwingUtilities.invokeAndWait { event_thread = java.lang.Thread.currentThread }
83
+ #event_thread.join
84
+ end
85
+
@@ -0,0 +1,88 @@
1
+ # Copyright (C) 2020 Chris Liaw <chrisliaw@antrapol.com>
2
+ # Author: Chris Liaw <chrisliaw@antrapol.com>
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+
18
+ module GvcsFx
19
+ class AddWorkspaceController
20
+ include JRubyFX::Controller
21
+ include Antrapol::ToolRack::ExceptionUtils
22
+ fxml "add_workspace.fxml"
23
+
24
+ ADDPROJ_KEY = "<Add New Project>"
25
+
26
+ attr_reader :result
27
+ def initialize
28
+ init
29
+ end
30
+
31
+ def init
32
+ @cmbProject.items.add_all(["",ADDPROJ_KEY])
33
+ hide_new_proj_entry
34
+ end
35
+
36
+ def add_option(opt)
37
+ @cmbProject.items.add(opt)
38
+ end
39
+
40
+ def butOpen_onAction(evt)
41
+
42
+ end # butOpen_onAction
43
+
44
+ def cmbProj_onAction(evt)
45
+ val = @cmbProject.selection_model.selected_item
46
+ if not_empty?(val)
47
+ if val == ADDPROJ_KEY
48
+ show_new_proj_entry
49
+ else
50
+ hide_new_proj_entry
51
+ end
52
+ else
53
+ hide_new_proj_entry
54
+ end
55
+ end # cmbProj_onAction
56
+
57
+ def butCreate_onAction(evt)
58
+ @result = [@cmbProject.selection_model.selected_item, @txtNewProjName.text]
59
+ @butOpen.scene.window.close
60
+ end
61
+
62
+ def butCancel_onAction(evt)
63
+ @butOpen.scene.window.close
64
+ end
65
+
66
+ def path=(val)
67
+ @lblWorkspacePath.text = val
68
+ end
69
+
70
+ def txtNewProjName_keyreleased(evt)
71
+ if (not evt.nil?) and evt.code == javafx.scene.input.KeyCode::ENTER
72
+ butCreate_onAction(nil)
73
+ end
74
+ end
75
+
76
+ private
77
+ def hide_new_proj_entry
78
+ @lblNewProjName.visible = false
79
+ @txtNewProjName.visible = false
80
+ end
81
+
82
+ def show_new_proj_entry
83
+ @lblNewProjName.visible = true
84
+ @txtNewProjName.visible = true
85
+ end
86
+
87
+ end
88
+ end
@@ -0,0 +1,58 @@
1
+ # Copyright (C) 2020 Chris Liaw <chrisliaw@antrapol.com>
2
+ # Author: Chris Liaw <chrisliaw@antrapol.com>
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+
18
+
19
+ module GvcsFx
20
+ module EventHandler
21
+
22
+ def install_handler
23
+ handle_workspace_add
24
+ handle_workspace_selection_changed
25
+ end
26
+
27
+ def handle_workspace_add
28
+
29
+ register(Listener::Event[:workspace_added], Proc.new do |opts|
30
+
31
+ # change display from landing to details
32
+ # NO workspace selected yet so hold
33
+ #show_details
34
+ refresh_workspace_list
35
+
36
+ end)
37
+
38
+ end
39
+
40
+ def handle_workspace_selection_changed
41
+ register(Listener::Event[:workspace_selection_changed], Proc.new do |opts|
42
+
43
+ refresh_details
44
+
45
+ #case @shownTab
46
+ #when :state
47
+ # refresh_tab_state
48
+ #when :logs
49
+ # refresh_tab_logs
50
+ #when :ignoreRules
51
+ # refresh_tab_ignore_rules
52
+ #end
53
+
54
+ end)
55
+ end
56
+
57
+ end
58
+ end
@@ -0,0 +1,68 @@
1
+ # Copyright (C) 2020 Chris Liaw <chrisliaw@antrapol.com>
2
+ # Author: Chris Liaw <chrisliaw@antrapol.com>
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+
18
+ java_import javafx.scene.control.ContextMenu
19
+
20
+ require_relative "main_win_controller"
21
+
22
+ module GvcsFx
23
+ class FloatWinController
24
+ include JRubyFX::Controller
25
+ fxml "float.fxml"
26
+
27
+ def initialize
28
+ end
29
+
30
+
31
+ def show_context_menu(evt)
32
+ init_ctxmenu.show(@imgFloat, evt.screen_x, evt.screen_y)
33
+ end
34
+
35
+
36
+ private
37
+ def init_ctxmenu
38
+
39
+ if @ctx.nil?
40
+
41
+ @ctx = ContextMenu.new
42
+ mnuItems = []
43
+ @mnuMain = javafx.scene.control.MenuItem.new("G-VCS")
44
+ @mnuMain.on_action do |evt|
45
+ stage = javafx.stage.Stage.new
46
+ stage.title = "G-VCS"
47
+ #stage.initModality(javafx.stage.Modality::WINDOW_MODAL)
48
+ #stage.initOwner(@imgFloat.scene.window)
49
+ ctrl = MainWinController.load_into(stage)
50
+ stage.show
51
+ end
52
+ mnuItems << @mnuMain
53
+
54
+ @mnuExit = javafx.scene.control.MenuItem.new("Exit")
55
+ @mnuExit.on_action do |evt|
56
+ @imgFloat.scene.window.close
57
+ end
58
+ mnuItems << @mnuExit
59
+
60
+ @ctx.items.add_all(mnuItems)
61
+
62
+ end
63
+
64
+ @ctx
65
+ end
66
+
67
+ end
68
+ end
@@ -0,0 +1,120 @@
1
+ # Copyright (C) 2020 Chris Liaw <chrisliaw@antrapol.com>
2
+ # Author: Chris Liaw <chrisliaw@antrapol.com>
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+
18
+ java_import javafx.scene.control.Alert
19
+
20
+ module GvcsFx
21
+ module FxAlert
22
+
23
+ def fx_alert_info(msg, title = "Information", owner = nil)
24
+ dlg = Alert.new(Alert::AlertType::INFORMATION)
25
+ #dlg.header_text = msg
26
+ dlg.title = title
27
+ lbl = javafx.scene.control.Label.new(msg)
28
+ lbl.wrap_text = true
29
+ dlg.dialog_pane.content = lbl
30
+ dlg.header_text = nil
31
+ #dlg.content_text = msg
32
+ dlg.init_modality(javafx.stage.Modality::WINDOW_MODAL)
33
+ dlg.init_owner(owner) if not owner.nil?
34
+ dlg.show_and_wait
35
+ end
36
+
37
+ def fx_alert_error(msg, title = "Error", owner = nil)
38
+ dlg = Alert.new(Alert::AlertType::ERROR)
39
+ #dlg.header_text = msg
40
+ dlg.title = title
41
+ lbl = javafx.scene.control.Label.new(msg)
42
+ lbl.wrap_text = true
43
+ dlg.dialog_pane.content = lbl
44
+ dlg.header_text = nil
45
+ dlg.init_modality(javafx.stage.Modality::WINDOW_MODAL)
46
+ dlg.init_owner(owner) if not owner.nil?
47
+ #dlg.init_style(javafx.stage.StageStyle::UTILITY)
48
+ dlg.show_and_wait
49
+ end
50
+
51
+ def fx_alert_warning(msg, title = "Warning", owner = nil)
52
+ dlg = Alert.new(Alert::AlertType::WARNING)
53
+ #dlg.header_text = msg
54
+ lbl = javafx.scene.control.Label.new(msg)
55
+ lbl.wrap_text = true
56
+ dlg.dialog_pane.content = lbl
57
+ #dlg.content_text = msg
58
+ dlg.title = title
59
+ dlg.header_text = nil
60
+ dlg.init_modality(javafx.stage.Modality::WINDOW_MODAL)
61
+ dlg.init_owner(owner) if not owner.nil?
62
+ dlg.show_and_wait
63
+ end
64
+
65
+ def fx_alert_confirmation(msg, header = nil, title = "Confirmation", owner = nil)
66
+
67
+ dlg = javafx.scene.control.Alert.new(javafx.scene.control.Alert::AlertType::CONFIRMATION)
68
+ dlg.init_modality(javafx.stage.Modality::WINDOW_MODAL)
69
+ dlg.init_owner(owner) if not owner.nil?
70
+ dlg.title = title
71
+ dlg.header_text = header
72
+ lbl = javafx.scene.control.Label.new(msg)
73
+ lbl.wrap_text = true
74
+ dlg.dialog_pane.content = lbl
75
+ # this will make long text not shown as no wrapping is provided
76
+ #dlg.content_text = msg
77
+
78
+ #if not (opts[:custom_buttons].nil? or opts[:custom_buttons].empty?)
79
+ # cusBut = { }
80
+ # opts.each do |key,act|
81
+ # par = [act[:name]]
82
+ # par << javafx.scene.control.ButtonBar.ButtonData::CANCEL_CLOSE if act[:is_cancel]
83
+ # cusBut[javafx.scene.control.ButtonType.new(*par)] = k
84
+
85
+ # dlg.getButtonTypes.setAll(*cusBut.keys)
86
+ # end
87
+ #end
88
+
89
+ res = dlg.show_and_wait
90
+
91
+ #if not (opts[:custom_buttons].nil? or opts[:custom_buttons].empty?)
92
+ # sel = res.get
93
+ # key = cusBut[sel]
94
+ # key
95
+ #else
96
+ if res.get == javafx.scene.control.ButtonType::OK
97
+ :ok
98
+ else
99
+ :cancel
100
+ end
101
+ #end
102
+
103
+ end # fx_alert_confirmation
104
+
105
+ def fx_alert_input(title, header, content)
106
+ dlg = javafx.scene.control.TextInputDialog.new
107
+ dlg.title = title
108
+ dlg.header_text = header
109
+ dlg.content_text = content
110
+ res = dlg.show_and_wait
111
+ if res.is_present
112
+ # there is some string in the text field
113
+ [true, res.get]
114
+ else
115
+ [false, ""]
116
+ end
117
+ end
118
+
119
+ end
120
+ end