redcar 0.6.1 → 0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +26 -0
- data/README.md +17 -31
- data/Rakefile +1 -1
- data/bin/redcar +1 -1
- data/lib/redcar.rb +8 -4
- data/lib/redcar/installer.rb +2 -1
- data/plugins/application/features/step_definitions/dialog_steps.rb +5 -0
- data/plugins/application/features/step_definitions/tree_steps.rb +1 -1
- data/plugins/application/features/support/env.rb +38 -17
- data/plugins/application/lib/application.rb +4 -0
- data/plugins/application/lib/application/command.rb +8 -2
- data/plugins/application/lib/application/command/executor.rb +37 -8
- data/plugins/application/lib/application/command/history.rb +3 -3
- data/plugins/application/lib/application/menu.rb +4 -0
- data/plugins/application/lib/application/menu/item.rb +9 -1
- data/plugins/application/lib/application/tab.rb +11 -0
- data/plugins/application/spec/application/command/executor_spec.rb +3 -3
- data/plugins/application/spec/application/command_spec.rb +24 -0
- data/plugins/application/spec/spec_helper.rb +1 -0
- data/plugins/application_swt/lib/application_swt.rb +27 -24
- data/plugins/application_swt/lib/application_swt/dialog_adapter.rb +4 -33
- data/plugins/application_swt/lib/application_swt/dialogs/input_dialog.rb +46 -0
- data/plugins/application_swt/lib/application_swt/dialogs/text_and_file_dialog.rb +118 -0
- data/plugins/application_swt/lib/application_swt/icon.rb +37 -0
- data/plugins/application_swt/lib/application_swt/menu.rb +8 -3
- data/plugins/application_swt/lib/application_swt/tab.rb +6 -3
- data/plugins/application_swt/lib/application_swt/treebook.rb +29 -31
- data/plugins/application_swt/lib/swt/graphics_utils.rb +170 -0
- data/plugins/application_swt/lib/swt/vtab_folder.rb +125 -0
- data/plugins/application_swt/lib/swt/vtab_item.rb +69 -0
- data/plugins/application_swt/lib/swt/vtab_label.rb +84 -0
- data/plugins/auto_indenter/lib/auto_indenter.rb +4 -2
- data/plugins/core/lib/core/controller.rb +18 -0
- data/plugins/declarations/lib/declarations.rb +1 -1
- data/plugins/document_search/lib/document_search.rb +8 -6
- data/plugins/document_search/lib/document_search/replace.rb +51 -31
- data/plugins/document_search/lib/document_search/search_and_replace.rb +12 -11
- data/plugins/edit_view/features/step_definitions/editing_steps.rb +33 -17
- data/plugins/edit_view/lib/edit_view.rb +100 -21
- data/plugins/edit_view/lib/edit_view/actions/arrow_keys.rb +34 -11
- data/plugins/edit_view/lib/edit_view/actions/deletion.rb +10 -0
- data/plugins/edit_view/lib/edit_view/command.rb +5 -1
- data/plugins/edit_view/lib/edit_view/document.rb +8 -3
- data/plugins/edit_view/lib/edit_view/document/command.rb +15 -1
- data/plugins/edit_view/lib/edit_view/document/controller.rb +9 -0
- data/plugins/edit_view/lib/edit_view/document/history.rb +41 -0
- data/plugins/edit_view/lib/edit_view/tab_settings.rb +1 -11
- data/plugins/edit_view_swt/lib/edit_view_swt.rb +150 -4
- data/plugins/edit_view_swt/lib/edit_view_swt/document.rb +1 -1
- data/plugins/edit_view_swt/vendor/java-mateview.rb +1 -1
- data/plugins/find-in-project/lib/find_in_project.rb +7 -5
- data/plugins/html_view/features/step_definitions/html_view_steps.rb +2 -2
- data/plugins/line_tools/features/step_definitions/line_tools_steps.rb +0 -1
- data/plugins/line_tools/lib/line_tools.rb +7 -9
- data/plugins/macros/features/block_selection_in_macros.feature +48 -0
- data/plugins/macros/features/predictive_macros.feature +79 -0
- data/plugins/macros/features/record_and_run_macro.feature +87 -0
- data/plugins/macros/features/step_definitions/macro_steps.rb +66 -0
- data/plugins/macros/features/step_definitions/prediction_steps.rb +8 -0
- data/plugins/macros/features/support/env.rb +2 -0
- data/plugins/macros/lib/macros.rb +167 -0
- data/plugins/macros/lib/macros/action_sequence.rb +30 -0
- data/plugins/macros/lib/macros/commands.rb +108 -0
- data/plugins/macros/lib/macros/macro.rb +37 -0
- data/plugins/macros/lib/macros/manager_controller.rb +67 -0
- data/plugins/macros/lib/macros/predictive/document_controller.rb +69 -0
- data/plugins/macros/lib/macros/predictive/sequence_finder.rb +112 -0
- data/plugins/macros/plugin.rb +9 -0
- data/plugins/macros/spec/macros/predictive/sequence_finder_spec.rb +142 -0
- data/plugins/macros/spec/spec_helper.rb +6 -0
- data/plugins/macros/views/macro_manager.html.erb +86 -0
- data/plugins/outline_view/lib/outline_view.rb +1 -1
- data/plugins/project/lib/project/commands.rb +2 -2
- data/plugins/redcar/redcar.rb +37 -46
- data/plugins/repl/lib/repl.rb +4 -4
- data/plugins/runnables/features/command_tree.feature +1 -1
- data/plugins/runnables/features/parameter_input.feature +42 -0
- data/plugins/runnables/features/step_definitions/runnable_steps.rb +6 -0
- data/plugins/runnables/features/support/env.rb +28 -8
- data/plugins/runnables/lib/runnables.rb +35 -206
- data/plugins/runnables/lib/runnables/commands.rb +65 -0
- data/plugins/runnables/lib/runnables/tree_mirror/nodes/runnable.rb +62 -0
- data/plugins/runnables/lib/runnables/tree_mirror/nodes/runnable_group.rb +59 -0
- data/plugins/runnables/lib/runnables/tree_mirror/nodes/runnable_type_group.rb +32 -0
- data/plugins/runnables/lib/runnables/tree_mirror/tree_controller.rb +41 -0
- data/plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb +61 -0
- data/plugins/scm/lib/scm.rb +78 -45
- data/plugins/scm/lib/scm/commands.rb +18 -4
- data/plugins/scm/lib/scm/model.rb +54 -41
- data/plugins/scm_svn/LICENSE +48 -0
- data/plugins/scm_svn/features/add_and_commit.feature +18 -0
- data/plugins/scm_svn/features/checkout.feature +5 -0
- data/plugins/scm_svn/features/edit_and_index.feature +12 -0
- data/plugins/scm_svn/features/ignore_files.feature +14 -0
- data/plugins/scm_svn/features/merge.feature +34 -0
- data/plugins/scm_svn/features/resolve_conflict.feature +23 -0
- data/plugins/scm_svn/features/revert_and_delete.feature +21 -0
- data/plugins/scm_svn/features/step_definitions/branch_and_merge_steps.rb +27 -0
- data/plugins/scm_svn/features/step_definitions/checkout_steps.rb +25 -0
- data/plugins/scm_svn/features/step_definitions/edit_and_index_steps.rb +50 -0
- data/plugins/scm_svn/features/step_definitions/scm_svn_steps.rb +57 -0
- data/plugins/scm_svn/features/support/env.rb +74 -0
- data/plugins/scm_svn/features/switch_branches.feature +53 -0
- data/plugins/scm_svn/features/update.feature +16 -0
- data/plugins/scm_svn/lib/scm_svn.rb +423 -9
- data/plugins/scm_svn/lib/scm_svn/change.rb +116 -0
- data/plugins/swt/lib/swt.rb +0 -15
- data/plugins/swt/lib/swt/cucumber_patches.rb +2 -37
- data/plugins/swt/lib/swt/cucumber_runner.rb +1 -0
- data/plugins/swt/lib/swt/full_swt.rb +2 -0
- data/plugins/textmate/vendor/redcar-bundles/Bundles/Clojure.tmbundle/Syntaxes/Clojure.tmLanguage +14 -2
- data/plugins/todo_list/lib/todo_list/todo_controller.rb +1 -1
- data/plugins/todo_list/views/default.css +50 -0
- data/plugins/todo_list/views/index.html.erb +5 -16
- data/plugins/todo_list/views/redcar_small_icon.png +0 -0
- data/plugins/tree_view_swt/lib/tree_view_swt.rb +14 -33
- data/plugins/view_shortcuts/views/default.css +31 -0
- data/plugins/view_shortcuts/views/index.html.erb +26 -16
- data/plugins/view_shortcuts/views/redcar_small_icon.png +0 -0
- data/{plugins/runnables → share}/icons/cog.png +0 -0
- data/share/icons/folder-gear-emblem.png +0 -0
- data/share/icons/folder-gear.png +0 -0
- data/share/icons/folder-open-small-gears.png +0 -0
- metadata +59 -5
@@ -19,7 +19,7 @@ module Redcar
|
|
19
19
|
if command.class.record?
|
20
20
|
self << command
|
21
21
|
end
|
22
|
-
|
22
|
+
truncate
|
23
23
|
end
|
24
24
|
|
25
25
|
# Adds a command to the command history if CommandHistory.recording is
|
@@ -32,7 +32,7 @@ module Redcar
|
|
32
32
|
self << command
|
33
33
|
end
|
34
34
|
end
|
35
|
-
|
35
|
+
truncate
|
36
36
|
end
|
37
37
|
|
38
38
|
# Set the maximum length of the history
|
@@ -42,7 +42,7 @@ module Redcar
|
|
42
42
|
|
43
43
|
private
|
44
44
|
|
45
|
-
def
|
45
|
+
def truncate #:nodoc:
|
46
46
|
(length - @max).times { delete_at(0) }
|
47
47
|
end
|
48
48
|
end
|
@@ -12,7 +12,7 @@ module Redcar
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
attr_reader :
|
15
|
+
attr_reader :command, :priority, :value, :type, :active
|
16
16
|
|
17
17
|
# Create a new Item, with the given text to display in the menu, and
|
18
18
|
# either:
|
@@ -54,6 +54,14 @@ module Redcar
|
|
54
54
|
@type
|
55
55
|
end
|
56
56
|
|
57
|
+
def text
|
58
|
+
@text.is_a?(Proc) ? @text.call : @text
|
59
|
+
end
|
60
|
+
|
61
|
+
def lazy_text?
|
62
|
+
@text.is_a?(Proc)
|
63
|
+
end
|
64
|
+
|
57
65
|
def merge(other)
|
58
66
|
@command = other.command
|
59
67
|
@priority = other.priority
|
@@ -3,6 +3,8 @@ module Redcar
|
|
3
3
|
include Redcar::Model
|
4
4
|
include Redcar::Observable
|
5
5
|
|
6
|
+
DEFAULT_ICON = :file
|
7
|
+
|
6
8
|
attr_reader :notebook
|
7
9
|
|
8
10
|
def initialize(notebook)
|
@@ -37,6 +39,15 @@ module Redcar
|
|
37
39
|
@title = title
|
38
40
|
notify_listeners(:changed_title, title)
|
39
41
|
end
|
42
|
+
|
43
|
+
def icon
|
44
|
+
@icon || DEFAULT_ICON
|
45
|
+
end
|
46
|
+
|
47
|
+
def icon=(value)
|
48
|
+
@icon = value
|
49
|
+
notify_listeners(:changed_icon, icon)
|
50
|
+
end
|
40
51
|
|
41
52
|
def inspect
|
42
53
|
"#<#{self.class.name} \"#{title}\">"
|
@@ -7,7 +7,7 @@ class Redcar::Command
|
|
7
7
|
end
|
8
8
|
|
9
9
|
before do
|
10
|
-
Executor.stub!(:current_environment).and_return(:current_environment)
|
10
|
+
Executor.stub!(:current_environment).and_return({:current_environment => 1})
|
11
11
|
Redcar.app = FakeApp.new
|
12
12
|
Redcar.app.history = History.new
|
13
13
|
end
|
@@ -15,7 +15,7 @@ class Redcar::Command
|
|
15
15
|
describe "executing a command" do
|
16
16
|
class MyCommand < Redcar::Command
|
17
17
|
def environment(env)
|
18
|
-
$spec_executor_env = env
|
18
|
+
$spec_executor_env = env if env
|
19
19
|
end
|
20
20
|
|
21
21
|
def execute
|
@@ -42,7 +42,7 @@ class Redcar::Command
|
|
42
42
|
|
43
43
|
it "should set the command environment" do
|
44
44
|
@executor.execute
|
45
|
-
$spec_executor_env.should == :current_environment
|
45
|
+
$spec_executor_env.should == {:current_environment => 1}
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -48,6 +48,30 @@ describe Redcar::Command do
|
|
48
48
|
SubSensitiveCommand.sensitivity_names.should == [:foo, :bar]
|
49
49
|
end
|
50
50
|
end
|
51
|
+
|
52
|
+
describe "a command that implements _finished" do
|
53
|
+
class FinishableCommand < Redcar::Command
|
54
|
+
attr_reader :stuff
|
55
|
+
|
56
|
+
def initialize
|
57
|
+
@stuff = []
|
58
|
+
end
|
59
|
+
|
60
|
+
def execute
|
61
|
+
@stuff << :executed
|
62
|
+
end
|
63
|
+
|
64
|
+
def _finished
|
65
|
+
@stuff << :finished
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should have _finished called after the command runs" do
|
70
|
+
command_instance = FinishableCommand.new
|
71
|
+
command_instance.run
|
72
|
+
command_instance.stuff.should == [:executed, :finished]
|
73
|
+
end
|
74
|
+
end
|
51
75
|
end
|
52
76
|
|
53
77
|
|
@@ -6,8 +6,11 @@ require "application_swt/tab"
|
|
6
6
|
require "application_swt/clipboard"
|
7
7
|
require "application_swt/dialog_adapter"
|
8
8
|
require "application_swt/dialogs/no_buttons_dialog"
|
9
|
+
require "application_swt/dialogs/text_and_file_dialog"
|
9
10
|
require "application_swt/dialogs/filter_list_dialog_controller"
|
11
|
+
require "application_swt/dialogs/input_dialog"
|
10
12
|
require "application_swt/html_tab"
|
13
|
+
require "application_swt/icon"
|
11
14
|
require "application_swt/menu"
|
12
15
|
require "application_swt/menu/binding_translator"
|
13
16
|
require "application_swt/toolbar"
|
@@ -24,9 +27,9 @@ require "application_swt-#{Redcar::VERSION}"
|
|
24
27
|
module Redcar
|
25
28
|
class ApplicationSWT
|
26
29
|
include Redcar::Controller
|
27
|
-
|
30
|
+
|
28
31
|
def self.display
|
29
|
-
@display ||= Swt.display
|
32
|
+
@display ||= Swt.display
|
30
33
|
end
|
31
34
|
|
32
35
|
def self.start
|
@@ -39,7 +42,7 @@ module Redcar
|
|
39
42
|
Redcar.gui.register_dialog_adapter(ApplicationSWT::DialogAdapter.new)
|
40
43
|
end
|
41
44
|
end
|
42
|
-
|
45
|
+
|
43
46
|
def self.add_debug_key_filters
|
44
47
|
display.add_filter(Swt::SWT::KeyDown) do |a|
|
45
48
|
puts "type: #{a.type}, keyCode: #{a.keyCode}, character: #{a.character}, statemask: #{a.stateMask}"
|
@@ -48,11 +51,11 @@ module Redcar
|
|
48
51
|
puts "type: #{a.type}, keyCode: #{a.keyCode}, character: #{a.character}, statemask: #{a.stateMask}"
|
49
52
|
end
|
50
53
|
end
|
51
|
-
|
54
|
+
|
52
55
|
def self.gui
|
53
56
|
Redcar.gui
|
54
57
|
end
|
55
|
-
|
58
|
+
|
56
59
|
class ShellListener
|
57
60
|
def shell_deactivated(_)
|
58
61
|
Swt.timer_exec(100) do
|
@@ -61,11 +64,11 @@ module Redcar
|
|
61
64
|
end
|
62
65
|
end
|
63
66
|
end
|
64
|
-
|
67
|
+
|
65
68
|
def shell_activated(_)
|
66
69
|
Redcar.app.gained_application_focus
|
67
70
|
end
|
68
|
-
|
71
|
+
|
69
72
|
def shell_closed(_); end
|
70
73
|
def shell_deiconified(_); end
|
71
74
|
def shell_iconified(_); end
|
@@ -76,19 +79,19 @@ module Redcar
|
|
76
79
|
def self.register_shell(shell)
|
77
80
|
shell.add_shell_listener(ShellListener.new)
|
78
81
|
end
|
79
|
-
|
82
|
+
|
80
83
|
def self.shell_dialogs
|
81
84
|
@shell_dialogs ||= {}
|
82
85
|
end
|
83
|
-
|
86
|
+
|
84
87
|
def self.register_dialog(shell, dialog)
|
85
88
|
shell_dialogs[shell] = dialog
|
86
89
|
end
|
87
|
-
|
90
|
+
|
88
91
|
def self.unregister_dialog(dialog)
|
89
92
|
shell_dialogs.delete(shell_dialogs.invert[dialog])
|
90
93
|
end
|
91
|
-
|
94
|
+
|
92
95
|
def initialize(model)
|
93
96
|
@model = model
|
94
97
|
add_listeners
|
@@ -96,11 +99,11 @@ module Redcar
|
|
96
99
|
create_clipboard
|
97
100
|
create_fake_window
|
98
101
|
end
|
99
|
-
|
102
|
+
|
100
103
|
def fake_shell
|
101
104
|
@fake_shell
|
102
105
|
end
|
103
|
-
|
106
|
+
|
104
107
|
def create_fake_window
|
105
108
|
if Redcar.platform == :osx
|
106
109
|
@fake_shell = Swt::Widgets::Shell.new(ApplicationSWT.display, Swt::SWT::NO_TRIM)
|
@@ -108,12 +111,12 @@ module Redcar
|
|
108
111
|
@fake_shell.set_size(0, 0)
|
109
112
|
end
|
110
113
|
end
|
111
|
-
|
114
|
+
|
112
115
|
class FakeWindow
|
113
116
|
def initialize(shell)
|
114
117
|
@shell = shell
|
115
118
|
end
|
116
|
-
|
119
|
+
|
117
120
|
attr_reader :shell
|
118
121
|
end
|
119
122
|
|
@@ -136,17 +139,17 @@ module Redcar
|
|
136
139
|
@model.add_listener(:new_window, &method(:new_window))
|
137
140
|
@model.add_listener(:refresh_menu, &method(:refresh_menu))
|
138
141
|
end
|
139
|
-
|
142
|
+
|
140
143
|
class Listener
|
141
144
|
def initialize(name)
|
142
145
|
@name = name
|
143
146
|
end
|
144
|
-
|
147
|
+
|
145
148
|
def handle_event(e)
|
146
149
|
Application::Dialog.message_box("#{@name} menu is not hooked up yet")
|
147
150
|
end
|
148
151
|
end
|
149
|
-
|
152
|
+
|
150
153
|
class QuitListener
|
151
154
|
def handle_event(e)
|
152
155
|
unless Redcar.app.events.ignore?(:application_close, Redcar.app)
|
@@ -155,7 +158,7 @@ module Redcar
|
|
155
158
|
end
|
156
159
|
end
|
157
160
|
end
|
158
|
-
|
161
|
+
|
159
162
|
def add_swt_listeners
|
160
163
|
if Redcar.platform == :osx
|
161
164
|
quit_listener = Listener.new(:quit)
|
@@ -164,21 +167,21 @@ module Redcar
|
|
164
167
|
enhancer = com.redcareditor.application_swt.CocoaUIEnhancer.new("Redcar")
|
165
168
|
enhancer.hook_application_menu(
|
166
169
|
ApplicationSWT.display,
|
167
|
-
QuitListener.new,
|
168
|
-
about_listener,
|
170
|
+
QuitListener.new,
|
171
|
+
about_listener,
|
169
172
|
prefs_listener
|
170
173
|
)
|
171
174
|
end
|
172
175
|
end
|
173
|
-
|
176
|
+
|
174
177
|
def create_clipboard
|
175
178
|
ApplicationSWT::Clipboard.new(@model.clipboard)
|
176
179
|
end
|
177
|
-
|
180
|
+
|
178
181
|
def new_window(win)
|
179
182
|
win.controller = ApplicationSWT::Window.new(win)
|
180
183
|
end
|
181
|
-
|
184
|
+
|
182
185
|
def menu_changed
|
183
186
|
Menu.new(self, @model.menu)
|
184
187
|
end
|
@@ -68,48 +68,19 @@ module Redcar
|
|
68
68
|
MESSAGE_BOX_BUTTON_COMBOS.keys
|
69
69
|
end
|
70
70
|
|
71
|
-
class PasswordDialog < JFace::Dialogs::Dialog
|
72
|
-
def initialize(parent_shell, title, message)
|
73
|
-
super(parent_shell)
|
74
|
-
@title, @message = title, message
|
75
|
-
end
|
76
|
-
|
77
|
-
def createDialogArea(parent)
|
78
|
-
composite = super(parent)
|
79
|
-
|
80
|
-
passwordLabel = Swt::Widgets::Label.new(composite, Swt::SWT::RIGHT)
|
81
|
-
passwordLabel.setText(@message)
|
82
|
-
|
83
|
-
@passwordField = Swt::Widgets::Text.new(composite, Swt::SWT::SINGLE | Swt::SWT::PASSWORD)
|
84
|
-
data = Swt::Layout::GridData.new(Swt::Layout::GridData::FILL_HORIZONTAL)
|
85
|
-
@passwordField.setLayoutData(data)
|
86
|
-
|
87
|
-
getShell.setText(@title)
|
88
|
-
end
|
89
|
-
|
90
|
-
def value
|
91
|
-
@password
|
92
|
-
end
|
93
|
-
|
94
|
-
def close
|
95
|
-
@password = @passwordField.getText
|
96
|
-
super
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
71
|
def input(title, message, initial_value, &block)
|
101
|
-
dialog =
|
72
|
+
dialog = Dialogs::InputDialog.new(
|
102
73
|
parent_shell,
|
103
|
-
title, message, initial_value) do |text|
|
74
|
+
title, message, :initial_text => initial_value) do |text|
|
104
75
|
block ? block[text] : nil
|
105
76
|
end
|
106
77
|
code = dialog.open
|
107
78
|
button = (code == 0 ? :ok : :cancel)
|
108
|
-
{:button => button, :value => dialog.
|
79
|
+
{:button => button, :value => dialog.value}
|
109
80
|
end
|
110
81
|
|
111
82
|
def password_input(title, message)
|
112
|
-
dialog =
|
83
|
+
dialog = Dialogs::InputDialog.new(parent_shell, title, message, :password => true)
|
113
84
|
code = dialog.open
|
114
85
|
button = (code == 0 ? :ok : :cancel)
|
115
86
|
{:button => button, :value => dialog.value}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Redcar
|
2
|
+
class ApplicationSWT
|
3
|
+
module Dialogs
|
4
|
+
class InputDialog < JFace::Dialogs::Dialog
|
5
|
+
def initialize(parent_shell, title, message, options={})
|
6
|
+
super(parent_shell)
|
7
|
+
@title, @message = title, message
|
8
|
+
@options = {:password => false, :initial_text => ""}.merge(options)
|
9
|
+
end
|
10
|
+
|
11
|
+
def password?
|
12
|
+
@options[:password]
|
13
|
+
end
|
14
|
+
|
15
|
+
def initial_text
|
16
|
+
@options[:initial_text]
|
17
|
+
end
|
18
|
+
|
19
|
+
def createDialogArea(parent)
|
20
|
+
composite = super(parent)
|
21
|
+
|
22
|
+
passwordLabel = Swt::Widgets::Label.new(composite, Swt::SWT::RIGHT)
|
23
|
+
passwordLabel.setText(@message)
|
24
|
+
|
25
|
+
style = Swt::SWT::SINGLE
|
26
|
+
style = style | Swt::SWT::PASSWORD if password?
|
27
|
+
@inputField = Swt::Widgets::Text.new(composite, style)
|
28
|
+
data = Swt::Layout::GridData.new(Swt::Layout::GridData::FILL_HORIZONTAL)
|
29
|
+
@inputField.setLayoutData(data)
|
30
|
+
@inputField.setText(initial_text)
|
31
|
+
|
32
|
+
getShell.setText(@title)
|
33
|
+
end
|
34
|
+
|
35
|
+
def value
|
36
|
+
@text
|
37
|
+
end
|
38
|
+
|
39
|
+
def close
|
40
|
+
@text = @inputField.getText
|
41
|
+
super
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
|
2
|
+
module Redcar
|
3
|
+
class ApplicationSWT
|
4
|
+
module Dialogs
|
5
|
+
class TextAndFileDialog < JFace::Dialogs::Dialog
|
6
|
+
|
7
|
+
CONTINUE_BUTTON = "Continue"
|
8
|
+
BROWSE_BUTTON = "Browse"
|
9
|
+
# TODO: refactor this mess!
|
10
|
+
def set_text(title,message_1,message_2)
|
11
|
+
@title = title
|
12
|
+
@message_1 = message_1
|
13
|
+
@message_2 = message_2
|
14
|
+
end
|
15
|
+
|
16
|
+
def result
|
17
|
+
@result
|
18
|
+
end
|
19
|
+
|
20
|
+
def set_result(result)
|
21
|
+
@result = result
|
22
|
+
end
|
23
|
+
|
24
|
+
def createContents(parent)
|
25
|
+
composite = Swt::Widgets::Composite.new(parent, Swt::SWT::NONE)
|
26
|
+
composite.setLayout(Swt::Layout::FormLayout.new)
|
27
|
+
composite.setSize(480,200)
|
28
|
+
composite.shell.setText(@title)
|
29
|
+
|
30
|
+
target_label = Swt::Widgets::Label.new(composite, Swt::SWT::NONE)
|
31
|
+
target_labelLData = Swt::Layout::FormData.new
|
32
|
+
target_labelLData.left = Swt::Layout::FormAttachment.new(0, 1000, 12)
|
33
|
+
target_labelLData.top = Swt::Layout::FormAttachment.new(0, 1000, 78)
|
34
|
+
target_labelLData.width = 200
|
35
|
+
target_labelLData.height = 17
|
36
|
+
target_label.setLayoutData(target_labelLData)
|
37
|
+
target_label.setText(@message_2)
|
38
|
+
|
39
|
+
dialog_message = Swt::Widgets::Label.new(composite, Swt::SWT::NONE);
|
40
|
+
dialog_messageLData = Swt::Layout::FormData.new
|
41
|
+
dialog_messageLData.left = Swt::Layout::FormAttachment.new(0, 1000, 12)
|
42
|
+
dialog_messageLData.top = Swt::Layout::FormAttachment.new(0, 1000, 6)
|
43
|
+
dialog_messageLData.width = 200
|
44
|
+
dialog_messageLData.height = 17
|
45
|
+
dialog_message.setLayoutData(dialog_messageLData)
|
46
|
+
dialog_message.setText(@message_1)
|
47
|
+
|
48
|
+
continue_button = Swt::Widgets::Button.new(composite, Swt::SWT::PUSH | Swt::SWT::CENTER)
|
49
|
+
continueLData = Swt::Layout::FormData.new
|
50
|
+
continueLData.left = Swt::Layout::FormAttachment.new(0, 1000, 146)
|
51
|
+
continueLData.top = Swt::Layout::FormAttachment.new(0, 1000, 141)
|
52
|
+
continueLData.width = 70
|
53
|
+
continueLData.height = 30
|
54
|
+
continue_button.setLayoutData(continueLData)
|
55
|
+
continue_button.setText(CONTINUE_BUTTON)
|
56
|
+
|
57
|
+
browse_files = Swt::Widgets::Button.new(composite, Swt::SWT::PUSH | Swt::SWT::CENTER)
|
58
|
+
browse_files.setText(BROWSE_BUTTON)
|
59
|
+
browse_filesLData = Swt::Layout::FormData.new
|
60
|
+
browse_filesLData.width = 70
|
61
|
+
browse_filesLData.height = 30
|
62
|
+
browse_filesLData.left = Swt::Layout::FormAttachment.new(0, 1000, 310)
|
63
|
+
browse_filesLData.top = Swt::Layout::FormAttachment.new(0, 1000, 110)
|
64
|
+
browse_files.setLayoutData(browse_filesLData)
|
65
|
+
|
66
|
+
target_dirLData = Swt::Layout::FormData.new
|
67
|
+
target_dirLData.left = Swt::Layout::FormAttachment.new(0, 1000, 12)
|
68
|
+
target_dirLData.top = Swt::Layout::FormAttachment.new(0, 1000, 110)
|
69
|
+
target_dirLData.width = 300
|
70
|
+
target_dirLData.height = 22
|
71
|
+
target_dir = Swt::Widgets::Text.new(composite, Swt::SWT::NONE)
|
72
|
+
target_dir.setLayoutData(target_dirLData)
|
73
|
+
|
74
|
+
repo_urlLData = Swt::Layout::FormData.new
|
75
|
+
repo_urlLData.left = Swt::Layout::FormAttachment.new(0, 1000, 12)
|
76
|
+
repo_urlLData.top = Swt::Layout::FormAttachment.new(0, 1000, 38)
|
77
|
+
repo_urlLData.width = 300
|
78
|
+
repo_urlLData.height = 22
|
79
|
+
repo_url = Swt::Widgets::Text.new(composite, Swt::SWT::NONE)
|
80
|
+
repo_url.setLayoutData(repo_urlLData)
|
81
|
+
|
82
|
+
listener = SelectionListener.new(self,composite,repo_url,target_dir)
|
83
|
+
browse_files.addListener(Swt::SWT::Selection, listener)
|
84
|
+
continue_button.addListener(Swt::SWT::Selection, listener)
|
85
|
+
|
86
|
+
composite
|
87
|
+
end
|
88
|
+
|
89
|
+
def open
|
90
|
+
super
|
91
|
+
@result
|
92
|
+
end
|
93
|
+
|
94
|
+
class SelectionListener
|
95
|
+
def initialize(parent,dialog,repo_url,target_dir)
|
96
|
+
@dialog = dialog.shell
|
97
|
+
@repo_url = repo_url
|
98
|
+
@target_dir = target_dir
|
99
|
+
@parent = parent
|
100
|
+
end
|
101
|
+
|
102
|
+
def handleEvent(event)
|
103
|
+
if (event.widget.getText == BROWSE_BUTTON)
|
104
|
+
target_dir_path = Application::Dialog.open_directory({})
|
105
|
+
@target_dir.setText(target_dir_path) if target_dir_path
|
106
|
+
elsif (event.widget.getText == CONTINUE_BUTTON)
|
107
|
+
@parent.set_result({
|
108
|
+
:text => @repo_url.text,
|
109
|
+
:directory => @target_dir.text
|
110
|
+
})
|
111
|
+
@dialog.close
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|