redcar 0.5.3dev → 0.5.4dev
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/bin/redcar +3 -1
- data/lib/redcar.rb +1 -3
- data/plugins/application/lib/application/window.rb +1 -9
- data/plugins/application/lib/application.rb +3 -43
- data/plugins/application_swt/lib/application_swt/window.rb +4 -33
- data/plugins/application_swt/lib/application_swt.rb +1 -12
- data/plugins/core/spec/core/resource_spec.rb +124 -123
- data/plugins/html_view/plugin.rb +2 -1
- data/plugins/project/lib/project.rb +2 -0
- data/plugins/redcar/redcar.rb +0 -18
- data/plugins/swt/lib/swt/full_swt.rb +117 -0
- data/plugins/swt/lib/swt.rb +13 -80
- metadata +4 -10
- data/plugins/application/lib/application/toolbar/builder/group.rb +0 -47
- data/plugins/application/lib/application/toolbar/builder.rb +0 -80
- data/plugins/application/lib/application/toolbar/item.rb +0 -72
- data/plugins/application/lib/application/toolbar/lazy_toolbar.rb +0 -25
- data/plugins/application/lib/application/toolbar.rb +0 -91
- data/plugins/application_swt/lib/application_swt/toolbar/binding_translator.rb +0 -94
- data/plugins/application_swt/lib/application_swt/toolbar.rb +0 -134
@@ -1,94 +0,0 @@
|
|
1
|
-
module Redcar
|
2
|
-
class ApplicationSWT
|
3
|
-
class ToolBar
|
4
|
-
module BindingTranslator
|
5
|
-
MODIFIERS = %w(Cmd Ctrl Alt Shift)
|
6
|
-
|
7
|
-
def self.platform_key_string(key_specifier)
|
8
|
-
if key_specifier.is_a?(Hash)
|
9
|
-
key_string = key_specifier[Redcar.platform]
|
10
|
-
else
|
11
|
-
key_string = key_specifier
|
12
|
-
end
|
13
|
-
key_string.gsub("Escape", "")
|
14
|
-
key_string.gsub("Space", "")
|
15
|
-
key_string
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.key(key_string)
|
19
|
-
value = 0
|
20
|
-
MODIFIERS.each do |modifier|
|
21
|
-
if key_string =~ /\b#{modifier}\b/
|
22
|
-
value += modifier_values[modifier]
|
23
|
-
end
|
24
|
-
end
|
25
|
-
if key_string =~ /Escape$/
|
26
|
-
value += Swt::SWT::ESC
|
27
|
-
elsif key_string =~ /Space$/
|
28
|
-
value += " "[0]
|
29
|
-
elsif key_string =~ /(F\d+)/
|
30
|
-
value += Swt::SWT.const_get $1
|
31
|
-
elsif key_string =~ /(Right|Left|Up|Down)/
|
32
|
-
value += Swt::SWT.const_get 'ARROW_'+$1.upcase
|
33
|
-
elsif key_string =~ /Tab/
|
34
|
-
value += Swt::SWT::TAB
|
35
|
-
elsif key_string =~ /Page Up$/
|
36
|
-
value += Swt::SWT::PAGE_UP
|
37
|
-
elsif key_string =~ /Page Down$/
|
38
|
-
value += Swt::SWT::PAGE_DOWN
|
39
|
-
elsif key_string =~ /Home$/
|
40
|
-
value += Swt::SWT::HOME
|
41
|
-
elsif key_string =~ /End$/
|
42
|
-
value += Swt::SWT::END
|
43
|
-
else
|
44
|
-
value += key_string[-1]
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def self.modifiers(key_event)
|
49
|
-
modifiers = []
|
50
|
-
modifier_values.each do |string, constant|
|
51
|
-
if (key_event.stateMask & constant) != 0
|
52
|
-
modifiers << string
|
53
|
-
end
|
54
|
-
end
|
55
|
-
modifiers = modifiers.sort_by {|m| MODIFIERS.index(m) }
|
56
|
-
end
|
57
|
-
|
58
|
-
def self.key_string(key_event)
|
59
|
-
modifiers = modifiers(key_event)
|
60
|
-
if key_event.character == 0
|
61
|
-
modifiers.join("+")
|
62
|
-
else
|
63
|
-
letter = java.lang.Character.new(key_event.character).toString.upcase # key_event.keyCode)
|
64
|
-
if modifiers.any?
|
65
|
-
modifiers.join("+") << "+" << (pretty_letter(letter) || letter)
|
66
|
-
else
|
67
|
-
(pretty_letter(letter) || letter)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def self.matches?(key_string, key_string2)
|
73
|
-
key_string.split("+").sort ==
|
74
|
-
key_string2.split("+").sort
|
75
|
-
end
|
76
|
-
|
77
|
-
def self.pretty_letter(char_string)
|
78
|
-
{"\r" => "Return"}[char_string]
|
79
|
-
end
|
80
|
-
|
81
|
-
private
|
82
|
-
|
83
|
-
def self.modifier_values
|
84
|
-
{
|
85
|
-
"Cmd" => Swt::SWT::COMMAND,
|
86
|
-
"Ctrl" => Swt::SWT::CTRL,
|
87
|
-
"Alt" => Swt::SWT::ALT,
|
88
|
-
"Shift" => Swt::SWT::SHIFT,
|
89
|
-
}
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
@@ -1,134 +0,0 @@
|
|
1
|
-
module Redcar
|
2
|
-
class ApplicationSWT
|
3
|
-
class ToolBar
|
4
|
-
|
5
|
-
|
6
|
-
FILE_DIR = File.join(Redcar.root, %w(share icons))
|
7
|
-
DEFAULT_ICON = File.join(Redcar.root, %w(share icons document.png))
|
8
|
-
|
9
|
-
def self.icons
|
10
|
-
@icons = {
|
11
|
-
:new => File.join(FILE_DIR, "document-text.png"),
|
12
|
-
:open => File.join(FILE_DIR, "folder-open-document.png"),
|
13
|
-
:save => File.join(FILE_DIR, "document-import.png"),
|
14
|
-
#:save_as => File.join(FILE_DIR, "save_as.png"),
|
15
|
-
#:save_all => File.join(FILE_DIR, "save_all.png"),
|
16
|
-
:undo => File.join(FILE_DIR, "arrow-circle-225-left.png"),
|
17
|
-
:redo => File.join(FILE_DIR, "arrow-circle-315.png"),
|
18
|
-
:search => File.join(FILE_DIR, "binocular.png")
|
19
|
-
}
|
20
|
-
end
|
21
|
-
|
22
|
-
|
23
|
-
def self.types
|
24
|
-
@types = { :check => Swt::SWT::CHECK, :radio => Swt::SWT::RADIO }
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.items
|
28
|
-
@items ||= Hash.new {|h,k| h[k] = []}
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.disable_items(key_string)
|
32
|
-
items[key_string].each {|i| p i.text; i.enabled = false}
|
33
|
-
end
|
34
|
-
|
35
|
-
attr_reader :toolbar_bar
|
36
|
-
|
37
|
-
def self.toolbar_types
|
38
|
-
[Swt::SWT::FLAT, Swt::SWT::HORIZONTAL]
|
39
|
-
end
|
40
|
-
|
41
|
-
def initialize(window, toolbar_model, options={})
|
42
|
-
s = Time.now
|
43
|
-
@window = window
|
44
|
-
@toolbar_bar = Swt::Widgets::ToolBar.new(window.shell, Swt::SWT::FLAT + Swt::SWT::SHADOW_OUT)
|
45
|
-
@toolbar_bar.set_visible(false)
|
46
|
-
@toolbar_bar.setLayout(Swt::Layout::FormLayout.new)
|
47
|
-
@toolbar_bar.setLayoutData(Swt::Layout::FormData.new)
|
48
|
-
return unless toolbar_model
|
49
|
-
add_entries_to_toolbar(@toolbar_bar, toolbar_model)
|
50
|
-
#puts "ApplicationSWT::ToolBar initialize took #{Time.now - s}s"
|
51
|
-
@toolbar_bar.pack
|
52
|
-
end
|
53
|
-
|
54
|
-
def show
|
55
|
-
@toolbar_bar.set_visible(true)
|
56
|
-
end
|
57
|
-
|
58
|
-
def hide
|
59
|
-
#@toolbar_bar.set_visible(false)
|
60
|
-
#@toolbar_bar.setRedraw(true)
|
61
|
-
@toolbar_bar.dispose()
|
62
|
-
end
|
63
|
-
|
64
|
-
def close
|
65
|
-
#@handlers.each {|obj, h| obj.remove_listener(h) }
|
66
|
-
@toolbar_bar.dispose
|
67
|
-
@result
|
68
|
-
end
|
69
|
-
|
70
|
-
def move(x, y)
|
71
|
-
@toolbar_bar.setLocation(x, y)
|
72
|
-
end
|
73
|
-
|
74
|
-
private
|
75
|
-
|
76
|
-
def add_entries_to_toolbar(toolbar, toolbar_model)
|
77
|
-
|
78
|
-
toolbar_model.each do |entry|
|
79
|
-
if entry.is_a?(Redcar::ToolBar::LazyToolBar)
|
80
|
-
toolbar_header = Swt::Widgets::ToolItem.new(toolbar, Swt::SWT::CASCADE)
|
81
|
-
toolbar_header.text = entry.text
|
82
|
-
#new_toolbar = Swt::Widgets::ToolBar.new(@window.shell, Swt::SWT::DROP_DOWN)
|
83
|
-
new_toolbar = Swt::Widgets::ToolBar.new(toolbar)
|
84
|
-
toolbar_header.toolbar = new_toolbar
|
85
|
-
toolbar_header.add_arm_listener do
|
86
|
-
new_toolbar.get_items.each {|i| i.dispose }
|
87
|
-
add_entries_to_toolbar(new_toolbar, entry)
|
88
|
-
end
|
89
|
-
elsif entry.is_a?(Redcar::ToolBar)
|
90
|
-
new_toolbar = Swt::Widgets::ToolBar.new(toolbar)
|
91
|
-
add_entries_to_toolbar(new_toolbar, entry)
|
92
|
-
elsif entry.is_a?(Redcar::ToolBar::Item::Separator)
|
93
|
-
item = Swt::Widgets::ToolItem.new(toolbar, Swt::SWT::SEPARATOR)
|
94
|
-
elsif entry.is_a?(Redcar::ToolBar::Item)
|
95
|
-
item = Swt::Widgets::ToolItem.new(toolbar, Swt::SWT::PUSH)
|
96
|
-
item.setEnabled(true)
|
97
|
-
item.setImage(Swt::Graphics::Image.new(ApplicationSWT.display, ToolBar.icons[entry.icon] || entry.icon || DEFAULT_ICON))
|
98
|
-
connect_command_to_item(item, entry)
|
99
|
-
else
|
100
|
-
raise "unknown object of type #{entry.class} in toolbar"
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
class SelectionListener
|
106
|
-
def initialize(entry)
|
107
|
-
@entry = entry
|
108
|
-
end
|
109
|
-
|
110
|
-
def widget_selected(e)
|
111
|
-
@entry.selected(e.stateMask != 0)
|
112
|
-
end
|
113
|
-
|
114
|
-
def widget_default_selected(e)
|
115
|
-
@entry.selected(e.stateMask != 0)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
def connect_command_to_item(item, entry)
|
120
|
-
item.setToolTipText(entry.text)
|
121
|
-
item.add_selection_listener(SelectionListener.new(entry))
|
122
|
-
h = entry.command.add_listener(:active_changed) do |value|
|
123
|
-
unless item.disposed
|
124
|
-
item.enabled = value
|
125
|
-
end
|
126
|
-
end
|
127
|
-
#@handlers << [entry.command, h]
|
128
|
-
if not entry.command.active?
|
129
|
-
item.enabled = false
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|