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
@@ -0,0 +1,117 @@
|
|
1
|
+
|
2
|
+
module Swt
|
3
|
+
import org.eclipse.swt.SWT
|
4
|
+
|
5
|
+
module Widgets
|
6
|
+
import org.eclipse.swt.widgets.Button
|
7
|
+
import org.eclipse.swt.widgets.Caret
|
8
|
+
import org.eclipse.swt.widgets.Combo
|
9
|
+
import org.eclipse.swt.widgets.Composite
|
10
|
+
import org.eclipse.swt.widgets.Event
|
11
|
+
import org.eclipse.swt.widgets.DirectoryDialog
|
12
|
+
import org.eclipse.swt.widgets.FileDialog
|
13
|
+
import org.eclipse.swt.widgets.List
|
14
|
+
import org.eclipse.swt.widgets.Menu
|
15
|
+
import org.eclipse.swt.widgets.MenuItem
|
16
|
+
import org.eclipse.swt.widgets.MessageBox
|
17
|
+
import org.eclipse.swt.widgets.Sash
|
18
|
+
import org.eclipse.swt.widgets.TabFolder
|
19
|
+
import org.eclipse.swt.widgets.TabItem
|
20
|
+
import org.eclipse.swt.widgets.Text
|
21
|
+
import org.eclipse.swt.widgets.ToolTip
|
22
|
+
import org.eclipse.swt.widgets.Table
|
23
|
+
import org.eclipse.swt.widgets.TableItem
|
24
|
+
end
|
25
|
+
|
26
|
+
module Custom
|
27
|
+
import org.eclipse.swt.custom.CTabFolder
|
28
|
+
import org.eclipse.swt.custom.CTabItem
|
29
|
+
import org.eclipse.swt.custom.SashForm
|
30
|
+
import org.eclipse.swt.custom.StackLayout
|
31
|
+
import org.eclipse.swt.custom.ST
|
32
|
+
import org.eclipse.swt.custom.StyledText
|
33
|
+
import org.eclipse.swt.custom.TreeEditor
|
34
|
+
end
|
35
|
+
|
36
|
+
module DND
|
37
|
+
import org.eclipse.swt.dnd.DND
|
38
|
+
import org.eclipse.swt.dnd.Clipboard
|
39
|
+
import org.eclipse.swt.dnd.Transfer
|
40
|
+
import org.eclipse.swt.dnd.TextTransfer
|
41
|
+
import org.eclipse.swt.dnd.FileTransfer
|
42
|
+
import org.eclipse.swt.dnd.ByteArrayTransfer
|
43
|
+
|
44
|
+
import org.eclipse.swt.dnd.DropTarget
|
45
|
+
import org.eclipse.swt.dnd.DropTargetEvent
|
46
|
+
import org.eclipse.swt.dnd.DropTargetListener
|
47
|
+
|
48
|
+
import org.eclipse.swt.dnd.DragSource
|
49
|
+
import org.eclipse.swt.dnd.DragSourceEvent
|
50
|
+
import org.eclipse.swt.dnd.DragSourceListener
|
51
|
+
end
|
52
|
+
|
53
|
+
module Layout
|
54
|
+
import org.eclipse.swt.layout.FillLayout
|
55
|
+
import org.eclipse.swt.layout.GridLayout
|
56
|
+
import org.eclipse.swt.layout.GridData
|
57
|
+
import org.eclipse.swt.layout.RowLayout
|
58
|
+
import org.eclipse.swt.layout.RowData
|
59
|
+
end
|
60
|
+
|
61
|
+
module Graphics
|
62
|
+
import org.eclipse.swt.graphics.Color
|
63
|
+
import org.eclipse.swt.graphics.Device
|
64
|
+
import org.eclipse.swt.graphics.Font
|
65
|
+
import org.eclipse.swt.graphics.GC
|
66
|
+
import org.eclipse.swt.graphics.Point
|
67
|
+
end
|
68
|
+
|
69
|
+
module Events
|
70
|
+
import org.eclipse.swt.events.KeyEvent
|
71
|
+
end
|
72
|
+
|
73
|
+
import org.eclipse.swt.browser.Browser
|
74
|
+
class Browser
|
75
|
+
import org.eclipse.swt.browser.BrowserFunction
|
76
|
+
end
|
77
|
+
|
78
|
+
class RRunnable
|
79
|
+
include java.lang.Runnable
|
80
|
+
|
81
|
+
def initialize(&block)
|
82
|
+
@block = block
|
83
|
+
end
|
84
|
+
|
85
|
+
def run
|
86
|
+
@block.call
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
module JFace
|
92
|
+
Dir[Redcar.asset_dir + "/jface/*.jar"].each do |jar_fn|
|
93
|
+
require jar_fn
|
94
|
+
end
|
95
|
+
|
96
|
+
module Viewers
|
97
|
+
import org.eclipse.jface.viewers.ColumnViewerToolTipSupport
|
98
|
+
import org.eclipse.jface.viewers.TreeViewer
|
99
|
+
import org.eclipse.jface.viewers.ITreeContentProvider
|
100
|
+
import org.eclipse.jface.viewers.ILabelProvider
|
101
|
+
import org.eclipse.jface.viewers.ILazyTreeContentProvider
|
102
|
+
import org.eclipse.jface.viewers.ILabelProvider
|
103
|
+
import org.eclipse.jface.viewers.TextCellEditor
|
104
|
+
import org.eclipse.jface.viewers.ViewerDropAdapter
|
105
|
+
end
|
106
|
+
|
107
|
+
module Text
|
108
|
+
import org.eclipse.jface.text.TextViewerUndoManager
|
109
|
+
end
|
110
|
+
|
111
|
+
module Dialogs
|
112
|
+
import org.eclipse.jface.dialogs.Dialog
|
113
|
+
import org.eclipse.jface.dialogs.InputDialog
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
require 'swt/grid_data'
|
data/plugins/swt/lib/swt.rb
CHANGED
@@ -3,7 +3,6 @@ require 'rbconfig'
|
|
3
3
|
|
4
4
|
require 'swt/cucumber_runner'
|
5
5
|
require 'swt/event_loop'
|
6
|
-
require 'swt/grid_data'
|
7
6
|
require 'swt/listener_helpers'
|
8
7
|
|
9
8
|
module Swt
|
@@ -127,96 +126,29 @@ module Swt
|
|
127
126
|
end
|
128
127
|
|
129
128
|
module Widgets
|
130
|
-
import org.eclipse.swt.widgets.Button
|
131
|
-
import org.eclipse.swt.widgets.Caret
|
132
|
-
import org.eclipse.swt.widgets.Combo
|
133
|
-
import org.eclipse.swt.widgets.Composite
|
134
129
|
import org.eclipse.swt.widgets.Display
|
135
|
-
import org.eclipse.swt.widgets.Event
|
136
|
-
import org.eclipse.swt.widgets.DirectoryDialog
|
137
|
-
import org.eclipse.swt.widgets.FileDialog
|
138
130
|
import org.eclipse.swt.widgets.Label
|
139
|
-
import org.eclipse.swt.widgets.List
|
140
|
-
import org.eclipse.swt.widgets.Menu
|
141
|
-
import org.eclipse.swt.widgets.MenuItem
|
142
|
-
import org.eclipse.swt.widgets.MessageBox
|
143
131
|
import org.eclipse.swt.widgets.ProgressBar
|
144
|
-
import org.eclipse.swt.widgets.Sash
|
145
132
|
import org.eclipse.swt.widgets.Shell
|
146
|
-
import org.eclipse.swt.widgets.TabFolder
|
147
|
-
import org.eclipse.swt.widgets.TabItem
|
148
|
-
import org.eclipse.swt.widgets.Text
|
149
|
-
import org.eclipse.swt.widgets.ToolTip
|
150
|
-
import org.eclipse.swt.widgets.Table
|
151
|
-
import org.eclipse.swt.widgets.TableItem
|
152
133
|
end
|
153
134
|
|
154
|
-
def self.display
|
155
|
-
return nil if Redcar.no_gui_mode?
|
156
|
-
if defined?(SWT_APP_NAME)
|
157
|
-
Swt::Widgets::Display.app_name = SWT_APP_NAME
|
158
|
-
end
|
159
|
-
@display ||= (Swt::Widgets::Display.getCurrent || Swt::Widgets::Display.new)
|
160
|
-
end
|
161
|
-
|
162
|
-
unless Redcar.no_gui_mode?
|
163
|
-
display # must be created before we import the Clipboard class.
|
164
|
-
end
|
165
|
-
|
166
135
|
module Custom
|
167
|
-
import org.eclipse.swt.custom.CTabFolder
|
168
|
-
import org.eclipse.swt.custom.CTabItem
|
169
|
-
import org.eclipse.swt.custom.SashForm
|
170
|
-
import org.eclipse.swt.custom.StackLayout
|
171
|
-
import org.eclipse.swt.custom.ST
|
172
|
-
import org.eclipse.swt.custom.StyledText
|
173
|
-
import org.eclipse.swt.custom.TreeEditor
|
174
136
|
end
|
175
137
|
|
176
138
|
module DND
|
177
|
-
import org.eclipse.swt.dnd.DND
|
178
|
-
import org.eclipse.swt.dnd.Clipboard
|
179
|
-
import org.eclipse.swt.dnd.Transfer
|
180
|
-
import org.eclipse.swt.dnd.TextTransfer
|
181
|
-
import org.eclipse.swt.dnd.FileTransfer
|
182
|
-
import org.eclipse.swt.dnd.ByteArrayTransfer
|
183
|
-
|
184
|
-
import org.eclipse.swt.dnd.DropTarget
|
185
|
-
import org.eclipse.swt.dnd.DropTargetEvent
|
186
|
-
import org.eclipse.swt.dnd.DropTargetListener
|
187
|
-
|
188
|
-
import org.eclipse.swt.dnd.DragSource
|
189
|
-
import org.eclipse.swt.dnd.DragSourceEvent
|
190
|
-
import org.eclipse.swt.dnd.DragSourceListener
|
191
139
|
end
|
192
140
|
|
193
141
|
module Layout
|
194
|
-
import org.eclipse.swt.layout.FillLayout
|
195
142
|
import org.eclipse.swt.layout.FormAttachment
|
196
|
-
import org.eclipse.swt.layout.FormLayout
|
197
143
|
import org.eclipse.swt.layout.FormData
|
198
|
-
import org.eclipse.swt.layout.
|
199
|
-
import org.eclipse.swt.layout.GridData
|
200
|
-
import org.eclipse.swt.layout.RowLayout
|
201
|
-
import org.eclipse.swt.layout.RowData
|
144
|
+
import org.eclipse.swt.layout.FormLayout
|
202
145
|
end
|
203
146
|
|
204
147
|
module Graphics
|
205
|
-
import org.eclipse.swt.graphics.Color
|
206
|
-
import org.eclipse.swt.graphics.Device
|
207
|
-
import org.eclipse.swt.graphics.Font
|
208
|
-
import org.eclipse.swt.graphics.GC
|
209
148
|
import org.eclipse.swt.graphics.Image
|
210
|
-
import org.eclipse.swt.graphics.Point
|
211
149
|
end
|
212
150
|
|
213
151
|
module Events
|
214
|
-
import org.eclipse.swt.events.KeyEvent
|
215
|
-
end
|
216
|
-
|
217
|
-
import org.eclipse.swt.browser.Browser
|
218
|
-
class Browser
|
219
|
-
import org.eclipse.swt.browser.BrowserFunction
|
220
152
|
end
|
221
153
|
|
222
154
|
class RRunnable
|
@@ -230,6 +162,18 @@ module Swt
|
|
230
162
|
@block.call
|
231
163
|
end
|
232
164
|
end
|
165
|
+
|
166
|
+
def self.display
|
167
|
+
return nil if Redcar.no_gui_mode?
|
168
|
+
if defined?(SWT_APP_NAME)
|
169
|
+
Swt::Widgets::Display.app_name = SWT_APP_NAME
|
170
|
+
end
|
171
|
+
@display ||= (Swt::Widgets::Display.getCurrent || Swt::Widgets::Display.new)
|
172
|
+
end
|
173
|
+
|
174
|
+
unless Redcar.no_gui_mode?
|
175
|
+
display # must be created before we import the Clipboard class.
|
176
|
+
end
|
233
177
|
end
|
234
178
|
|
235
179
|
module JFace
|
@@ -238,22 +182,11 @@ module JFace
|
|
238
182
|
end
|
239
183
|
|
240
184
|
module Viewers
|
241
|
-
import org.eclipse.jface.viewers.ColumnViewerToolTipSupport
|
242
|
-
import org.eclipse.jface.viewers.TreeViewer
|
243
|
-
import org.eclipse.jface.viewers.ITreeContentProvider
|
244
|
-
import org.eclipse.jface.viewers.ILabelProvider
|
245
|
-
import org.eclipse.jface.viewers.ILazyTreeContentProvider
|
246
|
-
import org.eclipse.jface.viewers.ILabelProvider
|
247
|
-
import org.eclipse.jface.viewers.TextCellEditor
|
248
|
-
import org.eclipse.jface.viewers.ViewerDropAdapter
|
249
185
|
end
|
250
186
|
|
251
187
|
module Text
|
252
|
-
import org.eclipse.jface.text.TextViewerUndoManager
|
253
188
|
end
|
254
189
|
|
255
190
|
module Dialogs
|
256
|
-
import org.eclipse.jface.dialogs.Dialog
|
257
|
-
import org.eclipse.jface.dialogs.InputDialog
|
258
191
|
end
|
259
192
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redcar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: -1574061313
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 4dev
|
10
|
+
version: 0.5.4dev
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Daniel Lucraft
|
@@ -661,11 +661,6 @@ files:
|
|
661
661
|
- plugins/application/lib/application/speedbar.rb
|
662
662
|
- plugins/application/lib/application/tab/command.rb
|
663
663
|
- plugins/application/lib/application/tab.rb
|
664
|
-
- plugins/application/lib/application/toolbar/builder/group.rb
|
665
|
-
- plugins/application/lib/application/toolbar/builder.rb
|
666
|
-
- plugins/application/lib/application/toolbar/item.rb
|
667
|
-
- plugins/application/lib/application/toolbar/lazy_toolbar.rb
|
668
|
-
- plugins/application/lib/application/toolbar.rb
|
669
664
|
- plugins/application/lib/application/treebook.rb
|
670
665
|
- plugins/application/lib/application/window.rb
|
671
666
|
- plugins/application/lib/application.rb
|
@@ -702,8 +697,6 @@ files:
|
|
702
697
|
- plugins/application_swt/lib/application_swt/notebook.rb
|
703
698
|
- plugins/application_swt/lib/application_swt/speedbar.rb
|
704
699
|
- plugins/application_swt/lib/application_swt/tab.rb
|
705
|
-
- plugins/application_swt/lib/application_swt/toolbar/binding_translator.rb
|
706
|
-
- plugins/application_swt/lib/application_swt/toolbar.rb
|
707
700
|
- plugins/application_swt/lib/application_swt/treebook.rb
|
708
701
|
- plugins/application_swt/lib/application_swt/window.rb
|
709
702
|
- plugins/application_swt/lib/application_swt.rb
|
@@ -1548,6 +1541,7 @@ files:
|
|
1548
1541
|
- plugins/swt/lib/swt/cucumber_patches.rb
|
1549
1542
|
- plugins/swt/lib/swt/cucumber_runner.rb
|
1550
1543
|
- plugins/swt/lib/swt/event_loop.rb
|
1544
|
+
- plugins/swt/lib/swt/full_swt.rb
|
1551
1545
|
- plugins/swt/lib/swt/grid_data.rb
|
1552
1546
|
- plugins/swt/lib/swt/listener_helpers.rb
|
1553
1547
|
- plugins/swt/lib/swt.rb
|
@@ -1,47 +0,0 @@
|
|
1
|
-
|
2
|
-
module Redcar
|
3
|
-
class ToolBar
|
4
|
-
class Builder
|
5
|
-
# An extension to the Builder to allow groups of toolbar object to inherit options.
|
6
|
-
#
|
7
|
-
# This is supported for all options, even options that don't exist yet!
|
8
|
-
#
|
9
|
-
# Currently, this is only useful in a practical sense to apply a :priority to a
|
10
|
-
# set of objects
|
11
|
-
class Group
|
12
|
-
|
13
|
-
def initialize(builder, options={}, &block)
|
14
|
-
@builder = builder
|
15
|
-
@defaults = options
|
16
|
-
|
17
|
-
if block.arity == 1
|
18
|
-
block.call(self)
|
19
|
-
else
|
20
|
-
instance_eval(&block)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def item(text, options={}, &block)
|
25
|
-
options = {:command => options} if not options.respond_to?('[]')
|
26
|
-
@builder.item(text, @defaults.merge(options), &block)
|
27
|
-
end
|
28
|
-
|
29
|
-
def separator(options={})
|
30
|
-
@builder.separator(@defaults.merge(options))
|
31
|
-
end
|
32
|
-
|
33
|
-
def sub_toolbar(text, options={}, &block)
|
34
|
-
@builder.sub_toolbar(text, @defaults.merge(options), &block)
|
35
|
-
end
|
36
|
-
|
37
|
-
def lazy_sub_toolbar(text, options={}, &block)
|
38
|
-
@builder.lazy_sub_toolbar(text, @defaults.merge(options), &block)
|
39
|
-
end
|
40
|
-
|
41
|
-
def append(item)
|
42
|
-
@builder.append(item)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
|
2
|
-
module Redcar
|
3
|
-
class ToolBar
|
4
|
-
# A DSL for building toolbars simply. An example of usage
|
5
|
-
#
|
6
|
-
# builder = ToolBar::Builder.new "Edit" do
|
7
|
-
# item "Select All", SelectAllCommand
|
8
|
-
# sub_toolbar "Indent" do
|
9
|
-
# item "Increase", IncreaseIndentCommand
|
10
|
-
# item("Decrease") { puts "decrease selected" }
|
11
|
-
# end
|
12
|
-
# end
|
13
|
-
#
|
14
|
-
# This is equivalent to:
|
15
|
-
#
|
16
|
-
# toolbar = Redcar::ToolBar.new("Edit")
|
17
|
-
# toolbar << Redcar::ToolBar::Item.new("Select All", SelectAllCommand)
|
18
|
-
# indent_toolbar = Redcar::ToolBar.new("Indent")
|
19
|
-
# indent_toolbar << Redcar::ToolBar::Item.new("Increase", IncreaseIndentCommand)
|
20
|
-
# indent_toolbar << Redcar::ToolBar::Item.new("Decrease") do
|
21
|
-
# puts "decrease selected"
|
22
|
-
# end
|
23
|
-
# toolbar << indent_toolbar
|
24
|
-
class Builder
|
25
|
-
attr_reader :toolbar
|
26
|
-
|
27
|
-
def self.build(name=nil, &block)
|
28
|
-
new(name, &block).toolbar
|
29
|
-
end
|
30
|
-
|
31
|
-
def initialize(toolbar_or_text=nil, &block)
|
32
|
-
case toolbar_or_text
|
33
|
-
when String, nil
|
34
|
-
@toolbar = Redcar::ToolBar.new(toolbar_or_text||"")
|
35
|
-
when ToolBar
|
36
|
-
@toolbar = toolbar_or_text
|
37
|
-
end
|
38
|
-
@current_toolbar = @toolbar
|
39
|
-
if block.arity == 1
|
40
|
-
block.call(self)
|
41
|
-
else
|
42
|
-
instance_eval(&block)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def item(text, options={}, &block)
|
47
|
-
@current_toolbar << Item.new(text, options, &block)
|
48
|
-
end
|
49
|
-
|
50
|
-
def separator(options={})
|
51
|
-
@current_toolbar << Item::Separator.new(options)
|
52
|
-
end
|
53
|
-
|
54
|
-
def sub_toolbar(text, options={}, &block)
|
55
|
-
new_toolbar = ToolBar.new(text, options)
|
56
|
-
@current_toolbar << new_toolbar
|
57
|
-
old_toolbar, @current_toolbar = @current_toolbar, new_toolbar
|
58
|
-
if block.arity == 1
|
59
|
-
block.call(self)
|
60
|
-
else
|
61
|
-
instance_eval(&block)
|
62
|
-
end
|
63
|
-
@current_toolbar = old_toolbar
|
64
|
-
end
|
65
|
-
|
66
|
-
def lazy_sub_toolbar(text, options={}, &block)
|
67
|
-
new_toolbar = LazyToolBar.new(block, text, options)
|
68
|
-
@current_toolbar << new_toolbar
|
69
|
-
end
|
70
|
-
|
71
|
-
def group(options={}, &block)
|
72
|
-
Builder::Group.new(self, options, &block)
|
73
|
-
end
|
74
|
-
|
75
|
-
def append(item)
|
76
|
-
@current_toolbar << item
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
|
2
|
-
module Redcar
|
3
|
-
class ToolBar
|
4
|
-
class Item
|
5
|
-
class Separator < Item
|
6
|
-
def initialize(options={})
|
7
|
-
super(nil, options)
|
8
|
-
end
|
9
|
-
|
10
|
-
def is_unique?
|
11
|
-
true
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
attr_reader :text, :command, :priority, :value, :type, :icon
|
16
|
-
|
17
|
-
# Create a new Item, with the given text to display in the toolbar, and
|
18
|
-
# either:
|
19
|
-
# the Redcar::Command that is run when the item is selected.
|
20
|
-
# or a block to run when the item is selected
|
21
|
-
def initialize(text, options={}, &block)
|
22
|
-
@text = text
|
23
|
-
|
24
|
-
if options.respond_to?('[]')
|
25
|
-
@command = options[:command] || block
|
26
|
-
@icon = options[:icon]
|
27
|
-
@value = options[:value]
|
28
|
-
@priority = options[:priority]
|
29
|
-
@type = options[:type]
|
30
|
-
@active = options[:active] ? true : false
|
31
|
-
# This branch is for compatibility with old code. Please use :command
|
32
|
-
# option in new code
|
33
|
-
# FIXME: Should this be removed at some point?
|
34
|
-
else
|
35
|
-
@command = options || block
|
36
|
-
end
|
37
|
-
|
38
|
-
@priority ||= ToolBar::DEFAULT_PRIORITY
|
39
|
-
end
|
40
|
-
|
41
|
-
# Call this to signal that the toolbar item has been selected by the user.
|
42
|
-
def selected(with_key=false)
|
43
|
-
if @value
|
44
|
-
@command.new.run(:value => @value)
|
45
|
-
else
|
46
|
-
@command.new.run#(:with_key => with_key)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def type
|
51
|
-
@type
|
52
|
-
end
|
53
|
-
|
54
|
-
def type
|
55
|
-
@type
|
56
|
-
end
|
57
|
-
|
58
|
-
def merge(other)
|
59
|
-
@command = other.command
|
60
|
-
@priority = other.priority
|
61
|
-
end
|
62
|
-
|
63
|
-
def ==(other)
|
64
|
-
text == other.text and command == other.command
|
65
|
-
end
|
66
|
-
|
67
|
-
def is_unique?
|
68
|
-
false
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
|
2
|
-
module Redcar
|
3
|
-
class ToolBar
|
4
|
-
class LazyToolBar < ToolBar
|
5
|
-
|
6
|
-
def initialize(block, text=nil, options={})
|
7
|
-
@text = text
|
8
|
-
@block = block
|
9
|
-
@priority = options[:priority] || ToolBar::DEFAULT_PRIORITY
|
10
|
-
end
|
11
|
-
|
12
|
-
def entries
|
13
|
-
ToolBar::Builder.build(&@block).entries
|
14
|
-
end
|
15
|
-
|
16
|
-
def <<(*_)
|
17
|
-
raise
|
18
|
-
end
|
19
|
-
|
20
|
-
def merge(*_)
|
21
|
-
raise
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
|
2
|
-
module Redcar
|
3
|
-
class ToolBar
|
4
|
-
include Enumerable
|
5
|
-
include Redcar::Model
|
6
|
-
|
7
|
-
# Default priority for all toolbar's and items if they aren't explicitly provided
|
8
|
-
DEFAULT_PRIORITY = 50
|
9
|
-
|
10
|
-
attr_reader :text, :entries, :priority
|
11
|
-
|
12
|
-
# A ToolBar will initially have nothing in it.
|
13
|
-
def initialize(text=nil, options={})
|
14
|
-
@text, @entries, @priority = text || "", [], options[:priority]
|
15
|
-
end
|
16
|
-
|
17
|
-
# Iterate over each entry, sorted by priority
|
18
|
-
def each
|
19
|
-
sorted = {:first => [], :last => []}
|
20
|
-
entries.each {|e| (sorted[e.priority || ToolBar::DEFAULT_PRIORITY] ||= []) << e}
|
21
|
-
|
22
|
-
# Get the nasty Symbols out of the hash so we can sort it
|
23
|
-
first = sorted.delete(:first)
|
24
|
-
last = sorted.delete(:last)
|
25
|
-
|
26
|
-
# Yield up the results
|
27
|
-
first.each {|val| yield val }
|
28
|
-
sorted.keys.sort.each {|i| sorted[i].each {|val| yield val }}
|
29
|
-
last.each {|val| yield val }
|
30
|
-
end
|
31
|
-
|
32
|
-
# Add a Redcar::ToolItem or a Redcar::ToolBar
|
33
|
-
def <<(entry)
|
34
|
-
entries << entry
|
35
|
-
self
|
36
|
-
end
|
37
|
-
|
38
|
-
# Number of entries in the toolbar
|
39
|
-
def length
|
40
|
-
entries.length
|
41
|
-
end
|
42
|
-
|
43
|
-
# Fetch the sub_toolbar with the given name
|
44
|
-
#
|
45
|
-
# @param [String]
|
46
|
-
# @return [ToolBar]
|
47
|
-
def sub_toolbar(text)
|
48
|
-
detect {|e| e.text == text and e.is_a?(ToolBar) }
|
49
|
-
end
|
50
|
-
|
51
|
-
def entry(text)
|
52
|
-
detect {|e| e.text == text }
|
53
|
-
end
|
54
|
-
|
55
|
-
# Append items and sub_toolbars using the same syntax as ToolBar::Builder
|
56
|
-
def build(&block)
|
57
|
-
ToolBar::Builder.new(self, &block)
|
58
|
-
end
|
59
|
-
|
60
|
-
def ==(other)
|
61
|
-
return false unless length == other.length
|
62
|
-
return false unless text == other.text
|
63
|
-
entries.zip(other.entries) do |here, there|
|
64
|
-
return false unless here.class == there.class and here == there
|
65
|
-
end
|
66
|
-
true
|
67
|
-
end
|
68
|
-
|
69
|
-
def is_unique?
|
70
|
-
false
|
71
|
-
end
|
72
|
-
|
73
|
-
# Merge two ToolBar trees together. Modifies this ToolBar.
|
74
|
-
#
|
75
|
-
# @param [ToolBar] another ToolBar
|
76
|
-
def merge(other)
|
77
|
-
@priority = @priority || other.priority
|
78
|
-
other.entries.each do |other_entry|
|
79
|
-
if here = entry(other_entry.text) and not other_entry.is_unique?
|
80
|
-
if here.class == other_entry.class
|
81
|
-
here.merge(other_entry)
|
82
|
-
else
|
83
|
-
entries[entries.index(here)] = other_entry
|
84
|
-
end
|
85
|
-
else
|
86
|
-
self << other_entry
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|