redcar 0.3.5 → 0.3.6
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.
- data/CHANGES +28 -0
- data/README.md +7 -0
- data/ROADMAP.md +11 -1
- data/Rakefile +61 -2
- data/bin/redcar +2 -1
- data/lib/redcar.rb +4 -3
- data/lib/redcar/installer.rb +3 -1
- data/lib/redcar/runner.rb +1 -1
- data/lib/redcar/usage.rb +4 -7
- data/lib/redcar_quick_start.rb +39 -5
- data/plugins/application/features/step_definitions/tree_steps.rb +6 -0
- data/plugins/application/features/support/env.rb +2 -6
- data/plugins/application/icons/redcar_icon_beta_dev.png +0 -0
- data/plugins/application/lib/application/command/executor.rb +8 -0
- data/plugins/application/lib/application/dialog.rb +25 -2
- data/plugins/application/lib/application/notebook.rb +4 -0
- data/plugins/application/lib/application/window.rb +4 -0
- data/plugins/application_swt/lib/application_swt.rb +2 -0
- data/plugins/application_swt/lib/application_swt/dialog_adapter.rb +28 -1
- data/plugins/application_swt/lib/application_swt/menu.rb +4 -0
- data/plugins/application_swt/lib/application_swt/menu/binding_translator.rb +4 -0
- data/plugins/application_swt/lib/application_swt/notebook.rb +22 -1
- data/plugins/application_swt/lib/application_swt/notebook/tab_drag_and_drop_listener.rb +124 -0
- data/plugins/application_swt/lib/application_swt/notebook/tab_transfer.rb +83 -0
- data/plugins/application_swt/lib/application_swt/swt_wrapper.rb +14 -0
- data/plugins/application_swt/lib/application_swt/tab.rb +28 -6
- data/plugins/application_swt/lib/application_swt/window.rb +88 -43
- data/plugins/application_swt/spec/application_swt/menu/binding_translator_spec.rb +11 -0
- data/plugins/application_swt/spec/spec_helper.rb +1 -1
- data/plugins/auto_completer/lib/auto_completer.rb +3 -20
- data/plugins/auto_pairer/lib/auto_pairer/document_controller.rb +1 -1
- data/plugins/declarations/lib/declarations/parser.rb +2 -2
- data/plugins/declarations/spec/spec_helper.rb +1 -0
- data/plugins/edit_view/features/step_definitions/notebook_steps.rb +3 -3
- data/plugins/edit_view/features/step_definitions/window_steps.rb +24 -9
- data/plugins/edit_view/features/support/env.rb +11 -9
- data/plugins/edit_view/lib/edit_view.rb +106 -6
- data/plugins/edit_view/lib/edit_view/info_speedbar.rb +32 -3
- data/plugins/edit_view/lib/edit_view/select_font_dialog.rb +39 -0
- data/plugins/edit_view/lib/edit_view/select_theme_dialog.rb +34 -0
- data/plugins/edit_view/lib/edit_view/tab_settings.rb +103 -8
- data/plugins/edit_view_swt/lib/edit_view_swt.rb +40 -3
- data/plugins/edit_view_swt/lib/edit_view_swt/edit_tab.rb +1 -1
- data/plugins/execute_current_tab/lib/execute_current_tab.rb +15 -6
- data/plugins/project/features/open_directory_tree.feature +10 -0
- data/plugins/project/lib/project.rb +10 -8
- data/plugins/project/lib/project/dir_mirror.rb +6 -5
- data/plugins/project/lib/project/drb_service.rb +16 -0
- data/plugins/project/lib/project/manager.rb +31 -5
- data/plugins/redcar/redcar.rb +115 -19
- data/plugins/tree_view_swt/lib/tree_view_swt.rb +15 -0
- data/textmate/Bundles/Cucumber.tmbundle/Preferences/Cucumber_Plain_Text_Feature_Completions.tmPreferences +3 -3
- data/textmate/Bundles/Cucumber.tmbundle/Preferences/Symbol_list___Scenario.tmPreferences +1 -1
- data/textmate/Bundles/Cucumber.tmbundle/Syntaxes/Cucumber_Plain_Text_Feature.tmLanguage +18 -76
- data/textmate/Bundles/Cucumber.tmbundle/Syntaxes/Cucumber_Steps.tmLanguage +1 -1
- data/textmate/Bundles/Palm-WebOS-Development.tmbundle/Snippets/Animation_animateStyle.tmSnippet +23 -0
- data/textmate/Bundles/Palm-WebOS-Development.tmbundle/Snippets/Event_listen.tmSnippet +16 -0
- data/textmate/Bundles/{Cucumber.tmbundle/Snippets/When_Step_Plaintext.tmSnippet → Palm-WebOS-Development.tmbundle/Snippets/Event_stop.tmSnippet} +5 -5
- data/textmate/Bundles/{Cucumber.tmbundle/Snippets/Then_Step.tmSnippet → Palm-WebOS-Development.tmbundle/Snippets/Event_stopListening.tmSnippet} +5 -9
- data/textmate/Bundles/{Cucumber.tmbundle/Snippets/Cucumber_Multiline_Steps.tmSnippet → Palm-WebOS-Development.tmbundle/Snippets/List_Model.tmSnippet} +10 -7
- data/textmate/Bundles/Palm-WebOS-Development.tmbundle/Snippets/Log_addLoggingMethodsToPrototype.tmSnippet +16 -0
- data/textmate/Bundles/{Cucumber.tmbundle/Snippets/Then_Step_Plaintext.tmSnippet → Palm-WebOS-Development.tmbundle/Snippets/Log_info.tmSnippet} +5 -5
- data/textmate/Bundles/{Cucumber.tmbundle/Snippets/Scenario___heading_only__.tmSnippet → Palm-WebOS-Development.tmbundle/Snippets/Log_logProperties.tmSnippet} +5 -7
- data/textmate/Bundles/{Cucumber.tmbundle/Snippets/When_Step.tmSnippet → Palm-WebOS-Development.tmbundle/Snippets/Model.tmSnippet} +7 -9
- data/textmate/Bundles/Palm-WebOS-Development.tmbundle/Snippets/__L____.tmSnippet +16 -0
- data/textmate/Bundles/Palm-WebOS-Development.tmbundle/Snippets/_insert____.tmSnippet +16 -0
- data/textmate/Bundles/Palm-WebOS-Development.tmbundle/Snippets/_update____.tmSnippet +16 -0
- data/textmate/Bundles/Palm-WebOS-Development.tmbundle/Snippets/controller_get.tmSnippet +16 -0
- data/textmate/Bundles/Palm-WebOS-Development.tmbundle/Snippets/controller_pushScene.tmSnippet +16 -0
- data/textmate/Bundles/Palm-WebOS-Development.tmbundle/Snippets/controller_serviceRequest.tmSnippet +21 -0
- data/textmate/Bundles/{Cucumber.tmbundle/Snippets/Scenario_Outline.tmSnippet → Palm-WebOS-Development.tmbundle/Snippets/controller_setupWidget.tmSnippet} +5 -9
- data/textmate/Bundles/{Cucumber.tmbundle/Snippets/Given_Step.tmSnippet → Palm-WebOS-Development.tmbundle/Snippets/controller_showBanner.tmSnippet} +5 -9
- data/textmate/Bundles/Palm-WebOS-Development.tmbundle/Syntaxes/Mojo.tmLanguage +713 -0
- data/textmate/Bundles/Palm-WebOS-Development.tmbundle/info.plist +188 -0
- data/textmate/Bundles/Smalltalk.tmbundle/Preferences/GNU_Smalltalk.tmPreferences +32 -0
- data/textmate/Bundles/{asciidoc.tmbundle/Preferences/Symbol_List___Heading.tmPreferences → Smalltalk.tmbundle/Preferences/GNU___Symbol_List___Method.tmPreferences} +7 -6
- data/textmate/Bundles/{Cucumber.tmbundle/Preferences/next_Symbol_list___Scenario.tmPreferences → Smalltalk.tmbundle/Preferences/GNU___Symbol_List___Section.tmPreferences} +7 -4
- data/textmate/Bundles/{asciidoc.tmbundle/Snippets/Bold.tmSnippet → Smalltalk.tmbundle/Preferences/MIST_Smalltalk_Format.tmPreferences} +8 -7
- data/textmate/Bundles/Smalltalk.tmbundle/Syntaxes/GNU_Smalltalk.tmLanguage +493 -0
- data/textmate/Bundles/Smalltalk.tmbundle/Syntaxes/GNU_Smalltalk_2.tmLanguage +807 -0
- data/textmate/Bundles/Smalltalk.tmbundle/Syntaxes/MIST_Smalltalk_Format.tmLanguage +645 -0
- data/textmate/Bundles/Smalltalk.tmbundle/info.plist +21 -0
- data/textmate/Themes/Twilight.tmTheme +4 -0
- metadata +2604 -2586
- data/textmate/Bundles/Cucumber.tmbundle/Preferences/next_Cucumber_Plain_Text_Feature_Completions.tmPreferences +0 -30
- data/textmate/Bundles/Cucumber.tmbundle/Syntaxes/next_Cucumber_Plain_Text_Feature.tmLanguage +0 -221
- data/textmate/Bundles/Cucumber.tmbundle/Syntaxes/next_Cucumber_Steps.tmLanguage +0 -424
- data/textmate/Bundles/asciidoc.tmbundle/Preferences/Typing_Pairs___Defaults.tmPreferences +0 -54
- data/textmate/Bundles/asciidoc.tmbundle/Snippets/Anchor.tmSnippet +0 -16
- data/textmate/Bundles/asciidoc.tmbundle/Snippets/Comment_Block.tmSnippet +0 -19
- data/textmate/Bundles/asciidoc.tmbundle/Snippets/Example_Block.tmSnippet +0 -19
- data/textmate/Bundles/asciidoc.tmbundle/Snippets/Italic.tmSnippet +0 -16
- data/textmate/Bundles/asciidoc.tmbundle/Snippets/Listing_Block.tmSnippet +0 -20
- data/textmate/Bundles/asciidoc.tmbundle/Snippets/Literal_Block.tmSnippet +0 -19
- data/textmate/Bundles/asciidoc.tmbundle/Snippets/Passthrough_Block.tmSnippet +0 -19
- data/textmate/Bundles/asciidoc.tmbundle/Snippets/Quote_Block.tmSnippet +0 -19
- data/textmate/Bundles/asciidoc.tmbundle/Snippets/Quoted.tmSnippet +0 -16
- data/textmate/Bundles/asciidoc.tmbundle/Snippets/Sidebar_Block.tmSnippet +0 -19
- data/textmate/Bundles/asciidoc.tmbundle/Snippets/Subscript.tmSnippet +0 -16
- data/textmate/Bundles/asciidoc.tmbundle/Snippets/Superscript.tmSnippet +0 -16
- data/textmate/Bundles/asciidoc.tmbundle/Syntaxes/AsciiDoc.tmLanguage +0 -428
- data/textmate/Bundles/asciidoc.tmbundle/info.plist +0 -91
|
@@ -36,6 +36,10 @@ module Redcar
|
|
|
36
36
|
value += Swt::SWT::PAGE_UP
|
|
37
37
|
elsif key_string =~ /Page Down$/
|
|
38
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
|
|
39
43
|
else
|
|
40
44
|
value += key_string[-1]
|
|
41
45
|
end
|
|
@@ -3,7 +3,7 @@ module Redcar
|
|
|
3
3
|
class Notebook
|
|
4
4
|
include Redcar::Observable
|
|
5
5
|
|
|
6
|
-
attr_reader :tab_folder
|
|
6
|
+
attr_reader :tab_folder, :model
|
|
7
7
|
|
|
8
8
|
class CTabFolder2Listener
|
|
9
9
|
def initialize(controller)
|
|
@@ -60,6 +60,21 @@ module Redcar
|
|
|
60
60
|
grid_data = Swt::Layout::GridData.new(Swt::Layout::GridData::FILL_BOTH)
|
|
61
61
|
@tab_folder.set_layout_data(grid_data)
|
|
62
62
|
@tab_folder.pack
|
|
63
|
+
register_tab_dnd(@tab_folder)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def register_tab_dnd(tab_folder)
|
|
67
|
+
dnd_listener = TabDragAndDropListener.new(self)
|
|
68
|
+
operations = (Swt::DND::DND::DROP_COPY | Swt::DND::DND::DROP_DEFAULT | Swt::DND::DND::DROP_MOVE)
|
|
69
|
+
transfer_types = [TabTransfer.get_instance].to_java(:"org.eclipse.swt.dnd.ByteArrayTransfer")
|
|
70
|
+
|
|
71
|
+
drag_source = Swt::DND::DragSource.new(tab_folder, operations)
|
|
72
|
+
drag_source.set_transfer(transfer_types)
|
|
73
|
+
drag_source.add_drag_listener(dnd_listener)
|
|
74
|
+
|
|
75
|
+
drop_target = Swt::DND::DropTarget.new(tab_folder, operations)
|
|
76
|
+
drop_target.set_transfer(transfer_types)
|
|
77
|
+
drop_target.add_drop_listener(dnd_listener)
|
|
63
78
|
end
|
|
64
79
|
|
|
65
80
|
def style_tab_folder
|
|
@@ -101,6 +116,12 @@ module Redcar
|
|
|
101
116
|
tab_model.deserialize(data)
|
|
102
117
|
end
|
|
103
118
|
|
|
119
|
+
def recalculate_tab_order
|
|
120
|
+
@model.sort_tabs! do |a,b|
|
|
121
|
+
tab_folder.index_of(a.controller.item) <=> tab_folder.index_of(b.controller.item)
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
104
125
|
def dispose
|
|
105
126
|
@tab_folder.dispose
|
|
106
127
|
end
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
module Redcar
|
|
2
|
+
class ApplicationSWT
|
|
3
|
+
class Notebook
|
|
4
|
+
class TabDragAndDropListener
|
|
5
|
+
include org.eclipse.swt.dnd.DragSourceListener
|
|
6
|
+
include org.eclipse.swt.dnd.DropTargetListener
|
|
7
|
+
|
|
8
|
+
# A TabPaintListener allows clients to draw
|
|
9
|
+
# indicators next to a tab in the tab folder
|
|
10
|
+
class TabPaintListener
|
|
11
|
+
include org.eclipse.swt.events.PaintListener
|
|
12
|
+
attr_writer :item, :indicate_front
|
|
13
|
+
|
|
14
|
+
def paintControl(event)
|
|
15
|
+
event.gc.background = ApplicationSWT.display.system_color Swt::SWT::COLOR_DARK_GRAY
|
|
16
|
+
if @item && @item.bounds
|
|
17
|
+
bounds = @item.bounds
|
|
18
|
+
side_length = bounds.height / 3
|
|
19
|
+
offset = (bounds.width unless @indicate_front) || 0
|
|
20
|
+
triangle = [bounds.x + offset, bounds.y + side_length,
|
|
21
|
+
bounds.x + offset + side_length, bounds.y,
|
|
22
|
+
bounds.x + offset - side_length, bounds.y]
|
|
23
|
+
else
|
|
24
|
+
triangle = [0, 0, 10, 10, 0, 20]
|
|
25
|
+
end
|
|
26
|
+
event.gc.fill_polygon(triangle.to_java(:int))
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def initialize(notebook)
|
|
31
|
+
@notebook = notebook
|
|
32
|
+
@paint_listener = TabPaintListener.new
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def tab_folder
|
|
36
|
+
@notebook.tab_folder
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# DragSourceListener interface implementation
|
|
40
|
+
# When a drag starts, the dragged tab is marked
|
|
41
|
+
def dragStart(event)
|
|
42
|
+
if tab_folder.item_count > 0
|
|
43
|
+
@dragged_tab_controller = @notebook.tab_widget_to_tab_model(tab_folder.selection).controller
|
|
44
|
+
@dragged_tab_controller.dragging = true
|
|
45
|
+
else
|
|
46
|
+
event.doit = false
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# DragSourceListener interface implementation
|
|
51
|
+
# When a drag finishes, the dragged tab is unmarked and released
|
|
52
|
+
def dragFinished(event)
|
|
53
|
+
@dragged_tab_controller.dragging = false
|
|
54
|
+
@dragged_tab_controller = @paint_listener.item = nil
|
|
55
|
+
tab_folder.redraw
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# DropTargetListener interface implementation
|
|
59
|
+
# A @link{TabPaintListener} is added to the tab folder when dragging into it
|
|
60
|
+
# to indicate where the drop would happen
|
|
61
|
+
def dragEnter(event)
|
|
62
|
+
tab_folder.add_paint_listener(@paint_listener)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# DropTargetListener interface implementation
|
|
66
|
+
# If a drag leaves the tab folder, remove the @link{TabPaintListener}
|
|
67
|
+
def dragLeave(event)
|
|
68
|
+
tab_folder.remove_paint_listener(@paint_listener)
|
|
69
|
+
tab_folder.redraw
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# DropTargetListener interface implementation
|
|
73
|
+
# While dragging, update the @link{TabPaintListener} to show drop indicators
|
|
74
|
+
def dragOver(event)
|
|
75
|
+
widget = event_to_tab_widget(event)
|
|
76
|
+
@paint_listener.item = widget
|
|
77
|
+
@paint_listener.indicate_front = move_to_front?(widget, event)
|
|
78
|
+
tab_folder.redraw
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# DropTargetListener interface implementation
|
|
82
|
+
# Drop the dragged tab on the notebook at the target position
|
|
83
|
+
def drop(event)
|
|
84
|
+
target_tab_widget = event_to_tab_widget(event)
|
|
85
|
+
unless @dragged_tab_controller && target_tab_widget == @dragged_tab_controller.item
|
|
86
|
+
dragged_tab_model = @dragged_tab_controller.model if @dragged_tab_controller
|
|
87
|
+
dragged_tab_model ||= Redcar.app.all_tabs.detect {|t| t.controller.dragging?}
|
|
88
|
+
@notebook.model.grab_tab_from(dragged_tab_model.notebook, dragged_tab_model)
|
|
89
|
+
move_tab(dragged_tab_model.controller, target_tab_widget, event)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Move the tab controlled by the given controller behind or before the indicated tab
|
|
94
|
+
# @param [Redcar::ApplicationSWT::Tab] the dragged tab's controller
|
|
95
|
+
# @param [SWT::Custom::CTabItem] the item to drop behind
|
|
96
|
+
def move_tab(tab_controller, tab_widget, event)
|
|
97
|
+
position = (tab_folder.index_of(tab_widget) if tab_widget) || 0
|
|
98
|
+
position -= 1 if move_to_front?(tab_widget, event)
|
|
99
|
+
position += 1 if tab_folder.index_of(tab_controller.item) > position
|
|
100
|
+
tab_controller.move_tab_widget_to_position(position)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# Find the CTabItem targeted by a given event
|
|
104
|
+
def event_to_tab_widget(event)
|
|
105
|
+
if tab_folder.item_count > 0
|
|
106
|
+
tab_folder.item(tab_folder.to_control(event.x, event.y)) or
|
|
107
|
+
tab_folder.items[tab_folder.item_count - 1]
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def move_to_front?(widget, event)
|
|
112
|
+
widget && (widget.bounds.width / 2 >
|
|
113
|
+
(tab_folder.to_control(event.x, event.y).x - widget.bounds.x))
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# Unimplemented interface methods
|
|
117
|
+
def dragSetData(event); end
|
|
118
|
+
def dragOperationChanged(event); end
|
|
119
|
+
def dropAccept(event); end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
module Redcar
|
|
2
|
+
class ApplicationSWT
|
|
3
|
+
class Notebook
|
|
4
|
+
class TabTransfer < Swt::DND::ByteArrayTransfer
|
|
5
|
+
|
|
6
|
+
class TabType
|
|
7
|
+
# Empty class for now, until we figure out which
|
|
8
|
+
# information we want to attach to the transfer.
|
|
9
|
+
# This _will_ be needed to DnD tabs between windows
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
TAB_TYPE = "TabType"
|
|
13
|
+
TAB_TYPE_ID = register_type(TAB_TYPE)
|
|
14
|
+
@@instance = nil
|
|
15
|
+
|
|
16
|
+
def self.get_instance
|
|
17
|
+
@@instance || TabTransfer.new
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def javaToNative(types, transfer_data)
|
|
21
|
+
return if (types.nil? || types.empty? || (types.first.class != TabType))
|
|
22
|
+
|
|
23
|
+
begin
|
|
24
|
+
# write data to a byte array and then ask super to convert to
|
|
25
|
+
out = java.io.ByteArrayOutputStream.new
|
|
26
|
+
write_out = java.io.DataOutputStream.new(out)
|
|
27
|
+
types.length.times do |i|
|
|
28
|
+
buffer = TAB_TYPE.to_java_bytes
|
|
29
|
+
write_out.write_int(buffer.length)
|
|
30
|
+
write_out.write(buffer)
|
|
31
|
+
end
|
|
32
|
+
buffer = out.to_byte_array
|
|
33
|
+
write_out.close
|
|
34
|
+
super(buffer, transfer_data)
|
|
35
|
+
rescue java.io.IOException => e
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def nativeToJava(transfer_data)
|
|
40
|
+
if (is_supported_type(transfer_data))
|
|
41
|
+
buffer = super
|
|
42
|
+
return nil unless buffer
|
|
43
|
+
|
|
44
|
+
data = []
|
|
45
|
+
begin
|
|
46
|
+
input = java.io.ByteArrayInputStream.new(buffer)
|
|
47
|
+
read_in = java.io.DataInputStream.new(input)
|
|
48
|
+
while (read_in.available > 20) do
|
|
49
|
+
datum = TabType.new
|
|
50
|
+
int size = read_in.read_int
|
|
51
|
+
name = Java::byte[size].new
|
|
52
|
+
read_in.read(name)
|
|
53
|
+
tab_type_name = String.from_java_bytes(name);
|
|
54
|
+
data << datum
|
|
55
|
+
end
|
|
56
|
+
read_in.close
|
|
57
|
+
rescue java.io.IOException => e
|
|
58
|
+
return null;
|
|
59
|
+
end
|
|
60
|
+
return data.to_java
|
|
61
|
+
end
|
|
62
|
+
return nil
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def get_type_names
|
|
66
|
+
[TAB_TYPE].to_java(:string)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def get_type_ids
|
|
70
|
+
[TAB_TYPE_ID].to_java(:int)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def getTypeIds
|
|
74
|
+
get_type_ids
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def getTypeNames
|
|
78
|
+
get_type_names
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -45,6 +45,7 @@ module Swt
|
|
|
45
45
|
import org.eclipse.swt.widgets.Menu
|
|
46
46
|
import org.eclipse.swt.widgets.MenuItem
|
|
47
47
|
import org.eclipse.swt.widgets.MessageBox
|
|
48
|
+
import org.eclipse.swt.widgets.Sash
|
|
48
49
|
import org.eclipse.swt.widgets.Shell
|
|
49
50
|
import org.eclipse.swt.widgets.TabFolder
|
|
50
51
|
import org.eclipse.swt.widgets.TabItem
|
|
@@ -71,13 +72,26 @@ module Swt
|
|
|
71
72
|
end
|
|
72
73
|
|
|
73
74
|
module DND
|
|
75
|
+
import org.eclipse.swt.dnd.DND
|
|
74
76
|
import org.eclipse.swt.dnd.Clipboard
|
|
75
77
|
import org.eclipse.swt.dnd.Transfer
|
|
76
78
|
import org.eclipse.swt.dnd.TextTransfer
|
|
79
|
+
import org.eclipse.swt.dnd.ByteArrayTransfer
|
|
80
|
+
|
|
81
|
+
import org.eclipse.swt.dnd.DropTarget
|
|
82
|
+
import org.eclipse.swt.dnd.DropTargetEvent
|
|
83
|
+
import org.eclipse.swt.dnd.DropTargetListener
|
|
84
|
+
|
|
85
|
+
import org.eclipse.swt.dnd.DragSource
|
|
86
|
+
import org.eclipse.swt.dnd.DragSourceEvent
|
|
87
|
+
import org.eclipse.swt.dnd.DragSourceListener
|
|
77
88
|
end
|
|
78
89
|
|
|
79
90
|
module Layout
|
|
80
91
|
import org.eclipse.swt.layout.FillLayout
|
|
92
|
+
import org.eclipse.swt.layout.FormAttachment
|
|
93
|
+
import org.eclipse.swt.layout.FormLayout
|
|
94
|
+
import org.eclipse.swt.layout.FormData
|
|
81
95
|
import org.eclipse.swt.layout.GridLayout
|
|
82
96
|
import org.eclipse.swt.layout.GridData
|
|
83
97
|
import org.eclipse.swt.layout.RowLayout
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
module Redcar
|
|
2
2
|
class ApplicationSWT
|
|
3
3
|
class Tab
|
|
4
|
+
|
|
4
5
|
attr_reader :item, :model, :notebook, :widget
|
|
5
6
|
|
|
6
7
|
FILE_ICON = File.join(Redcar.root, %w(plugins application lib application assets file.png))
|
|
7
8
|
|
|
8
|
-
def initialize(model, notebook)
|
|
9
|
+
def initialize(model, notebook, position = nil)
|
|
9
10
|
@model, @notebook = model, notebook
|
|
10
|
-
create_item_widget
|
|
11
|
+
create_item_widget(position || @notebook.tab_folder.item_count)
|
|
11
12
|
create_tab_widget
|
|
12
13
|
attach_listeners
|
|
13
14
|
end
|
|
14
15
|
|
|
15
|
-
def create_item_widget
|
|
16
|
+
def create_item_widget(position = nil)
|
|
17
|
+
position ||= notebook.tab_folder.item_count
|
|
16
18
|
if @item
|
|
17
19
|
@item.dispose
|
|
18
|
-
end
|
|
19
|
-
@item = Swt::Custom::CTabItem.new(notebook.tab_folder, Swt::SWT::CLOSE)
|
|
20
|
+
end
|
|
21
|
+
@item = Swt::Custom::CTabItem.new(notebook.tab_folder, Swt::SWT::CLOSE, position)
|
|
20
22
|
@icon = Swt::Graphics::Image.new(ApplicationSWT.display, FILE_ICON)
|
|
21
23
|
@item.image = @icon
|
|
22
24
|
end
|
|
@@ -27,11 +29,31 @@ module Redcar
|
|
|
27
29
|
@item.control = @widget
|
|
28
30
|
end
|
|
29
31
|
|
|
32
|
+
def dragging?
|
|
33
|
+
@dragging
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def dragging= boolean
|
|
37
|
+
@dragging = boolean
|
|
38
|
+
end
|
|
39
|
+
|
|
30
40
|
def move_tab_widget_to_current_notebook
|
|
31
41
|
@widget.setParent(notebook.tab_folder)
|
|
32
42
|
@item.control = @widget
|
|
33
43
|
end
|
|
34
|
-
|
|
44
|
+
|
|
45
|
+
def move_tab_widget_to_position(position)
|
|
46
|
+
# CTabItem state
|
|
47
|
+
state_variables = [:font, :tool_tip_text, :text]
|
|
48
|
+
view_state = state_variables.collect {|var| @item.send(var)}
|
|
49
|
+
create_item_widget(position)
|
|
50
|
+
state_variables.each_with_index {|var, idx| @item.send(:"#{var}=", view_state[idx])}
|
|
51
|
+
@item.control = @widget
|
|
52
|
+
@item.image = @icon
|
|
53
|
+
@notebook.recalculate_tab_order
|
|
54
|
+
focus
|
|
55
|
+
end
|
|
56
|
+
|
|
35
57
|
def set_notebook(notebook_controller)
|
|
36
58
|
@notebook = notebook_controller
|
|
37
59
|
end
|
|
@@ -2,9 +2,14 @@
|
|
|
2
2
|
module Redcar
|
|
3
3
|
class ApplicationSWT
|
|
4
4
|
class Window
|
|
5
|
-
attr_reader :shell, :window
|
|
5
|
+
attr_reader :shell, :window
|
|
6
|
+
|
|
7
|
+
SASH_WIDTH = 5
|
|
8
|
+
TREEBOOK_WIDTH = 200
|
|
6
9
|
|
|
7
10
|
class ShellListener
|
|
11
|
+
include org.eclipse.swt.events.ShellListener
|
|
12
|
+
|
|
8
13
|
def initialize(controller)
|
|
9
14
|
@win = controller.window
|
|
10
15
|
end
|
|
@@ -38,7 +43,7 @@ module Redcar
|
|
|
38
43
|
create_treebook_controller
|
|
39
44
|
reset_sash_widths
|
|
40
45
|
@treebook_unopened = true
|
|
41
|
-
set_icon
|
|
46
|
+
set_icon
|
|
42
47
|
end
|
|
43
48
|
|
|
44
49
|
def add_listeners
|
|
@@ -116,10 +121,23 @@ module Redcar
|
|
|
116
121
|
old_menu_bar.dispose if old_menu_bar
|
|
117
122
|
end
|
|
118
123
|
|
|
119
|
-
def set_icon
|
|
124
|
+
def set_icon
|
|
125
|
+
path = File.join(icon_dir, icon_file)
|
|
120
126
|
icon = Swt::Graphics::Image.new(ApplicationSWT.display, path)
|
|
121
127
|
shell.image = icon
|
|
122
128
|
end
|
|
129
|
+
|
|
130
|
+
def icon_dir
|
|
131
|
+
File.join(Redcar.root, %w(plugins application icons))
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def icon_file
|
|
135
|
+
if Redcar::VERSION =~ /dev$/
|
|
136
|
+
"redcar_icon_beta_dev.png"
|
|
137
|
+
else
|
|
138
|
+
"redcar_icon_beta.png"
|
|
139
|
+
end
|
|
140
|
+
end
|
|
123
141
|
|
|
124
142
|
def bring_to_front
|
|
125
143
|
@shell.set_minimized(false) # unminimize, just in case
|
|
@@ -189,51 +207,79 @@ module Redcar
|
|
|
189
207
|
|
|
190
208
|
private
|
|
191
209
|
|
|
192
|
-
|
|
193
|
-
TREEBOOK_WIDTH = 20
|
|
210
|
+
attr_reader :right_composite
|
|
194
211
|
|
|
195
212
|
def create_shell
|
|
196
213
|
@shell = Swt::Widgets::Shell.new(ApplicationSWT.display)
|
|
197
|
-
@shell.layout = Swt::Layout::
|
|
198
|
-
|
|
199
|
-
@shell.
|
|
214
|
+
@shell.layout = Swt::Layout::FormLayout.new
|
|
215
|
+
@shell.add_shell_listener(ShellListener.new(self))
|
|
216
|
+
@shell.add_listener Swt::SWT::Resize do |e|
|
|
217
|
+
client_area = @shell.client_area
|
|
218
|
+
if client_area.width < @sash.bounds.x
|
|
219
|
+
@sash.layout_data.left = Swt::Layout::FormAttachment.new(0, client_area.width - SASH_WIDTH)
|
|
220
|
+
end
|
|
221
|
+
end
|
|
200
222
|
ApplicationSWT.register_shell(@shell)
|
|
201
223
|
end
|
|
202
224
|
|
|
203
225
|
def create_sashes(window_model)
|
|
204
226
|
orientation = horizontal_vertical(window_model.notebook_orientation)
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
@
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
227
|
+
|
|
228
|
+
@tree_composite = Swt::Widgets::Composite.new(@shell, Swt::SWT::NONE)
|
|
229
|
+
@tree_layout = Swt::Custom::StackLayout.new
|
|
230
|
+
@tree_composite.setLayout(@tree_layout)
|
|
231
|
+
|
|
232
|
+
@sash = Swt::Widgets::Sash.new(@shell, Swt::SWT::VERTICAL)
|
|
233
|
+
@right_composite = Swt::Widgets::Composite.new(@shell, Swt::SWT::NONE)
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
@tree_composite.layout_data = Swt::Layout::FormData.new.tap do |l|
|
|
237
|
+
l.left = Swt::Layout::FormAttachment.new(0, 5)
|
|
238
|
+
l.right = Swt::Layout::FormAttachment.new(@sash, 0)
|
|
239
|
+
l.top = Swt::Layout::FormAttachment.new(0, 5)
|
|
240
|
+
l.bottom = Swt::Layout::FormAttachment.new(100, -5)
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
@right_composite.layout = Swt::Layout::GridLayout.new(1, false).tap do |l|
|
|
244
|
+
l.verticalSpacing = 0
|
|
245
|
+
l.marginHeight = 0
|
|
246
|
+
l.horizontalSpacing = 0
|
|
247
|
+
l.marginWidth = 0
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
@sash.layout_data = Swt::Layout::FormData.new.tap do |d|
|
|
251
|
+
d.left = Swt::Layout::FormAttachment.new(0, 0)
|
|
252
|
+
d.top = Swt::Layout::FormAttachment.new(0, 0)
|
|
253
|
+
d.bottom = Swt::Layout::FormAttachment.new(100, 0)
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
@sash.add_selection_listener do |e|
|
|
257
|
+
sash_rect = @sash.bounds
|
|
258
|
+
shell_rect = @shell.client_area
|
|
259
|
+
right = shell_rect.width - sash_rect.width - SASH_WIDTH
|
|
260
|
+
e.x = [[e.x, right].min, SASH_WIDTH].max
|
|
261
|
+
if (e.x != sash_rect.x)
|
|
262
|
+
if @window.treebook.trees.any?
|
|
263
|
+
@sash.layout_data.left = Swt::Layout::FormAttachment.new(0, e.x)
|
|
264
|
+
else
|
|
265
|
+
@sash.layout_data.left = Swt::Layout::FormAttachment.new(0, 0)
|
|
266
|
+
end
|
|
267
|
+
@shell.layout
|
|
268
|
+
end
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
@right_composite.layout_data = Swt::Layout::FormData.new.tap do |d|
|
|
272
|
+
d.left = Swt::Layout::FormAttachment.new(@sash, 0)
|
|
273
|
+
d.right = Swt::Layout::FormAttachment.new(100, -5)
|
|
274
|
+
d.top = Swt::Layout::FormAttachment.new(0, 5)
|
|
275
|
+
d.bottom = Swt::Layout::FormAttachment.new(100, -5)
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
@notebook_sash = Swt::Custom::SashForm.new(@right_composite, orientation)
|
|
231
279
|
grid_data = Swt::Layout::GridData.new(Swt::Layout::GridData::FILL_BOTH)
|
|
232
|
-
|
|
233
|
-
|
|
280
|
+
@notebook_sash.layout_data = grid_data
|
|
281
|
+
@notebook_sash.sash_width = SASH_WIDTH
|
|
234
282
|
end
|
|
235
|
-
|
|
236
|
-
attr_reader :right_composite
|
|
237
283
|
|
|
238
284
|
def horizontal_vertical(symbol)
|
|
239
285
|
case symbol
|
|
@@ -245,14 +291,13 @@ module Redcar
|
|
|
245
291
|
end
|
|
246
292
|
|
|
247
293
|
def reset_sash_widths
|
|
294
|
+
@treebook_unopened = !@window.treebook.trees.any?
|
|
248
295
|
if @window.treebook.trees.any?
|
|
249
|
-
@sash.
|
|
250
|
-
@sash.setSashWidth(SASH_WIDTH)
|
|
296
|
+
@sash.layout_data.left = Swt::Layout::FormAttachment.new(0, TREEBOOK_WIDTH + SASH_WIDTH)
|
|
251
297
|
else
|
|
252
|
-
@sash.
|
|
253
|
-
@sash.setSashWidth(0)
|
|
254
|
-
@treebook_unopened = true
|
|
298
|
+
@sash.layout_data.left = Swt::Layout::FormAttachment.new(0, 0)
|
|
255
299
|
end
|
|
300
|
+
@shell.layout
|
|
256
301
|
end
|
|
257
302
|
|
|
258
303
|
def reset_notebook_sash_widths
|