Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVeronika Irvine2001-05-11 14:41:57 +0000
committerVeronika Irvine2001-05-11 14:41:57 +0000
commite8a548ccf0b77e5ae2f0f36f15d62066ef047786 (patch)
tree77b2b35e425a0449135e8ec494a3e692417fb088
parent3275970ab8046022b8d2069b5c21bf117c223db7 (diff)
downloadeclipse.platform.swt-e8a548ccf0b77e5ae2f0f36f15d62066ef047786.tar.gz
eclipse.platform.swt-e8a548ccf0b77e5ae2f0f36f15d62066ef047786.tar.xz
eclipse.platform.swt-e8a548ccf0b77e5ae2f0f36f15d62066ef047786.zip
initializing database with SWT 0.105
-rwxr-xr-xexamples/org.eclipse.swt.examples/.classpath_win327
-rwxr-xr-xexamples/org.eclipse.swt.examples/.cvsignore2
-rwxr-xr-xexamples/org.eclipse.swt.examples/.vcm_meta6
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_addressbook.properties59
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_control.properties169
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_explorer.properties67
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_helloworld.properties1
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_hover.properties3
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_images.properties92
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_javaviewer.properties7
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_texteditor.properties6
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/addressbook/AddressBook.java903
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/addressbook/DataEntryDialog.java152
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/addressbook/FindListener.java8
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/addressbook/SearchDialog.java191
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/AlignableTab.java76
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ButtonTab.java176
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ComboTab.java103
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ControlExample.java97
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/DialogTab.java418
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/Images.java51
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/LabelTab.java153
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ListTab.java72
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ProgressBarTab.java100
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/RangeTab.java155
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/SashTab.java156
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ScrollableTab.java48
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ShellTab.java213
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/SliderTab.java213
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/Tab.java357
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/TableTab.java173
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/TextTab.java97
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ToolBarTab.java262
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/TreeTab.java112
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/folder.gifbin0 -> 906 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/folderOpen.gifbin0 -> 184 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/stop.gifbin0 -> 917 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/Explorer.java1318
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/Images.java107
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/copy.bmpbin0 -> 246 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/copy_mask.bmpbin0 -> 126 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/cut.bmpbin0 -> 246 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/cut_mask.bmpbin0 -> 126 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/delete.bmpbin0 -> 214 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/delete_mask.bmpbin0 -> 126 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/details.bmpbin0 -> 1334 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/details_mask.bmpbin0 -> 126 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/disconnect.bmpbin0 -> 214 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/disconnect_mask.bmpbin0 -> 126 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/drive.bmpbin0 -> 566 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/drive_mask.bmpbin0 -> 126 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/file.bmpbin0 -> 214 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/file_mask.bmpbin0 -> 126 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/folder.bmpbin0 -> 214 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/folder_mask.bmpbin0 -> 126 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/folderopen.bmpbin0 -> 246 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/folderopen_mask.bmpbin0 -> 126 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/largeicons.bmpbin0 -> 1334 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/largeicons_mask.bmpbin0 -> 126 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/list.bmpbin0 -> 1334 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/list_mask.bmpbin0 -> 126 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/mapnetwork.bmpbin0 -> 246 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/mapnetwork_mask.bmpbin0 -> 126 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/oti.icobin0 -> 766 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/paste.bmpbin0 -> 438 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/paste_mask.bmpbin0 -> 126 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/properties.bmpbin0 -> 246 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/properties_mask.bmpbin0 -> 126 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/smallicons.bmpbin0 -> 1334 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/smallicons_mask.bmpbin0 -> 126 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/undo.bmpbin0 -> 246 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/undo_mask.bmpbin0 -> 126 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/up.bmpbin0 -> 214 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/up_mask.bmpbin0 -> 126 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/helloworld/HelloWorld1.java28
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/helloworld/HelloWorld2.java35
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/helloworld/HelloWorld3.java42
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/helloworld/HelloWorld4.java37
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/helloworld/HelloWorld5.java45
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/hover/HoverHelpExample.java137
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/imageexample/ImageAnalyzer.java1801
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/javaviewer/JavaLineStyler.java357
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/javaviewer/JavaViewer.java185
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/ColorTextEditor.java357
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/Images.java47
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/blue.bmpbin0 -> 334 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/blue_mask.bmpbin0 -> 134 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/bold.bmpbin0 -> 134 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/bold_mask.bmpbin0 -> 134 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/erase.bmpbin0 -> 334 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/erase_mask.bmpbin0 -> 134 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/green.bmpbin0 -> 334 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/green_mask.bmpbin0 -> 134 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/red.bmpbin0 -> 334 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/red_mask.bmpbin0 -> 134 bytes
95 files changed, 9201 insertions, 0 deletions
diff --git a/examples/org.eclipse.swt.examples/.classpath_win32 b/examples/org.eclipse.swt.examples/.classpath_win32
new file mode 100755
index 0000000000..eb767008f0
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/.classpath_win32
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="lib" path="J:\teamswt\swt-builddir\jre\lib\rt.jar"/>
+ <classpathentry kind="src" path="\org.eclipse.swt"/>
+ <classpathentry kind="src" path="Eclipse SWT Examples\common"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/examples/org.eclipse.swt.examples/.cvsignore b/examples/org.eclipse.swt.examples/.cvsignore
new file mode 100755
index 0000000000..43e9b71b6f
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/.cvsignore
@@ -0,0 +1,2 @@
+bin
+.classpath \ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples/.vcm_meta b/examples/org.eclipse.swt.examples/.vcm_meta
new file mode 100755
index 0000000000..aae2e1b3ef
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/.vcm_meta
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-description>
+ <nature id="org.eclipse.jdt.core.javanature"/>
+ <builder name="org.eclipse.jdt.core.javabuilder">
+ </builder>
+</project-description>
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_addressbook.properties b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_addressbook.properties
new file mode 100755
index 0000000000..b416bed826
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_addressbook.properties
@@ -0,0 +1,59 @@
+Last_name = Last Name
+First_name = First Name
+Business_phone = Business Phone
+Home_phone = Home Phone
+Email = Email
+Fax = Fax
+Close_save = The address book contents have changed.\nDo you want to save the changes?
+New_title = Untitled
+Column = Column:
+Book_extension = .adr
+Book_filter_name = Address Books
+All_filter_name = All Files
+File = File
+Does_not_exist = does not exist.
+File_not_found = File not found:
+IO_error_read = IO error reading text file:
+IO_error_write = IO error writing text file:
+IO_error_close = IO error closing text file:
+Title_bar = Address Book -
+Save_as_title = Save As
+Query_overwrite = already exists.\nDo you want to replace it?
+File_menu_title = &File
+New_contact = &New Contact\tCtrl+N
+Edit_contact = &Edit Contact\tCtrl+E
+New_address_book = New Address &Book\tCtrl+B
+Open_address_book = &Open Address Book\tCtrl+O
+Save_address_book = &Save Address Book\tCtrl+S
+Save_book_as = Save &Address Book As
+Exit = E&xit
+Edit_menu_title = &Edit
+Edit = &Edit\tCtrl+E
+Copy = &Copy\tCtrl+C
+Paste = &Paste\tCtrl+V
+Delete = De&lete\tDel
+Sort = &Sort
+Search_menu_title = &Search
+Find = &Find...\tCtrl+F
+Find_next = Find &Next...\tF3
+Pop_up_new = &New
+Pop_up_edit = &Edit
+Pop_up_copy = &Copy
+Pop_up_paste = &Paste
+Pop_up_delete = &Delete
+Pop_up_find = &Find...
+Help_menu_title = &Help
+About = &About Address Book...
+About_1 = About
+About_2 = \nversion 1.0
+OK = OK
+Cancel = Cancel
+Search_dialog_title = Find
+Dialog_find_what = Fi&nd what:
+Dialog_match_case = Match &case
+Dialog_match_word = Match &whole word
+Dialog_direction = Direction
+Dialog_dir_up = &Up
+Dialog_dir_down = &Down
+Dialog_find = &Find
+Cannot_find = Cannot find \ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_control.properties b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_control.properties
new file mode 100755
index 0000000000..c3731c71f6
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_control.properties
@@ -0,0 +1,169 @@
+Text_Buttons = Text Buttons
+Size = Size
+Alignment = Alignment
+Left = Left
+Right = Right
+Up = Up
+Down = Down
+Center = Center
+One = One
+Two = Two
+Three = Three
+Image_Buttons = Image Buttons
+Control_Example = Control Example
+Parameters = Parameters
+State = State
+Enabled = Enabled
+Visible = Visible
+Preferred = Preferred
+Styles = Styles
+Text_Labels = Text Labels
+Image_Labels = Image Labels
+One_Two_Three = One Two Three
+Text_ToolBar = Text ToolBar
+Image_ToolBar = Image ToolBar
+Maximum = Maximum
+Minimum = Minimum
+Selection = Selection
+Increment = Increment
+Page_Increment = Page Increment
+Thumb = Thumb
+Tree_With_Images = Tree With Images
+Dialog_Type = Dialog Type
+Create_Dialog = Create Dialog
+Button_Styles = Button Styles
+Icon_Styles = Icon Styles
+Modal_Styles = Modal Styles
+File_Dialog_Styles = File Dialog Styles
+Dialog_Result = Dialog Result
+ColorDialog = ColorDialog
+DirectoryDialog = DirectoryDialog
+FileDialog = FileDialog
+FontDialog = FontDialog
+MessageBox = MessageBox
+Multi_line = A multi line text widget.
+Example_string = The quick brown fox jumped over the lazy dogs.
+Header_Visible = Header Visible
+Lines_Visible = Lines Visible
+Node_1 = Node 1
+Node_2 = Node 2
+Node_3 = Node 3
+Node_4 = Node 4
+Node_1_1 = Node 1.1
+Node_2_1 = Node 2.1
+Node_3_1 = Node 3.1
+Node_2_2 = Node 2.2
+Node_2_2_1 = Node 2.2.1
+Parent = Parent
+No_Parent = No Parent
+Decoration_Styles = Decoration Styles
+Create_Shell = Create Shell
+Close_All_Shells = Close All Shells
+Push = Push
+Radio = Radio
+Check = Check
+Drop_Down = Drop Down
+Images_failed = Warning: Failed to load images
+readme_txt = readme.txt
+Index = Index:
+Title = Title:
+Result = Result:
+FilterName_0 = Text Files
+FilterName_1 = Batch Files
+FilterName_2 = Doc Files
+TableTitle_0 = Name
+TableTitle_1 = Type
+TableTitle_2 = Size
+TableTitle_3 = Modified
+TableLine0_0 = <empty>
+TableLine0_1 = classes
+TableLine0_2 = 0
+TableLine0_3 = today
+TableLine1_0 = <empty>
+TableLine1_1 = databases
+TableLine1_2 = 2556
+TableLine1_3 = <empty>
+TableLine2_0 = <empty>
+TableLine2_1 = images
+TableLine2_2 = 91571
+TableLine2_3 = yesterday
+ListData0_0 = Line 1
+ListData0_1 = Line 2
+ListData0_2 = Line 3
+ListData0_3 = Line 4
+ListData0_4 = Line 5
+ListData0_5 = Line 6
+ListData0_6 = Line 7
+ListData0_7 = Line 8
+ListData0_8 = Longest Line In List
+ListData1_0 = Apples
+ListData1_1 = Oranges
+ListData1_2 = Bananas
+ListData1_3 = Grapefruit
+ListData1_4 = Peaches
+ListData1_5 = Kiwi
+ListData1_6 = Apricots
+ListData1_7 = Strawberries
+ListData1_8 = The Longest String
+Button = Button
+Combo = Combo
+Dialog = Dialog
+Label = Label
+List = List
+ProgressBar = ProgressBar
+Sash = Sash
+Shell = Shell
+Slider_and_Scale = Slider and Scale
+Table = Table
+Text = Text
+ToolBar = ToolBar
+Tree = Tree
+RichText = RichText
+Slider = Slider
+Scale = Scale
+SWT_PUSH = SWT.PUSH
+SWT_CHECK = SWT.CHECK
+SWT_RADIO = SWT.RADIO
+SWT_TOGGLE = SWT.TOGGLE
+SWT_ARROW = SWT.ARROW
+SWT_BORDER = SWT.BORDER
+SWT_DROP_DOWN = SWT.DROP_DOWN
+SWT_READ_ONLY = SWT.READ_ONLY
+SWT_SIMPLE = SWT.SIMPLE
+SWT_SEPARATOR = SWT.SEPARATOR
+SWT_HORIZONTAL = SWT.HORIZONTAL
+SWT_VERTICAL = SWT.VERTICAL
+SWT_SHADOW_IN = SWT.SHADOW_IN
+SWT_SHADOW_OUT = SWT.SHADOW_OUT
+SWT_SINGLE = SWT.SINGLE
+SWT_MULTI = SWT.MULTI
+SWT_H_SCROLL = SWT.H_SCROLL
+SWT_V_SCROLL = SWT.V_SCROLL
+SWT_FLAT = SWT.FLAT
+SWT_WRAP = SWT.WRAP
+SWT_SAVE = SWT.SAVE
+SWT_OPEN = SWT.OPEN
+SWT_PRIMARY_MODAL = SWT.PRIMARY_MODAL
+SWT_APPLICATION_MODAL = SWT.APPLICATION_MODAL
+SWT_SYSTEM_MODAL = SWT.SYSTEM_MODAL
+SWT_MODELESS = SWT.MODELESS
+SWT_ICON_ERROR = SWT.ICON_ERROR
+SWT_ICON_INFORMATION = SWT.ICON_INFORMATION
+SWT_ICON_QUESTION = SWT.ICON_QUESTION
+SWT_ICON_WARNING = SWT.ICON_WARNING
+SWT_ICON_WORKING = SWT.ICON_WORKING
+SWT_OK = SWT.OK
+SWT_CANCEL = SWT.CANCEL
+SWT_YES = SWT.YES
+SWT_NO = SWT.NO
+SWT_RETRY = SWT.RETRY
+SWT_ABORT = SWT.ABORT
+SWT_IGNORE = SWT.IGNORE
+SWT_NO_TRIM = SWT.NO_TRIM
+SWT_CLOSE = SWT.CLOSE
+SWT_TITLE = SWT.TITLE
+SWT_MIN = SWT.MIN
+SWT_MAX = SWT.MAX
+SWT_RESIZE = SWT.RESIZE
+SWT_FULL_SELECTION = SWT.FULL_SELECTION
+SWT_SMOOTH = SWT.SMOOTH \ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_explorer.properties b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_explorer.properties
new file mode 100755
index 0000000000..9a4f11c8ea
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_explorer.properties
@@ -0,0 +1,67 @@
+Large_icons_menuitem = Lar&ge Icons
+Small_icons_menuitem = S&mall Icons
+List_menuitem = &List
+Details_menuitem = &Details
+Undo_menuitem = &Undo\tCtrl+Z
+Cut_menuitem = Cu&t\tCtrl+X
+Copy_menuitem = &Copy\tCtrl+C
+Paste_menuitem = &Paste\tCtrl+V
+New_menuitem = &New
+Shortcut_menuitem = Create &Shortcut
+Delete_menuitem = &Delete
+Rename_menuitem = Rena&me
+Properties_menuitem = &Properties
+Close_menuitem = &Close
+Help_menuitem = &Help Topics
+About_menuitem = &About
+File_menutitle = &File
+Edit_menutitle = &Edit
+View_menutitle = &View
+Tools_menutitle = &Tools
+Help_menutitle = &Help
+Folder = Folder
+Shortcut = Shortcut
+Title = SWT Explorer -
+By_name = by &Name
+By_type = by &Type
+By_size = by &Size
+By_date = by &Date
+Auto_arrange = &Auto Arrange
+All_folders = All Folders
+Name = Name
+Size = Size
+Type = Type
+Modified = Modified
+Popup_view = &View
+Popup_arrange = Arrange &Icons
+Popup_lineup = Lin&e up Icons
+Popup_paste = &Paste
+Popup_shortcut = Paste &Shortcut
+Popup_new = Ne&w
+Popup_properties = P&roperites
+Find_menuitem = &Find
+File_find = &Files or Folders...
+Computer_find = &Computer
+Internet_find = On the &Internet
+Autoarrange_menuitem = &Auto Arrange
+Mapdrive_menuitem = &Map Network Drive
+Disconnect_menuitem = &Disconnect Network Drive
+Goto_menuitem = &Go to...
+Toolbar_menuitem = &Toolbar
+Statusbar_menuitem = &Status Bar
+Refresh_menuitem = &Refresh
+Options_menuitem = &Options...
+Unavailable = is not accessible.\n\nThe device is not ready. Retry?
+Content_of = Content of
+Filesize_1 = bytes (Disk free space:
+Filesize_2 = MB)
+Objects = object(s)
+File_folder = File Folder
+KB = KB
+System_file = System File
+Arrange_menuitem = Arrange &Icons
+Lineup_menuitem = Lin&e up Icons
+Refresh_menuitem = &Refresh
+Options_menuitem = &Options...
+Failed_launch= Could not launch
+
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_helloworld.properties b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_helloworld.properties
new file mode 100755
index 0000000000..2db6671c37
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_helloworld.properties
@@ -0,0 +1 @@
+Hello_world = Hello World \ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_hover.properties b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_hover.properties
new file mode 100755
index 0000000000..466b950c70
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_hover.properties
@@ -0,0 +1,3 @@
+F1_help_for = F1 Help for
+Item = Item
+Hello = Hello
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_images.properties b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_images.properties
new file mode 100755
index 0000000000..6072599352
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_images.properties
@@ -0,0 +1,92 @@
+Image_analyzer = Image Analyzer
+None = None
+White = White
+Black = Black
+Red = Red
+Green = Green
+Blue = Blue
+X_scale = X Scale
+Y_scale = Y Scale
+Alpha_K = Alpha-K
+Display = Display
+Incremental = Incremental
+Transparent = Transparent
+Transparent_lc = transparent
+Mask = Mask
+Background = Background
+Animation = Animation
+Previous = < &Previous
+Next = &Next >
+Animate = &Animate
+Type_initial = Type:
+Type_string = Type: {0}
+Type_index = Type: {0} [{1,number,integer} of {2,number,integer}]
+Size_initial = Size:
+Size_value = Size: {0,number,integer} x {1,number,integer}
+Depth_initial = Depth:
+Depth_value = Depth: {0}
+Transparent_pixel_initial = Transparent pixel:
+Transparent_pixel_value = Transparent pixel: {0}
+Animation_size_initial = Animation size:
+Animation_size_value = Animation size: {0,number,integer} x {1,number,integer}
+Background_pixel_initial = Background pixel:
+Background_pixel_value = Background pixel: {0}
+Image_location_initial = Image location:
+Image_location_value = Image location: ({0,number,integer}, {1,number,integer})
+Disposal_initial = Disposal:
+Disposal_value = Disposal: {0,number,integer} ({1})
+Delay_initial = Delay:
+Delay_value = Delay: {0,number,integer} ms (using {1,number,integer} ms)
+Delay_used = Delay: {0,number,integer} ms
+Repeats_initial = Repeats:
+Repeats_value = Repeats: {0,number,integer}
+Repeats_forever = Repeats: {0,number,integer} (forever)
+Palette_initial = Palette:
+Palette_direct = Palette: Direct
+Palette_value = Palette size: {0,number,integer}
+Pixel_data_initial = Pixel data:
+Pixel_data_value = Pixel data: Bytes per line: {0,number,integer} \
+ Scanline pad: {1,number,integer} {2}
+File = &File
+Open = &Open...\tCtrl+O
+Reopen = &Reopen
+Save = &Save\tCtrl+S
+Save_as = Save &As...
+Save_mask_as = Save &Mask As...
+Exit = E&xit
+Alpha = Alpha
+All_images = All Image Files
+Loading_lc = loading
+Saving_lc = saving
+Unknown_extension = Unknown file extension: {0}\nPlease use bmp, gif, ico, \
+ jpg, jpeg, or png.
+Overwrite = Overwrite {0}?
+Analyzer_on = Image Analyzer on: {0}
+Reloading_lc = reloading
+Color_at = Image color at ({0,number,integer}, {1,number,integer}) \
+ index {2,number,integer} (0x{3}) is {4}
+Color_at_trans = Image color at ({0,number,integer}, {1,number,integer}) \
+ index {2,number,integer} (0x{3}) is {4} (transparent)
+Creating_image = Creating image # {0,number,integer} from
+Stop = &Stop
+Creating_from = Creating image read from
+Palette_direct = Palette: Direct
+Palette_size = Palette size: {0,number,integer}
+Bytes_per_line = Bytes per line:
+Scanline_pad = Scanline pad:
+Error = Error {0} file\n{1}\n\n
+Pixels_per_byte = pixels per byte
+Byte_per_pixel = byte per pixel
+Bytes_per_pixel = bytes per pixel
+Unsupported_lc = unsupported
+None_lc = none
+Background_lc = background
+Previous_lc = previous
+Unspecified_lc = unspecified
+Unknown_ac = UNKNOWN
+Forever_lc = forever
+Depth_info = Depth: {0,number,integer} -- {1}
+One_byte = 1 byte per pixel
+Multi_bytes = {0,number,integer} bytes per pixel
+Multi_pixels = {0,number,integer} pixels per byte {1}
+Max_length_string = Transparent pixel: -1 (none) \ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_javaviewer.properties b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_javaviewer.properties
new file mode 100755
index 0000000000..8c589d1470
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_javaviewer.properties
@@ -0,0 +1,7 @@
+Open_menuitem=&Open
+Close_menuitem=&Close
+File_menuitem=&File
+Window_title=SWT Java Viewer
+Err_file_no_exist=File {0} does not exist.
+Err_file_io=IO error reading file:\n{0}
+Err_file_not_found=File not found:\n{0} \ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_texteditor.properties b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_texteditor.properties
new file mode 100755
index 0000000000..64d240800b
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/examples_texteditor.properties
@@ -0,0 +1,6 @@
+Cut_menuitem=Cu&t\tCtrl+X
+Copy_menuitem=&Copy\tCtrl+C
+Paste_menuitem=&Paste\tCtrl+V
+Window_title=SWT Color Editor
+Font_menuitem=Set &Font...
+Edit_menuitem=&Edit \ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/addressbook/AddressBook.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/addressbook/AddressBook.java
new file mode 100755
index 0000000000..fc29445dbc
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/addressbook/AddressBook.java
@@ -0,0 +1,903 @@
+package org.eclipse.swt.examples.addressbook;
+
+/* Imports */
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+import java.io.*;
+import java.util.zip.*;
+import java.util.ResourceBundle;
+
+/**
+ * AddressBookExample is an example that uses <code>org.eclipse.swt</code>
+ * libraries to implement a simple address book. This application has
+ * save, load, sorting, and searching functions common
+ * to basic address books.
+ */
+public class AddressBook {
+
+ private static ResourceBundle resAddressBook = ResourceBundle.getBundle("examples_addressbook");
+
+ private Shell shell;
+ private Table table;
+ private SearchDialog searchDialog;
+
+ private File file;
+ private boolean isModified;
+
+ private String[] copyBuffer;
+
+ private static final String DELIMITER = ",";
+ private static final String[] columnNames = {resAddressBook.getString("Last_name"),
+ resAddressBook.getString("First_name"),
+ resAddressBook.getString("Business_phone"),
+ resAddressBook.getString("Home_phone"),
+ resAddressBook.getString("Email"),
+ resAddressBook.getString("Fax")};
+
+public static void main(String[] args) {
+ AddressBook application = new AddressBook();
+ application.open();
+ application.run();
+}
+private boolean closeAddressBook() {
+ if(isModified) {
+ //ask user if they want to save current address book
+ MessageBox box = new MessageBox(shell, SWT.ICON_WARNING | SWT.YES | SWT.NO | SWT.CANCEL);
+ box.setText(shell.getText());
+ box.setMessage(resAddressBook.getString("Close_save"));
+
+ int choice = box.open();
+ if(choice == SWT.CANCEL) {
+ return false;
+ } else if(choice == SWT.YES) {
+ if (!save()) return false;
+ }
+ }
+
+ TableItem[] items = table.getItems();
+ for (int i = 0; i < items.length; i ++) {
+ items[i].dispose();
+ }
+
+ return true;
+}
+/**
+ * Creates the menu at the top of the shell where most
+ * of the programs functionality is accessed.
+ *
+ * @return The <code>Menu</code> widget that was created
+ */
+private Menu createMenuBar() {
+ Menu menuBar = new Menu(shell, SWT.BAR);
+ shell.setMenuBar(menuBar);
+
+ //create each header and subMenu for the menuBar
+ createFileMenu(menuBar);
+ createEditMenu(menuBar);
+ createSearchMenu(menuBar);
+ createHelpMenu(menuBar);
+
+ return menuBar;
+}
+
+/**
+ * Converts an encoded <code>String</code> to a String array representing a table entry.
+ */
+private String[] decodeLine(String line) {
+ if(line == null) return null;
+
+ String[] parsedLine = new String[table.getColumnCount()];
+ for(int i = 0; i < parsedLine.length - 1; i++) {
+ String newString = "";
+ int index = line.indexOf(DELIMITER);
+ if (index > -1) {
+ parsedLine[i] = line.substring(0, index);
+ line = line.substring(index + DELIMITER.length(), line.length());
+ } else {
+ return null;
+ }
+ }
+
+ if (line.indexOf(DELIMITER) != -1) return null;
+
+ parsedLine[parsedLine.length - 1] = line;
+
+ return parsedLine;
+}
+private void displayError(String msg) {
+ MessageBox box = new MessageBox(shell, SWT.ICON_ERROR);
+ box.setMessage(msg);
+ box.open();
+}
+private void editEntry(TableItem item) {
+ DataEntryDialog dialog = new DataEntryDialog(shell);
+ dialog.setLabels(columnNames);
+ String[] values = new String[table.getColumnCount()];
+ for (int i = 0; i < values.length; i++) {
+ values[i] = item.getText(i);
+ }
+ dialog.setValues(values);
+ values = dialog.open();
+ if (values != null) {
+ item.setText(values);
+ isModified = true;
+ }
+}
+private String encodeLine(String[] tableItems) {
+ String line = "";
+ for (int i = 0; i < tableItems.length - 1; i++) {
+ line += tableItems[i] + DELIMITER;
+ }
+ line += tableItems[tableItems.length - 1] + "\n";
+
+ return line;
+}
+private boolean findEntry() {
+ Cursor waitCursor = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
+ shell.setCursor(waitCursor);
+
+ boolean matchCase = searchDialog.getMatchCase();
+ boolean matchWord = searchDialog.getMatchWord();
+ String searchString = searchDialog.getSearchString();
+ int column = searchDialog.getSelectedSearchArea();
+
+ searchString = matchCase ? searchString : searchString.toLowerCase();
+
+ boolean found = false;
+ if (searchDialog.getSearchDown()) {
+ for(int i = table.getSelectionIndex() + 1; i < table.getItemCount(); i++) {
+ if (found = findMatch(searchString, table.getItem(i), column, matchWord, matchCase)){
+ table.setSelection(i);
+ break;
+ }
+ }
+ } else {
+ for(int i = table.getSelectionIndex() - 1; i > -1; i--) {
+ if (found = findMatch(searchString, table.getItem(i), column, matchWord, matchCase)){
+ table.setSelection(i);
+ break;
+ }
+ }
+ }
+
+ shell.setCursor(null);
+ if (waitCursor != null)
+ waitCursor.dispose();
+
+ return found;
+}
+private boolean findMatch(String searchString, TableItem item, int column, boolean matchWord, boolean matchCase) {
+
+ String tableText = matchCase ? item.getText(column) : item.getText(column).toLowerCase();
+ if (matchWord) {
+ if (tableText != null && tableText.equals(searchString)) {
+ return true;
+ }
+
+ } else {
+ if(tableText!= null && tableText.indexOf(searchString) != -1) {
+ return true;
+ }
+ }
+ return false;
+}
+/**
+ * Merges two arrays (assumed to be individually sorted) of string arrays into
+ * one sorted array by the value stored at the columnIndex parameter. This method
+ * is used in <code>mergeSort(String[][] tableItems, int columnIndex)</code>.
+ *
+ * @param firstHalf String[][]
+ * The first array of Strings to be merged.
+ * @param secondHalf String[][]
+ * The second array of Strings to be merged.
+ * @param columnIndex int
+ * The column by which the String arrays will be compared.
+ * @return String[][]
+ * An array of array of String that is the merged (and sorted) combination
+ * of the two parameter arrays.
+ */
+private String[][] merge(String[][] firstHalf, String[][] secondHalf, int column) {
+ int x = firstHalf.length + secondHalf.length;
+ int y = Math.max(firstHalf[0].length, secondHalf[0].length);
+ String[][] sorted = new String[x][y];
+
+ int firstHalfIndex = 0;
+ int secondHalfIndex = 0;
+ int sortedIndex = 0;
+
+ //merge
+ while(firstHalfIndex < firstHalf.length && secondHalfIndex < secondHalf.length) {
+ if(firstHalf[firstHalfIndex][column].compareToIgnoreCase(secondHalf[secondHalfIndex][column]) <= 0 ) {
+ sorted[sortedIndex] = firstHalf[firstHalfIndex];
+ sortedIndex++;
+ firstHalfIndex++;
+ } else {
+ sorted[sortedIndex] = secondHalf[secondHalfIndex];
+ sortedIndex++;
+ secondHalfIndex++;
+ }
+ }
+
+ //copy remaining items into sorted.
+ while(firstHalfIndex < firstHalf.length) {
+ sorted[sortedIndex] = firstHalf[firstHalfIndex];
+ sortedIndex++;
+ firstHalfIndex++;
+ }
+
+ while(secondHalfIndex < secondHalf.length) {
+ sorted[sortedIndex] = secondHalf[secondHalfIndex];
+ sortedIndex++;
+ secondHalfIndex++;
+ }
+
+ return sorted;
+}
+/**
+ * Takes an array of array of Strings and sorts them into ascending order according to the
+ * data in the column specified. Note that this sort is recursive.
+ *
+ * @param tableItems String[][]
+ * The array of Strings that will be sorted.
+ * @param columnIndex int
+ * The column in the String arrays by which the arrays will be compared.
+ * @return String[][]
+ * The resultant sorted version of the tableItems parameter.
+ * @see #merge(String[][] firstHalf, String[][] secondHalf, int columnIndex)
+ */
+private String[][] mergeSort(String[][] items, int column) {
+ int numItems = items.length;
+
+ if(numItems <= 1) return items;
+
+ int split = numItems / 2;
+ String[][] firstHalf = new String[split][items[0].length];
+ String[][] secondHalf = new String[numItems - split][items[0].length];
+ for(int i = 0; i < firstHalf.length; i++) {
+ firstHalf[i] = items[i];
+ }
+ for(int i = 0; i < secondHalf.length; i++) {
+ secondHalf[i] = items[split + i];
+ }
+
+ String[][] firstHalfSorted = mergeSort(firstHalf, column);
+ String[][] secondHalfSorted = mergeSort(secondHalf, column);
+ String[][] sortedItems = merge(firstHalfSorted, secondHalfSorted, column);
+
+ return sortedItems;
+}
+private void newAddressBook() {
+ shell.setText(resAddressBook.getString("Title_bar") + resAddressBook.getString("New_title"));
+ isModified = false;
+}
+private void newEntry() {
+ DataEntryDialog dialog = new DataEntryDialog(shell);
+ dialog.setLabels(columnNames);
+ String[] data = dialog.open();
+ if (data != null) {
+ TableItem item = new TableItem(table, SWT.NONE);
+ item.setText(data);
+ isModified = true;
+ }
+}
+private void open() {
+ Display display = new Display();
+ shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ shell.addShellListener(new ShellAdapter(){
+ public void shellClosed(ShellEvent e) {
+ e.doit = closeAddressBook();
+ }
+ });
+
+ createMenuBar();
+
+ searchDialog = new SearchDialog(shell);
+ searchDialog.setSearchAreaNames(columnNames);
+ searchDialog.setSearchAreaLabel(resAddressBook.getString("Column"));
+ searchDialog.addFindListener(new FindListener () {
+ public boolean find() {
+ return findEntry();
+ }
+ });
+
+ table = new Table(shell, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
+ table.setHeaderVisible(true);
+ table.setMenu(createPopUpMenu());
+ table.addSelectionListener(new SelectionAdapter() {
+ public void widgetDoubleSelected(SelectionEvent e) {
+ TableItem[] items = table.getSelection();
+ if (items.length > 0) editEntry(items[0]);
+ }
+ });
+ for(int i = 0; i < columnNames.length; i++) {
+ TableColumn column = new TableColumn(table, SWT.NONE);
+ column.setText(columnNames[i]);
+ column.setWidth(150);
+ final int columnIndex = i;
+ column.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ sort(columnIndex);
+ }
+ });
+ }
+
+ newAddressBook();
+
+ shell.setSize(table.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, 300);
+ shell.open();
+}
+private void openAddressBook() {
+ FileDialog fileDialog = new FileDialog(shell, SWT.OPEN);
+
+ fileDialog.setFilterExtensions(new String[] {"*.adr;", "*.*"});
+ fileDialog.setFilterNames(new String[] {resAddressBook.getString("Book_filter_name") + " (*.adr)",
+ resAddressBook.getString("All_filter_name") + " (*.*)"});
+ fileDialog.open();
+ String name = fileDialog.getFileName();
+
+ if(name == null) return;
+
+ File file = new File(fileDialog.getFilterPath(), name);
+ if (!file.exists()) {
+ displayError(resAddressBook.getString("File")+file.getName()+" "+resAddressBook.getString("Does_not_exist"));
+ return;
+ }
+
+ Cursor waitCursor = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
+ shell.setCursor(waitCursor);
+
+ FileReader fileReader = null;
+ BufferedReader bufferedReader = null;
+ String[] data = new String[0];
+ try {
+ fileReader = new FileReader(file.getAbsolutePath());
+ bufferedReader = new BufferedReader(fileReader);
+ String nextLine = bufferedReader.readLine();
+ while (nextLine != null){
+ String[] newData = new String[data.length + 1];
+ System.arraycopy(data, 0, newData, 0, data.length);
+ newData[data.length] = nextLine;
+ data = newData;
+ nextLine = bufferedReader.readLine();
+ }
+ } catch(FileNotFoundException e) {
+ displayError(resAddressBook.getString("File_not_found") + "\n" + file.getName());
+ return;
+ } catch (IOException e ) {
+ displayError(resAddressBook.getString("IO_error_read") + "\n" + file.getName());
+ return;
+ } finally {
+
+ shell.setCursor(null);
+ waitCursor.dispose();
+
+ if(fileReader != null) {
+ try {
+ fileReader.close();
+ } catch(IOException e) {
+ displayError(resAddressBook.getString("IO_error_close") + "\n" + file.getName());
+ return;
+ }
+ }
+ }
+
+ String[][] tableInfo = new String[data.length][table.getColumnCount()];
+ for (int i = 0; i < data.length; i++) {
+ tableInfo[i] = decodeLine(data[i]);
+ }
+ tableInfo = mergeSort(tableInfo, 0);
+ for (int i = 0; i < tableInfo.length; i++) {
+ TableItem item = new TableItem(table, SWT.NONE);
+ item.setText(tableInfo[i]);
+ }
+ shell.setText(resAddressBook.getString("Title_bar")+fileDialog.getFileName());
+ isModified = false;
+ this.file = file;
+}
+private void run() {
+ //read and dispatch until termination
+ Display display = shell.getDisplay();
+ while(!shell.isDisposed()){
+ if(!display.readAndDispatch())
+ display.sleep();
+ }
+}
+private boolean save() {
+ if(file == null) return saveAs();
+
+ Cursor waitCursor = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
+ shell.setCursor(waitCursor);
+
+ TableItem[] items = table.getItems();
+ String[] lines = new String[items.length];
+ for(int i = 0; i < items.length; i++) {
+ String[] itemText = new String[table.getColumnCount()];
+ for (int j = 0; j < itemText.length; j++) {
+ itemText[j] = items[i].getText(j);
+ }
+ lines[i] = encodeLine(itemText);
+ }
+
+ FileWriter fileWriter = null;
+ try {
+ fileWriter = new FileWriter(file.getAbsolutePath(), false);
+ for (int i = 0; i < lines.length; i++) {
+ fileWriter.write(lines[i]);
+ }
+ } catch(FileNotFoundException e) {
+ displayError(resAddressBook.getString("File_not_found") + "\n" + file.getName());
+ return false;
+ } catch(IOException e ) {
+ displayError(resAddressBook.getString("IO_error_write") + "\n" + file.getName());
+ return false;
+ } finally {
+ shell.setCursor(null);
+ waitCursor.dispose();
+
+ if(fileWriter != null) {
+ try {
+ fileWriter.close();
+ } catch(IOException e) {
+ displayError(resAddressBook.getString("IO_error_close") + "\n" + file.getName());
+ return false;
+ }
+ }
+ }
+
+ shell.setText(resAddressBook.getString("Title_bar")+file.getName());
+ isModified = false;
+ return true;
+}
+private boolean saveAs() {
+
+ FileDialog saveDialog = new FileDialog(shell, SWT.SAVE);
+ saveDialog.setFilterExtensions(new String[] {"*.adr;", "*.*"});
+ saveDialog.setFilterNames(new String[] {"Address Books (*.adr)", "All Files "});
+
+ saveDialog.open();
+ String name = saveDialog.getFileName();
+
+ if(name.equals("")) return false;
+
+ if(name.indexOf(".adr") != name.length() - 4) {
+ name += ".adr";
+ }
+
+ File file = new File(saveDialog.getFilterPath(), name);
+ if(file.exists()) {
+ MessageBox box = new MessageBox(shell, SWT.ICON_WARNING | SWT.YES | SWT.NO);
+ box.setText(resAddressBook.getString("Save_as_title"));
+ box.setMessage(resAddressBook.getString("File") + file.getName()+" "+resAddressBook.getString("Query_overwrite"));
+ if(box.open() != SWT.YES) {
+ return false;
+ }
+ }
+ this.file = file;
+ return save();
+}
+private void sort(int column) {
+ if(table.getItemCount() <= 1) return;
+
+ TableItem[] items = table.getItems();
+ String[][] data = new String[items.length][table.getColumnCount()];
+ for(int i = 0; i < items.length; i++) {
+ for(int j = 0; j < table.getColumnCount(); j++) {
+ data[i][j] = items[i].getText(j);
+ }
+ }
+
+ data = mergeSort(data, column);
+
+ for (int i = 0; i < data.length; i++) {
+ items[i].setText(data[i]);
+ }
+
+}
+/**
+ * Creates all the items located in the File submenu and
+ * associate all the menu items with their appropriate
+ * functions.
+ *
+ * @param menuBar Menu
+ * the <code>Menu</code> that file contain
+ * the File submenu.
+ */
+private void createFileMenu(Menu menuBar) {
+ //File menu.
+ MenuItem item = new MenuItem(menuBar, SWT.CASCADE);
+ item.setText(resAddressBook.getString("File_menu_title"));
+ Menu menu = new Menu(shell, SWT.DROP_DOWN);
+ item.setMenu(menu);
+ /**
+ * Adds a listener to handle enabling and disabling
+ * some items in the Edit submenu.
+ */
+ menu.addMenuListener(new MenuAdapter() {
+ public void menuShown(MenuEvent e) {
+ Menu menu = (Menu)e.widget;
+ MenuItem[] items = menu.getItems();
+ items[1].setEnabled(table.getSelectionCount() != 0); // edit contact
+ items[5].setEnabled((file != null) && isModified); // save
+ items[6].setEnabled(table.getItemCount() != 0); // save as
+ }
+ });
+
+
+ //File -> New Contact
+ MenuItem subItem = new MenuItem(menu, SWT.NULL);
+ subItem.setText(resAddressBook.getString("New_contact"));
+ subItem.setAccelerator(SWT.CTRL + 'N');
+ subItem.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ newEntry();
+ }
+ });
+ subItem = new MenuItem(menu, SWT.NULL);
+ subItem.setText(resAddressBook.getString("Edit_contact"));
+ subItem.setAccelerator(SWT.CTRL + 'E');
+ subItem.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ TableItem[] items = table.getSelection();
+ if (items.length == 0) return;
+ editEntry(items[0]);
+ }
+ });
+
+
+ new MenuItem(menu, SWT.SEPARATOR);
+
+ //File -> New Address Book
+ subItem = new MenuItem(menu, SWT.NULL);
+ subItem.setText(resAddressBook.getString("New_address_book"));
+ subItem.setAccelerator(SWT.CTRL + 'B');
+ subItem.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ closeAddressBook();
+ newAddressBook();
+ }
+ });
+
+ //File -> Open
+ subItem = new MenuItem(menu, SWT.NULL);
+ subItem.setText(resAddressBook.getString("Open_address_book"));
+ subItem.setAccelerator(SWT.CTRL + 'O');
+ subItem.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ closeAddressBook();
+ openAddressBook();
+ }
+ });
+
+ //File -> Save.
+ subItem = new MenuItem(menu, SWT.NULL);
+ subItem.setText(resAddressBook.getString("Save_address_book"));
+ subItem.setAccelerator(SWT.CTRL + 'S');
+ subItem.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ save();
+ }
+ });
+
+ //File -> Save As.
+ subItem = new MenuItem(menu, SWT.NULL);
+ subItem.setText(resAddressBook.getString("Save_book_as"));
+ subItem.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ saveAs();
+ }
+ });
+
+
+ new MenuItem(menu, SWT.SEPARATOR);
+
+ //File -> Exit.
+ subItem = new MenuItem(menu, SWT.NULL);
+ subItem.setText(resAddressBook.getString("Exit"));
+ subItem.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ shell.close();
+ }
+ });
+}
+
+/**
+ * Creates all the items located in the Edit submenu and
+ * associate all the menu items with their appropriate
+ * functions.
+ *
+ * @param menuBar Menu
+ * the <code>Menu</code> that file contain
+ * the Edit submenu.
+ *
+ * @see #createSortMenu()
+ */
+private MenuItem createEditMenu(Menu menuBar) {
+ //Edit menu.
+ MenuItem item = new MenuItem(menuBar, SWT.CASCADE);
+ item.setText(resAddressBook.getString("Edit_menu_title"));
+ Menu menu = new Menu(shell, SWT.DROP_DOWN);
+ item.setMenu(menu);
+
+ /**
+ * Add a listener to handle enabling and disabling
+ * some items in the Edit submenu.
+ */
+ menu.addMenuListener(new MenuAdapter() {
+ public void menuShown(MenuEvent e) {
+ Menu menu = (Menu)e.widget;
+ MenuItem[] items = menu.getItems();
+ int count = table.getSelectionCount();
+ items[0].setEnabled(count != 0); // edit
+ items[1].setEnabled(count != 0); // copy
+ items[2].setEnabled(copyBuffer != null); // paste
+ items[3].setEnabled(count != 0); // delete
+ items[5].setEnabled(table.getItemCount() != 0); // sort
+ }
+ });
+
+ //Edit -> Edit
+ MenuItem subItem = new MenuItem(menu, SWT.CASCADE);
+ subItem.setText(resAddressBook.getString("Edit"));
+ subItem.setAccelerator(SWT.CTRL + 'E');
+ subItem.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ TableItem[] items = table.getSelection();
+ if (items.length == 0) return;
+ editEntry(items[0]);
+ }
+ });
+
+ //Edit -> Copy
+ subItem = new MenuItem(menu, SWT.NULL);
+ subItem.setText(resAddressBook.getString("Copy"));
+ subItem.setAccelerator(SWT.CTRL + 'C');
+ subItem.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ TableItem[] items = table.getSelection();
+ if (items.length == 0) return;
+ copyBuffer = new String[table.getColumnCount()];
+ for (int i = 0; i < copyBuffer.length; i++) {
+ copyBuffer[i] = items[0].getText(i);
+ }
+ }
+ });
+
+ //Edit -> Paste
+ subItem = new MenuItem(menu, SWT.NULL);
+ subItem.setText(resAddressBook.getString("Paste"));
+ subItem.setAccelerator(SWT.CTRL + 'V');
+ subItem.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ if (copyBuffer == null) return;
+ TableItem item = new TableItem(table, SWT.NONE);
+ item.setText(copyBuffer);
+ isModified = true;
+ }
+ });
+
+ //Edit -> Delete
+ subItem = new MenuItem(menu, SWT.NULL);
+ subItem.setText(resAddressBook.getString("Delete"));
+ subItem.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ TableItem[] items = table.getSelection();
+ if (items.length == 0) return;
+ items[0].dispose();
+ isModified = true; }
+ });
+
+ new MenuItem(menu, SWT.SEPARATOR);
+
+ //Edit -> Sort(Cascade)
+ subItem = new MenuItem(menu, SWT.CASCADE);
+ subItem.setText(resAddressBook.getString("Sort"));
+ Menu submenu = createSortMenu();
+ subItem.setMenu(submenu);
+
+ return item;
+
+}
+
+/**
+ * Creates all the items located in the Sort cascading submenu and
+ * associate all the menu items with their appropriate
+ * functions.
+ *
+ * @return Menu
+ * The cascading menu with all the sort menu items on it.
+ */
+private Menu createSortMenu() {
+ Menu submenu = new Menu(shell, SWT.DROP_DOWN);
+ MenuItem subitem;
+ for(int i = 0; i < columnNames.length; i++) {
+ subitem = new MenuItem (submenu, SWT.NULL);
+ subitem.setText(columnNames [i]);
+ final int column = i;
+ subitem.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ sort(column);
+ }
+ });
+
+ }
+
+ return submenu;
+}
+
+/**
+ * Creates all the items located in the Search submenu and
+ * associate all the menu items with their appropriate
+ * functions.
+ *
+ * @param menuBar Menu
+ * the <code>Menu</code> that file contain
+ * the Search submenu.
+ */
+private void createSearchMenu(Menu menuBar) {
+ //Search menu.
+ MenuItem item = new MenuItem(menuBar, SWT.CASCADE);
+ item.setText(resAddressBook.getString("Search_menu_title"));
+ Menu searchMenu = new Menu(shell, SWT.DROP_DOWN);
+ item.setMenu(searchMenu);
+
+ //Search -> Find...
+ item = new MenuItem(searchMenu, SWT.NULL);
+ item.setText(resAddressBook.getString("Find"));
+ item.setAccelerator(SWT.CTRL + 'F');
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ searchDialog.setMatchCase(false);
+ searchDialog.setMatchWord(false);
+ searchDialog.setSearchDown(true);
+ searchDialog.setSearchString("");
+ searchDialog.setSelectedSearchArea(0);
+ searchDialog.open();
+ }
+ });
+
+ //Search -> Find Next
+ item = new MenuItem(searchMenu, SWT.NULL);
+ item.setText(resAddressBook.getString("Find_next"));
+ item.setAccelerator(SWT.F3);
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ searchDialog.open();
+ }
+ });
+}
+
+/**
+ * Creates all items located in the popup menu and associates
+ * all the menu items with their appropriate functions.
+ *
+ * @return Menu
+ * The created popup menu.
+ */
+private Menu createPopUpMenu() {
+ Menu popUpMenu = new Menu(shell, SWT.POP_UP);
+
+ /**
+ * Adds a listener to handle enabling and disabling
+ * some items in the Edit submenu.
+ */
+ popUpMenu.addMenuListener(new MenuAdapter() {
+ public void menuShown(MenuEvent e) {
+ Menu menu = (Menu)e.widget;
+ MenuItem[] items = menu.getItems();
+ int count = table.getSelectionCount();
+ items[2].setEnabled(count != 0); // edit
+ items[3].setEnabled(count != 0); // copy
+ items[4].setEnabled(copyBuffer != null); // paste
+ items[5].setEnabled(count != 0); // delete
+ items[7].setEnabled(table.getItemCount() != 0); // find
+ }
+ });
+
+ //New
+ MenuItem item = new MenuItem(popUpMenu, SWT.CASCADE);
+ item.setText(resAddressBook.getString("Pop_up_new"));
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ newEntry();
+ }
+ });
+
+ new MenuItem(popUpMenu, SWT.SEPARATOR);
+
+ //Edit
+ item = new MenuItem(popUpMenu, SWT.CASCADE);
+ item.setText(resAddressBook.getString("Pop_up_edit"));
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ TableItem[] items = table.getSelection();
+ if (items.length == 0) return;
+ editEntry(items[0]);
+ }
+ });
+
+ //Copy
+ item = new MenuItem(popUpMenu, SWT.CASCADE);
+ item.setText(resAddressBook.getString("Pop_up_copy"));
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ TableItem[] items = table.getSelection();
+ if (items.length == 0) return;
+ copyBuffer = new String[table.getColumnCount()];
+ for (int i = 0; i < copyBuffer.length; i++) {
+ copyBuffer[i] = items[0].getText(i);
+ }
+ }
+ });
+
+ //Paste
+ item = new MenuItem(popUpMenu, SWT.CASCADE);
+ item.setText(resAddressBook.getString("Pop_up_paste"));
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ if (copyBuffer == null) return;
+ TableItem item = new TableItem(table, SWT.NONE);
+ item.setText(copyBuffer);
+ isModified = true;
+ }
+ });
+
+ //Delete
+ item = new MenuItem(popUpMenu, SWT.CASCADE);
+ item.setText(resAddressBook.getString("Pop_up_delete"));
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ TableItem[] items = table.getSelection();
+ if (items.length == 0) return;
+ items[0].dispose();
+ isModified = true;
+ }
+ });
+
+ new MenuItem(popUpMenu, SWT.SEPARATOR);
+
+ //Find...
+ item = new MenuItem(popUpMenu, SWT.NULL);
+ item.setText(resAddressBook.getString("Pop_up_find"));
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ searchDialog.open();
+ }
+ });
+
+ return popUpMenu;
+}
+
+/**
+ * Creates all the items located in the Help submenu and
+ * associate all the menu items with their appropriate
+ * functions.
+ *
+ * @param menuBar Menu
+ * the <code>Menu</code> that file contain
+ * the Help submenu.
+ */
+private void createHelpMenu(Menu menuBar) {
+
+ //Help Menu
+ MenuItem item = new MenuItem(menuBar, SWT.CASCADE);
+ item.setText(resAddressBook.getString("Help_menu_title"));
+ Menu menu = new Menu(shell, SWT.DROP_DOWN);
+ item.setMenu(menu);
+
+ //Help -> About Text Editor
+ MenuItem subItem = new MenuItem(menu, SWT.NULL);
+ subItem.setText(resAddressBook.getString("About"));
+ subItem.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ MessageBox box = new MessageBox(shell, SWT.NONE);
+ box.setText(resAddressBook.getString("About_1") + shell.getText());
+ box.setMessage(shell.getText() + resAddressBook.getString("About_2"));
+ box.open();
+ }
+ });
+}
+} \ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/addressbook/DataEntryDialog.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/addressbook/DataEntryDialog.java
new file mode 100755
index 0000000000..f6716199d9
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/addressbook/DataEntryDialog.java
@@ -0,0 +1,152 @@
+package org.eclipse.swt.examples.addressbook;
+
+/* Imports */
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+import java.util.ResourceBundle;
+
+/**
+ * DataEntryDialog class uses <code>org.eclipse.swt</code>
+ * libraries to implement a dialog that accepts basic personal information that
+ * is added to a <code>Table</code> widget or edits a <code>TableItem</code> entry
+ * to represent the entered data.
+ */
+public class DataEntryDialog {
+
+ private static ResourceBundle resAddressBook = ResourceBundle.getBundle("examples_addressbook");
+
+ Shell shell;
+ String[] values;
+ String[] labels;
+
+public DataEntryDialog(Shell parent) {
+ shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL);
+ shell.setLayout(new GridLayout());
+}
+
+private void addTextListener(final Text text) {
+ text.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e){
+ Integer index = (Integer)(text.getData("index"));
+ values[index.intValue()] = text.getText();
+ }
+ });
+}
+private void createControlButtons() {
+ Composite composite = new Composite(shell, SWT.NULL);
+ composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ composite.setLayout(layout);
+
+ Button okButton = new Button(composite, SWT.PUSH);
+ okButton.setText(resAddressBook.getString("OK"));
+ okButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ shell.close();
+ }
+ });
+
+ Button cancelButton = new Button(composite, SWT.PUSH);
+ cancelButton.setText(resAddressBook.getString("Cancel"));
+ cancelButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ values = null;
+ shell.close();
+ }
+ });
+
+ shell.setDefaultButton(okButton);
+}
+
+private void createTextWidgets() {
+ if (labels == null) return;
+
+ Composite composite = new Composite(shell, SWT.NULL);
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ GridLayout layout= new GridLayout();
+ layout.numColumns = 2;
+ composite.setLayout(layout);
+
+ if (values == null)
+ values = new String[labels.length];
+
+ for (int i = 0; i < labels.length; i++) {
+ Label label = new Label(composite, SWT.RIGHT);
+ label.setText(labels[i]);
+ Text text = new Text(composite, SWT.BORDER);
+ GridData gridData = new GridData();
+ gridData.widthHint = 400;
+ text.setLayoutData(gridData);
+ if (values[i] != null) {
+ text.setText(values[i]);
+ }
+ text.setData("index", new Integer(i));
+ addTextListener(text);
+ }
+}
+
+public String[] getLabels() {
+ return labels;
+}
+public String getTitle() {
+ return shell.getText();
+}
+/**
+ * Returns the contents of the <code>Text</code> widgets in the dialog in a
+ * <code>String</code> array.
+ *
+ * @return String[]
+ * The contents of the text widgets of the dialog.
+ * May return null if all text widgets are empty.
+ */
+public String[] getValues() {
+ return values;
+}
+/**
+ * Opens the dialog in the given state. Sets <code>Text</code> widget contents
+ * and dialog behaviour accordingly.
+ *
+ * @param dialogState int
+ * The state the dialog should be opened in.
+ */
+public String[] open() {
+ createTextWidgets();
+ createControlButtons();
+ shell.pack();
+ shell.open();
+ Display display = shell.getDisplay();
+ while(!shell.isDisposed()){
+ if(!display.readAndDispatch())
+ display.sleep();
+ }
+
+ return getValues();
+}
+public void setLabels(String[] labels) {
+ this.labels = labels;
+}
+public void setTitle(String title) {
+ shell.setText(title);
+}
+/**
+ * Sets the values of the <code>Text</code> widgets of the dialog to
+ * the values supplied in the parameter array.
+ *
+ * @param itemInfo String[]
+ * The values to which the dialog contents will be set.
+ */
+public void setValues(String[] itemInfo) {
+ if (labels == null) return;
+
+ if (values == null)
+ values = new String[labels.length];
+
+ int numItems = Math.min(values.length, itemInfo.length);
+ for(int i = 0; i < numItems; i++) {
+ values[i] = itemInfo[i];
+ }
+}
+} \ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/addressbook/FindListener.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/addressbook/FindListener.java
new file mode 100755
index 0000000000..b92bf55360
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/addressbook/FindListener.java
@@ -0,0 +1,8 @@
+package org.eclipse.swt.examples.addressbook;
+
+
+public interface FindListener {
+
+public boolean find();
+
+} \ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/addressbook/SearchDialog.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/addressbook/SearchDialog.java
new file mode 100755
index 0000000000..a86f762e69
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/addressbook/SearchDialog.java
@@ -0,0 +1,191 @@
+package org.eclipse.swt.examples.addressbook;
+
+/* Imports */
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+import java.util.ResourceBundle;
+
+/**
+ * SearchDialog is a simple class that uses <code>org.eclipse.swt</code>
+ * libraries to implement a basic search dialog.
+ */
+public class SearchDialog {
+
+ private static ResourceBundle resAddressBook = ResourceBundle.getBundle("examples_addressbook");
+
+ Shell shell;
+ Text searchText;
+ Combo searchArea;
+ Label searchAreaLabel;
+ Button matchCase;
+ Button matchWord;
+ Button findButton;
+ Button down;
+ FindListener findHandler;
+
+/**
+ * Class constructor that sets the parent shell and the table widget that
+ * the dialog will search.
+ *
+ * @param parent Shell
+ * The shell that is the parent of the dialog.
+ */
+public SearchDialog(Shell parent) {
+ shell = new Shell(parent, SWT.CLOSE | SWT.BORDER | SWT.TITLE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ shell.setLayout(layout);
+ shell.setText(resAddressBook.getString("Search_dialog_title"));
+ shell.addShellListener(new ShellAdapter(){
+ public void shellClosed(ShellEvent e) {
+ // don't dispose of the shell, just hide it for later use
+ e.doit = false;
+ shell.setVisible(false);
+ }
+ });
+
+ Label label = new Label(shell, SWT.LEFT);
+ label.setText(resAddressBook.getString("Dialog_find_what"));
+ searchText = new Text(shell, SWT.BORDER);
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.widthHint = 200;
+ searchText.setLayoutData(gridData);
+ searchText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ boolean enableFind = (searchText.getCharCount() != 0);
+ findButton.setEnabled(enableFind);
+ }
+ });
+
+ searchAreaLabel = new Label(shell, SWT.LEFT);
+ searchArea = new Combo(shell, SWT.DROP_DOWN | SWT.READ_ONLY);
+ gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.widthHint = 200;
+ searchArea.setLayoutData(gridData);
+
+ matchCase = new Button(shell, SWT.CHECK);
+ matchCase.setText(resAddressBook.getString("Dialog_match_case"));
+ gridData = new GridData();
+ gridData.horizontalSpan = 2;
+ matchCase.setLayoutData(gridData);
+
+ matchWord = new Button(shell, SWT.CHECK);
+ matchWord.setText(resAddressBook.getString("Dialog_match_word"));
+ gridData = new GridData();
+ gridData.horizontalSpan = 2;
+ matchWord.setLayoutData(gridData);
+
+ Group direction = new Group(shell, SWT.NONE);
+ gridData = new GridData();
+ gridData.horizontalSpan = 2;
+ direction.setLayoutData(gridData);
+ direction.setLayout (new FillLayout ());
+ direction.setText(resAddressBook.getString("Dialog_direction"));
+
+ Button up = new Button(direction, SWT.RADIO);
+ up.setText(resAddressBook.getString("Dialog_dir_up"));
+
+ down = new Button(direction, SWT.RADIO);
+ down.setText(resAddressBook.getString("Dialog_dir_down"));
+ down.setSelection(true);
+
+ Composite composite = new Composite(shell, SWT.NONE);
+ gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gridData.horizontalSpan = 2;
+ composite.setLayoutData(gridData);
+ layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.makeColumnsEqualWidth = true;
+ composite.setLayout(layout);
+
+ findButton = new Button(composite, SWT.PUSH);
+ findButton.setText(resAddressBook.getString("Dialog_find"));
+ findButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
+ findButton.setEnabled(false);
+ findButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ if (!findHandler.find()){
+ MessageBox box = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK | SWT.PRIMARY_MODAL);
+ box.setText(shell.getText());
+ box.setMessage(resAddressBook.getString("Cannot_find") + "\"" + searchText.getText() + "\"");
+ box.open();
+ }
+ }
+ });
+
+ Button cancelButton = new Button(composite, SWT.PUSH);
+ cancelButton.setText(resAddressBook.getString("Cancel"));
+ cancelButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+ cancelButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ shell.setVisible(false);
+ }
+ });
+
+ shell.pack();
+}
+public String getSearchAreaLabel(String label) {
+ return searchAreaLabel.getText();
+}
+
+public String[] getsearchAreaNames() {
+ return searchArea.getItems();
+}
+public boolean getMatchCase() {
+ return matchCase.getSelection();
+}
+public boolean getMatchWord() {
+ return matchWord.getSelection();
+}
+public String getSearchString() {
+ return searchText.getText();
+}
+public boolean getSearchDown(){
+ return down.getSelection();
+}
+public int getSelectedSearchArea() {
+ return searchArea.getSelectionIndex();
+}
+public void open() {
+ if (shell.isVisible()) {
+ shell.setFocus();
+ } else {
+ shell.open();
+ }
+ searchText.setFocus();
+}
+public void setSearchAreaNames(String[] names) {
+ for (int i = 0; i < names.length; i++) {
+ searchArea.add(names[i]);
+ }
+ searchArea.select(0);
+}
+public void setSearchAreaLabel(String label) {
+ searchAreaLabel.setText(label);
+}
+public void setMatchCase(boolean match) {
+ matchCase.setSelection(match);
+}
+public void setMatchWord(boolean match) {
+ matchWord.setSelection(match);
+}
+public void setSearchDown(boolean searchDown){
+ down.setSelection(searchDown);
+}
+public void setSearchString(String searchString) {
+ searchText.setText(searchString);
+}
+
+public void setSelectedSearchArea(int index) {
+ searchArea.select(index);
+}
+public void addFindListener(FindListener listener) {
+ this.findHandler = listener;
+}
+public void removeFindListener(FindListener listener) {
+ this.findHandler = null;
+}
+} \ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/AlignableTab.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/AlignableTab.java
new file mode 100755
index 0000000000..15bc9a729f
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/AlignableTab.java
@@ -0,0 +1,76 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+/* Imports */
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+
+/**
+* <code>AlignableTab</code> is the abstract
+* superclass of example controls that can be
+* aligned.
+*/
+
+/* Class Definition */
+abstract class AlignableTab extends Tab {
+
+ /* Allignment Controls */
+ Button leftButton, rightButton, centerButton;
+
+ /* Alignment Group */
+ Group allignmentGroup;
+/**
+* Creates the "Control" group.
+*/
+void createControlGroup () {
+ super.createControlGroup ();
+
+ /* Create the group */
+ allignmentGroup = new Group (controlGroup, SWT.NULL);
+ allignmentGroup.setLayout (new GridLayout ());
+ allignmentGroup.setLayoutData (new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ allignmentGroup.setText (resControls.getString("Alignment"));
+
+ /* Create the controls */
+ leftButton = new Button (allignmentGroup, SWT.RADIO);
+ leftButton.setText (resControls.getString("Left"));
+ centerButton = new Button (allignmentGroup, SWT.RADIO);
+ centerButton.setText(resControls.getString("Center"));
+ rightButton = new Button (allignmentGroup, SWT.RADIO);
+ rightButton.setText (resControls.getString("Right"));
+
+ /* Add the listeners */
+ SelectionListener selectionListener = new SelectionAdapter () {
+ public void widgetSelected(SelectionEvent event) {
+ if (!((Button) event.widget).getSelection ()) return;
+ setExampleWidgetAlignment ();
+ };
+ };
+ leftButton.addSelectionListener (selectionListener);
+ centerButton.addSelectionListener (selectionListener);
+ rightButton.addSelectionListener (selectionListener);
+}
+/**
+* Sets the alignment of the "Example" widgets.
+*/
+abstract void setExampleWidgetAlignment ();
+/**
+* Sets the state of the "Example" widgets.
+*/
+void setExampleWidgetState () {
+ super.setExampleWidgetState ();
+ Control [] controls = getExampleWidgets ();
+ if (controls.length != 0) {
+ leftButton.setSelection ((controls [0].getStyle () & SWT.LEFT) != 0);
+ centerButton.setSelection ((controls [0].getStyle () & SWT.CENTER) != 0);
+ rightButton.setSelection ((controls [0].getStyle () & SWT.RIGHT) != 0);
+ }
+}
+}
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ButtonTab.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ButtonTab.java
new file mode 100755
index 0000000000..a7c3ca95f1
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ButtonTab.java
@@ -0,0 +1,176 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+
+/**
+* <code>ButtonTab</code> is the class that
+* demonstrates SWT buttons.
+*/
+
+class ButtonTab extends AlignableTab {
+
+ /* Example widgets and groups that contain them */
+ Button button1, button2, button3, button4, button5, button6;
+ Group textButtonGroup, imageButtonGroup;
+
+ /* Allignment widgets added to the "Control" group */
+ Button upButton, downButton;
+
+ /* Style widgets added to the "Style" group */
+ Button pushButton, checkButton, radioButton, toggleButton, arrowButton;
+/**
+* Creates the "Control" group.
+*/
+void createControlGroup () {
+ super.createControlGroup ();
+
+ /* Create the controls */
+ upButton = new Button (allignmentGroup, SWT.RADIO);
+ upButton.setText (resControls.getString("Up"));
+ downButton = new Button (allignmentGroup, SWT.RADIO);
+ downButton.setText (resControls.getString("Down"));
+
+ /* Add the listeners */
+ SelectionListener selectionListener = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ if (!((Button) event.widget).getSelection()) return;
+ setExampleWidgetAlignment ();
+ };
+ };
+ upButton.addSelectionListener(selectionListener);
+ downButton.addSelectionListener(selectionListener);
+}
+/**
+* Creates the "Example" group.
+*/
+void createExampleGroup () {
+ super.createExampleGroup ();
+
+ /* Create a group for text buttons */
+ textButtonGroup = new Group(exampleGroup, SWT.NONE);
+ GridLayout gridLayout = new GridLayout ();
+ textButtonGroup.setLayout(gridLayout);
+ gridLayout.numColumns = 3;
+ textButtonGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ textButtonGroup.setText (resControls.getString("Text_Buttons"));
+
+ /* Create a group for the image buttons */
+ imageButtonGroup = new Group(exampleGroup, SWT.NONE);
+ gridLayout = new GridLayout();
+ imageButtonGroup.setLayout(gridLayout);
+ gridLayout.numColumns = 3;
+ imageButtonGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ imageButtonGroup.setText (resControls.getString("Image_Buttons"));
+
+}
+/**
+* Creates the "Example" widgets.
+*/
+void createExampleWidgets () {
+
+ /* Compute the widget style */
+ int style = SWT.NONE;
+ if (pushButton.getSelection()) style |= SWT.PUSH;
+ if (checkButton.getSelection()) style |= SWT.CHECK;
+ if (radioButton.getSelection()) style |= SWT.RADIO;
+ if (toggleButton.getSelection()) style |= SWT.TOGGLE;
+ if (arrowButton.getSelection()) style |= SWT.ARROW;
+ if (borderButton.getSelection()) style |= SWT.BORDER;
+
+ /* Create the example widgets */
+ button1 = new Button(textButtonGroup, style);
+ button1.setText(resControls.getString("One"));
+ button2 = new Button(textButtonGroup, style);
+ button2.setText(resControls.getString("Two"));
+ button3 = new Button(textButtonGroup, style);
+ button3.setText(resControls.getString("Three"));
+ button4 = new Button(imageButtonGroup, style);
+ button4.setImage(Images.CLOSED_FOLDER_IMAGE);
+ button5 = new Button(imageButtonGroup, style);
+ button5.setImage(Images.OPEN_FOLDER_IMAGE);
+ button6 = new Button(imageButtonGroup, style);
+ button6.setImage(Images.TARGET_IMAGE);
+}
+/**
+* Creates the "Style" group.
+*/
+void createStyleGroup() {
+ super.createStyleGroup ();
+
+ /* Create the extra widgets */
+ pushButton = new Button (styleGroup, SWT.RADIO);
+ pushButton.setText(resControls.getString("SWT_PUSH"));
+ checkButton = new Button (styleGroup, SWT.RADIO);
+ checkButton.setText (resControls.getString("SWT_CHECK"));
+ radioButton = new Button (styleGroup, SWT.RADIO);
+ radioButton.setText (resControls.getString("SWT_RADIO"));
+ toggleButton = new Button (styleGroup, SWT.RADIO);
+ toggleButton.setText (resControls.getString("SWT_TOGGLE"));
+ arrowButton = new Button (styleGroup, SWT.RADIO);
+ arrowButton.setText (resControls.getString("SWT_ARROW"));
+ borderButton = new Button (styleGroup, SWT.CHECK);
+ borderButton.setText (resControls.getString("SWT_BORDER"));
+}
+/**
+* Gets the "Example" widget children.
+*/
+Control [] getExampleWidgets () {
+ return new Control [] {button1, button2, button3, button4, button5, button6};
+}
+/**
+* Gets the text for the tab folder item.
+*/
+String getTabText () {
+ return resControls.getString("Button");
+}
+/**
+* Sets the alignment of the "Example" widgets.
+*/
+void setExampleWidgetAlignment () {
+ int allignment = 0;
+ if (leftButton.getSelection ()) allignment = SWT.LEFT;
+ if (centerButton.getSelection ()) allignment = SWT.CENTER;
+ if (rightButton.getSelection ()) allignment = SWT.RIGHT;
+ if (upButton.getSelection ()) allignment = SWT.UP;
+ if (downButton.getSelection ()) allignment = SWT.DOWN;
+ button1.setAlignment (allignment);
+ button2.setAlignment (allignment);
+ button3.setAlignment (allignment);
+ button4.setAlignment (allignment);
+ button5.setAlignment (allignment);
+ button6.setAlignment (allignment);
+}
+/**
+* Sets the state of the "Example" widgets.
+*/
+void setExampleWidgetState () {
+ super.setExampleWidgetState ();
+ if (arrowButton.getSelection ()) {
+ upButton.setEnabled (true);
+ centerButton.setEnabled (false);
+ downButton.setEnabled (true);
+ } else {
+ upButton.setEnabled (false);
+ centerButton.setEnabled (true);
+ downButton.setEnabled (false);
+ }
+ upButton.setSelection ((button1.getStyle () & SWT.UP) != 0);
+ downButton.setSelection ((button1.getStyle () & SWT.DOWN) != 0);
+ pushButton.setSelection ((button1.getStyle () & SWT.PUSH) != 0);
+ checkButton.setSelection ((button1.getStyle () & SWT.CHECK) != 0);
+ radioButton.setSelection ((button1.getStyle () & SWT.RADIO) != 0);
+ toggleButton.setSelection ((button1.getStyle () & SWT.TOGGLE) != 0);
+ arrowButton.setSelection ((button1.getStyle () & SWT.ARROW) != 0);
+ borderButton.setSelection ((button1.getStyle () & SWT.BORDER) != 0);
+}
+}
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ComboTab.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ComboTab.java
new file mode 100755
index 0000000000..e457e1719e
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ComboTab.java
@@ -0,0 +1,103 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+
+class ComboTab extends Tab {
+
+ /* Example widgets and groups that contain them */
+ Combo combo1;
+ Group comboGroup;
+
+ /* Style widgets added to the "Style" group */
+ Button dropDownButton, readOnlyButton, simpleButton;
+
+ static String [] ListData = {resControls.getString("ListData0_0"),
+ resControls.getString("ListData0_1"),
+ resControls.getString("ListData0_2"),
+ resControls.getString("ListData0_3"),
+ resControls.getString("ListData0_4"),
+ resControls.getString("ListData0_5"),
+ resControls.getString("ListData0_6"),
+ resControls.getString("ListData0_7"),
+ resControls.getString("ListData0_8")};
+/**
+* Creates the "Example" group.
+*/
+void createExampleGroup () {
+ super.createExampleGroup ();
+
+ /* Create a group for the combo box */
+ comboGroup = new Group (exampleGroup, SWT.NULL);
+ comboGroup.setLayout (new GridLayout ());
+ comboGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ comboGroup.setText (resControls.getString("Combo"));
+}
+/**
+* Creates the "Example" widgets.
+*/
+void createExampleWidgets () {
+
+ /* Compute the widget style */
+ int style = SWT.NONE;
+ if (dropDownButton.getSelection ()) style |= SWT.DROP_DOWN;
+ if (readOnlyButton.getSelection ()) style |= SWT.READ_ONLY;
+ if (simpleButton.getSelection ()) style |= SWT.SIMPLE;
+ if (borderButton.getSelection ()) style |= SWT.BORDER;
+
+ /* Create the example widgets */
+ combo1 = new Combo (comboGroup, style);
+ combo1.setItems (ListData);
+ if (ListData.length >= 3) {
+ combo1.setText(ListData [2]);
+ }
+
+}
+/**
+* Creates the "Style" group.
+*/
+void createStyleGroup () {
+ super.createStyleGroup ();
+
+ /* Create the extra widgets */
+ dropDownButton = new Button (styleGroup, SWT.RADIO);
+ dropDownButton.setText (resControls.getString("SWT_DROP_DOWN"));
+ simpleButton = new Button (styleGroup, SWT.RADIO);
+ simpleButton.setText(resControls.getString("SWT_SIMPLE"));
+ readOnlyButton = new Button (styleGroup, SWT.CHECK);
+ readOnlyButton.setText (resControls.getString("SWT_READ_ONLY"));
+ borderButton = new Button (styleGroup, SWT.CHECK);
+ borderButton.setText (resControls.getString("SWT_BORDER"));
+}
+/**
+* Gets the "Example" widget children.
+*/
+Control [] getExampleWidgets () {
+ return new Control [] {combo1};
+}
+/**
+* Gets the text for the tab folder item.
+*/
+String getTabText () {
+ return resControls.getString("Combo");
+}
+/**
+* Sets the state of the "Example" widgets.
+*/
+void setExampleWidgetState () {
+ super.setExampleWidgetState ();
+ dropDownButton.setSelection ((combo1.getStyle () & SWT.DROP_DOWN) != 0);
+ simpleButton.setSelection ((combo1.getStyle () & SWT.SIMPLE) != 0);
+ readOnlyButton.setSelection ((combo1.getStyle () & SWT.READ_ONLY) != 0);
+ borderButton.setSelection ((combo1.getStyle () & SWT.BORDER) != 0);
+}
+}
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ControlExample.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ControlExample.java
new file mode 100755
index 0000000000..d48640a6dc
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ControlExample.java
@@ -0,0 +1,97 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+/* Imports */
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.widgets.*;
+import java.util.ResourceBundle;
+
+/**
+* <code>ControlExample</code> is a simple demonstration
+* of the controls defined by SWT. It consists of a shell
+* and tab folder where each tab in the folder allows the
+* user to interact with a control.
+*/
+
+/* Class Definition */
+public class ControlExample {
+ Shell shell;
+ TabFolder tabFolder;
+ ResourceBundle resControls = ResourceBundle.getBundle("examples_control");
+/**
+* Create a new example and open it.
+*
+* @param args the command line arguments
+*
+*/
+public static void main (String[] args) {
+ new ControlExample ().open ();
+}
+/**
+* Open the example.
+*/
+void open () {
+
+ /* Load resources */
+ Images.loadImages ();
+
+ /* Create the shell */
+ shell = new Shell ();
+ shell.setText (resControls.getString("Control_Example"));
+ shell.addControlListener (new ControlAdapter () {
+ public void controlResized (ControlEvent e) {
+ tabFolder.setBounds (shell.getClientArea ());
+ }
+ });
+
+ /* Create the tab folder */
+ ShellTab shellTab = new ShellTab ();
+ tabFolder = new TabFolder (shell, SWT.NULL);
+ Tab [] tabs = new Tab [] {
+ new ButtonTab (),
+ new ComboTab (),
+ new DialogTab (),
+ new LabelTab (),
+ new ListTab (),
+ new ProgressBarTab (),
+ new SashTab (),
+ shellTab,
+ new SliderTab (),
+ new TableTab (),
+ new TextTab (),
+ new ToolBarTab (),
+ new TreeTab (),
+ };
+ for (int i=0; i<tabs.length; i++) {
+ TabItem item = new TabItem (tabFolder, SWT.NULL);
+ item.setText (tabs [i].getTabText ());
+ item.setControl (tabs [i].createTabFolderPage (tabFolder));
+ }
+
+ /* Run the event loop */
+ shell.open ();
+ Display display = Display.getDefault ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+
+ /*
+ * Destroy any shells that may have been created
+ * by the Shells tab. When a shell is disposed,
+ * all child shells are also disposed. Therefore
+ * it is necessary to check for disposed shells
+ * in the shells list to avoid disposing a shell
+ * twice.
+ */
+ shellTab.closeAllShells ();
+
+ /* Free resources */
+ Images.freeImages ();
+}
+}
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/DialogTab.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/DialogTab.java
new file mode 100755
index 0000000000..a87cd6b65b
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/DialogTab.java
@@ -0,0 +1,418 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+
+class DialogTab extends Tab {
+
+ /* Example widgets and groups that contain them */
+ Group dialogStyleGroup, resultGroup;
+ Text textWidget;
+
+ /* Style widgets added to the "Style" group */
+ Combo dialogCombo;
+ Button okButton, cancelButton;
+ Button yesButton, noButton;
+ Button retryButton;
+ Button abortButton, ignoreButton;
+ Button iconErrorButton, iconInformationButton, iconQuestionButton;
+ Button iconWarningButton, iconWorkingButton;
+ Button modelessButton, primaryModalButton, applicationModalButton, systemModalButton;
+ Button saveButton, openButton;
+
+ static String [] FilterExtensions = {".txt.", ".bat", ".doc"};
+ static String [] FilterNames = {resControls.getString("FilterName_0"),
+ resControls.getString("FilterName_1"),
+ resControls.getString("FilterName_2")};
+
+/**
+* Handle a button style selection event.
+*
+* @param event the selection event
+*/
+void buttonStyleSelected(SelectionEvent event) {
+ /*
+ * Only certain combinations of button styles are
+ * supported for various dialogs. Make sure the
+ * control widget reflects only valid combinations.
+ */
+ okButton.setEnabled (
+ !(yesButton.getSelection () || noButton.getSelection () ||
+ retryButton.getSelection () || abortButton.getSelection () ||
+ ignoreButton.getSelection ()));
+ cancelButton.setEnabled (
+ !(abortButton.getSelection () || ignoreButton.getSelection ()));
+ yesButton.setEnabled (
+ !(okButton.getSelection () || retryButton.getSelection () ||
+ abortButton.getSelection () || ignoreButton.getSelection ()));
+ noButton.setEnabled (
+ !(okButton.getSelection () || retryButton.getSelection () ||
+ abortButton.getSelection () || ignoreButton.getSelection ()));
+ retryButton.setEnabled (
+ !(okButton.getSelection() || yesButton.getSelection() || noButton.getSelection ()));
+ abortButton.setEnabled (
+ !(okButton.getSelection () || cancelButton.getSelection () ||
+ yesButton.getSelection () || noButton.getSelection ()));
+ ignoreButton.setEnabled (
+ !(okButton.getSelection () || cancelButton.getSelection () |
+ yesButton.getSelection () || noButton.getSelection ()));
+}
+/**
+ * Handle the create button selection event.
+ *
+ * @param event org.eclipse.swt.events.SelectionEvent
+ */
+void createButtonSelected(SelectionEvent event) {
+
+ /* Compute the appropriate dialog style */
+ int style = SWT.NULL;
+ if (okButton.getEnabled () && okButton.getSelection ()) style |= SWT.OK;
+ if (cancelButton.getEnabled () && cancelButton.getSelection ()) style |= SWT.CANCEL;
+ if (yesButton.getEnabled () && yesButton.getSelection ()) style |= SWT.YES;
+ if (noButton.getEnabled () && noButton.getSelection ()) style |= SWT.NO;
+ if (retryButton.getEnabled () && retryButton.getSelection ()) style |= SWT.RETRY;
+ if (abortButton.getEnabled () && abortButton.getSelection ()) style |= SWT.ABORT;
+ if (ignoreButton.getEnabled () && ignoreButton.getSelection ()) style |= SWT.IGNORE;
+ if (iconErrorButton.getEnabled () && iconErrorButton.getSelection ()) style |= SWT.ICON_ERROR;
+ if (iconInformationButton.getEnabled () && iconInformationButton.getSelection ()) style |= SWT.ICON_INFORMATION;
+ if (iconQuestionButton.getEnabled () && iconQuestionButton.getSelection ()) style |= SWT.ICON_QUESTION;
+ if (iconWarningButton.getEnabled () && iconWarningButton.getSelection ()) style |= SWT.ICON_WARNING;
+ if (iconWorkingButton.getEnabled () && iconWorkingButton.getSelection ()) style |= SWT.ICON_WORKING;
+ if (primaryModalButton.getEnabled () && primaryModalButton.getSelection ()) style |= SWT.PRIMARY_MODAL;
+ if (applicationModalButton.getEnabled () && applicationModalButton.getSelection ()) style |= SWT.APPLICATION_MODAL;
+ if (systemModalButton.getEnabled () && systemModalButton.getSelection ()) style |= SWT.SYSTEM_MODAL;
+ if (saveButton.getEnabled () && saveButton.getSelection ()) style |= SWT.SAVE;
+ if (openButton.getEnabled () && openButton.getSelection ()) style |= SWT.OPEN;
+
+ /* Open the appropriate dialog type */
+ String name = dialogCombo.getText ();
+ Shell shell = tabFolderPage.getShell ();
+
+ if (name.equals (resControls.getString("ColorDialog"))) {
+ ColorDialog dialog = new ColorDialog (shell ,style);
+ dialog.setRGB (new RGB (100, 100, 100));
+ dialog.setText (resControls.getString("Title"));
+ RGB result = dialog.open ();
+ textWidget.append (resControls.getString("ColorDialog") + Text.DELIMITER);
+ textWidget.append (resControls.getString("Result") + " " + result + Text.DELIMITER + Text.DELIMITER);
+ return;
+ }
+
+ if (name.equals (resControls.getString("DirectoryDialog"))) {
+ DirectoryDialog dialog = new DirectoryDialog (shell, style);
+ dialog.setMessage (resControls.getString("Example_string"));
+ dialog.setText (resControls.getString("Title"));
+ String result = dialog.open ();
+ textWidget.append (resControls.getString("DirectoryDialog") + Text.DELIMITER);
+ textWidget.append (resControls.getString("Result") + " " + result + Text.DELIMITER + Text.DELIMITER);
+ return;
+ }
+
+ if (name.equals (resControls.getString("FileDialog"))) {
+ FileDialog dialog = new FileDialog (shell, style);
+ dialog.setFileName (resControls.getString("readme_txt"));
+ dialog.setFilterNames (FilterNames);
+ dialog.setFilterExtensions (FilterExtensions);
+ dialog.setText (resControls.getString("Title"));
+ String result = dialog.open();
+ textWidget.append (resControls.getString("FileDialog") + Text.DELIMITER);
+ textWidget.append (resControls.getString("Result") + " " + result + Text.DELIMITER + Text.DELIMITER);
+ return;
+ }
+
+ if (name.equals (resControls.getString("FontDialog"))) {
+ FontDialog dialog = new FontDialog (shell, style);
+ dialog.setText (resControls.getString("Title"));
+ FontData result = dialog.open ();
+ textWidget.append (resControls.getString("FontDialog") + Text.DELIMITER);
+ textWidget.append (resControls.getString("Result") + " " + result + Text.DELIMITER + Text.DELIMITER);
+ return;
+ }
+
+ if (name.equals(resControls.getString("MessageBox"))) {
+ MessageBox dialog = new MessageBox (shell, style);
+ dialog.setMessage (resControls.getString("Example_string"));
+ dialog.setText (resControls.getString("Title"));
+ int result = dialog.open ();
+ textWidget.append (resControls.getString("MessageBox") + Text.DELIMITER);
+ /*
+ * The resulting integer depends on the original
+ * dialog style. Decode the result and display it.
+ */
+ switch (result) {
+ case SWT.OK:
+ textWidget.append (resControls.getString("Result") + resControls.getString("SWT_OK"));
+ break;
+ case SWT.YES:
+ textWidget.append (resControls.getString("Result") + resControls.getString("SWT_YES"));
+ break;
+ case SWT.NO:
+ textWidget.append (resControls.getString("Result") + resControls.getString("SWT_NO"));
+ break;
+ case SWT.CANCEL:
+ textWidget.append (resControls.getString("Result") + resControls.getString("SWT_CANCEL"));
+ break;
+ case SWT.ABORT:
+ textWidget.append (resControls.getString("Result") + resControls.getString("SWT_ABORT"));
+ break;
+ case SWT.RETRY:
+ textWidget.append (resControls.getString("Result") + resControls.getString("SWT_RETRY"));
+ break;
+ case SWT.IGNORE:
+ textWidget.append (resControls.getString("Result") + resControls.getString("SWT_IGNORE"));
+ break;
+ default:
+ textWidget.append(resControls.getString("Result") + result);
+ break;
+ }
+ textWidget.append (Text.DELIMITER + Text.DELIMITER);
+ }
+}
+/**
+* Creates the "Control" group.
+*/
+void createControlGroup () {
+ /*
+ * Create the "Control" group. This is the group on the
+ * left half of each example tab. It consists of the
+ * style group, the display group and the size group.
+ */
+ controlGroup = new Group (tabFolderPage, SWT.NULL);
+ GridLayout gridLayout= new GridLayout ();
+ controlGroup.setLayout(gridLayout);
+ gridLayout.numColumns = 2;
+ gridLayout.makeColumnsEqualWidth = true;
+ controlGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ controlGroup.setText (resControls.getString("Parameters"));
+
+ /*
+ * Create a group to hold the dialog style combo box and
+ * create dialog button.
+ */
+ dialogStyleGroup = new Group (controlGroup, SWT.NULL);
+ dialogStyleGroup.setLayout (new GridLayout ());
+ GridData gridData = new GridData (GridData.HORIZONTAL_ALIGN_CENTER);
+ gridData.horizontalSpan = 2;
+ dialogStyleGroup.setLayoutData (gridData);
+ dialogStyleGroup.setText (resControls.getString("Dialog_Type"));
+}
+/**
+* Creates the "Control" widget children.
+*/
+void createControlWidgets () {
+
+ /* Create the combo */
+ String [] strings = {
+ resControls.getString("ColorDialog"),
+ resControls.getString("DirectoryDialog"),
+ resControls.getString("FileDialog"),
+ resControls.getString("FontDialog"),
+ resControls.getString("MessageBox"),
+ };
+ dialogCombo = new Combo (dialogStyleGroup, SWT.READ_ONLY);
+ dialogCombo.setItems (strings);
+ dialogCombo.setText (strings [0]);
+
+ /* Create the create dialog button */
+ Button createButton = new Button(dialogStyleGroup, SWT.NULL);
+ createButton.setText (resControls.getString("Create_Dialog"));
+ createButton.setLayoutData (new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
+
+ /* Create a group for the various dialog button style controls */
+ Group buttonStyleGroup = new Group (controlGroup, SWT.NULL);
+ buttonStyleGroup.setLayout (new GridLayout ());
+ buttonStyleGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ buttonStyleGroup.setText (resControls.getString("Button_Styles"));
+
+ /* Create the button style buttons */
+ okButton = new Button (buttonStyleGroup, SWT.CHECK);
+ okButton.setText (resControls.getString("SWT_OK"));
+ cancelButton = new Button (buttonStyleGroup, SWT.CHECK);
+ cancelButton.setText (resControls.getString("SWT_CANCEL"));
+ yesButton = new Button (buttonStyleGroup, SWT.CHECK);
+ yesButton.setText (resControls.getString("SWT_YES"));
+ noButton = new Button (buttonStyleGroup, SWT.CHECK);
+ noButton.setText (resControls.getString("SWT_NO"));
+ retryButton = new Button (buttonStyleGroup, SWT.CHECK);
+ retryButton.setText (resControls.getString("SWT_RETRY"));
+ abortButton = new Button (buttonStyleGroup, SWT.CHECK);
+ abortButton.setText (resControls.getString("SWT_ABORT"));
+ ignoreButton = new Button (buttonStyleGroup, SWT.CHECK);
+ ignoreButton.setText (resControls.getString("SWT_IGNORE"));
+
+ /* Create a group for the icon style controls */
+ Group iconStyleGroup = new Group (controlGroup, SWT.NULL);
+ iconStyleGroup.setLayout (new GridLayout ());
+ iconStyleGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ iconStyleGroup.setText (resControls.getString("Icon_Styles"));
+
+ /* Create the icon style buttons */
+ iconErrorButton = new Button (iconStyleGroup, SWT.RADIO);
+ iconErrorButton.setText (resControls.getString("SWT_ICON_ERROR"));
+ iconInformationButton = new Button (iconStyleGroup, SWT.RADIO);
+ iconInformationButton.setText (resControls.getString("SWT_ICON_INFORMATION"));
+ iconQuestionButton = new Button (iconStyleGroup, SWT.RADIO);
+ iconQuestionButton.setText (resControls.getString("SWT_ICON_QUESTION"));
+ iconWarningButton = new Button (iconStyleGroup, SWT.RADIO);
+ iconWarningButton.setText (resControls.getString("SWT_ICON_WARNING"));
+ iconWorkingButton = new Button (iconStyleGroup, SWT.RADIO);
+ iconWorkingButton.setText (resControls.getString("SWT_ICON_WORKING"));
+
+ /* Create a group for the modal style controls */
+ Group modalStyleGroup = new Group (controlGroup, SWT.NULL);
+ modalStyleGroup.setLayout (new GridLayout ());
+ modalStyleGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ modalStyleGroup.setText (resControls.getString("Modal_Styles"));
+
+ /* Create the modal style buttons */
+ modelessButton = new Button (modalStyleGroup, SWT.RADIO);
+ modelessButton.setText (resControls.getString("SWT_MODELESS"));
+ primaryModalButton = new Button (modalStyleGroup, SWT.RADIO);
+ primaryModalButton.setText (resControls.getString("SWT_PRIMARY_MODAL"));
+ applicationModalButton = new Button (modalStyleGroup, SWT.RADIO);
+ applicationModalButton.setText (resControls.getString("SWT_APPLICATION_MODAL"));
+ systemModalButton = new Button (modalStyleGroup, SWT.RADIO);
+ systemModalButton.setText (resControls.getString("SWT_SYSTEM_MODAL"));
+
+ /* Create a group for the file dialog style controls */
+ Group fileDialogStyleGroup = new Group (controlGroup, SWT.NULL);
+ fileDialogStyleGroup.setLayout (new GridLayout ());
+ fileDialogStyleGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ fileDialogStyleGroup.setText (resControls.getString("File_Dialog_Styles"));
+
+ /* Create the file dialog style buttons */
+ saveButton = new Button (fileDialogStyleGroup, SWT.RADIO);
+ saveButton.setText (resControls.getString("SWT_SAVE"));
+ openButton = new Button(fileDialogStyleGroup, SWT.RADIO);
+ openButton.setText(resControls.getString("SWT_OPEN"));
+
+ /* Add the listeners */
+ dialogCombo.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ dialogSelected (event);
+ };
+ });
+ createButton.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ createButtonSelected (event);
+ };
+ });
+ SelectionListener buttonStyleListener = new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ buttonStyleSelected (event);
+ };
+ };
+ okButton.addSelectionListener (buttonStyleListener);
+ cancelButton.addSelectionListener (buttonStyleListener);
+ yesButton.addSelectionListener (buttonStyleListener);
+ noButton.addSelectionListener (buttonStyleListener);
+ retryButton.addSelectionListener (buttonStyleListener);
+ abortButton.addSelectionListener (buttonStyleListener);
+ ignoreButton.addSelectionListener (buttonStyleListener);
+
+ /* Set default values for style buttons */
+ okButton.setEnabled (false);
+ cancelButton.setEnabled (false);
+ yesButton.setEnabled (false);
+ noButton.setEnabled (false);
+ retryButton.setEnabled (false);
+ abortButton.setEnabled (false);
+ ignoreButton.setEnabled (false);
+ iconErrorButton.setEnabled (false);
+ iconInformationButton.setEnabled (false);
+ iconQuestionButton.setEnabled (false);
+ iconWarningButton.setEnabled (false);
+ iconWorkingButton.setEnabled (false);
+ saveButton.setEnabled (false);
+ openButton.setEnabled (false);
+ openButton.setSelection (true);
+ iconInformationButton.setSelection (true);
+ modelessButton.setSelection (true);
+}
+/**
+* Creates the "Example" group.
+*/
+void createExampleGroup () {
+ super.createExampleGroup ();
+
+ /*
+ * Create a group for the text widget to display
+ * the results returned by the example dialogs.
+ */
+ resultGroup = new Group (exampleGroup, SWT.NULL);
+ resultGroup.setLayout (new GridLayout ());
+ resultGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ resultGroup.setText (resControls.getString("Dialog_Result"));
+}
+/**
+* Creates the "Example" widgets.
+*/
+void createExampleWidgets () {
+ /*
+ * Create a multi lined, scrolled text widget for output.
+ */
+ textWidget = new Text(resultGroup, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ GridData gridData = new GridData ();
+ gridData.widthHint = 300;
+ gridData.heightHint = 400;
+ textWidget.setLayoutData (gridData);
+}
+/**
+* Handle a dialog type combo selection event.
+*
+* @param event the selection event
+*/
+void dialogSelected (SelectionEvent event) {
+
+ /* Enable/Disable the buttons */
+ String name = dialogCombo.getText ();
+ boolean isMessageBox = name.equals (resControls.getString("MessageBox"));
+ boolean isFileDialog = name.equals (resControls.getString("FileDialog"));
+ okButton.setEnabled (isMessageBox);
+ cancelButton.setEnabled (isMessageBox);
+ yesButton.setEnabled (isMessageBox);
+ noButton.setEnabled (isMessageBox);
+ retryButton.setEnabled (isMessageBox);
+ abortButton.setEnabled (isMessageBox);
+ ignoreButton.setEnabled (isMessageBox);
+ iconErrorButton.setEnabled (isMessageBox);
+ iconInformationButton.setEnabled (isMessageBox);
+ iconQuestionButton.setEnabled (isMessageBox);
+ iconWarningButton.setEnabled (isMessageBox);
+ iconWorkingButton.setEnabled (isMessageBox);
+ saveButton.setEnabled (isFileDialog);
+ openButton.setEnabled (isFileDialog);
+
+ /* Unselect the buttons */
+ if (!isMessageBox) {
+ okButton.setSelection (false);
+ cancelButton.setSelection (false);
+ yesButton.setSelection (false);
+ noButton.setSelection (false);
+ retryButton.setSelection (false);
+ abortButton.setSelection (false);
+ ignoreButton.setSelection (false);
+ }
+}
+/**
+* Gets the "Example" widget children.
+*/
+Control [] getExampleWidgets () {
+ return new Control [0];
+}
+/**
+* Gets the text for the tab folder item.
+*/
+String getTabText () {
+ return resControls.getString("Dialog");
+}
+}
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/Images.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/Images.java
new file mode 100755
index 0000000000..f68ef6d015
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/Images.java
@@ -0,0 +1,51 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.util.ResourceBundle;
+
+/**
+* <code>Images</code> contains every image
+* that is used by the example.
+*/
+class Images {
+ static Image CLOSED_FOLDER_IMAGE;
+ static Image OPEN_FOLDER_IMAGE;
+ static Image TARGET_IMAGE;
+ private static ResourceBundle resControl = ResourceBundle.getBundle("examples_control");
+/**
+* Free the images.
+*/
+public static void freeImages () {
+ CLOSED_FOLDER_IMAGE.dispose ();
+ OPEN_FOLDER_IMAGE.dispose ();
+ TARGET_IMAGE.dispose ();
+}
+/**
+ * Load the images.
+ */
+public static void loadImages () {
+ Class clazz = Images.class;
+ try {
+ ImageData source = new ImageData(clazz.getResourceAsStream ("folder.gif"));
+ ImageData mask = source.getTransparencyMask();
+ CLOSED_FOLDER_IMAGE = new Image (null, source, mask);
+
+ source = new ImageData(clazz.getResourceAsStream ("folderOpen.gif"));
+ mask = source.getTransparencyMask();
+ OPEN_FOLDER_IMAGE = new Image (null, source, mask);
+
+ source = new ImageData(clazz.getResourceAsStream ("stop.gif"));
+ mask = source.getTransparencyMask();
+ TARGET_IMAGE = new Image (null, source, mask);
+ } catch (Throwable ex) {
+ System.out.println (resControl.getString("Images_failed"));
+ }
+}
+}
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/LabelTab.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/LabelTab.java
new file mode 100755
index 0000000000..40093766c5
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/LabelTab.java
@@ -0,0 +1,153 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+
+class LabelTab extends AlignableTab {
+
+ /* Example widgets and groups that contain them */
+ Label label1, label2, label3, label4, label5, label6;
+ Group textLabelGroup, imageLabelGroup;
+
+ /* Style widgets added to the "Style" group */
+ Button separatorButton, horizontalButton, verticalButton, shadowInButton, shadowOutButton;
+/**
+* Creates the "Example" group.
+*/
+void createExampleGroup () {
+ super.createExampleGroup ();
+
+ /* Create a group for the text labels */
+ textLabelGroup = new Group(exampleGroup, SWT.NULL);
+ GridLayout gridLayout = new GridLayout ();
+ textLabelGroup.setLayout (gridLayout);
+ gridLayout.numColumns = 3;
+ textLabelGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ textLabelGroup.setText (resControls.getString("Text_Labels"));
+
+ /* Create a group for the image labels */
+ imageLabelGroup = new Group (exampleGroup, SWT.SHADOW_NONE);
+ gridLayout = new GridLayout ();
+ imageLabelGroup.setLayout (gridLayout);
+ gridLayout.numColumns = 3;
+ imageLabelGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ imageLabelGroup.setText (resControls.getString("Image_Labels"));
+}
+/**
+* Creates the "Example" widgets.
+*/
+void createExampleWidgets () {
+
+ /* Compute the widget style */
+ int style = SWT.NONE;
+ if (separatorButton.getSelection ()) style |= SWT.SEPARATOR;
+ if (horizontalButton.getSelection ()) style |= SWT.HORIZONTAL;
+ if (verticalButton.getSelection ()) style |= SWT.VERTICAL;
+ if (shadowInButton.getSelection ()) style |= SWT.SHADOW_IN;
+ if (shadowOutButton.getSelection ()) style |= SWT.SHADOW_OUT;
+ if (borderButton.getSelection ()) style |= SWT.BORDER;
+
+ /* Create the example widgets */
+ label1 = new Label (textLabelGroup, style);
+ label1.setText(resControls.getString("One"));
+ label2 = new Label (textLabelGroup, style);
+ label2.setText(resControls.getString("Two"));
+ label3 = new Label (textLabelGroup, style);
+ label3.setText (resControls.getString("Three"));
+ label4 = new Label (imageLabelGroup, style);
+ label4.setImage (Images.CLOSED_FOLDER_IMAGE);
+ label5 = new Label (imageLabelGroup, style);
+ label5.setImage (Images.OPEN_FOLDER_IMAGE);
+ label6 = new Label(imageLabelGroup, style);
+ label6.setImage (Images.TARGET_IMAGE);
+}
+/**
+* Creates the "Style" group.
+*/
+void createStyleGroup() {
+ super.createStyleGroup ();
+
+ /* Create the extra widgets */
+ separatorButton = new Button (styleGroup, SWT.CHECK);
+ separatorButton.setText (resControls.getString("SWT_SEPARATOR"));
+ horizontalButton = new Button (styleGroup, SWT.RADIO);
+ horizontalButton.setText (resControls.getString("SWT_HORIZONTAL"));
+ verticalButton = new Button (styleGroup, SWT.RADIO);
+ verticalButton.setText (resControls.getString("SWT_VERTICAL"));
+ Group styleSubGroup = new Group (styleGroup, SWT.NULL);
+ styleSubGroup.setLayout (new GridLayout ());
+ shadowInButton = new Button (styleSubGroup, SWT.RADIO);
+ shadowInButton.setText (resControls.getString("SWT_SHADOW_IN"));
+ shadowOutButton = new Button (styleSubGroup, SWT.RADIO);
+ shadowOutButton.setText (resControls.getString("SWT_SHADOW_OUT"));
+ borderButton = new Button(styleGroup, SWT.CHECK);
+ borderButton.setText(resControls.getString("SWT_BORDER"));
+
+ /* Add the listeners */
+ SelectionListener selectionListener = new SelectionAdapter () {
+ public void widgetSelected(SelectionEvent event) {
+ if ((event.widget.getStyle() & SWT.RADIO) != 0) {
+ if (!((Button) event.widget).getSelection ()) return;
+ }
+ recreateExampleWidgets ();
+ };
+ };
+ shadowInButton.addSelectionListener (selectionListener);
+ shadowOutButton.addSelectionListener (selectionListener);
+}
+/**
+* Gets the "Example" widget children.
+*/
+Control [] getExampleWidgets () {
+ return new Control [] {label1, label2, label3, label4, label5, label6};
+}
+/**
+* Gets the text for the tab folder item.
+*/
+String getTabText () {
+ return resControls.getString("Label");
+}
+/**
+* Sets the alignment of the "Example" widgets.
+*/
+void setExampleWidgetAlignment () {
+ int allignment = 0;
+ if (leftButton.getSelection ()) allignment = SWT.LEFT;
+ if (centerButton.getSelection ()) allignment = SWT.CENTER;
+ if (rightButton.getSelection ()) allignment = SWT.RIGHT;
+ label1.setAlignment (allignment);
+ label2.setAlignment (allignment);
+ label3.setAlignment (allignment);
+ label4.setAlignment (allignment);
+ label5.setAlignment (allignment);
+ label6.setAlignment (allignment);
+}
+/**
+* Sets the state of the "Example" widgets.
+*/
+void setExampleWidgetState () {
+ super.setExampleWidgetState ();
+ boolean isSeparator = (label1.getStyle () & SWT.SEPARATOR) != 0;
+ leftButton.setSelection (!isSeparator && (label1.getStyle () & SWT.LEFT) != 0);
+ centerButton.setSelection (!isSeparator && (label1.getStyle () & SWT.CENTER) != 0);
+ rightButton.setSelection (!isSeparator && (label1.getStyle () & SWT.RIGHT) != 0);
+ shadowInButton.setSelection (isSeparator && (label1.getStyle () & SWT.SHADOW_IN) != 0);
+ shadowOutButton.setSelection (isSeparator && (label1.getStyle () & SWT.SHADOW_OUT) != 0);
+ leftButton.setEnabled (!isSeparator);
+ centerButton.setEnabled (!isSeparator);
+ rightButton.setEnabled (!isSeparator);
+ shadowInButton.setEnabled (isSeparator);
+ shadowOutButton.setEnabled (isSeparator);
+ horizontalButton.setEnabled (isSeparator);
+ verticalButton.setEnabled (isSeparator);
+}
+}
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ListTab.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ListTab.java
new file mode 100755
index 0000000000..ff9a8aa892
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ListTab.java
@@ -0,0 +1,72 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+
+class ListTab extends ScrollableTab {
+
+ /* Example widgets and groups that contain them */
+ List list1;
+ Group listGroup;
+
+ static String [] ListData1 = {resControls.getString("ListData1_0"),
+ resControls.getString("ListData1_1"),
+ resControls.getString("ListData1_2"),
+ resControls.getString("ListData1_3"),
+ resControls.getString("ListData1_4"),
+ resControls.getString("ListData1_5"),
+ resControls.getString("ListData1_6"),
+ resControls.getString("ListData1_7"),
+ resControls.getString("ListData1_8")};
+
+/**
+* Creates the "Example" group.
+*/
+void createExampleGroup () {
+ super.createExampleGroup ();
+
+ /* Create a group for the list */
+ listGroup = new Group (exampleGroup, SWT.NULL);
+ listGroup.setLayout (new GridLayout ());
+ listGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ listGroup.setText (resControls.getString("List"));
+}
+/**
+* Creates the "Example" widgets.
+*/
+void createExampleWidgets () {
+
+ /* Compute the widget style */
+ int style = SWT.NONE;
+ if (singleButton.getSelection ()) style |= SWT.SINGLE;
+ if (multiButton.getSelection ()) style |= SWT.MULTI;
+ if (horizontalButton.getSelection ()) style |= SWT.H_SCROLL;
+ if (verticalButton.getSelection ()) style |= SWT.V_SCROLL;
+ if (borderButton.getSelection ()) style |= SWT.BORDER;
+
+ /* Create the example widgets */
+ list1 = new List (listGroup, style);
+ list1.setItems (ListData1);
+}
+/**
+* Gets the "Example" widget children.
+*/
+Control [] getExampleWidgets () {
+ return new Control [] {list1};
+}
+/**
+* Gets the text for the tab folder item.
+*/
+String getTabText () {
+ return resControls.getString("List");
+}
+}
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ProgressBarTab.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ProgressBarTab.java
new file mode 100755
index 0000000000..605a376ccf
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ProgressBarTab.java
@@ -0,0 +1,100 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+
+class ProgressBarTab extends RangeTab {
+
+ /* Example widgets and groups that contain them */
+ ProgressBar progressBar1;
+ Group progressBarGroup;
+
+ /* Style widgets added to the "Style" group */
+ Button smoothButton;
+/**
+* Creates the "Example" group.
+*/
+void createExampleGroup() {
+ super.createExampleGroup ();
+
+ /* Create a group for the progress bar */
+ progressBarGroup = new Group (exampleGroup, SWT.NULL);
+ progressBarGroup.setLayout (new GridLayout ());
+ progressBarGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ progressBarGroup.setText (resControls.getString("ProgressBar"));
+}
+/**
+* Creates the "Example" widgets.
+*/
+void createExampleWidgets () {
+
+ /* Compute the widget style */
+ int style = SWT.NONE;
+ if (horizontalButton.getSelection ()) style |= SWT.HORIZONTAL;
+ if (verticalButton.getSelection ()) style |= SWT.VERTICAL;
+ if (smoothButton.getSelection ()) style |= SWT.SMOOTH;
+ if (borderButton.getSelection ()) style |= SWT.BORDER;
+
+ /* Create the example widgets */
+ progressBar1 = new ProgressBar (progressBarGroup, style);
+ progressBar1.setMaximum (100);
+ progressBar1.setSelection (50);
+}
+/**
+* Creates the "Style" group.
+*/
+void createStyleGroup () {
+ super.createStyleGroup ();
+
+ /* Create the extra widgets */
+ smoothButton = new Button (styleGroup, SWT.CHECK);
+ smoothButton.setText (resControls.getString("SWT_SMOOTH"));
+}
+/**
+* Gets the "Example" widget children.
+*/
+Control [] getExampleWidgets () {
+ return new Control [] {progressBar1};
+}
+/**
+* Gets the text for the tab folder item.
+*/
+String getTabText () {
+ return resControls.getString("ProgressBar");
+}
+/**
+* Sets the state of the "Example" widgets.
+*/
+void setExampleWidgetState () {
+ super.setExampleWidgetState ();
+ maximumScale.setMaximum (progressBar1.getMaximum ());
+ smoothButton.setSelection ((progressBar1.getStyle () & SWT.SMOOTH) != 0);
+}
+/**
+* Sets the maximum of the "Example" widgets.
+*/
+void setWidgetMaximum () {
+ progressBar1.setMaximum (maximumScale.getSelection ());
+}
+/**
+* Sets the minimim of the "Example" widgets.
+*/
+void setWidgetMinimum () {
+ progressBar1.setMinimum (minimumScale.getSelection ());
+}
+/**
+* Sets the selection of the "Example" widgets.
+*/
+void setWidgetSelection () {
+ progressBar1.setSelection (selectionScale.getSelection ());
+}
+}
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/RangeTab.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/RangeTab.java
new file mode 100755
index 0000000000..4f6575be62
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/RangeTab.java
@@ -0,0 +1,155 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+
+abstract class RangeTab extends Tab {
+
+ /* Style widgets added to the "Style" group */
+ Button horizontalButton, verticalButton;
+
+ /* Scale widgets added to the "Control" group */
+ Scale minimumScale, selectionScale, maximumScale;
+
+/**
+* Creates the "Control" widget children.
+*/
+void createControlWidgets () {
+
+ /* Leave an empty cell */
+ new Composite (controlGroup, SWT.NULL);
+
+ /* Create controls specific to this example */
+ createMinimumGroup ();
+ createMaximumGroup ();
+ createSelectionGroup ();
+}
+/**
+* Create a group of widgets to control the maximum
+* attribute of the example widget.
+*/
+void createMaximumGroup() {
+
+ /* Create the group */
+ Group maximumGroup = new Group (controlGroup, SWT.NULL);
+ maximumGroup.setLayout (new GridLayout ());
+ maximumGroup.setText (resControls.getString("Maximum"));
+
+ /* Create a scale widget */
+ maximumScale = new Scale (maximumGroup, SWT.NULL);
+ maximumScale.setMaximum (100);
+ maximumScale.setSelection (100);
+ maximumScale.setPageIncrement (10);
+ maximumScale.setIncrement (5);
+
+ /* Add the listeners */
+ maximumScale.addSelectionListener(new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ setWidgetMaximum ();
+ };
+ });
+}
+/**
+* Create a group of widgets to control the minimum
+* attribute of the example widget.
+*/
+void createMinimumGroup() {
+
+ /* Create the group */
+ Group minimumGroup = new Group (controlGroup, SWT.NULL);
+ minimumGroup.setLayout (new GridLayout ());
+ minimumGroup.setText (resControls.getString("Minimum"));
+
+ /* Create a scale widget */
+ minimumScale = new Scale (minimumGroup, SWT.NULL);
+ minimumScale.setMaximum (100);
+ minimumScale.setPageIncrement (10);
+ minimumScale.setIncrement (5);
+
+ /* Add the listeners */
+ minimumScale.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ setWidgetMinimum ();
+ };
+ });
+
+}
+/**
+* Create a group of widgets to control the selection
+* attribute of the example widget.
+*/
+void createSelectionGroup() {
+
+ /* Create the group */
+ Group selectionGroup = new Group(controlGroup, SWT.NULL);
+ selectionGroup.setLayout(new GridLayout());
+ GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
+ gridData.horizontalSpan = 2;
+ selectionGroup.setLayoutData(gridData);
+ selectionGroup.setText(resControls.getString("Selection"));
+
+ /* Create a scale widget */
+ selectionScale = new Scale (selectionGroup, SWT.NULL);
+ selectionScale.setMaximum (100);
+ selectionScale.setSelection (50);
+ selectionScale.setPageIncrement (10);
+ selectionScale.setIncrement (5);
+
+ /* Add the listeners */
+ selectionScale.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ setWidgetSelection ();
+ };
+ });
+
+}
+/**
+* Creates the "Style" group.
+*/
+void createStyleGroup () {
+ super.createStyleGroup ();
+
+ /* Create the extra widgets */
+ horizontalButton = new Button (styleGroup, SWT.RADIO);
+ horizontalButton.setText (resControls.getString("SWT_HORIZONTAL"));
+ verticalButton = new Button (styleGroup, SWT.RADIO);
+ verticalButton.setText (resControls.getString("SWT_VERTICAL"));
+ borderButton = new Button (styleGroup, SWT.CHECK);
+ borderButton.setText (resControls.getString("SWT_BORDER"));
+}
+/**
+* Sets the state of the "Example" widgets.
+*/
+void setExampleWidgetState () {
+ super.setExampleWidgetState ();
+ setWidgetMinimum ();
+ setWidgetMaximum ();
+ setWidgetSelection ();
+ Control [] controls = getExampleWidgets ();
+ if (controls.length != 0){
+ horizontalButton.setSelection ((controls [0].getStyle () & SWT.HORIZONTAL) != 0);
+ verticalButton.setSelection ((controls [0].getStyle () & SWT.VERTICAL) != 0);
+ borderButton.setSelection ((controls [0].getStyle () & SWT.BORDER) != 0);
+ }
+}
+/**
+* Sets the maximum of the "Example" widgets.
+*/
+abstract void setWidgetMaximum ();
+/**
+* Sets the minimim of the "Example" widgets.
+*/
+abstract void setWidgetMinimum ();
+/**
+* Sets the selection of the "Example" widgets.
+*/
+abstract void setWidgetSelection ();
+}
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/SashTab.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/SashTab.java
new file mode 100755
index 0000000000..2b23b9a4e7
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/SashTab.java
@@ -0,0 +1,156 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+
+class SashTab extends Tab {
+
+ /* Example widgets and groups that contain them */
+ Sash hSash, vSash;
+ List list1, list2, list3;
+ Text text;
+
+ static String [] ListData0 = {resControls.getString("ListData0_0"),
+ resControls.getString("ListData0_1"),
+ resControls.getString("ListData0_2"),
+ resControls.getString("ListData0_3"),
+ resControls.getString("ListData0_4"),
+ resControls.getString("ListData0_5"),
+ resControls.getString("ListData0_6"),
+ resControls.getString("ListData0_7"),
+ resControls.getString("ListData0_8")};
+
+ static String [] ListData1 = {resControls.getString("ListData1_0"),
+ resControls.getString("ListData1_1"),
+ resControls.getString("ListData1_2"),
+ resControls.getString("ListData1_3"),
+ resControls.getString("ListData1_4"),
+ resControls.getString("ListData1_5"),
+ resControls.getString("ListData1_6"),
+ resControls.getString("ListData1_7"),
+ resControls.getString("ListData1_8")};
+
+ /* Constants */
+ static final int SASH_WIDTH = 3;
+/**
+* Creates the tab folder page.
+*/
+Composite createTabFolderPage (TabFolder tabFolder) {
+ /*
+ * Create the page. This example does not use layouts.
+ */
+ tabFolderPage = new Composite(tabFolder, SWT.BORDER);
+
+ /* Create the list and text widgets */
+ list1 = new List (tabFolderPage, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
+ list1.setItems (ListData0);
+ list2 = new List (tabFolderPage, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
+ list2.setItems (ListData1);
+ text = new Text (tabFolderPage, SWT.MULTI | SWT.BORDER);
+ text.setText (resControls.getString("Multi_line"));
+
+ /* Create the sashes */
+ vSash = new Sash (tabFolderPage, SWT.VERTICAL);
+ hSash = new Sash (tabFolderPage, SWT.HORIZONTAL);
+
+ /* Add the listeners */
+ hSash.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ if (event.detail != SWT.DRAG) {
+ hSash.setBounds (event.x, event.y, event.width, event.height);
+ layout ();
+ }
+ }
+ });
+ vSash.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ if (event.detail != SWT.DRAG) {
+ vSash.setBounds(event.x, event.y, event.width, event.height);
+ layout ();
+ }
+ }
+ });
+ tabFolderPage.addControlListener (new ControlAdapter () {
+ public void controlResized (ControlEvent event) {
+ shellResized ();
+ }
+ });
+
+ /*
+ * Do not set the bounds of the lists, text and sashes here
+ * because this method is run before the widget is opened
+ * so we do not know how big the tabComposite is going to be.
+ * When the widget is opened a resize event will occur
+ * and the contained widgets can be sized accordingly.
+ */
+ return tabFolderPage;
+}
+/**
+* Gets the text for the tab folder item.
+*/
+String getTabText () {
+ return resControls.getString("Sash");
+}
+/**
+* Layout the list and text widgets according to the new
+* positions of the sashes..events.SelectionEvent
+*/
+void layout () {
+
+ Rectangle tabCompositeBounds = tabFolderPage.getClientArea ();
+ Rectangle hSashBounds = hSash.getBounds ();
+ Rectangle vSashBounds = vSash.getBounds ();
+
+ list1.setBounds (0, 0, vSashBounds.x, hSashBounds.y);
+ list2.setBounds (vSashBounds.x + vSashBounds.width, 0, tabCompositeBounds.width - (vSashBounds.x + vSashBounds.width), hSashBounds.y);
+ text.setBounds (0, hSashBounds.y + hSashBounds.height, tabCompositeBounds.width, tabCompositeBounds.height - (hSashBounds.y + hSashBounds.height));
+
+ /**
+ * If the horizontal sash has been moved then the vertical
+ * sash is either too long or too short and its size must
+ * be adjusted.
+ */
+ vSashBounds.height = hSashBounds.y;
+ vSash.setBounds (vSashBounds);
+}
+/**
+* Handle the shell resized event.
+*/
+void shellResized () {
+
+ /* Get the client area for the shell */
+ Rectangle tabFolderPageBounds = tabFolderPage.getClientArea ();
+
+ /*
+ * Make list 1 half the width and half the height of the tab leaving room for the sash.
+ * Place list 1 in the top left quadrant of the tab.
+ */
+ Rectangle list1Bounds = new Rectangle (0, 0, (tabFolderPageBounds.width - SASH_WIDTH) / 2, (tabFolderPageBounds.height - SASH_WIDTH) / 2);
+ list1.setBounds (list1Bounds);
+
+ /*
+ * Make list 2 half the width and half the height of the tab leaving room for the sash.
+ * Place list 2 in the top right quadrant of the tab.
+ */
+ list2.setBounds (list1Bounds.width + SASH_WIDTH, 0, tabFolderPageBounds.width - (list1Bounds.width + SASH_WIDTH), list1Bounds.height);
+
+ /*
+ * Make the text area the full width and half the height of the tab leaving room for the sash.
+ * Place the text area in the bottom half of the tab.
+ */
+ text.setBounds (0, list1Bounds.height + SASH_WIDTH, tabFolderPageBounds.width, tabFolderPageBounds.height - (list1Bounds.height + SASH_WIDTH));
+
+ /* Position the sashes */
+ vSash.setBounds (list1Bounds.width, 0, SASH_WIDTH, list1Bounds.height);
+ hSash.setBounds (0, list1Bounds.height, tabFolderPageBounds.width, SASH_WIDTH);
+}
+}
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ScrollableTab.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ScrollableTab.java
new file mode 100755
index 0000000000..181c6a448e
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ScrollableTab.java
@@ -0,0 +1,48 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+
+abstract class ScrollableTab extends Tab {
+
+ /* Style widgets added to the "Style" group */
+ Button singleButton, multiButton, horizontalButton, verticalButton, borderButton;
+/**
+* Creates the "Style" group.
+*/
+void createStyleGroup () {
+ super.createStyleGroup ();
+
+ /* Create the extra widgets */
+ singleButton = new Button (styleGroup, SWT.RADIO);
+ singleButton.setText (resControls.getString("SWT_SINGLE"));
+ multiButton = new Button (styleGroup, SWT.RADIO);
+ multiButton.setText (resControls.getString("SWT_MULTI"));
+ horizontalButton = new Button (styleGroup, SWT.CHECK);
+ horizontalButton.setText (resControls.getString("SWT_H_SCROLL"));
+ verticalButton = new Button (styleGroup, SWT.CHECK);
+ verticalButton.setText (resControls.getString("SWT_V_SCROLL"));
+ borderButton = new Button (styleGroup, SWT.CHECK);
+ borderButton.setText (resControls.getString("SWT_BORDER"));
+}
+/**
+* Sets the state of the "Example" widgets.
+*/
+void setExampleWidgetState () {
+ super.setExampleWidgetState ();
+ Control [] controls = getExampleWidgets ();
+ if (controls.length != 0){
+ singleButton.setSelection ((controls [0].getStyle () & SWT.SINGLE) != 0);
+ multiButton.setSelection ((controls [0].getStyle () & SWT.MULTI) != 0);
+ horizontalButton.setSelection ((controls [0].getStyle () & SWT.H_SCROLL) != 0);
+ verticalButton.setSelection ((controls [0].getStyle () & SWT.V_SCROLL) != 0);
+ borderButton.setSelection ((controls [0].getStyle () & SWT.BORDER) != 0);
+ }
+}
+}
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ShellTab.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ShellTab.java
new file mode 100755
index 0000000000..31f8d13beb
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ShellTab.java
@@ -0,0 +1,213 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+
+class ShellTab extends Tab {
+
+ /* Style widgets added to the "Style" group */
+ Button noParentButton, parentButton;
+ Button noTrimButton, closeButton, titleButton, minButton, maxButton, borderButton, resizeButton;
+ Button createButton, closeAllButton;
+ Group parentStyleGroup;
+
+ /* Variables used to track the open shells */
+ int shellCount = 0;
+ Shell [] shells = new Shell [4];
+/**
+* Close all the example shells.
+*/
+void closeAllShells() {
+ for (int i = 0; i<shellCount; i++) {
+ if (shells[i] != null & !shells [i].isDisposed ()) {
+ shells [i].dispose();
+ }
+ }
+ shellCount = 0;
+}
+/**
+* Handle the Create button selection event.
+*
+* @param event org.eclipse.swt.events.SelectionEvent
+*/
+public void createButtonSelected(SelectionEvent event) {
+
+ /*
+ * Remember the example shells so they
+ * can be disposed by the user.
+ */
+ if (shellCount >= shells.length) {
+ Shell [] newShells = new Shell [shells.length + 4];
+ System.arraycopy (shells, 0, newShells, 0, shells.length);
+ shells = newShells;
+ }
+
+ /* Compute the shell style */
+ int style = SWT.NONE;
+ if (noTrimButton.getSelection()) style |= SWT.NO_TRIM;
+ if (closeButton.getSelection()) style |= SWT.CLOSE;
+ if (titleButton.getSelection()) style |= SWT.TITLE;
+ if (minButton.getSelection()) style |= SWT.MIN;
+ if (maxButton.getSelection()) style |= SWT.MAX;
+ if (borderButton.getSelection()) style |= SWT.BORDER;
+ if (resizeButton.getSelection()) style |= SWT.RESIZE;
+
+ /* Create the shell with or without a parent */
+ if (noParentButton.getSelection ()) {
+ shells [shellCount] = new Shell (style);
+ } else {
+ Shell shell = tabFolderPage.getShell ();
+ shells [shellCount] = new Shell (shell, style);
+ }
+
+ /* Set the size, title and open the shell */
+ shells [shellCount].setSize (300, 100);
+ shells [shellCount].setText (resControls.getString("Title") + shellCount);
+ shells [shellCount++].open ();
+}
+/**
+* Creates the "Control" group.
+*/
+void createControlGroup () {
+ /*
+ * Create the "Control" group. This is the group on the
+ * left half of each example tab. It consists of the
+ * style group, the display group and the size group.
+ */
+ controlGroup = new Group (tabFolderPage, SWT.NULL);
+ GridLayout gridLayout= new GridLayout ();
+ controlGroup.setLayout (gridLayout);
+ gridLayout.numColumns = 1;
+ gridLayout.makeColumnsEqualWidth = true;
+ controlGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ controlGroup.setText (resControls.getString("Parameters"));
+
+ /* Create individual groups inside the "Control" group */
+ styleGroup = new Group (controlGroup, SWT.NULL);
+ gridLayout = new GridLayout ();
+ styleGroup.setLayout (gridLayout);
+ gridLayout.numColumns = 2;
+ styleGroup.setLayoutData (new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ styleGroup.setText (resControls.getString("Styles"));
+
+ /* Create a group for the parent sytle controls */
+ parentStyleGroup = new Group (styleGroup, SWT.NULL);
+ parentStyleGroup.setLayout (new GridLayout ());
+ GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
+ gridData.horizontalSpan = 2;
+ parentStyleGroup.setLayoutData (gridData);
+ parentStyleGroup.setText (resControls.getString("Parent"));
+}
+/**
+* Creates the "Control" widget children.
+*/
+void createControlWidgets () {
+
+ /* Create the parent style buttons */
+ noParentButton = new Button (parentStyleGroup, SWT.RADIO);
+ noParentButton.setText (resControls.getString("No_Parent"));
+ parentButton = new Button (parentStyleGroup, SWT.RADIO);
+ parentButton.setText (resControls.getString("Parent"));
+
+ /* Create a group for the decoration style controls */
+ Group decorationStyleGroup = new Group(styleGroup, SWT.NULL);
+ decorationStyleGroup.setLayout (new GridLayout ());
+ GridData gridData = new GridData (GridData.HORIZONTAL_ALIGN_CENTER);
+ gridData.horizontalSpan = 2;
+ decorationStyleGroup.setLayoutData (gridData);
+ decorationStyleGroup.setText (resControls.getString("Decoration_Styles"));
+
+ /* Create the decoration style buttons */
+ noTrimButton = new Button (decorationStyleGroup, SWT.CHECK);
+ noTrimButton.setText (resControls.getString("SWT_NO_TRIM"));
+ closeButton = new Button (decorationStyleGroup, SWT.CHECK);
+ closeButton.setText (resControls.getString("SWT_CLOSE"));
+ titleButton = new Button (decorationStyleGroup, SWT.CHECK);
+ titleButton.setText (resControls.getString("SWT_TITLE"));
+ minButton = new Button (decorationStyleGroup, SWT.CHECK);
+ minButton.setText (resControls.getString("SWT_MIN"));
+ maxButton = new Button (decorationStyleGroup, SWT.CHECK);
+ maxButton.setText (resControls.getString("SWT_MAX"));
+ borderButton = new Button (decorationStyleGroup, SWT.CHECK);
+ borderButton.setText (resControls.getString("SWT_BORDER"));
+ resizeButton = new Button (decorationStyleGroup, SWT.CHECK);
+ resizeButton.setText (resControls.getString("SWT_RESIZE"));
+
+ /* Create the "create" and "closeAll" buttons */
+ createButton = new Button (styleGroup, SWT.NULL);
+ gridData = new GridData (GridData.HORIZONTAL_ALIGN_CENTER);
+ createButton.setLayoutData (gridData);
+ createButton.setText (resControls.getString("Create_Shell"));
+ closeAllButton = new Button (styleGroup, SWT.NULL);
+ closeAllButton.setText (resControls.getString("Close_All_Shells"));
+ closeAllButton.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_CENTER));
+
+ /* Add the listeners */
+ createButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ createButtonSelected(e);
+ };
+ });
+ closeAllButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ closeAllShells ();
+ };
+ });
+ SelectionListener decorationButtonListener = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ decorationButtonSelected(event);
+ };
+ };
+ noTrimButton.addSelectionListener (decorationButtonListener);
+ closeButton.addSelectionListener (decorationButtonListener);
+ titleButton.addSelectionListener (decorationButtonListener);
+ minButton.addSelectionListener (decorationButtonListener);
+ maxButton.addSelectionListener (decorationButtonListener);
+ borderButton.addSelectionListener (decorationButtonListener);
+ resizeButton.addSelectionListener (decorationButtonListener);
+
+ /* Set the default state */
+ noParentButton.setSelection (true);
+}
+/**
+* Handle a decoration button selection event.
+*
+* @param event org.eclipse.swt.events.SelectionEvent
+*/
+public void decorationButtonSelected(SelectionEvent event) {
+
+ /*
+ * Make sure if the No Trim button is selected then
+ * all other decoration buttons are deselected.
+ */
+ Button widget = (Button) event.widget;
+ if (widget.getSelection() && widget != noTrimButton) {
+ noTrimButton.setSelection (false);
+ return;
+ }
+ if (widget.getSelection() && widget == noTrimButton) {
+ closeButton.setSelection (false);
+ titleButton.setSelection (false);
+ minButton.setSelection (false);
+ maxButton.setSelection (false);
+ borderButton.setSelection (false);
+ resizeButton.setSelection (false);
+ return;
+ }
+}
+/**
+* Gets the text for the tab folder item.
+*/
+String getTabText () {
+ return resControls.getString("Shell");
+}
+}
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/SliderTab.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/SliderTab.java
new file mode 100755
index 0000000000..b71874ec62
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/SliderTab.java
@@ -0,0 +1,213 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+
+class SliderTab extends RangeTab {
+
+ /* Example widgets and groups that contain them */
+ Scale scale1;
+ Slider slider1;
+ Group sliderGroup, scaleGroup;
+
+ /* Scale widgets added to the "Control" group */
+ Scale incrementScale, pageIncrementScale, thumbScale;
+/**
+* Creates the "Control" widget children.
+*/
+void createControlWidgets () {
+ super.createControlWidgets ();
+ createThumbGroup ();
+ createIncrementGroup ();
+ createPageIncrementGroup ();
+}
+/**
+* Creates the "Example" group.
+*/
+void createExampleGroup () {
+ super.createExampleGroup ();
+
+ /* Create a group for the slider */
+ sliderGroup = new Group (exampleGroup, SWT.NULL);
+ sliderGroup.setLayout (new GridLayout ());
+ sliderGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ sliderGroup.setText (resControls.getString("Slider"));
+
+ /* Create a group for the scale */
+ scaleGroup = new Group (exampleGroup, SWT.NULL);
+ scaleGroup.setLayout (new GridLayout ());
+ scaleGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ scaleGroup.setText (resControls.getString("Scale"));
+
+}
+/**
+* Creates the "Example" widgets.
+*/
+void createExampleWidgets () {
+
+ /* Compute the widget style */
+ int style = SWT.NONE;
+ if (horizontalButton.getSelection ()) style |= SWT.HORIZONTAL;
+ if (verticalButton.getSelection ()) style |= SWT.VERTICAL;
+ if (borderButton.getSelection ()) style |= SWT.BORDER;
+
+ /* Create the example widgets */
+ scale1 = new Scale (scaleGroup, style);
+ scale1.setMaximum (100);
+ scale1.setSelection (50);
+ scale1.setIncrement (5);
+ scale1.setPageIncrement (10);
+ slider1 = new Slider(sliderGroup, style);
+ slider1.setMaximum (100);
+ slider1.setSelection (50);
+ slider1.setIncrement(5);
+ slider1.setPageIncrement (10);
+ slider1.setThumb (10);
+}
+/**
+* Create a group of widgets to control the increment
+* attribute of the example widget.
+*/
+void createIncrementGroup() {
+
+ /* Create the group */
+ Group incrementGroup = new Group (controlGroup, SWT.NULL);
+ incrementGroup.setLayout (new GridLayout ());
+ incrementGroup.setText (resControls.getString("Increment"));
+
+ /* Create the scale widget */
+ incrementScale = new Scale (incrementGroup, SWT.NULL);
+ incrementScale.setMaximum (100);
+ incrementScale.setSelection (5);
+ incrementScale.setPageIncrement (10);
+ incrementScale.setIncrement (5);
+
+ /* Add the listeners */
+ incrementScale.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent e) {
+ setWidgetIncrement ();
+ };
+ });
+}
+/**
+* Create a group of widgets to control the page increment
+* attribute of the example widget.
+*/
+void createPageIncrementGroup() {
+
+ /* Create the group */
+ Group pageIncrementGroup = new Group (controlGroup, SWT.NULL);
+ pageIncrementGroup.setLayout (new GridLayout ());
+ pageIncrementGroup.setText (resControls.getString("Page_Increment"));
+
+ /* Create the scale widget */
+ pageIncrementScale = new Scale (pageIncrementGroup, SWT.NULL);
+ pageIncrementScale.setMaximum (100);
+ pageIncrementScale.setSelection (10);
+ pageIncrementScale.setPageIncrement (10);
+ pageIncrementScale.setIncrement (5);
+
+ /* Add the listeners */
+ pageIncrementScale.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ setWidgetIncrement ();
+ }
+ });
+}
+/**
+* Create a group of widgets to control the thumb
+* attribute of the example widget.
+*/
+void createThumbGroup() {
+
+ /* Create the group */
+ Group thumbGroup = new Group (controlGroup, SWT.NULL);
+ thumbGroup.setLayout (new GridLayout ());
+ thumbGroup.setText (resControls.getString("Thumb"));
+
+ /* Create the scale widget */
+ thumbScale = new Scale (thumbGroup, SWT.NULL);
+ thumbScale.setMaximum (100);
+ thumbScale.setSelection (10);
+ thumbScale.setPageIncrement (10);
+ thumbScale.setIncrement (5);
+
+ /* Add the listeners */
+ thumbScale.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ setWidgetThumb ();
+ };
+ });
+}
+/**
+* Gets the "Example" widget children.
+*/
+Control [] getExampleWidgets () {
+ return new Control [] {scale1, slider1};
+}
+/**
+* Gets the text for the tab folder item.
+*/
+String getTabText () {
+ return resControls.getString("Slider_and_Scale");
+}
+/**
+* Sets the state of the "Example" widgets.
+*/
+void setExampleWidgetState () {
+ super.setExampleWidgetState ();
+ setWidgetIncrement ();
+ setWidgetPageIncrement ();
+ setWidgetThumb ();
+}
+/**
+* Sets the increment of the "Example" widgets.
+*/
+void setWidgetIncrement () {
+ slider1.setIncrement (incrementScale.getSelection ());
+ scale1.setIncrement (incrementScale.getSelection ());
+}
+/**
+* Sets the minimim of the "Example" widgets.
+*/
+void setWidgetMaximum () {
+ slider1.setMaximum (maximumScale.getSelection ());
+ scale1.setMaximum (maximumScale.getSelection ());
+}
+/**
+* Sets the minimim of the "Example" widgets.
+*/
+void setWidgetMinimum () {
+ slider1.setMinimum (minimumScale.getSelection ());
+ scale1.setMinimum (minimumScale.getSelection ());
+}
+/**
+* Sets the page increment of the "Example" widgets.
+*/
+void setWidgetPageIncrement () {
+ slider1.setPageIncrement (pageIncrementScale.getSelection ());
+ scale1.setPageIncrement (pageIncrementScale.getSelection ());
+}
+/**
+* Sets the selection of the "Example" widgets.
+*/
+void setWidgetSelection () {
+ slider1.setSelection (selectionScale.getSelection ());
+ scale1.setSelection (selectionScale.getSelection ());
+}
+/**
+* Sets the thumb of the "Example" widgets.
+*/
+void setWidgetThumb () {
+ slider1.setThumb (thumbScale.getSelection ());
+}
+}
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/Tab.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/Tab.java
new file mode 100755
index 0000000000..fdd1e94aac
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/Tab.java
@@ -0,0 +1,357 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+/* Imports */
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+import java.util.ResourceBundle;
+
+/**
+* <code>Tab</code> is the abstract superclass of every page
+* in the example's tab folder. Each page in the tab folder
+* describes a control.
+*
+* A Tab itself is not a control but instead provides a
+* hierarchy with which to share code that is common to
+* every page in the folder.
+*
+* A typical page in a Tab contains a two column composite.
+* The left column contains the "Example" group. The right
+* column contains "Control" group. The "Control" group
+* contains controls that allow the user to interact with
+* the example control. The "Control" group typically
+* contains a "Style", "Display" and "Size" group. Subclasses
+* can override these defaults to augment a group or stop
+* a group from being created.
+*/
+
+/* Class Definition */
+abstract class Tab {
+
+ protected static ResourceBundle resControls = ResourceBundle.getBundle("examples_control");
+
+ /* Common control buttons */
+ Button borderButton, enabledButton, visibleButton;
+ Button preferredButton, tooSmallButton, smallButton, largeButton;
+
+ /* Common groups and composites */
+ Composite tabFolderPage;
+ Group exampleGroup, controlGroup, displayGroup, sizeGroup, styleGroup;
+
+ /* Sizing constants for the "Size" group */
+ static final int TOO_SMALL_SIZE = 10;
+ static final int SMALL_SIZE = 50;
+ static final int LARGE_SIZE = 100;
+/**
+* Creates the "Control" group. The "Control" group
+* is typically the right hand column in the tab.
+*/
+void createControlGroup () {
+
+ /*
+ * Create the "Control" group. This is the group on the
+ * left half of each example tab. It consists of the
+ * style group, the display group and the size group.
+ */
+ controlGroup = new Group (tabFolderPage, SWT.NONE);
+ GridLayout gridLayout= new GridLayout ();
+ controlGroup.setLayout (gridLayout);
+ gridLayout.numColumns = 2;
+ gridLayout.makeColumnsEqualWidth = true;
+ controlGroup.setLayoutData (new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ controlGroup.setText (resControls.getString("Parameters"));
+
+ /* Create individual groups inside the "Control" group */
+ createStyleGroup ();
+ createDisplayGroup ();
+ createSizeGroup ();
+
+ /*
+ * For each Button child in the style group, add a selection
+ * listener that will recreate the example controls. If the
+ * style group button is a RADIO button, ensure that the radio
+ * button is selected before recreating the example controls.
+ * When the user selects a RADIO button, the curreont RADIO
+ * button in the group is deselected and the new RADIO button
+ * is selected automatically. The listeners are notified for
+ * both these operations but typically only do work when a RADIO
+ * button is selected.
+ */
+ SelectionListener selectionListener = new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ if ((event.widget.getStyle () & SWT.RADIO) != 0) {
+ if (!((Button) event.widget).getSelection ()) return;
+ }
+ recreateExampleWidgets ();
+ };
+ };
+ Control [] children = styleGroup.getChildren ();
+ for (int i=0; i<children.length; i++) {
+ if (children [i] instanceof Button) {
+ Button button = (Button) children [i];
+ button.addSelectionListener (selectionListener);
+ }
+ }
+}
+/**
+* Creates the "Control" widget children.
+* Subclasses override this method to augment
+* the standard controls created in the "Style",
+* "Display" and "Size" groups.
+*/
+void createControlWidgets () {
+}
+/**
+* Creates the "Display" group. This is typically
+* a child of the "Control" group.
+*/
+void createDisplayGroup () {
+
+ /* Create the group */
+ displayGroup = new Group (controlGroup, SWT.NONE);
+ displayGroup.setLayout (new GridLayout ());
+ displayGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ displayGroup.setText (resControls.getString("State"));
+
+ /* Create the controls */
+ enabledButton = new Button(displayGroup, SWT.CHECK);
+ enabledButton.setText(resControls.getString("Enabled"));
+ visibleButton = new Button(displayGroup, SWT.CHECK);
+ visibleButton.setText(resControls.getString("Visible"));
+
+ /* Add the listeners */
+ enabledButton.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ setExampleWidgetEnabled ();
+ }
+ });
+ visibleButton.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ setExampleWidgetVisibility ();
+ }
+ });
+
+ /* Set the default state */
+ enabledButton.setSelection(true);
+ visibleButton.setSelection(true);
+}
+/**
+* Creates the "Example" group. The "Example" group
+* is typically the left hand column in the tab.
+*/
+void createExampleGroup () {
+ /*
+ * Create the example group. This is the
+ * group on the right half of each example
+ * tab.
+ */
+ exampleGroup = new Group (tabFolderPage, SWT.NONE);
+ GridLayout gridLayout = new GridLayout ();
+ exampleGroup.setLayout (gridLayout);
+ exampleGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+}
+/**
+* Creates the "Example" widget children of the "Example" group.
+* Subclasses override this method to create the particular
+* example control.
+*/
+void createExampleWidgets () {
+ /* Do nothing */
+}
+/**
+* Creates the "Size" group. The "Size" group contains
+* controls that allow the user to change the size of
+* the example widgets.
+*/
+void createSizeGroup () {
+
+ /* Create the group */
+ sizeGroup = new Group (controlGroup, SWT.NONE);
+ sizeGroup.setLayout (new GridLayout());
+ sizeGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ sizeGroup.setText (resControls.getString("Size"));
+
+ /* Create the controls */
+
+ /*
+ * The preferred size of a widget is the size returned
+ * by widget.computeSize (SWT.DEFAULT, SWT.DEFAULT).
+ * This size is defined on a widget by widget basis.
+ * Many widgets will attempt to display their contents.
+ */
+ preferredButton = new Button (sizeGroup, SWT.RADIO);
+ preferredButton.setText (resControls.getString("Preferred"));
+ tooSmallButton = new Button (sizeGroup, SWT.RADIO);
+ tooSmallButton.setText (TOO_SMALL_SIZE + " X " + TOO_SMALL_SIZE);
+ smallButton = new Button(sizeGroup, SWT.RADIO);
+ smallButton.setText (SMALL_SIZE + " X " + SMALL_SIZE);
+ largeButton = new Button (sizeGroup, SWT.RADIO);
+ largeButton.setText (LARGE_SIZE + " X " + LARGE_SIZE);
+
+ /* Add the listeners */
+ SelectionAdapter selectionListener = new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ if (!((Button) event.widget).getSelection ()) return;
+ setExampleWidgetSize ();
+ };
+ };
+ preferredButton.addSelectionListener(selectionListener);
+ tooSmallButton.addSelectionListener(selectionListener);
+ smallButton.addSelectionListener(selectionListener);
+ largeButton.addSelectionListener(selectionListener);
+
+ /* Set the default state */
+ preferredButton.setSelection (true);
+}
+/**
+* Creates the "Style" group. The "Style" group contains
+* controls that allow the user to change the style of
+* the example widgets. Changing a widget "Style" causes
+* the widget to be destroyed and recreated.
+*/
+void createStyleGroup () {
+ styleGroup = new Group (controlGroup, SWT.NONE);
+ styleGroup.setLayout (new GridLayout ());
+ styleGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ styleGroup.setText (resControls.getString("Styles"));
+}
+/**
+* Creates the tab folder page.
+*
+* @param tabFolder org.eclipse.swt.widgets.TabFolder
+* @return the new page for the tab folder
+*/
+Composite createTabFolderPage (TabFolder tabFolder) {
+ /*
+ * Create a two column page.
+ */
+ tabFolderPage = new Composite (tabFolder, SWT.NULL);
+ GridLayout gridLayout = new GridLayout ();
+ tabFolderPage.setLayout (gridLayout);
+ gridLayout.numColumns = 2;
+
+ /* Create the "Example" and "Control" columns */
+ createExampleGroup ();
+ createControlGroup ();
+
+ /* Create the widgets in the two columns */
+ createExampleWidgets ();
+ createControlWidgets ();
+ setExampleWidgetState ();
+
+ return tabFolderPage;
+}
+/**
+* Disposes the "Example" widgets.
+*/
+void disposeExampleWidgets () {
+ Control [] controls = getExampleWidgets ();
+ for (int i=0; i<controls.length; i++) {
+ controls [i].dispose ();
+ }
+}
+/**
+* Gets the "Example" widget children.
+*
+* @return an array of example widget children
+*/
+Control [] getExampleWidgets () {
+ return new Control [0];
+}
+/**
+* Gets the text for the tab folder item.
+*
+* @return the text for the tab item
+*/
+String getTabText () {
+ return "";
+}
+/**
+* Recreates the "Example" widgets.
+*/
+void recreateExampleWidgets () {
+ disposeExampleWidgets ();
+ createExampleWidgets ();
+ setExampleWidgetState ();
+}
+/**
+* Sets the enabled state of the "Example" widgets.
+*/
+void setExampleWidgetEnabled () {
+ Control [] controls = getExampleWidgets ();
+ for (int i=0; i<controls.length; i++) {
+ controls [i].setEnabled (enabledButton.getSelection ());
+ }
+}
+/**
+* Sets the size of the "Example" widgets.
+*/
+void setExampleWidgetSize () {
+ int size = SWT.DEFAULT;
+ if (preferredButton == null) return;
+ if (preferredButton.getSelection()) size = SWT.DEFAULT;
+ if (tooSmallButton.getSelection()) size = TOO_SMALL_SIZE;
+ if (smallButton.getSelection()) size = SMALL_SIZE;
+ if (largeButton.getSelection()) size = LARGE_SIZE;
+ Control [] controls = getExampleWidgets ();
+ for (int i=0; i<controls.length; i++) {
+ GridData gridData = new GridData ();
+ gridData.widthHint = size;
+ gridData.heightHint = size;
+ controls [i].setLayoutData (gridData);
+ }
+ /*
+ * Force the entire widget tree to layout,
+ * even when the child sizes nay not have
+ * changed.
+ */
+ int seenCount = 0;
+ Composite [] seen = new Composite [4];
+ for (int i=0; i<controls.length; i++) {
+ Control control = controls [i];
+ while (control != exampleGroup) {
+ Composite parent = control.getParent ();
+ int index = 0;
+ while (index < seenCount) {
+ if (seen [index] == parent) break;
+ index++;
+ }
+ if (index == seenCount) parent.layout ();
+ if (seenCount == seen.length) {
+ Composite [] newSeen = new Composite [seen.length + 4];
+ System.arraycopy (seen, 0, newSeen, 0, seen.length);
+ seen = newSeen;
+ }
+ seen [seenCount++] = parent;
+ control = control.getParent ();
+ }
+ }
+}
+/**
+* Sets the state of the "Example" widgets. Subclasses
+* reimplement this method to set "Example" widget state
+* that is specific to the widget.
+*/
+void setExampleWidgetState () {
+ setExampleWidgetEnabled ();
+ setExampleWidgetVisibility ();
+ setExampleWidgetSize ();
+}
+/**
+* Sets the visibility of the "Example" widgets.
+*/
+void setExampleWidgetVisibility () {
+ Control [] controls = getExampleWidgets ();
+ for (int i=0; i<controls.length; i++) {
+ controls [i].setVisible (visibleButton.getSelection ());
+ }
+}
+}
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/TableTab.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/TableTab.java
new file mode 100755
index 0000000000..6376a6313e
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/TableTab.java
@@ -0,0 +1,173 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+
+class TableTab extends ScrollableTab {
+
+ /* Example widgets and groups that contain them */
+ Table table1;
+ Group tableGroup;
+
+ /* Style widgets added to the "Style" group */
+ Button fullSelectionButton;
+
+ /* Display widgets added to the "Display" group */
+ Button headerVisibleButton, linesVisibleButton;
+
+ static String [] columnTitles = {resControls.getString("TableTitle_0"),
+ resControls.getString("TableTitle_1"),
+ resControls.getString("TableTitle_2"),
+ resControls.getString("TableTitle_3")};
+
+ static String [] stringLine0 = {resControls.getString("TableLine0_0"),
+ resControls.getString("TableLine0_1"),
+ resControls.getString("TableLine0_2"),
+ resControls.getString("TableLine0_3")};
+
+ static String [] stringLine1 = {resControls.getString("TableLine1_0"),
+ resControls.getString("TableLine1_1"),
+ resControls.getString("TableLine1_2"),
+ resControls.getString("TableLine1_3")};
+
+ static String [] stringLine2 = {resControls.getString("TableLine2_0"),
+ resControls.getString("TableLine2_1"),
+ resControls.getString("TableLine2_2"),
+ resControls.getString("TableLine2_3")};
+
+/**
+* Creates the "Display" group.
+*/
+void createDisplayGroup () {
+ super.createDisplayGroup ();
+
+ /* Create display controls specific to this example */
+ headerVisibleButton = new Button (displayGroup, SWT.CHECK);
+ headerVisibleButton.setText (resControls.getString("Header_Visible"));
+ linesVisibleButton = new Button (displayGroup, SWT.CHECK);
+ linesVisibleButton.setText (resControls.getString("Lines_Visible"));
+
+ /* Add the listeners */
+ headerVisibleButton.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ setWidgetHeaderVisible ();
+ }
+ });
+ linesVisibleButton.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ setWidgetLinesVisible ();
+ };
+ });
+}
+/**
+* Creates the "Example" group.
+*/
+void createExampleGroup () {
+ super.createExampleGroup ();
+
+ /* Create a group for the table */
+ tableGroup = new Group (exampleGroup, SWT.NULL);
+ tableGroup.setLayout (new GridLayout ());
+ tableGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ tableGroup.setText (resControls.getString("Table"));
+}
+/**
+* Creates the "Example" widgets.
+*/
+void createExampleWidgets () {
+
+ /* Compute the widget style */
+ int style = SWT.NONE;
+ if (singleButton.getSelection ()) style |= SWT.SINGLE;
+ if (multiButton.getSelection ()) style |= SWT.MULTI;
+ if (fullSelectionButton.getSelection ()) style |= SWT.FULL_SELECTION;
+ if (borderButton.getSelection ()) style |= SWT.BORDER;
+
+ /* Create the table widget */
+ table1 = new Table (tableGroup, style);
+
+ /* Fill the table with data */
+ Image [] images = new Image [] {
+ Images.CLOSED_FOLDER_IMAGE,
+ Images.OPEN_FOLDER_IMAGE,
+ Images.TARGET_IMAGE,
+ };
+ int[] columnWidths = {150, 60, 75, 150};
+ for (int i = 0; i < columnTitles.length; i++) {
+ TableColumn tableColumn = new TableColumn(table1, SWT.NULL);
+ tableColumn.setWidth(columnWidths[i]);
+ tableColumn.setText(columnTitles[i]);
+ }
+ for (int i=0; i<16; i++) {
+ TableItem item = new TableItem (table1, SWT.NULL);
+ item.setImage (images [i % 3]);
+ switch (i % 3) {
+ case 0:
+ stringLine0 [0] = resControls.getString("Index") + i;
+ item.setText(stringLine0);
+ break;
+ case 1:
+ stringLine1 [0] = resControls.getString("Index") + i;
+ item.setText(stringLine1);
+ break;
+ case 2:
+ stringLine2 [0] = resControls.getString("Index") + i;
+ item.setText(stringLine2);
+ break;
+ }
+ }
+}
+/**
+* Creates the "Style" group.
+*/
+void createStyleGroup () {
+ super.createStyleGroup ();
+
+ /* Create the extra widgets */
+ fullSelectionButton = new Button (styleGroup, SWT.CHECK);
+ fullSelectionButton.setText (resControls.getString("SWT_FULL_SELECTION"));
+}
+/**
+* Gets the "Example" widget children.
+*/
+Control [] getExampleWidgets () {
+ return new Control [] {table1};
+}
+/**
+* Gets the text for the tab folder item.
+*/
+String getTabText () {
+ return resControls.getString("Table");
+}
+/**
+* Sets the state of the "Example" widgets.
+*/
+void setExampleWidgetState () {
+ super.setExampleWidgetState ();
+ setWidgetHeaderVisible ();
+ setWidgetLinesVisible ();
+ fullSelectionButton.setSelection ((table1.getStyle () & SWT.FULL_SELECTION) != 0);
+}
+
+/**
+* Sets the header visible state of the "Example" widgets.
+*/
+void setWidgetHeaderVisible () {
+ table1.setHeaderVisible (headerVisibleButton.getSelection ());
+}
+/**
+* Sets the lines visible state of the "Example" widgets.
+*/
+void setWidgetLinesVisible () {
+ table1.setLinesVisible (linesVisibleButton.getSelection ());
+}
+}
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/TextTab.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/TextTab.java
new file mode 100755
index 0000000000..df2095c7df
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/TextTab.java
@@ -0,0 +1,97 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.custom.*;
+
+class TextTab extends ScrollableTab {
+
+ /* Example widgets and groups that contain them */
+ Text text;
+ StyledText richText;
+ Group textGroup, richTextGroup;
+
+ /* Style widgets added to the "Style" group */
+ Button readOnlyButton;
+/**
+* Creates the "Example" group.
+*/
+void createExampleGroup () {
+ super.createExampleGroup ();
+
+ /* Create a group for the text widget */
+ textGroup = new Group (exampleGroup, SWT.NULL);
+ textGroup.setLayout (new GridLayout ());
+ textGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ textGroup.setText (resControls.getString("Text"));
+
+ /* Create a group for the rich text widget */
+ richTextGroup = new Group (exampleGroup, SWT.NULL);
+ richTextGroup.setLayout (new GridLayout ());
+ richTextGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ richTextGroup.setText (resControls.getString("RichText"));
+}
+/**
+* Creates the "Example" widgets.
+*/
+void createExampleWidgets () {
+
+ /* Compute the widget style */
+ int style = SWT.NONE;
+ if (singleButton.getSelection ()) style |= SWT.SINGLE;
+ if (multiButton.getSelection ()) style |= SWT.MULTI;
+ if (horizontalButton.getSelection ()) style |= SWT.H_SCROLL;
+ if (verticalButton.getSelection ()) style |= SWT.V_SCROLL;
+ if (readOnlyButton.getSelection ()) style |= SWT.READ_ONLY;
+ if (borderButton.getSelection ()) style |= SWT.BORDER;
+
+ /* Create the example widgets */
+ text = new Text (textGroup, style);
+ text.setText (resControls.getString("Example_string"));
+ text.append (text.DELIMITER);
+ text.append (resControls.getString("One_Two_Three"));
+ richText = new StyledText (richTextGroup, style);
+ richText.setText (resControls.getString("Example_string"));
+ richText.append ("\n");
+ richText.append (resControls.getString("One_Two_Three"));
+}
+/**
+* Creates the "Style" group.
+*/
+void createStyleGroup() {
+ super.createStyleGroup();
+
+ /* Create the extra widgets */
+ readOnlyButton = new Button (styleGroup, SWT.CHECK);
+ readOnlyButton.setText (resControls.getString("SWT_READ_ONLY"));
+}
+/**
+* Gets the "Example" widget children.
+*/
+Control [] getExampleWidgets () {
+ return new Control [] {text, richText};
+}
+/**
+* Gets the text for the tab folder item.
+*/
+String getTabText () {
+ return resControls.getString("Text");
+}
+/**
+* Sets the state of the "Example" widgets.
+*/
+void setExampleWidgetState () {
+ super.setExampleWidgetState ();
+ readOnlyButton.setSelection ((text.getStyle () & SWT.READ_ONLY) != 0);
+}
+
+}
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ToolBarTab.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ToolBarTab.java
new file mode 100755
index 0000000000..d05d2873b5
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/ToolBarTab.java
@@ -0,0 +1,262 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+
+class ToolBarTab extends Tab {
+
+ /* Example widgets and groups that contain them */
+ ToolBar imageToolBar, textToolBar;
+ Shell dropDownShell;
+ List dropDownList;
+ Group imageToolBarGroup, textToolBarGroup;
+
+ /* Style widgets added to the "Style" group */
+ Button flatButton, wrapButton;
+
+ static String [] ListData0 = {resControls.getString("ListData0_0"),
+ resControls.getString("ListData0_1"),
+ resControls.getString("ListData0_2"),
+ resControls.getString("ListData0_3"),
+ resControls.getString("ListData0_4"),
+ resControls.getString("ListData0_5"),
+ resControls.getString("ListData0_6"),
+ resControls.getString("ListData0_7"),
+ resControls.getString("ListData0_8")};
+
+/**
+* Create the drop down list widget used by the
+* drop down style tool bar item.
+*/
+void createDropDownList() {
+
+ /* Don't create more than one list */
+ if (dropDownList != null) return;
+
+ /* Create the list */
+ Shell shell = tabFolderPage.getShell ();
+ dropDownShell = new Shell (shell, SWT.NO_TRIM);
+ dropDownList = new List(dropDownShell, SWT.VERTICAL);
+ dropDownShell.setLayout (new FillLayout ());
+ dropDownList.setItems (ListData0);
+
+ /*
+ * Add a list selection listener so that the list is hidden
+ * when the user selects an item from the drop down list.
+ */
+ dropDownList.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ disposeDropDownList ();
+ }
+ });
+}
+/**
+* Creates the "Example" group.
+*/
+void createExampleGroup () {
+ super.createExampleGroup ();
+
+ /* Create a group for the image tool bar */
+ imageToolBarGroup = new Group (exampleGroup, SWT.NULL);
+ imageToolBarGroup.setLayout (new GridLayout ());
+ imageToolBarGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ imageToolBarGroup.setText (resControls.getString("Image_ToolBar"));
+
+ /* Create a group for the text tool bar */
+ textToolBarGroup = new Group (exampleGroup, SWT.NULL);
+ textToolBarGroup.setLayout (new GridLayout ());
+ textToolBarGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ textToolBarGroup.setText (resControls.getString("Text_ToolBar"));
+}
+/**
+* Creates the "Example" widgets.
+*/
+void createExampleWidgets () {
+
+ /* Compute the widget style */
+ int style = SWT.NONE;
+ if (flatButton.getSelection()) style |= SWT.FLAT;
+ if (wrapButton.getSelection()) style |= SWT.WRAP;
+ if (borderButton.getSelection()) style |= SWT.BORDER;
+
+ /*
+ * Create the example widgets.
+ *
+ * A tool bar must consist of all image tool
+ * items or all text tool items but not both.
+ */
+
+ /* Create the image tool bar */
+ imageToolBar = new ToolBar (imageToolBarGroup, style);
+ ToolItem item = new ToolItem (imageToolBar, SWT.PUSH);
+ item.setImage (Images.CLOSED_FOLDER_IMAGE);
+ item.setToolTipText(resControls.getString("SWT_PUSH"));
+ item = new ToolItem (imageToolBar, SWT.PUSH);
+ item.setImage (Images.CLOSED_FOLDER_IMAGE);
+ item.setToolTipText (resControls.getString("SWT_PUSH"));
+ item = new ToolItem (imageToolBar, SWT.RADIO);
+ item.setImage (Images.OPEN_FOLDER_IMAGE);
+ item.setToolTipText (resControls.getString("SWT_RADIO"));
+ item = new ToolItem (imageToolBar, SWT.RADIO);
+ item.setImage (Images.OPEN_FOLDER_IMAGE);
+ item.setToolTipText (resControls.getString("SWT_RADIO"));
+ item = new ToolItem (imageToolBar, SWT.CHECK);
+ item.setImage (Images.TARGET_IMAGE);
+ item.setToolTipText (resControls.getString("SWT_CHECK"));
+ item = new ToolItem (imageToolBar, SWT.RADIO);
+ item.setImage (Images.CLOSED_FOLDER_IMAGE);
+ item.setToolTipText (resControls.getString("SWT_RADIO"));
+ item = new ToolItem (imageToolBar, SWT.RADIO);
+ item.setImage (Images.CLOSED_FOLDER_IMAGE);
+ item.setToolTipText (resControls.getString("SWT_RADIO"));
+ item = new ToolItem (imageToolBar, SWT.SEPARATOR);
+ item.setToolTipText(resControls.getString("SWT_SEPARATOR"));
+ item = new ToolItem (imageToolBar, SWT.DROP_DOWN);
+ item.setImage (Images.TARGET_IMAGE);
+ item.setToolTipText (resControls.getString("SWT_DROP_DOWN"));
+
+ /*
+ * Add a selection listener to the drop down tool item
+ * so that we can show the list when the drop down area
+ * is pressed.
+ */
+ item.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ dropDownToolItemSelected (event);
+ }
+ });
+
+ /* Create the text tool bar */
+ textToolBar = new ToolBar (textToolBarGroup, style);
+ item = new ToolItem (textToolBar, SWT.PUSH);
+ item.setText (resControls.getString("Push"));
+ item.setToolTipText(resControls.getString("SWT_PUSH"));
+ item = new ToolItem (textToolBar, SWT.PUSH);
+ item.setText (resControls.getString("Push"));
+ item.setToolTipText(resControls.getString("SWT_PUSH"));
+ item = new ToolItem (textToolBar, SWT.RADIO);
+ item.setText (resControls.getString("Radio"));
+ item.setToolTipText(resControls.getString("SWT_RADIO"));
+ item = new ToolItem (textToolBar, SWT.RADIO);
+ item.setText (resControls.getString("Radio"));
+ item.setToolTipText(resControls.getString("SWT_RADIO"));
+ item = new ToolItem (textToolBar, SWT.CHECK);
+ item.setText (resControls.getString("Check"));
+ item.setToolTipText(resControls.getString("SWT_CHECK"));
+ item = new ToolItem (textToolBar, SWT.RADIO);
+ item.setText (resControls.getString("Radio"));
+ item.setToolTipText(resControls.getString("SWT_RADIO"));
+ item = new ToolItem (textToolBar, SWT.RADIO);
+ item.setText (resControls.getString("Radio"));
+ item.setToolTipText(resControls.getString("SWT_RADIO"));
+ item = new ToolItem (textToolBar, SWT.SEPARATOR);
+ item.setToolTipText(resControls.getString("SWT_SEPARATOR"));
+ item = new ToolItem (textToolBar, SWT.DROP_DOWN);
+ item.setText (resControls.getString("Drop_Down"));
+ item.setToolTipText(resControls.getString("SWT_DROP_DOWN"));
+
+ /*
+ * Do not add the selection event for this drop down
+ * tool item. Without hooking the event, the drop down
+ * widget does nothing special when the drop down area
+ * is selected.
+ */
+}
+/**
+* Creates the "Style" group.
+*/
+void createStyleGroup() {
+ super.createStyleGroup();
+
+ /* Create the extra widgets */
+ flatButton = new Button (styleGroup, SWT.CHECK);
+ flatButton.setText (resControls.getString("SWT_FLAT"));
+ wrapButton = new Button (styleGroup, SWT.CHECK);
+ wrapButton.setText (resControls.getString("SWT_WRAP"));
+ borderButton = new Button (styleGroup, SWT.CHECK);
+ borderButton.setText (resControls.getString("SWT_BORDER"));
+}
+void disposeDropDownList () {
+ if (dropDownShell != null) dropDownShell.dispose ();
+ dropDownShell = null; dropDownList = null;
+}
+void disposeExampleWidgets () {
+ super.disposeExampleWidgets ();
+ disposeDropDownList ();
+}
+/**
+* Handle the drop down tool item selection event.
+*
+* @param event the selection event
+*/
+void dropDownToolItemSelected (SelectionEvent event) {
+
+ /*
+ * If list was already dropped down then close it.
+ * We would do this regardless of where the tool
+ * item was selected.
+ */
+ createDropDownList ();
+ if (dropDownShell.getVisible ()) {
+ disposeDropDownList ();
+ return;
+ }
+
+ /**
+ * A selection event will be fired when a drop down tool
+ * item is selected in the main area and in the drop
+ * down arrow. Examine the event detail to determine
+ * where the widget was selected.
+ */
+ if (event.detail == SWT.ARROW) {
+ /*
+ * The drop down arrow was selected.
+ * Position the list below and vertically
+ * alligned with the the drop down tool button.
+ */
+ ToolItem item = (ToolItem) event.widget;
+ Rectangle toolItemBounds = item.getBounds ();
+ Point point1 = imageToolBar.toDisplay (new Point (toolItemBounds.x, toolItemBounds.y));
+ dropDownShell.setBounds (point1.x, point1.y + toolItemBounds.height, 100, 100);
+ dropDownShell.setVisible (true);
+ } else {
+ /*
+ * Main area of drop down tool item selected.
+ * An application would invoke the code was
+ * required to perform the action for the tool
+ * item.
+ */
+ }
+}
+/**
+* Gets the "Example" widget children.
+*/
+Control [] getExampleWidgets () {
+ return new Control [] {imageToolBar, textToolBar};
+}
+/**
+* Gets the text for the tab folder item.
+*/
+String getTabText () {
+ return resControls.getString("ToolBar");
+}
+/**
+* Sets the state of the "Example" widgets.
+*/
+void setExampleWidgetState () {
+ super.setExampleWidgetState ();
+ flatButton.setSelection ((imageToolBar.getStyle () & SWT.FLAT) != 0);
+ wrapButton.setSelection ((imageToolBar.getStyle () & SWT.WRAP) != 0);
+ borderButton.setSelection ((imageToolBar.getStyle () & SWT.BORDER) != 0);
+}
+
+}
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/TreeTab.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/TreeTab.java
new file mode 100755
index 0000000000..1f0721ddb3
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/TreeTab.java
@@ -0,0 +1,112 @@
+package org.eclipse.swt.examples.controlexample;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+
+class TreeTab extends ScrollableTab {
+
+ /* Example widgets and groups that contain them */
+ Tree tree1, tree2;
+ Group treeGroup, imageTreeGroup;
+/**
+* Creates the "Example" group.
+*/
+void createExampleGroup () {
+ super.createExampleGroup ();
+
+ /* Create a group for the text tree */
+ treeGroup = new Group (exampleGroup, SWT.NULL);
+ treeGroup.setLayout (new GridLayout ());
+ treeGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ treeGroup.setText (resControls.getString("Tree"));
+
+ /* Create a group for the image tree */
+ imageTreeGroup = new Group (exampleGroup, SWT.NULL);
+ imageTreeGroup.setLayout (new GridLayout ());
+ imageTreeGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ imageTreeGroup.setText (resControls.getString("Tree_With_Images"));
+}
+/**
+* Creates the "Example" widgets.
+*/
+void createExampleWidgets () {
+
+ /* Compute the widget style */
+ int style = SWT.NONE;
+ if (singleButton.getSelection()) style |= SWT.SINGLE;
+ if (multiButton.getSelection()) style |= SWT.MULTI;
+ if (borderButton.getSelection()) style |= SWT.BORDER;
+
+ /* Create the text tree */
+ tree1 = new Tree (treeGroup, style);
+ TreeItem node1 = new TreeItem (tree1, SWT.NULL);
+ node1.setText (resControls.getString("Node_1"));
+ TreeItem node2 = new TreeItem (tree1, SWT.NULL);
+ node2.setText (resControls.getString("Node_2"));
+ TreeItem node3 = new TreeItem (tree1, SWT.NULL);
+ node3.setText (resControls.getString("Node_3"));
+ TreeItem node4 = new TreeItem (tree1, SWT.NULL);
+ node4.setText (resControls.getString("Node_4"));
+ TreeItem node1_1 = new TreeItem (node1, SWT.NULL);
+ node1_1.setText (resControls.getString("Node_1_1"));
+ TreeItem node2_1 = new TreeItem (node2, SWT.NULL);
+ node2_1.setText (resControls.getString("Node_2_1"));
+ TreeItem node3_1 = new TreeItem (node3, SWT.NULL);
+ node3_1.setText (resControls.getString("Node_3_1"));
+ TreeItem node2_2 = new TreeItem (node2, SWT.NULL);
+ node2_2.setText (resControls.getString("Node_2_2"));
+ TreeItem node2_2_1 = new TreeItem (node2_2, SWT.NULL);
+ node2_2_1.setText (resControls.getString("Node_2_2_1"));
+
+ /* Create the image tree */
+ tree2 = new Tree (imageTreeGroup, style);
+ node1 = new TreeItem (tree2, SWT.NULL);
+ node1.setText (resControls.getString("Node_1"));
+ node1.setImage (Images.CLOSED_FOLDER_IMAGE);
+ node2 = new TreeItem (tree2, SWT.NULL);
+ node2.setText (resControls.getString("Node_2"));
+ node2.setImage (Images.CLOSED_FOLDER_IMAGE);
+ node3 = new TreeItem (tree2, SWT.NULL);
+ node3.setText (resControls.getString("Node_3"));
+ node3.setImage (Images.CLOSED_FOLDER_IMAGE);
+ node4 = new TreeItem (tree2, SWT.NULL);
+ node4.setText (resControls.getString("Node_4"));
+ node4.setImage (Images.CLOSED_FOLDER_IMAGE);
+ node1_1 = new TreeItem (node1, SWT.NULL);
+ node1_1.setText (resControls.getString("Node_1_1"));
+ node1_1.setImage (Images.CLOSED_FOLDER_IMAGE);
+ node2_1 = new TreeItem (node2, SWT.NULL);
+ node2_1.setText (resControls.getString("Node_2_1"));
+ node2_1.setImage (Images.CLOSED_FOLDER_IMAGE);
+ node3_1 = new TreeItem (node3, SWT.NULL);
+ node3_1.setText (resControls.getString("Node_3_1"));
+ node3_1.setImage (Images.CLOSED_FOLDER_IMAGE);
+ node2_2 = new TreeItem(node2, SWT.NULL);
+ node2_2.setText (resControls.getString("Node_2_2"));
+ node2_2.setImage (Images.CLOSED_FOLDER_IMAGE);
+ node2_2_1 = new TreeItem (node2_2, SWT.NULL);
+ node2_2_1.setText (resControls.getString("Node_2_2_1"));
+ node2_2_1.setImage (Images.CLOSED_FOLDER_IMAGE);
+}
+/**
+* Gets the "Example" widget children.
+*/
+Control [] getExampleWidgets () {
+ return new Control [] {tree1, tree2};
+}
+/**
+* Gets the text for the tab folder item.
+*/
+String getTabText () {
+ return resControls.getString("Tree");
+}
+}
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/folder.gif b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/folder.gif
new file mode 100755
index 0000000000..6660d0b11a
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/folder.gif
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/folderOpen.gif b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/folderOpen.gif
new file mode 100755
index 0000000000..fc9943f111
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/folderOpen.gif
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/stop.gif b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/stop.gif
new file mode 100755
index 0000000000..9807ae648d
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/controlexample/stop.gif
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/Explorer.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/Explorer.java
new file mode 100755
index 0000000000..fc34dd962a
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/Explorer.java
@@ -0,0 +1,1318 @@
+package org.eclipse.swt.examples.explorer;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.dnd.*;
+import org.eclipse.swt.program.*;
+
+import java.util.*;
+import java.io.*;
+
+/**
+*/
+public class Explorer {
+
+ ResourceBundle resExplorer = ResourceBundle.getBundle("examples_explorer");
+
+ Display display;
+ Shell shell;
+ Combo combo;
+ ToolBar toolBar;
+ Tree tree;
+ Table table;
+ Sash sash;
+
+ Label numObjectsLabel;
+ Label diskSpaceLabel;
+ Label allFoldersLabel;
+ Label contentLabel;
+
+ TreeItem [] comboContents;
+ TreeItem previousSelectedTreeItem;
+
+ static final String DRIVE_A = "a:"+File.separator;
+ static final String DRIVE_B = "b:"+File.separator;
+
+ boolean cancel = false;
+ Thread tableThread;
+
+ DragSource tableDragSource;
+ DropTarget tableDropTarget;
+ DragSource treeDragSource;
+ DropTarget treeDropTarget;
+ TreeItem[] oldTreeSelection;
+ TableItem[] oldTableSelection;
+ TreeItem[] treeDragItems;
+ TableItem[] tableDragItems;
+
+
+public void close () {
+ if (shell != null && !shell.isDisposed ()) {
+ shell.dispose ();
+ }
+ Images.freeAll ();
+ display.dispose ();
+}
+boolean copyFile(File oldFile, File newFile) {
+ if (oldFile == null || !oldFile.exists() || newFile == null || newFile.exists())
+ return false;
+
+ // copy directory
+ if (oldFile.isDirectory()) {
+ boolean result = newFile.mkdirs();
+ if (result) {
+ String[] subFiles = oldFile.list();
+ if (subFiles != null) {
+ for (int i = 0; i < subFiles.length; i++) {
+ File oldSubFile = new File(subFiles[i]);
+ File newSubFile = new File(newFile, oldSubFile.getName());
+ copyFile(oldSubFile, newSubFile);
+ }
+ }
+ }
+ return result;
+ }
+
+ // copy file
+ FileReader in;
+ try {
+ in = new FileReader(oldFile);
+ } catch (FileNotFoundException e) {
+ return false;
+ }
+ FileWriter out;
+ try {
+ out = new FileWriter(newFile);
+ } catch (FileNotFoundException e) {
+ try { in.close(); } catch (IOException e2) {}
+ return false;
+ }catch (IOException e) {
+ try { in.close(); } catch (IOException e2) {}
+ return false;
+ }
+
+ try {
+ int count;
+ while ((count = in.read()) != -1)
+ out.write(count);
+ } catch (IOException e) {
+ return false;
+ } finally {
+ try { in.close(); } catch (IOException e) {}
+ try { out.close();} catch (IOException e) {}
+ }
+
+ return true;
+}
+void createCombo () {
+ combo = new Combo (toolBar, SWT.READ_ONLY);
+ ToolItem comboItem = toolBar.getItems () [0];
+ comboItem.setControl (combo);
+ comboItem.setWidth (185);
+ /*
+ * It would be nice to use File.listRoots but this
+ * feature is only available in JDK 1.22.
+ */
+// File[] roots = File.listRoots();
+// if (roots != null) {
+// for (int i = 0, length = roots.length; i < length; i++) {
+// combo.add(roots[i].getAbsolutePath());
+// }
+// }
+ if (System.getProperty ("os.name").indexOf ("Windows") != -1) {
+ combo.add (DRIVE_A);
+ combo.add (DRIVE_B);
+ for (int i='c'; i<='z'; i++) {
+ File drive = new File ((char)i + ":" + File.separator);
+ if (drive.isDirectory ()) {
+ combo.add (drive.getPath());
+ }
+ }
+ } else {
+ combo.add (File.separator);
+ }
+ combo.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent e) {
+ selectCombo ();
+ }
+ });
+}
+void createDetailsItems (Menu menu) {
+ String [] strings = {resExplorer.getString("Large_icons_menuitem"),
+ resExplorer.getString("Small_icons_menuitem"),
+ resExplorer.getString("List_menuitem"),
+ resExplorer.getString("Details_menuitem")};
+ final MenuItem [] items = new MenuItem [strings.length];
+ SelectionListener l = new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent e) {
+ for (int i=0; i<items.length; i++) {
+ items [i].setSelection (items [i] == e.widget);
+ }
+ }
+ };
+ for (int i=0; i<strings.length; i++) {
+ items [i] = new MenuItem (menu, SWT.RADIO);
+ items [i].setText (strings [i]);
+ items [i].addSelectionListener (l);
+ }
+ items [3].setSelection (true);
+}
+Menu createEditMenu() {
+ Menu bar = shell.getMenuBar ();
+ Menu menu = new Menu (bar);
+
+ MenuItem item = new MenuItem (menu, SWT.PUSH);
+ item.setText (resExplorer.getString("Undo_menuitem"));
+ item.setAccelerator(SWT.CONTROL + 'Z');
+
+ new MenuItem (menu, SWT.SEPARATOR);
+
+ item = new MenuItem (menu, SWT.PUSH);
+ item.setText (resExplorer.getString("Cut_menuitem"));
+ item.setAccelerator(SWT.CONTROL + 'X');
+
+ item = new MenuItem (menu, SWT.PUSH);
+ item.setText (resExplorer.getString("Copy_menuitem"));
+ item.setAccelerator(SWT.CONTROL + 'C');
+
+ item = new MenuItem (menu, SWT.PUSH);
+ item.setText (resExplorer.getString("Paste_menuitem"));
+ item.setAccelerator(SWT.CONTROL + 'V');
+
+
+ return menu;
+}
+Menu createFileMenu() {
+ Menu bar = shell.getMenuBar ();
+ Menu menu = new Menu (bar);
+ MenuItem item;
+
+ // New with submenu
+ item = new MenuItem (menu, SWT.CASCADE);
+ item.setText (resExplorer.getString("New_menuitem"));
+ Menu submenu = new Menu (shell, SWT.DROP_DOWN);
+ createNewMenu (submenu);
+ item.setMenu (submenu);
+
+ // -------------
+ new MenuItem (menu, SWT.SEPARATOR);
+
+ // Create shortcut
+ item = new MenuItem (menu, SWT.PUSH);
+ item.setText (resExplorer.getString("Shortcut_menuitem"));
+
+ // Delete
+ item = new MenuItem (menu, SWT.PUSH);
+ item.setText (resExplorer.getString("Delete_menuitem"));
+
+ // Rename
+ item = new MenuItem (menu, SWT.PUSH);
+ item.setText (resExplorer.getString("Rename_menuitem"));
+
+ // Properties
+ item = new MenuItem(menu, SWT.PUSH);
+ item.setText (resExplorer.getString("Properties_menuitem"));
+
+ // ------------
+ new MenuItem (menu, SWT.SEPARATOR);
+
+ // Close
+ item = new MenuItem (menu, SWT.PUSH);
+ item.setText (resExplorer.getString("Close_menuitem"));
+ item.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent e) {
+ menuFileExit ();
+ }
+ });
+ return menu;
+}
+Menu createHelpMenu () {
+ // Help topics
+ Menu bar = shell.getMenuBar ();
+ Menu menu = new Menu (bar);
+ MenuItem item = new MenuItem (menu, SWT.PUSH);
+ item.setText (resExplorer.getString("Help_menuitem"));
+
+ // ----------
+ new MenuItem (menu, SWT.SEPARATOR);
+
+ // About the OS
+ item = new MenuItem (menu, SWT.PUSH);
+ item.setText (resExplorer.getString("About_menuitem") + " " + System.getProperty ("os.name"));
+
+ return menu;
+}
+void createMenuBar () {
+ Menu bar = new Menu (shell, SWT.BAR);
+ shell.setMenuBar (bar);
+
+ MenuItem fileItem = new MenuItem (bar, SWT.CASCADE);
+ fileItem.setText (resExplorer.getString("File_menutitle"));
+ fileItem.setMenu (createFileMenu ());
+
+ MenuItem editItem = new MenuItem (bar, SWT.CASCADE);
+ editItem.setText (resExplorer.getString("Edit_menutitle"));
+ editItem.setMenu (createEditMenu ());
+
+ MenuItem viewItem = new MenuItem (bar, SWT.CASCADE);
+ viewItem.setText (resExplorer.getString("View_menutitle"));
+ viewItem.setMenu (createViewMenu ());
+
+ MenuItem toolsItem = new MenuItem (bar, SWT.CASCADE);
+ toolsItem.setText (resExplorer.getString("Tools_menutitle"));
+ toolsItem.setMenu (createToolsMenu ());
+
+ MenuItem helpItem = new MenuItem (bar, SWT.CASCADE);
+ helpItem.setText (resExplorer.getString("Help_menutitle"));
+ helpItem.setMenu (createHelpMenu ());
+}
+void createNewMenu(Menu submenu) {
+ MenuItem subitem1 = new MenuItem (submenu, SWT.NULL);
+ subitem1.setText (resExplorer.getString("Folder"));
+
+ subitem1 = new MenuItem (submenu, SWT.NULL);
+ subitem1.setText (resExplorer.getString("Shortcut"));
+}
+void createSash () {
+ sash = new Sash (shell, SWT.VERTICAL);
+ sash.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ selectSash(e);
+ }
+ });
+ Point size = sash.computeSize (SWT.DEFAULT, SWT.DEFAULT);
+ sash.setBounds (300, 0, size.x, 0);
+}
+void createShell () {
+ display = new Display ();
+ shell = new Shell (display);
+ shell.setText (resExplorer.getString("Title"));
+ Images.loadAll (display);
+ shell.setImage (Images.ShellIcon);
+}
+void createSortByMenu(Menu menu) {
+ String [] strings = {resExplorer.getString("By_name"),
+ resExplorer.getString("By_type"),
+ resExplorer.getString("By_size"),
+ resExplorer.getString("By_date")};
+ MenuItem subitem;
+ for (int i=0; i<strings.length; i++) {
+ subitem = new MenuItem (menu, SWT.PUSH);
+ subitem.setText (strings [i]);
+ }
+ subitem = new MenuItem (menu, SWT.SEPARATOR);
+ subitem = new MenuItem (menu, SWT.PUSH);
+ subitem.setText (resExplorer.getString("Auto_arrange"));
+}
+void createStatusLine () {
+ numObjectsLabel = new Label (shell, SWT.BORDER);
+ Point size = numObjectsLabel.computeSize (145, SWT.DEFAULT);
+ numObjectsLabel.setSize (size.x, size.y + 2);
+ diskSpaceLabel = new Label (shell, SWT.BORDER);
+ allFoldersLabel = new Label (shell, SWT.BORDER);
+ allFoldersLabel.setText(resExplorer.getString("All_folders"));
+ contentLabel = new Label (shell, SWT.BORDER);
+}
+void createTable () {
+ table = new Table (shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+ String [] titles = new String [] {resExplorer.getString("Name"),
+ resExplorer.getString("Size"),
+ resExplorer.getString("Type"),
+ resExplorer.getString("Modified")};
+ int [] widths = new int [] {150, 60, 75, 150};
+ for (int i=0; i<titles.length; i++) {
+ TableColumn column = new TableColumn (table, SWT.NONE);
+ column.setText (titles [i]);
+ column.setWidth (widths [i]);
+ }
+ table.setHeaderVisible (true);
+ table.setMenu (createTableMenu ());
+ table.addSelectionListener(new SelectionAdapter() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ defaultSelectTable (e);
+ }
+ });
+
+ createTableDragSource();
+
+ createTableDropTarget();
+
+}
+void createTableDragSource(){
+ // create a drag source for the table
+ int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
+ tableDragSource = new DragSource(table, operations);
+ tableDragSource.setTransfer(new Transfer[]{FileTransfer.getInstance()});
+ DragSourceListener listener2 = new DragSourceListener() {
+ public void dragStart(DragSourceEvent e){
+ TableItem[] selection = table.getSelection();
+ if (selection == null || selection.length == 0) {
+ e.doit = false;
+ }
+ };
+ public void dragSetData(DragSourceEvent event){
+ if (!FileTransfer.getInstance().isSupportedType(event.dataType)) return;
+ tableDragItems = table.getSelection();
+ if (tableDragItems == null || tableDragItems.length == 0) return;
+ String[] data = new String[tableDragItems.length];
+ for (int i = 0; i < tableDragItems.length; i++) {
+ File file = (File)tableDragItems[i].getData();
+ data[i] = file.getAbsolutePath();
+ }
+ event.data = data;
+ }
+ public void dragFinished(DragSourceEvent event){
+ if (event.detail != DND.DROP_NONE)
+ refresh();
+ tableDragItems = null;
+ }
+ };
+ tableDragSource.addDragListener(listener2);
+}
+void createTableDropTarget(){
+ // create a drop target for the Table
+ int operations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
+ tableDropTarget = new DropTarget(table, operations);
+ tableDropTarget.setTransfer(new Transfer[] {FileTransfer.getInstance()});
+ DropTargetListener listener = new DropTargetAdapter() {
+ public void dragEnter(DropTargetEvent event) {
+ oldTableSelection = table.getSelection();
+ };
+ public void dragOver(DropTargetEvent event) {
+ Point p = table.toControl(new Point(event.x, event.y));
+ TableItem item = table.getItem (p);
+ if (item != null) {
+ File file = (File)item.getData();
+ if (file.isDirectory()) {
+ //table.setDropSelection (item);
+ table.setSelection (new TableItem[] {item});
+ return;
+ }
+ }
+ table.setSelection(new TableItem[0]);
+ };
+ public void dragLeave(DropTargetEvent event) {
+ table.setSelection(oldTableSelection);
+ oldTableSelection = null;
+ //table.setDropSelection(null);
+ };
+ public void drop(DropTargetEvent event) {
+ // Get dropped data
+ Object value = event.data;
+ if (value == null) {
+ event.detail = DND.DROP_NONE;
+ return;
+ }
+ String[] names = (String[]) value;
+
+ // Find parent file
+ File parentFile = null;
+ Point p = table.toControl(new Point(event.x, event.y));
+ TableItem item = table.getItem(p);
+ // was the file dropped on a directory?
+ if (item != null) {
+ File file = (File)item.getData();
+ if (file != null && file.isDirectory()){
+ parentFile = file;
+ }
+ }
+ if (parentFile == null) {
+ // use the same parent as all other entries in the table
+ parentFile = (File)table.getData();
+ }
+ if (parentFile == null) {
+ event.detail = DND.DROP_NONE;
+ return;
+ }
+
+ // Perform drop
+ for (int i = 0; i < names.length; i++){
+
+ // manipulate underlying file
+ File source = new File(names[i]);
+ File dest = new File(parentFile, source.getName());
+ if (event.detail == DND.DROP_COPY) {
+ if (!copyFile(source, dest)) {
+ event.detail = DND.DROP_NONE;
+ return;
+ }
+ } else if (event.detail == DND.DROP_MOVE) {
+ if (!moveFile(source, dest)) {
+ event.detail = DND.DROP_NONE;
+ return;
+ }
+ }
+ }
+
+ refresh();
+ }
+ };
+ tableDropTarget.addDropListener(listener);
+}
+Menu createTableMenu () {
+ Menu menu = new Menu (shell, SWT.POP_UP);
+ MenuItem menuItem;
+
+ // View, with submenu
+ menuItem = new MenuItem (menu, SWT.CASCADE);
+ menuItem.setText (resExplorer.getString("Popup_view"));
+
+ Menu submenu = new Menu (shell, SWT.DROP_DOWN);
+ createDetailsItems (submenu);
+ menuItem.setMenu (submenu);
+
+ menuItem = new MenuItem (menu, SWT.SEPARATOR);
+
+ // Arrange Icons with submenu
+ menuItem = new MenuItem (menu, SWT.CASCADE);
+ menuItem.setText (resExplorer.getString("Popup_arrange"));
+
+ submenu = new Menu (shell, SWT.DROP_DOWN);
+ createSortByMenu(submenu);
+ menuItem.setMenu(submenu);
+
+ // Line up Icons
+ menuItem = new MenuItem (menu, SWT.PUSH);
+ menuItem.setText (resExplorer.getString("Popup_lineup"));
+ menuItem.setEnabled(false);
+
+ // ----------------
+ menuItem = new MenuItem (menu, SWT.SEPARATOR);
+
+ // Paste
+ menuItem = new MenuItem (menu, SWT.PUSH);
+ menuItem.setText (resExplorer.getString("Popup_paste"));
+ menuItem.setEnabled(false);
+
+ // Paste shortcut
+ menuItem = new MenuItem (menu, SWT.PUSH);
+ menuItem.setText (resExplorer.getString("Popup_shortcut"));
+ menuItem.setEnabled(false);
+
+ // ---------------
+ menuItem = new MenuItem (menu, SWT.SEPARATOR);
+
+ // New with submenu
+ menuItem = new MenuItem (menu, SWT.CASCADE);
+ menuItem.setText (resExplorer.getString("Popup_new"));
+
+ submenu = new Menu (shell, SWT.DROP_DOWN);
+ createNewMenu(submenu);
+ menuItem.setMenu(submenu);
+
+ // ------------------
+ menuItem = new MenuItem (menu, SWT.SEPARATOR);
+
+ // Properties
+ menuItem = new MenuItem (menu, SWT.PUSH);
+ menuItem.setText (resExplorer.getString("Popup_properties"));
+
+ return menu;
+}
+void createToolBar() {
+ toolBar = new ToolBar(shell, SWT.NULL);
+ ToolItem item = new ToolItem(toolBar, SWT.SEPARATOR);
+ item = new ToolItem(toolBar, SWT.SEPARATOR);
+ item = new ToolItem(toolBar, SWT.PUSH);
+ item.setImage(Images.UpDirectory);
+ item.addSelectionListener(new SelectionAdapter () {
+ public void widgetSelected(SelectionEvent e) {
+ selectParentTreeItem();
+ }
+ });
+ item = new ToolItem(toolBar, SWT.SEPARATOR);
+ item = new ToolItem(toolBar, SWT.PUSH);
+ item.setImage(Images.MapNetwork);
+ item = new ToolItem(toolBar, SWT.PUSH);
+ item.setImage(Images.Disconnect);
+ item = new ToolItem(toolBar, SWT.SEPARATOR);
+ item = new ToolItem(toolBar, SWT.PUSH);
+ item.setImage(Images.Cut);
+ item = new ToolItem(toolBar, SWT.PUSH);
+ item.setImage(Images.Copy);
+ item = new ToolItem(toolBar, SWT.PUSH);
+ item.setImage(Images.Paste);
+ item = new ToolItem(toolBar, SWT.SEPARATOR);
+ item = new ToolItem(toolBar, SWT.PUSH);
+ item.setImage(Images.Undo);
+ item = new ToolItem(toolBar, SWT.SEPARATOR);
+ item = new ToolItem(toolBar, SWT.PUSH);
+ item.setImage(Images.Delete);
+ item = new ToolItem(toolBar, SWT.PUSH);
+ item.setImage(Images.Properties);
+ item = new ToolItem(toolBar, SWT.SEPARATOR);
+ item = new ToolItem(toolBar, SWT.RADIO);
+ item.setImage(Images.Large);
+ item = new ToolItem(toolBar, SWT.RADIO);
+ item.setImage(Images.Small);
+ item = new ToolItem(toolBar, SWT.RADIO);
+ item.setImage(Images.List);
+ item = new ToolItem(toolBar, SWT.RADIO);
+ item.setImage(Images.Details);
+ item.setSelection(true);
+}
+Menu createToolsMenu () {
+ Menu bar = shell.getMenuBar ();
+ Menu menu = new Menu (bar);
+
+ MenuItem item = new MenuItem (menu, SWT.CASCADE);
+ item.setText (resExplorer.getString("Find_menuitem"));
+
+ String [] strings = {
+ resExplorer.getString("File_find"),
+ resExplorer.getString("Computer_find"),
+ resExplorer.getString("Internet_find")
+ };
+
+ Menu submenu = new Menu (shell, SWT.DROP_DOWN);
+ MenuItem subitem;
+ for (int i=0; i<strings.length; i++){
+ subitem = new MenuItem (submenu, SWT.PUSH);
+ subitem.setText (strings[i]);
+ }
+ subitem = new MenuItem (submenu, SWT.SEPARATOR);
+ subitem = new MenuItem (submenu, SWT.PUSH);
+ subitem.setText(resExplorer.getString("Autoarrange_menuitem"));
+
+ item.setMenu(submenu);
+
+
+ new MenuItem (menu, SWT.SEPARATOR);
+
+ item = new MenuItem (menu, SWT.CHECK);
+ item.setText (resExplorer.getString("Mapdrive_menuitem"));
+
+ item = new MenuItem (menu, SWT.CHECK);
+ item.setText (resExplorer.getString("Disconnect_menuitem"));
+
+ new MenuItem (menu, SWT.SEPARATOR);
+
+ item = new MenuItem (menu, SWT.CHECK);
+ item.setText (resExplorer.getString("Goto_menuitem"));
+
+
+ return menu;
+}
+void createTree () {
+ tree = new Tree (shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+ tree.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ selectTree();
+ }
+ });
+ tree.addTreeListener(new TreeAdapter() {
+ public void treeExpanded(TreeEvent e) {
+ expandTree(e);
+ }
+ public void treeCollapsed(TreeEvent e) {
+ expandTree(e);
+ }
+ });
+ int length = combo.getItems().length;
+ comboContents = new TreeItem [length];
+ boolean first = false;
+ for (int i=0; i<length; i++){
+ TreeItem newItem = new TreeItem (tree, SWT.NULL);
+ File file = new File(combo.getItem(i));
+ newItem.setText (file.getPath());
+ newItem.setImage(Images.Drive);
+ newItem.setData(file);
+ comboContents [i] = newItem;
+ setExpandable(newItem);
+ }
+
+ createTreeDragSource();
+
+ createTreeDropTarget();
+}
+void createTreeDragSource(){
+ // create a drag source for the tree
+ treeDragSource = new DragSource(tree, DND.DROP_COPY | DND.DROP_LINK | DND.DROP_MOVE);
+ treeDragSource.setTransfer(new Transfer[]{FileTransfer.getInstance()});
+
+ DragSourceListener listener = new DragSourceListener() {
+ public void dragStart(DragSourceEvent e){
+ treeDragItems = tree.getSelection();
+ if (treeDragItems == null || treeDragItems.length == 0) {
+ e.doit = false;
+ }
+ };
+ public void dragSetData(DragSourceEvent event){
+ if (treeDragItems == null || treeDragItems.length == 0) return;
+
+ if (FileTransfer.getInstance().isSupportedType(event.dataType)) {
+ // build an array of the absolute file names
+ String[] fileData = new String[treeDragItems.length];
+ for (int i = 0; i < treeDragItems.length; i++){
+ File file = (File)treeDragItems[i].getData();
+ fileData[i] = file.getAbsolutePath();
+ }
+ event.data = fileData;
+ }
+ }
+ public void dragFinished(DragSourceEvent event) {
+ if (event.detail != DND.DROP_NONE) {
+ refresh();
+ }
+ treeDragItems = null;
+
+ }
+ };
+ treeDragSource.addDragListener(listener);
+}
+void createTreeDropTarget() {
+ // create a drop target for the tree
+ treeDropTarget = new DropTarget(tree, DND.DROP_COPY | DND.DROP_MOVE);
+ treeDropTarget.setTransfer(new Transfer[] {FileTransfer.getInstance()});
+
+ DropTargetListener listener2 = new DropTargetAdapter() {
+ public void dragEnter(DropTargetEvent event) {
+ oldTreeSelection = tree.getSelection();
+ };
+ public void dragOver(DropTargetEvent event) {
+ Point p = tree.toControl(new Point(event.x, event.y));
+ TreeItem item = tree.getItem (p);
+ if (item != null) {
+ //tree.setDropSelection (item);
+ tree.setSelection(new TreeItem[] {item});
+ }
+ };
+ public void dragLeave(DropTargetEvent event) {
+ tree.setSelection(oldTreeSelection);
+ oldTreeSelection = null;
+ //tree.setDropSelection (null);
+ };
+ public void drop(DropTargetEvent event) {
+ // Find the item this was dropped on
+ Point p = tree.toControl(new Point(event.x, event.y));
+ TreeItem parent = tree.getItem (p);
+ if (parent == null) {
+ event.detail = DND.DROP_NONE;
+ return;
+ }
+
+ // Get the dropped files
+ Object value = event.data;
+ if (value == null) {
+ event.detail = DND.DROP_NONE;
+ return;
+ }
+ String[] fileNames = (String[]) value;
+ File[] files = new File[fileNames.length];
+ for (int i = 0; i < fileNames.length; i++){
+ File file = new File(fileNames[i]);
+ if (!file.exists()) {
+ files = null;
+ break;
+ }
+ files[i] = file;
+ }
+ if (files == null || files.length == 0) {
+ event.detail = DND.DROP_NONE;
+ return;
+ }
+
+ // Make sure we are not dropping on ourselves - we will not add
+ // a file to itself
+ File parentFile = (File)parent.getData();
+ for (int i = 0; i < files.length; i++){
+ if (files[i].getAbsolutePath().equals(parentFile.getAbsolutePath())){
+ event.detail = DND.DROP_NONE;
+ return;
+ }
+ }
+
+ // Perform drop
+ for (int i = 0; i < files.length; i++){
+ // manipulate the underlying file
+ File source = files[i];
+ File dest = new File(parentFile, source.getName());
+ if (event.detail == DND.DROP_COPY){
+ if (!copyFile(source, dest)){
+ event.detail = DND.DROP_NONE;
+ return;
+ }
+ } else if (event.detail == DND.DROP_MOVE) {
+ if (!moveFile(source, dest)){
+ event.detail = DND.DROP_NONE;
+ return;
+ }
+ }
+ }
+
+ refresh();
+ }
+ };
+ treeDropTarget.addDropListener(listener2);
+
+}
+Menu createViewMenu() {
+ Menu bar = shell.getMenuBar();
+ Menu menu = new Menu(bar);
+ MenuItem item = new MenuItem(menu, SWT.CHECK);
+ item.setText(resExplorer.getString("Toolbar_menuitem"));
+ item.setSelection (true);
+ item.addSelectionListener (new SelectionAdapter() {
+ public void widgetSelected (SelectionEvent e) {
+ setToolBarVisible (((MenuItem) e.widget).getSelection ());
+ }
+ });
+ item = new MenuItem (menu, SWT.CHECK);
+ item.setText (resExplorer.getString("Statusbar_menuitem"));
+ item.setSelection (true);
+ item.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent e) {
+ setStatusBarVisible (((MenuItem) e.widget).getSelection ());
+ }
+ });
+ new MenuItem (menu, SWT.SEPARATOR);
+
+ // Radio items in the menu
+ createDetailsItems (menu);
+
+ // menuItems that come after the radio section
+
+ new MenuItem (menu, SWT.SEPARATOR);
+ item = new MenuItem (menu, SWT.CASCADE);
+ item.setText (resExplorer.getString("Arrange_menuitem"));
+ Menu submenu = new Menu (shell, SWT.DROP_DOWN);
+ createSortByMenu (submenu);
+ item.setMenu (submenu);
+ item = new MenuItem (menu, SWT.PUSH);
+ item.setText (resExplorer.getString("Lineup_menuitem"));
+ item = new MenuItem (menu, SWT.SEPARATOR);
+ String[] strings = {resExplorer.getString("Refresh_menuitem"),
+ resExplorer.getString("Options_menuitem")};
+ for (int i = 0; i < strings.length; i++) {
+ item = new MenuItem(menu, SWT.PUSH);
+ item.setText (strings [i]);
+ }
+ return menu;
+}
+void defaultSelectTable (SelectionEvent event) {
+ TableItem [] items = table.getSelection ();
+ if (items.length == 0) return;
+ TreeItem item = previousSelectedTreeItem;
+ if (item == null) return;
+ String path = ((File)(item.getData ())).getAbsolutePath ();
+ String fileName = path + File.separator + items [0].getText ();
+ if (!Program.launch (fileName)) {
+ MessageBox dialog = new MessageBox (shell, SWT.ICON_ERROR | SWT.OK);
+ dialog.setMessage (resExplorer.getString("Failed_launch") + " " + fileName);
+ dialog.setText (shell.getText ());
+ dialog.open ();
+ }
+}
+void expandTree (TreeEvent event) {
+ TreeItem item = (TreeItem) event.item;
+ Shell shell = tree.getShell ();
+ shell.setCursor (Images.CursorWait);
+
+ // if this is the a or b drive, check if the drive is expandable
+
+ // if directory hasn't been viewed yet, remove dummy treeItem then populate the tree
+ TreeItem[] items = item.getItems ();
+ if (items[0].getText().equals ("?????")) {
+ // dispose of dummy items
+ for (int i=0; i<items.length; i++) {
+ items [i].dispose ();
+ }
+ // expand the tree item
+ expandTree (item);
+ }
+
+ shell.setCursor(null);
+}
+void expandTree (final TreeItem item) {
+
+ File file = (File)item.getData();
+ // Get a list of subdirectories
+ File[] subFiles = file.listFiles();
+
+
+ // Special case: if drive a or b is selected and does not contain a disk
+ // then prompt user to retry
+ String path = file.getAbsolutePath();
+ if (subFiles==null && ( path.equals(DRIVE_A) || path.equals(DRIVE_B))) {
+ int index = -1;
+ if (messageBoxRetry (path) == SWT.RETRY) {
+ expandTree(item);
+ } else {
+ tree.setSelection (new TreeItem [] {previousSelectedTreeItem});
+ index = -1;
+ for (int i = 0; i < comboContents.length; i++) {
+ if (comboContents[i].equals(previousSelectedTreeItem)){
+ index = i;
+ break;
+ }
+ }
+ if (index != -1)
+ combo.select (index);
+
+ display.asyncExec(new Runnable() {
+ public void run() {
+ item.setExpanded(false);
+ setExpandable(item);
+ }
+ });
+
+ }
+ return;
+ }
+
+
+ sort(subFiles);
+
+ // for each of this directory's subdirectories (and files)
+ for (int i=0; i<subFiles.length; i++) {
+ if (!subFiles[i].isDirectory()) continue;
+
+ // add the directory to the tree
+ TreeItem newItem = new TreeItem (item, SWT.NULL);
+ newItem.setText (subFiles[i].getName());
+ newItem.setImage(Images.Folder);
+ newItem.setData(subFiles[i]);
+
+ // make the directory "expandable"
+ setExpandable(newItem);
+ }
+
+}
+
+public static void main (String [] args) {
+ Explorer example = new Explorer ();
+ example.open ();
+ example.run ();
+ example.close ();
+}
+void menuFileExit () {
+ shell.close ();
+}
+int messageBoxRetry (String s) {
+ MessageBox box = new MessageBox (shell, SWT.RETRY | SWT.CANCEL | SWT.APPLICATION_MODAL | SWT.ICON_ERROR);
+ box.setMessage (s + " " + resExplorer.getString("Unavailable"));
+ box.setText (shell.getText ());
+ return box.open ();
+}
+boolean moveFile(File oldFile, File newFile) {
+ if (oldFile == null || !oldFile.exists() || newFile.exists())
+ return false;
+ return oldFile.renameTo(newFile);
+}
+public void open () {
+ createShell ();
+ createMenuBar ();
+ createToolBar ();
+ createStatusLine ();
+ createCombo ();
+ createTable ();
+ createTree (); // creating Tree depends on Table already existing
+ createSash ();
+ int last = combo.getItemCount() - 1;
+ combo.select (last);
+ selectCombo();
+
+ shell.addControlListener(new ControlAdapter () {
+ public void controlResized (ControlEvent e) {
+ shellResized (e);
+ }
+ });
+ shell.open ();
+}
+void refresh() {
+ // update the tree
+ TreeItem[] items = tree.getItems();
+ for (int i = 0; i < items.length; i++) {
+ refresh(items[i]);
+ }
+
+ // update the table
+ TreeItem[] selection = tree.getSelection();
+ if (selection.length == 1){
+ updateTable((File)selection[0].getData());
+ }
+}
+void refresh(TreeItem item) {
+
+ if (item.getText().equals("?????")) return;
+
+ TreeItem[] subItems = item.getItems();
+ for (int i = 0; i < subItems.length; i++) {
+ refresh (subItems[i]);
+ }
+
+ // is this item is collapsed, replace subitems with a dummy item
+ // and refresh subitems next time it is expanded
+ if (!item.getExpanded()) {
+ for (int i = 0; i < subItems.length; i++) {
+ if (subItems[i].equals(previousSelectedTreeItem)) {
+ previousSelectedTreeItem = null;
+ }
+ subItems[i].dispose();
+ }
+ setExpandable(item);
+ } else {
+ // compare subitems with real ones
+ File file = (File)item.getData();
+ File[] subFiles = file.listFiles();
+ if (subFiles == null) {
+ setExpandable(item);
+ item.setExpanded(false);
+ return;
+ }
+
+ sort(subFiles);
+
+ // for each of this directory's subdirectories (and files)
+ for (int i=0; i<subFiles.length; i++) {
+ if (!subFiles[i].isDirectory()) continue;
+
+ // is the file in the tree?
+ boolean found = false;
+ for (int j = 0; j < subItems.length; j++) {
+ Object temp = subItems[j].getData();
+ if (subFiles[i].equals(temp)){
+ found = true;
+ break;
+ }
+ }
+
+ if (!found) {
+ // add the directory to the tree
+ TreeItem newItem = new TreeItem (item, SWT.NULL);
+ newItem.setText (subFiles[i].getName());
+ newItem.setImage(Images.Folder);
+ newItem.setData(subFiles[i]);
+
+ // make the directory "expandable"
+ setExpandable(newItem);
+
+ }
+ }
+
+ // are there extra files in the tree
+ for (int i = 0; i < subItems.length; i++) {
+ boolean found = false;
+ Object temp = subItems[i].getData();
+ for (int j = 0; j < subFiles.length; j++) {
+ if (temp.equals(subFiles[j])){
+ found = true;
+ break;
+ }
+ }
+
+ if (!found) {
+ if (subItems[i].equals(previousSelectedTreeItem)) {
+ previousSelectedTreeItem = null;
+ }
+ subItems[i].dispose();
+ }
+ }
+ }
+
+}
+public void run () {
+ while (!shell.isDisposed ())
+ if (!display.readAndDispatch ()) display.sleep ();
+}
+// Called when a drive is selected from the combo box
+// Behavior is supposed to be as close as possible to that of Win 95 Explorer
+void selectCombo () {
+ // update what the widgets display
+ String comboText = combo.getText();
+
+ TreeItem ti = comboContents [combo.getSelectionIndex ()];
+ tree.setSelection (new TreeItem [] {ti});
+ File file = (File)ti.getData();
+
+ // Special case: if drive a or b is selected and does not contain a disk
+ // then prompt user to retry
+ String path = file.getAbsolutePath();
+ if (! file.exists () && ( path.equals(DRIVE_A) || path.equals(DRIVE_B))) {
+ if (messageBoxRetry (path) == SWT.RETRY) {
+ selectCombo();
+ } else {
+ tree.setSelection (new TreeItem [] {previousSelectedTreeItem});
+ int index = -1;
+ for (int i = 0; i < comboContents.length; i++) {
+ if (comboContents[i].equals(previousSelectedTreeItem)){
+ index = i;
+ break;
+ }
+ }
+ if (index != -1)
+ combo.select (index);
+ }
+ return;
+ }
+
+ setText(file);
+
+ // change tree item images
+ if (previousSelectedTreeItem != null && previousSelectedTreeItem.getImage() == Images.FolderOpen)
+ previousSelectedTreeItem.setImage(Images.Folder);
+
+ // update the table and other widgets
+ updateTable(file);
+ updateNumObjects(file);
+
+ // Update previousSelectedTreeItem
+ previousSelectedTreeItem = ti;
+}
+
+/**
+ * This method selects the parent item in the tree (of the currently selected item)
+ * @param e org.eclipse.swt.widgets.Event
+ */
+void selectParentTreeItem() {
+ TreeItem [] items = tree.getSelection();
+ if (items.length == 0) return;
+
+ if (items [0].getParentItem() != null ){
+ tree.setSelection (new TreeItem [] {items [0].getParentItem()});
+ }
+}
+void selectSash(SelectionEvent event) {
+ if (event.detail != SWT.DRAG) {
+ sash.setBounds (event.x, event.y, event.width, event.height);
+ Rectangle rect = shell.getClientArea ();
+
+ Rectangle toolRect = toolBar.getBounds ();
+ Point size = allFoldersLabel.getSize ();
+ allFoldersLabel.setBounds (0, toolRect.height, event.x, size.y);
+ size = contentLabel.getSize ();
+ contentLabel.setBounds (event.x + event.width, toolRect.height, rect.width - (event.x + event.width), size.y);
+
+ size = tree.getSize ();
+ tree.setSize (event.x, size.y);
+ Rectangle bounds = table.getBounds ();
+ table.setBounds (event.x + event.width, bounds.y, rect.width - (event.x + event.width), bounds.height);
+ return;
+ }
+ Rectangle rect = shell.getClientArea ();
+ event.x = Math.min (Math.max (30, event.x), rect.width - 30);
+}
+// Update the appropriate widgets when a tree item is selected
+void selectTree () {
+ TreeItem[] selection = tree.getSelection();
+ if (selection.length == 0) return;
+
+ TreeItem item = selection[0];
+ File file = (File)item.getData();
+
+ // Special case: if drive a or b is selected and does not contain a disk
+ // then prompt user to retry
+ String path = file.getAbsolutePath();
+ if (!file.exists () && ( path.equals(DRIVE_A) || path.equals(DRIVE_B))) {
+ if (messageBoxRetry (path) == SWT.RETRY) {
+ selectTree ();
+ } else {
+ tree.setSelection (new TreeItem [] {previousSelectedTreeItem});
+ int index = -1;
+ for (int i = 0; i < comboContents.length; i++) {
+ if (comboContents[i].equals(previousSelectedTreeItem)){
+ index = i;
+ break;
+ }
+ }
+ if (index != -1)
+ combo.select (index);
+ }
+ return;
+ }
+
+ // Update the widgets
+ setText (file);
+
+ // Update the combo box if a new drive is selected
+ String drive = file.getAbsolutePath();
+ int end = drive.indexOf(File.separator);
+ drive = drive.substring(0, end + 1);
+ if (!combo.getText().equals(drive)){
+ combo.select (combo.indexOf(drive));
+ }
+
+ // Update the contents of the table
+ updateTable(file);
+ updateNumObjects(file);
+
+ // Update the images of the tree items
+ if (item.getImage() == Images.Folder) item.setImage(Images.FolderOpen);
+ if (previousSelectedTreeItem != null && previousSelectedTreeItem.getImage() == Images.FolderOpen) previousSelectedTreeItem.setImage(Images.Folder);
+
+ // Update previousSelectedTreeItem
+ previousSelectedTreeItem = item;
+}
+/**
+ * Insert the method's description here.
+ * @param file java.io.File
+ */
+void setExpandable(TreeItem treeItem) {
+ File file = (File)treeItem.getData();
+ String path = file.getAbsolutePath();
+ if (path.equals(DRIVE_A) || path.equals(DRIVE_B) || (file.exists() && file.list() != null) ) {
+ // if the tree item doesn't have a "+", then add a dummy item
+ if (treeItem.getItems().length == 0) {
+ TreeItem newItem2 = new TreeItem (treeItem, SWT.NULL);
+ newItem2.setText ("?????");
+ }
+ }
+
+}
+
+/**
+ * Insert the method's description here.
+ * @param s java.lang.String
+ */
+void setText(File file) {
+ String name = null;
+ if (file != null) {
+ name = file.getName();
+ if (name.length() == 0) {
+ name = file.getPath();
+ }
+ }
+ shell.setText (resExplorer.getString("Title") + " " + name);
+
+ name = file.getPath();
+ if (!file.isDirectory()) name = file.getParent();
+ contentLabel.setText(resExplorer.getString("Content_of")+" '"+name+"'");
+
+ long folderSize = file.length();
+ long diskFreeSize = 0;
+ diskSpaceLabel.setText(folderSize+" "+resExplorer.getString("Filesize_1")+" "+diskFreeSize+resExplorer.getString("Filesize_2"));
+
+}
+void setStatusBarVisible(boolean show) {
+}
+/**
+ * Insert method's description here.
+ * @param show boolean
+ */
+void setToolBarVisible(boolean show) {
+}
+void shellResized (ControlEvent event) {
+ Rectangle rect = shell.getClientArea ();
+ Point comboSize = combo.computeSize (combo.getSize ().x, SWT.DEFAULT);
+ Point toolBarSize = toolBar.computeSize (rect.width, SWT.DEFAULT);
+ int toolHeight = Math.max (comboSize.y, toolBarSize.y) + 2;
+ toolBar.setBounds (0, 0, rect.width, toolHeight);
+
+ Rectangle sashBounds = sash.getBounds ();
+ int sashX = sashBounds.x, sashWidth = sashBounds.width;
+
+ Point size = numObjectsLabel.getSize ();
+ allFoldersLabel.setBounds (0, toolHeight, sashX, size.y);
+ contentLabel.setBounds (sashX + sashWidth, toolHeight, rect.width - (sashX + sashWidth), size.y);
+
+ sash.setBounds (sashX, toolHeight, sashWidth, rect.height - toolHeight - size.y);
+ tree.setBounds (0, toolHeight + size.y, sashX, rect.height - toolHeight - (size.y * 2));
+ table.setBounds (sashX + sashWidth, toolHeight + size.y, rect.width - (sashX + sashWidth), rect.height - toolHeight - (size.y * 2));
+
+ numObjectsLabel.setBounds (0, rect.height - size.y, size.x, size.y);
+ diskSpaceLabel.setBounds (size.x, rect.height - size.y, rect.width - size.x, size.y);
+}
+void sort (File[] files) {
+ boolean done;
+ do {
+ done = true;
+ for (int i=files.length-1; i>0; i--) {
+ if (cancel) return;
+ if (files [i-1].getName().toUpperCase ().compareTo (files [i].getName().toUpperCase ()) > 0) {
+ File temp = files [i];
+ files [i] = files [i-1];
+ files [i-1] = temp;
+ done = false;
+ }
+ }
+ } while (!done);
+ return;
+}
+/**
+ * This method adjusts the contents of the label
+ * @param numElements int
+ */
+void updateNumObjects(File file) {
+ String[] items = file.list();
+ int count = 0;
+ if (items != null) {
+ count = items.length;
+ }
+ numObjectsLabel.setText (count+" "+resExplorer.getString("Objects"));
+}
+
+void updateTable (final File root) {
+ if (tableThread != null) {
+ cancel = true;
+ while (cancel) {
+ while (display.readAndDispatch ());
+ }
+ }
+ if (!root.exists ()) return;
+
+ cancel = false;
+ tableThread = new Thread (new Runnable () {
+ public void run () {
+ display.syncExec (new Runnable () {
+ public void run () {
+ table.setRedraw (false);
+ table.removeAll ();
+ table.setData(root);
+ }
+ });
+ File [] list = root.listFiles ();
+ if (list == null) list = new File [0];
+ sort (list);
+ for (int i=0; i<list.length; i++) {
+ if (cancel) break;
+ final File file = list[i];
+ /*
+ * (the format of the date should be modified, using something similar to:
+ * parsing the date: g.MONTH+1+"/"+g.DAY_OF_MONTH+"/"+g.YEAR+" ||| "+
+ * Note: Deprecated: date.toLocaleString()
+ */
+ Image image = null;
+ String [] strings = null;
+ String date = new Date(file.lastModified()).toLocaleString();
+ if (list[i].isDirectory ()) {
+ strings = new String [] {file.getName(), "", resExplorer.getString("File_folder"), date};
+ image = Images.Folder;
+ } else {
+ strings = new String [] {file.getName(),
+ file.length() / 1024 + 1 + " " + resExplorer.getString("KB"),
+ resExplorer.getString("System_file"),
+ date};
+ image = Images.File;
+ }
+ final Image finalImage = image;
+ final String [] finalStrings = strings;
+ display.syncExec (new Runnable () {
+ public void run () {
+ TableItem tableItem = new TableItem(table, 0);
+ tableItem.setText(finalStrings);
+ tableItem.setImage(finalImage);
+ tableItem.setData(file);
+ }
+ });
+ }
+ display.syncExec (new Runnable () {
+ public void run () {
+ table.setRedraw (true);
+ }
+ });
+ tableThread = null;
+ cancel = false;
+ }
+ });
+ tableThread.start ();
+}
+
+}
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/Images.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/Images.java
new file mode 100755
index 0000000000..55f0416349
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/Images.java
@@ -0,0 +1,107 @@
+package org.eclipse.swt.examples.explorer;
+
+import java.io.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+public class Images {
+
+ // Bitmap Images
+ public static Image Copy;
+ public static Image Cut;
+ public static Image Delete;
+ public static Image Details;
+ public static Image Disconnect;
+ public static Image Drive;
+ public static Image File;
+ public static Image Folder;
+ public static Image FolderOpen;
+ public static Image Large;
+ public static Image List;
+ public static Image MapNetwork;
+ public static Image Paste;
+ public static Image Properties;
+ public static Image Small;
+ public static Image Undo;
+ public static Image UpDirectory;
+
+ // Icon Images
+ public static Image ShellIcon;
+
+ // Cursors
+ public static Cursor CursorWait;
+
+ static Image [] AllIcons;
+ static Image [] AllBitmaps;
+ static Cursor [] AllCursors;
+
+public static void freeAll () {
+ if (AllIcons == null) return;
+ for (int i=0; i<AllIcons.length; i++) AllIcons [i].dispose ();
+ for (int i=0; i<AllBitmaps.length; i++) AllBitmaps [i].dispose ();
+ for (int i=0; i<AllCursors.length; i++) AllCursors [i].dispose ();
+ AllIcons = null; AllBitmaps = null; AllCursors = null;
+}
+
+static Image createBitmapImage(Display display, String fileName) {
+ ImageData source = new ImageData(Images.class.getResourceAsStream(fileName+".bmp"));
+ ImageData mask = new ImageData(Images.class.getResourceAsStream(fileName+"_mask.bmp"));
+ return new Image (display, source, mask);
+}
+public static void loadAll (Display display) {
+
+ // Bitmap Images
+ Copy = createBitmapImage (display, "copy");
+ Cut = createBitmapImage (display, "cut");
+ Delete = createBitmapImage (display, "delete");
+ Details = createBitmapImage (display, "details");
+ Disconnect = createBitmapImage (display, "disconnect");
+ Drive = createBitmapImage (display, "drive");
+ File = createBitmapImage (display, "file");
+ Folder = createBitmapImage (display, "folder");
+ FolderOpen = createBitmapImage (display, "folderopen");
+ Large = createBitmapImage (display, "largeicons");
+ List = createBitmapImage (display, "list");
+ MapNetwork = createBitmapImage (display, "mapnetwork");
+ Paste = createBitmapImage (display, "paste");
+ Properties = createBitmapImage (display, "properties");
+ Small = createBitmapImage (display, "smallicons");
+ Undo = createBitmapImage (display, "undo");
+ UpDirectory = createBitmapImage (display, "up");
+
+ // Icon Images
+ ShellIcon = new Image(display, Images.class.getResourceAsStream("oti.ico"));
+
+ // Cursors
+ CursorWait = new Cursor (display, SWT.CURSOR_WAIT);
+
+ AllBitmaps = new Image [] {
+ Drive,
+ Folder,
+ FolderOpen,
+ UpDirectory,
+ MapNetwork,
+ Disconnect,
+ Cut,
+ Copy,
+ Paste,
+ Undo,
+ Delete,
+ Properties,
+ Large,
+ Small,
+ List,
+ Details,
+ File,
+ };
+
+ AllIcons = new Image [] {
+ ShellIcon
+ };
+
+ AllCursors = new Cursor [] {
+ CursorWait,
+ };
+}
+}
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/copy.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/copy.bmp
new file mode 100755
index 0000000000..9b678bffdc
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/copy.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/copy_mask.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/copy_mask.bmp
new file mode 100755
index 0000000000..52dfc5a1e0
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/copy_mask.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/cut.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/cut.bmp
new file mode 100755
index 0000000000..41fe01da7f
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/cut.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/cut_mask.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/cut_mask.bmp
new file mode 100755
index 0000000000..bb862185e7
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/cut_mask.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/delete.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/delete.bmp
new file mode 100755
index 0000000000..e3999e348c
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/delete.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/delete_mask.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/delete_mask.bmp
new file mode 100755
index 0000000000..f0201aa7fc
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/delete_mask.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/details.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/details.bmp
new file mode 100755
index 0000000000..8e5939e759
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/details.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/details_mask.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/details_mask.bmp
new file mode 100755
index 0000000000..3422674b9b
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/details_mask.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/disconnect.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/disconnect.bmp
new file mode 100755
index 0000000000..888bc65568
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/disconnect.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/disconnect_mask.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/disconnect_mask.bmp
new file mode 100755
index 0000000000..8838070883
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/disconnect_mask.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/drive.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/drive.bmp
new file mode 100755
index 0000000000..39165d3afa
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/drive.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/drive_mask.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/drive_mask.bmp
new file mode 100755
index 0000000000..72143da904
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/drive_mask.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/file.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/file.bmp
new file mode 100755
index 0000000000..f3620adf2c
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/file.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/file_mask.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/file_mask.bmp
new file mode 100755
index 0000000000..55def8ced0
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/file_mask.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/folder.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/folder.bmp
new file mode 100755
index 0000000000..eaf25d0c93
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/folder.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/folder_mask.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/folder_mask.bmp
new file mode 100755
index 0000000000..49ba23d3ce
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/folder_mask.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/folderopen.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/folderopen.bmp
new file mode 100755
index 0000000000..7b9cc3ada6
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/folderopen.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/folderopen_mask.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/folderopen_mask.bmp
new file mode 100755
index 0000000000..93c1a98a71
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/folderopen_mask.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/largeicons.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/largeicons.bmp
new file mode 100755
index 0000000000..e554abe945
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/largeicons.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/largeicons_mask.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/largeicons_mask.bmp
new file mode 100755
index 0000000000..3422674b9b
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/largeicons_mask.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/list.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/list.bmp
new file mode 100755
index 0000000000..832520885f
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/list.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/list_mask.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/list_mask.bmp
new file mode 100755
index 0000000000..3422674b9b
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/list_mask.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/mapnetwork.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/mapnetwork.bmp
new file mode 100755
index 0000000000..af86c86140
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/mapnetwork.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/mapnetwork_mask.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/mapnetwork_mask.bmp
new file mode 100755
index 0000000000..32250e2077
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/mapnetwork_mask.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/oti.ico b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/oti.ico
new file mode 100755
index 0000000000..3e6e389a7c
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/oti.ico
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/paste.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/paste.bmp
new file mode 100755
index 0000000000..17d31d1b29
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/paste.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/paste_mask.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/paste_mask.bmp
new file mode 100755
index 0000000000..6febea32d1
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/paste_mask.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/properties.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/properties.bmp
new file mode 100755
index 0000000000..d62721328b
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/properties.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/properties_mask.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/properties_mask.bmp
new file mode 100755
index 0000000000..97d1a167ea
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/properties_mask.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/smallicons.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/smallicons.bmp
new file mode 100755
index 0000000000..bf3b66066c
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/smallicons.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/smallicons_mask.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/smallicons_mask.bmp
new file mode 100755
index 0000000000..3422674b9b
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/smallicons_mask.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/undo.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/undo.bmp
new file mode 100755
index 0000000000..844b16f56f
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/undo.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/undo_mask.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/undo_mask.bmp
new file mode 100755
index 0000000000..535b608293
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/undo_mask.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/up.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/up.bmp
new file mode 100755
index 0000000000..b3e89bcf7c
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/up.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/up_mask.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/up_mask.bmp
new file mode 100755
index 0000000000..b020edceb0
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/explorer/up_mask.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/helloworld/HelloWorld1.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/helloworld/HelloWorld1.java
new file mode 100755
index 0000000000..5fedc32e04
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/helloworld/HelloWorld1.java
@@ -0,0 +1,28 @@
+package org.eclipse.swt.examples.helloworld;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/* Imports */
+
+import org.eclipse.swt.widgets.*;
+
+/*
+* This example demonstrates the minimum amount of code required to open an SWT Shell
+* and process the events.
+*/
+public class HelloWorld1 {
+
+public static void main (String [] args) {
+ Display display = new Display ();
+ Shell shell = new Shell (display);
+ shell.open ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+}
+} \ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/helloworld/HelloWorld2.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/helloworld/HelloWorld2.java
new file mode 100755
index 0000000000..b901972288
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/helloworld/HelloWorld2.java
@@ -0,0 +1,35 @@
+package org.eclipse.swt.examples.helloworld;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/* Imports */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import java.util.ResourceBundle;
+
+/*
+* This example builds on HelloWorld1 and demonstrates the minimum amount
+* of code required to open an SWT Shell with a Label and process the events.
+*/
+
+public class HelloWorld2 {
+ private static ResourceBundle resHello = ResourceBundle.getBundle("examples_helloworld");
+
+public static void main (String [] args) {
+ Display display = new Display ();
+ Shell shell = new Shell (display);
+ Label label = new Label (shell, SWT.CENTER);
+ label.setText (resHello.getString("Hello_world"));
+ label.setBounds (shell.getClientArea ());
+ shell.open ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+}
+} \ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/helloworld/HelloWorld3.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/helloworld/HelloWorld3.java
new file mode 100755
index 0000000000..53144a2e17
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/helloworld/HelloWorld3.java
@@ -0,0 +1,42 @@
+package org.eclipse.swt.examples.helloworld;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/* Imports */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.events.*;
+import java.util.ResourceBundle;
+
+/*
+* This example builds on HelloWorld2 and demonstrates how to resize the
+* Label when the Shell resizes using a Listener mechanism.
+*/
+
+public class HelloWorld3 {
+ private static ResourceBundle resHello = ResourceBundle.getBundle("examples_helloworld");
+
+public static void main (String [] args) {
+ Display display = new Display ();
+ final Shell shell = new Shell (display);
+ final Label label = new Label (shell, SWT.CENTER);
+ label.setText (resHello.getString("Hello_world"));
+ label.pack();
+ shell.addControlListener(new ControlAdapter() {
+ public void controlResized(ControlEvent e) {
+ label.setBounds (shell.getClientArea ());
+ }
+ });
+ shell.pack();
+ shell.open ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+}
+} \ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/helloworld/HelloWorld4.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/helloworld/HelloWorld4.java
new file mode 100755
index 0000000000..2e04ebec2d
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/helloworld/HelloWorld4.java
@@ -0,0 +1,37 @@
+package org.eclipse.swt.examples.helloworld;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/* Imports */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import java.util.ResourceBundle;
+
+/*
+* This example builds on HelloWorld2 and demonstrates how to resize the
+* Label when the Shell resizes using a Layout.
+*/
+
+public class HelloWorld4 {
+ private static ResourceBundle resHello = ResourceBundle.getBundle("examples_helloworld");
+
+public static void main (String [] args) {
+ Display display = new Display ();
+ Shell shell = new Shell (display);
+ shell.setLayout(new FillLayout());
+ Label label = new Label (shell, SWT.CENTER);
+ label.setText (resHello.getString("Hello_world"));
+ shell.pack ();
+ shell.open ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+}
+} \ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/helloworld/HelloWorld5.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/helloworld/HelloWorld5.java
new file mode 100755
index 0000000000..2b49b825a0
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/helloworld/HelloWorld5.java
@@ -0,0 +1,45 @@
+package org.eclipse.swt.examples.helloworld;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/* Imports */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import java.util.ResourceBundle;
+
+/*
+* This example builds on HelloWorld1 and demonstrates how to draw directly
+* on an SWT Control.
+*/
+
+public class HelloWorld5 {
+ private static ResourceBundle resHello = ResourceBundle.getBundle("examples_helloworld");
+
+public static void main (String [] args) {
+ Display display = new Display ();
+ final Color red = new Color(display, 0xFF, 0, 0);
+ final Shell shell = new Shell (display);
+ shell.addPaintListener(new PaintListener () {
+ public void paintControl(PaintEvent event){
+ GC gc = event.gc;
+ gc.setForeground(red);
+ Rectangle rect = shell.getClientArea();
+ gc.drawRectangle(rect.x + 10, rect.y + 10, rect.width - 20, rect.height - 20);
+ gc.drawString(resHello.getString("Hello_world"), rect.x + 20, rect.y + 20);
+ }
+ });
+ shell.open ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ red.dispose();
+ display.dispose ();
+}
+} \ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/hover/HoverHelpExample.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/hover/HoverHelpExample.java
new file mode 100755
index 0000000000..716756b31c
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/hover/HoverHelpExample.java
@@ -0,0 +1,137 @@
+package org.eclipse.swt.examples.hover;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/* Imports */
+
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import java.util.ResourceBundle;
+
+/* This example demonstrates how to implement hover help feedback
+ * using the MouseTrackListener.
+ */
+public class HoverHelpExample {
+ private static ResourceBundle resHover = ResourceBundle.getBundle("examples_hover");
+
+public static void main (String args []) {
+ Display display = new Display ();
+ final Shell shell = new Shell (display);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
+ shell.setLayout(layout);
+
+ final Shell tip = new Shell (shell, SWT.NONE);
+ tip.setLayout(new FillLayout());
+ Label label = new Label (tip, SWT.NONE);
+ label.setForeground (display.getSystemColor (SWT.COLOR_INFO_FOREGROUND));
+ label.setBackground (display.getSystemColor (SWT.COLOR_INFO_BACKGROUND));
+
+ shell.addHelpListener (new HelpListener () {
+ public void helpRequested (HelpEvent event) {
+ if (tip.isVisible ()) {
+ tip.setVisible (false);
+ Shell help = new Shell (shell, SWT.SHELL_TRIM);
+ help.setLayout(new FillLayout());
+ Label label = new Label (help, SWT.NONE);
+ label.setText (resHover.getString("F1_help_for") + " " + tip.getData ("TIP_WIDGET"));
+ help.pack ();
+ help.open ();
+ }
+ }
+ });
+
+ ToolBar bar = new ToolBar (shell, SWT.BORDER);
+ for (int i=0; i<5; i++) {
+ ToolItem item = new ToolItem (bar, SWT.PUSH);
+ item.setText (resHover.getString("Item") + " " + i);
+ item.setData ("TIP_TEXT", item.getText ());
+ }
+ GridData gridData = new GridData();
+ gridData.horizontalSpan = 3;
+ bar.setLayoutData(gridData);
+ setHoverHelp (bar, tip);
+
+ Table table = new Table (shell, SWT.BORDER);
+ for (int i=0; i<4; i++) {
+ TableItem item = new TableItem (table, SWT.PUSH);
+ item.setText (resHover.getString("Item") + " " + i);
+ item.setData ("TIP_TEXT", item.getText ());
+ }
+ table.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL));
+ setHoverHelp (table, tip);
+
+ Tree tree = new Tree (shell, SWT.BORDER);
+ for (int i=0; i<4; i++) {
+ TreeItem item = new TreeItem (tree, SWT.PUSH);
+ item.setText (resHover.getString("Item") + " " + i);
+ item.setData ("TIP_TEXT", item.getText ());
+ }
+ tree.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL));
+ setHoverHelp (tree, tip);
+
+ Button button = new Button (shell, SWT.PUSH);
+ button.setText (resHover.getString("Hello"));
+ button.setData ("TIP_TEXT", button.getText ());
+ setHoverHelp (button, tip);
+
+ shell.pack ();
+ shell.open ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+}
+
+static void setHoverHelp (final Control control, final Shell tip) {
+ control.addMouseListener (new MouseAdapter () {
+ public void mouseDown (MouseEvent e) {
+ if (tip.isVisible ()) tip.setVisible (false);
+ }
+ });
+ control.addMouseTrackListener (new MouseTrackAdapter () {
+ public void mouseExit (MouseEvent e) {
+ if (tip.isVisible ()) tip.setVisible (false);
+ tip.setData ("TIP_WIDGET", null);
+ }
+ public void mouseHover (MouseEvent e) {
+ Point pt = new Point (e.x, e.y);
+ Widget widget = e.widget;
+ if (widget instanceof ToolBar) {
+ ToolBar w = (ToolBar) widget;
+ widget = w.getItem (pt);
+ }
+ if (widget instanceof Table) {
+ Table w = (Table) widget;
+ widget = w.getItem (pt);
+ }
+ if (widget instanceof Tree) {
+ Tree w = (Tree) widget;
+ widget = w.getItem (pt);
+ }
+ if (widget == null) {
+ tip.setVisible (false);
+ tip.setData ("TIP_WIDGET", null);
+ return;
+ }
+ if (widget == tip.getData ("TIP_WIDGET")) return;
+ tip.setData ("TIP_WIDGET", widget);
+ pt.y += 16;
+ pt = control.toDisplay (pt);
+ tip.setLocation (pt);
+ Label label = (Label) (tip.getChildren () [0]);
+ String text = (String) widget.getData ("TIP_TEXT");
+ if (text != null) label.setText (text);
+ tip.pack ();
+ tip.setVisible (true);
+ }
+ });
+}
+
+} \ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/imageexample/ImageAnalyzer.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/imageexample/ImageAnalyzer.java
new file mode 100755
index 0000000000..c4135f4bed
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/imageexample/ImageAnalyzer.java
@@ -0,0 +1,1801 @@
+package org.eclipse.swt.examples.imageexample;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.graphics.*;
+import java.util.ResourceBundle;
+import java.text.MessageFormat;
+
+public class ImageAnalyzer {
+ private static ResourceBundle bundle = ResourceBundle.getBundle("examples_images");
+
+ Shell shell;
+ Canvas imageCanvas, paletteCanvas;
+ Label typeLabel, sizeLabel, depthLabel, transparentPixelLabel,
+ screenSizeLabel, backgroundPixelLabel, locationLabel,
+ disposalMethodLabel, delayTimeLabel, repeatCountLabel,
+ paletteLabel, dataLabel, statusLabel;
+ Combo backgroundCombo, scaleXCombo, scaleYCombo, alphaCombo;
+ Button incrementalCheck, transparentCheck, maskCheck, backgroundCheck;
+ Button previousButton, nextButton, animateButton;
+ Text dataText;
+ Display display;
+ Color whiteColor, blackColor, redColor, greenColor, blueColor, canvasBackground;
+ Font fixedWidthFont;
+ Cursor crossCursor;
+ GC imageCanvasGC;
+
+ int paletteWidth = 140; // recalculated and used as a width hint
+ int ix = 0, iy = 0, py = 0; // used to scroll the image and palette
+ float xscale = 1, yscale = 1; // used to scale the image
+ int alpha = 255; // used to modify the alpha value of the image
+ boolean incremental = false; // used to incrementally display an image
+ boolean transparent = true; // used to display an image with transparency
+ boolean showMask = false; // used to display an icon mask or transparent image mask
+ boolean showBackground = false; // used to display the background of an animated image
+ boolean animate = false; // used to animate a multi-image file
+ Thread animateThread;
+ String lastPath; // used to seed the file dialog
+ String fileName; // the current image file
+ ImageLoader loader; // the loader for the current image file
+ ImageData[] imageDataArray; // all image data read from the current file
+ int imageDataIndex; // the index of the current image data
+ ImageData imageData; // the currently-displayed image data
+ Image image; // the currently-displayed image
+ int drawIncrement = 0; // the index of the current incremental imageData to draw
+ int finalIncrement = 0; // the index of the final incremental imageData to draw
+
+ public static final int ALPHA_CONSTANT = 0;
+ public static final int ALPHA_X = 1;
+ public static final int ALPHA_Y = 2;
+
+ public static void main(String [] args) {
+ ImageAnalyzer imageAnalyzer = new ImageAnalyzer();
+ imageAnalyzer.open();
+ }
+
+ void open() {
+ // Create a window and set its title.
+ shell = new Shell();
+ shell.setText(bundle.getString("Image_analyzer"));
+
+ // Hook resize and dispose listeners.
+ shell.addControlListener(new ControlAdapter() {
+ public void controlResized(ControlEvent event) {
+ resizeShell(event);
+ }
+ });
+ shell.addShellListener(new ShellAdapter() {
+ public void shellClosed(ShellEvent event) {
+ if (animate && animateThread != null) {
+ // Stop the animation and wait for the
+ // thread to die before disposing the shell.
+ animate = false;
+ while (animateThread.isAlive()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ }
+ }
+ });
+
+ // Create colors and fonts.
+ display = shell.getDisplay();
+ whiteColor = new Color(display, 255, 255, 255);
+ blackColor = new Color(display, 0, 0, 0);
+ redColor = new Color(display, 255, 0, 0);
+ greenColor = new Color(display, 0, 255, 0);
+ blueColor = new Color(display, 0, 0, 255);
+ fixedWidthFont = new Font(display, "courier", 10, 0);
+ crossCursor = new Cursor(display, SWT.CURSOR_CROSS);
+
+ // Add a menu bar and widgets.
+ Menu menuBar = createMenuBar();
+ createWidgets();
+ shell.pack();
+
+ // Create a GC for drawing.
+ imageCanvasGC = new GC(imageCanvas);
+
+ // Open the window, and run an event loop until the window is closed.
+ shell.open();
+ while (!shell.isDisposed())
+ if (!display.readAndDispatch()) display.sleep();
+
+ // Clean up.
+ if (image != null)
+ image.dispose();
+ whiteColor.dispose();
+ blackColor.dispose();
+ redColor.dispose();
+ greenColor.dispose();
+ blueColor.dispose();
+ fixedWidthFont.dispose();
+ crossCursor.dispose();
+ imageCanvasGC.dispose();
+ }
+
+ void createWidgets() {
+ // Add the widgets to the shell in a grid layout.
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.numColumns = 2;
+ shell.setLayout(layout);
+
+ // Separate the menu bar from the rest of the widgets.
+ Label separator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
+ GridData gridData = new GridData();
+ gridData.horizontalSpan = 2;
+ gridData.horizontalAlignment = GridData.FILL;
+ separator.setLayoutData(gridData);
+
+ // Add a composite to contain some control widgets across the top.
+ Composite controls = new Composite(shell, SWT.NULL);
+ RowLayout rowLayout = new RowLayout();
+ rowLayout.marginTop = 0;
+ rowLayout.marginBottom = 5;
+ rowLayout.spacing = 8;
+ controls.setLayout(rowLayout);
+ gridData = new GridData();
+ gridData.horizontalSpan = 2;
+ controls.setLayoutData(gridData);
+
+ // Combo to change the background.
+ Group group = new Group(controls, SWT.NULL);
+ group.setLayout(new RowLayout());
+ group.setText(bundle.getString("Background"));
+ backgroundCombo = new Combo(group, SWT.DROP_DOWN | SWT.READ_ONLY);
+ backgroundCombo.setItems(new String[] {
+ bundle.getString("None"),
+ bundle.getString("White"),
+ bundle.getString("Black"),
+ bundle.getString("Red"),
+ bundle.getString("Green"),
+ bundle.getString("Blue")});
+ backgroundCombo.select(backgroundCombo.indexOf(bundle.getString("White")));
+ backgroundCombo.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ changeBackground();
+ }
+ });
+
+
+ // Combo to change the x scale.
+ String[] values = {
+ "0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9", "1",
+ "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "2",
+ "3", "4", "5", "6", "7", "8", "9", "10",};
+ group = new Group(controls, SWT.NULL);
+ group.setLayout(new RowLayout());
+ group.setText(bundle.getString("X_scale"));
+ scaleXCombo = new Combo(group, SWT.DROP_DOWN);
+ for (int i = 0; i < values.length; i++) {
+ scaleXCombo.add(values[i]);
+ }
+ scaleXCombo.select(scaleXCombo.indexOf("1"));
+ scaleXCombo.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ scaleX();
+ }
+ });
+
+ // Combo to change the y scale.
+ group = new Group(controls, SWT.NULL);
+ group.setLayout(new RowLayout());
+ group.setText(bundle.getString("Y_scale"));
+ scaleYCombo = new Combo(group, SWT.DROP_DOWN);
+ for (int i = 0; i < values.length; i++) {
+ scaleYCombo.add(values[i]);
+ }
+ scaleYCombo.select(scaleYCombo.indexOf("1"));
+ scaleYCombo.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ scaleY();
+ }
+ });
+
+ // Combo to change the alpha value.
+ group = new Group(controls, SWT.NULL);
+ group.setLayout(new RowLayout());
+ group.setText(bundle.getString("Alpha_K"));
+ alphaCombo = new Combo(group, SWT.DROP_DOWN | SWT.READ_ONLY);
+ for (int i = 0; i <= 255; i += 5) {
+ alphaCombo.add(String.valueOf(i));
+ }
+ alphaCombo.select(alphaCombo.indexOf("255"));
+ alphaCombo.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ alpha();
+ }
+ });
+
+ // Check box to request incremental display.
+ group = new Group(controls, SWT.NULL);
+ group.setLayout(new RowLayout());
+ group.setText(bundle.getString("Display"));
+ incrementalCheck = new Button(group, SWT.CHECK);
+ incrementalCheck.setText(bundle.getString("Incremental"));
+ incrementalCheck.setSelection(incremental);
+ incrementalCheck.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ incremental = ((Button)event.widget).getSelection();
+ }
+ });
+
+ // Check box to request transparent display.
+ transparentCheck = new Button(group, SWT.CHECK);
+ transparentCheck.setText(bundle.getString("Transparent"));
+ transparentCheck.setSelection(transparent);
+ transparentCheck.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ transparent = ((Button)event.widget).getSelection();
+ if (image != null) {
+ imageCanvas.redraw();
+ }
+ }
+ });
+
+ // Check box to request mask display.
+ maskCheck = new Button(group, SWT.CHECK);
+ maskCheck.setText(bundle.getString("Mask"));
+ maskCheck.setSelection(showMask);
+ maskCheck.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ showMask = ((Button)event.widget).getSelection();
+ if (image != null) {
+ imageCanvas.redraw();
+ }
+ }
+ });
+
+ // Check box to request background display.
+ backgroundCheck = new Button(group, SWT.CHECK);
+ backgroundCheck.setText(bundle.getString("Background"));
+ backgroundCheck.setSelection(showBackground);
+ backgroundCheck.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ showBackground = ((Button)event.widget).getSelection();
+ }
+ });
+
+ // Group the animation buttons.
+ group = new Group(controls, SWT.NULL);
+ group.setLayout(new RowLayout());
+ group.setText(bundle.getString("Animation"));
+
+ // Push button to display the previous image in a multi-image file.
+ previousButton = new Button(group, SWT.PUSH);
+ previousButton.setText(bundle.getString("Previous"));
+ previousButton.setEnabled(false);
+ previousButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ previous();
+ }
+ });
+
+ // Push button to display the next image in a multi-image file.
+ nextButton = new Button(group, SWT.PUSH);
+ nextButton.setText(bundle.getString("Next"));
+ nextButton.setEnabled(false);
+ nextButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ next();
+ }
+ });
+
+ // Push button to toggle animation of a multi-image file.
+ animateButton = new Button(group, SWT.PUSH);
+ animateButton.setText(bundle.getString("Animate"));
+ animateButton.setEnabled(false);
+ animateButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ animate();
+ }
+ });
+
+ // Separate the control widgets from the rest of the widgets.
+// Label separator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
+// gridData = new GridData();
+// gridData.horizontalSpan = 2;
+// gridData.horizontalAlignment = GridData.FILL;
+// separator.setLayoutData(gridData);
+
+ // Label to show the image file type.
+ typeLabel = new Label(shell, SWT.NULL);
+ typeLabel.setText(bundle.getString("Type_initial"));
+ typeLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+
+ // Canvas to show the image.
+ imageCanvas = new Canvas(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.NO_REDRAW_RESIZE);
+ imageCanvas.setBackground(whiteColor);
+ imageCanvas.setCursor(crossCursor);
+ gridData = new GridData();
+ gridData.verticalSpan = 14;
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ imageCanvas.setLayoutData(gridData);
+ imageCanvas.addPaintListener(new PaintListener() {
+ public void paintControl(PaintEvent event) {
+ if (image != null)
+ paintImage(event);
+ }
+ });
+ imageCanvas.addMouseMoveListener(new MouseMoveListener() {
+ public void mouseMove(MouseEvent event) {
+ if (image != null) {
+ showColorAt(event.x, event.y);
+ }
+ }
+ });
+
+ // Set up the image canvas scroll bars.
+ ScrollBar horizontal = imageCanvas.getHorizontalBar();
+ horizontal.setVisible(true);
+ horizontal.setMinimum(0);
+ horizontal.setEnabled(false);
+ horizontal.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ scrollHorizontally((ScrollBar)event.widget);
+ }
+ });
+ ScrollBar vertical = imageCanvas.getVerticalBar();
+ vertical.setVisible(true);
+ vertical.setMinimum(0);
+ vertical.setEnabled(false);
+ vertical.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ scrollVertically((ScrollBar)event.widget);
+ }
+ });
+
+ // Label to show the image size.
+ sizeLabel = new Label(shell, SWT.NULL);
+ sizeLabel.setText(bundle.getString("Size_initial"));
+ sizeLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+
+ // Label to show the image depth.
+ depthLabel = new Label(shell, SWT.NULL);
+ depthLabel.setText(bundle.getString("Depth_initial"));
+ depthLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+
+ // Label to show the transparent pixel.
+ transparentPixelLabel = new Label(shell, SWT.NULL);
+ transparentPixelLabel.setText(bundle.getString("Transparent_pixel_initial"));
+ transparentPixelLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+
+ // Separate the animation fields from the rest of the fields.
+ separator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
+ separator.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+
+ // Label to show the logical screen size for animation.
+ screenSizeLabel = new Label(shell, SWT.NULL);
+ screenSizeLabel.setText(bundle.getString("Animation_size_initial"));
+ screenSizeLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+
+ // Label to show the background pixel.
+ backgroundPixelLabel = new Label(shell, SWT.NULL);
+ backgroundPixelLabel.setText(bundle.getString("Background_pixel_initial"));
+ backgroundPixelLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+
+ // Label to show the image location (x, y).
+ locationLabel = new Label(shell, SWT.NULL);
+ locationLabel.setText(bundle.getString("Image_location_initial"));
+ locationLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+
+ // Label to show the image disposal method.
+ disposalMethodLabel = new Label(shell, SWT.NULL);
+ disposalMethodLabel.setText(bundle.getString("Disposal_initial"));
+ disposalMethodLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+
+ // Label to show the image delay time.
+ delayTimeLabel = new Label(shell, SWT.NULL);
+ delayTimeLabel.setText(bundle.getString("Delay_initial"));
+ delayTimeLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+
+ // Label to show the background pixel.
+ repeatCountLabel = new Label(shell, SWT.NULL);
+ repeatCountLabel.setText(bundle.getString("Repeats_initial"));
+ repeatCountLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+
+ // Separate the animation fields from the palette.
+ separator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
+ separator.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+
+ // Label to show if the image has a direct or indexed palette.
+ paletteLabel = new Label(shell, SWT.NULL);
+ paletteLabel.setText(bundle.getString("Palette_initial"));
+ paletteLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+
+ // Canvas to show the image's palette.
+ paletteCanvas = new Canvas(shell, SWT.BORDER | SWT.V_SCROLL | SWT.NO_REDRAW_RESIZE);
+ paletteCanvas.setFont(fixedWidthFont);
+ paletteCanvas.getVerticalBar().setVisible(true);
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.FILL;
+ GC gc = new GC(paletteLabel);
+ paletteWidth = gc.stringExtent(bundle.getString("Max_length_string")).x;
+ gc.dispose();
+ gridData.widthHint = paletteWidth;
+ gridData.heightHint = 16 * 11; // show at least 16 colors
+ paletteCanvas.setLayoutData(gridData);
+ paletteCanvas.addPaintListener(new PaintListener() {
+ public void paintControl(PaintEvent event) {
+ if (image != null)
+ paintPalette(event);
+ }
+ });
+
+ // Set up the palette canvas scroll bar.
+ vertical = paletteCanvas.getVerticalBar();
+ vertical.setVisible(true);
+ vertical.setMinimum(0);
+ vertical.setIncrement(10);
+ vertical.setEnabled(false);
+ vertical.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ scrollPalette((ScrollBar)event.widget);
+ }
+ });
+
+ // Sash to see more of image or image data.
+ Sash sash = new Sash(shell, SWT.HORIZONTAL);
+ gridData = new GridData();
+ gridData.horizontalSpan = 2;
+ gridData.horizontalAlignment = GridData.FILL;
+ sash.setLayoutData(gridData);
+
+ // Label to show data-specific fields.
+ dataLabel = new Label(shell, SWT.NULL);
+ dataLabel.setText(bundle.getString("Pixel_data_initial"));
+ gridData = new GridData();
+ gridData.horizontalSpan = 2;
+ gridData.horizontalAlignment = GridData.FILL;
+ dataLabel.setLayoutData(gridData);
+
+ // Text to show a dump of the data.
+ dataText = new Text(shell, SWT.BORDER | SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL);
+ dataText.setFont(fixedWidthFont);
+ gridData = new GridData();
+ gridData.horizontalSpan = 2;
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.heightHint = 128;
+ gridData.grabExcessVerticalSpace = true;
+ dataText.setLayoutData(gridData);
+ dataText.addMouseListener(new MouseAdapter() {
+ public void mouseDown(MouseEvent event) {
+ if (image != null && event.button == 1) {
+ showColorForData();
+ }
+ }
+ });
+ dataText.addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent event) {
+ if (image != null) {
+ showColorForData();
+ }
+ }
+ });
+
+ // Label to show status and cursor location in image.
+ statusLabel = new Label(shell, SWT.NULL);
+ statusLabel.setText("");
+ gridData = new GridData();
+ gridData.horizontalSpan = 2;
+ gridData.horizontalAlignment = GridData.FILL;
+ statusLabel.setLayoutData(gridData);
+ }
+
+ Menu createMenuBar() {
+ // Menu bar.
+ Menu menuBar = new Menu(shell, SWT.BAR);
+ shell.setMenuBar(menuBar);
+
+ createFileMenu(menuBar);
+ createAlphaMenu(menuBar);
+
+ return menuBar;
+ }
+
+ void createFileMenu(Menu menuBar) {
+ // File menu
+ MenuItem item = new MenuItem(menuBar, SWT.CASCADE);
+ item.setText(bundle.getString("File"));
+ Menu fileMenu = new Menu(shell, SWT.DROP_DOWN);
+ item.setMenu(fileMenu);
+
+ // File -> Open...
+ item = new MenuItem(fileMenu, SWT.NULL);
+ item.setText(bundle.getString("Open"));
+ item.setAccelerator(SWT.CTRL + 'O');
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ menuOpen();
+ }
+ });
+
+ // File -> Reopen
+ item = new MenuItem(fileMenu, SWT.NULL);
+ item.setText(bundle.getString("Reopen"));
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ menuReopen();
+ }
+ });
+
+ new MenuItem(fileMenu, SWT.SEPARATOR);
+
+ // File -> Save
+ item = new MenuItem(fileMenu, SWT.NULL);
+ item.setText(bundle.getString("Save"));
+ item.setAccelerator(SWT.CTRL + 'S');
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ menuSave();
+ }
+ });
+
+ // File -> Save As...
+ item = new MenuItem(fileMenu, SWT.NULL);
+ item.setText(bundle.getString("Save_as"));
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ menuSaveAs();
+ }
+ });
+
+ // File -> Save Mask As...
+ item = new MenuItem(fileMenu, SWT.NULL);
+ item.setText(bundle.getString("Save_mask_as"));
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ menuSaveMaskAs();
+ }
+ });
+
+ new MenuItem(fileMenu, SWT.SEPARATOR);
+
+ // File -> Exit
+ item = new MenuItem(fileMenu, SWT.NULL);
+ item.setText(bundle.getString("Exit"));
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ animate = false; // stop any animation in progress
+ shell.close();
+ }
+ });
+
+ }
+
+ void createAlphaMenu(Menu menuBar) {
+ // Alpha menu
+ MenuItem item = new MenuItem(menuBar, SWT.CASCADE);
+ item.setText(bundle.getString("Alpha"));
+ Menu alphaMenu = new Menu(shell, SWT.DROP_DOWN);
+ item.setMenu(alphaMenu);
+
+ // Alpha -> K
+ item = new MenuItem(alphaMenu, SWT.NULL);
+ item.setText("K");
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ menuComposeAlpha(ALPHA_CONSTANT);
+ }
+ });
+
+ // Alpha -> (K + x) % 256
+ item = new MenuItem(alphaMenu, SWT.NULL);
+ item.setText("(K + x) % 256");
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ menuComposeAlpha(ALPHA_X);
+ }
+ });
+
+ // Alpha -> (K + y) % 256
+ item = new MenuItem(alphaMenu, SWT.NULL);
+ item.setText("(K + y) % 256");
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ menuComposeAlpha(ALPHA_Y);
+ }
+ });
+ }
+
+ void menuComposeAlpha(int alpha_op) {
+ if (image == null) return;
+ animate = false; // stop any animation in progress
+
+ Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
+ shell.setCursor(waitCursor);
+ try {
+ if (alpha_op == ALPHA_CONSTANT) {
+ imageData.alpha = alpha;
+ } else {
+ imageData.alpha = -1;
+ switch (alpha_op) {
+ case ALPHA_X:
+ for (int y = 0; y < imageData.height; y++) {
+ for (int x = 0; x < imageData.width; x++) {
+ imageData.setAlpha(x, y, (x + alpha) % 256);
+ }
+ }
+ break;
+ case ALPHA_Y:
+ for (int y = 0; y < imageData.height; y++) {
+ for (int x = 0; x < imageData.width; x++) {
+ imageData.setAlpha(x, y, (y + alpha) % 256);
+ }
+ }
+ break;
+ default: break;
+ }
+ }
+ displayImage(imageData);
+ } finally {
+ shell.setCursor(null);
+ waitCursor.dispose();
+ }
+ }
+
+ void menuOpen() {
+ animate = false; // stop any animation in progress
+ resetScaleCombos();
+
+ // Get the user to choose an image file.
+ FileDialog fileChooser = new FileDialog(shell, SWT.OPEN);
+ if (lastPath != null)
+ fileChooser.setFilterPath(lastPath);
+ fileChooser.setFilterExtensions(new String[] { "*.bmp; *.gif; *.ico; *.jpg; *.pcx; *.png; *.tif", "*.bmp", "*.gif", "*.ico", "*.jpg", "*.pcx", "*.png", "*.tif" });
+ fileChooser.setFilterNames(new String[] { bundle.getString("All_images") + " (bmp, gif, ico, jpg, pcx, png, tif)",
+ "BMP (*.bmp)", "GIF (*.gif)", "ICO (*.ico)", "JPEG (*.jpg)", "PCX (*.pcx)", "PNG (*.png)", "TIFF (*.tif)" });
+ String filename = fileChooser.open();
+ lastPath = fileChooser.getFilterPath();
+ if (filename == null)
+ return;
+
+ Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
+ shell.setCursor(waitCursor);
+ try {
+ loader = new ImageLoader();
+ if (incremental) {
+ // Prepare to handle incremental images.
+ drawIncrement = 0;
+ finalIncrement = 0;
+ loader.addImageLoaderListener(new ImageLoaderListener() {
+ public void imageDataLoaded(ImageLoaderEvent event) {
+ incrementalDataLoaded(event);
+ }
+ });
+ }
+ // Read the new image(s) from the chosen file.
+ imageDataArray = loader.load(filename);
+ if (imageDataArray.length > 0) {
+
+ // Cache the filename.
+ fileName = filename;
+
+ // If there are multiple images in the file (typically GIF)
+ // then enable the Previous, Next and Animate buttons.
+ previousButton.setEnabled(imageDataArray.length > 1);
+ nextButton.setEnabled(imageDataArray.length > 1);
+ animateButton.setEnabled(imageDataArray.length > 1 && loader.logicalScreenWidth > 0 && loader.logicalScreenHeight > 0);
+
+ // Display the first image in the file.
+ imageDataIndex = 0;
+ displayImage(imageDataArray[imageDataIndex]);
+ resetScrollBars();
+ }
+ } catch (SWTException e) {
+ showErrorDialog(bundle.getString("Loading_lc"), filename, e);
+ } finally {
+ shell.setCursor(null);
+ waitCursor.dispose();
+ }
+ }
+
+ /*
+ * Called when incremental image data has been loaded,
+ * for example, for interlaced GIF/PNG or progressive JPEG.
+ */
+ void incrementalDataLoaded(final ImageLoaderEvent event) {
+ if (event.endOfImage) {
+ finalIncrement = event.incrementCount;
+ } else {
+ Thread incrementalThread = new Thread("Incremental") {
+ public void run() {
+ // make absolutely certain that threads draw in order
+ while (event.incrementCount != drawIncrement) {
+ yield();
+ }
+
+ // lock so threads draw one at a time
+ synchronized (imageCanvas) {
+ drawIncrement++;
+ if (image != null) image.dispose();
+ image = new Image(null, event.imageData);
+ imageData = event.imageData;
+ imageCanvasGC.drawImage(
+ image,
+ 0,
+ 0,
+ imageData.width,
+ imageData.height,
+ imageData.x,
+ imageData.y,
+ imageData.width,
+ imageData.height);
+ }
+ display.wake();
+ }
+ };
+ incrementalThread.start();
+ }
+ }
+
+ void menuSave() {
+ if (image == null) return;
+ animate = false; // stop any animation in progress
+
+ // If the image file type is unknown, we can't 'Save',
+ // so we have to use 'Save As...'.
+ if (imageData.type == SWT.IMAGE_UNDEFINED) {
+ menuSaveAs();
+ return;
+ }
+
+ Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
+ shell.setCursor(waitCursor);
+ try {
+ // Save the current image to the current file.
+ loader.data = new ImageData[] {imageData};
+ loader.save(fileName, imageData.type);
+
+ } catch (SWTException e) {
+ showErrorDialog(bundle.getString("Saving_lc"), fileName, e);
+ } finally {
+ shell.setCursor(null);
+ waitCursor.dispose();
+ }
+ }
+
+ void menuSaveAs() {
+ if (image == null) return;
+ animate = false; // stop any animation in progress
+
+ // Get the user to choose a file name and type to save.
+ FileDialog fileChooser = new FileDialog(shell, SWT.SAVE);
+ fileChooser.setFilterPath(lastPath);
+ fileChooser.setFileName(fileName);
+ fileChooser.setFilterExtensions(new String[] { "*.bmp", "*.gif", "*.ico", "*.jpg", "*.png" });
+ fileChooser.setFilterNames(new String[] { "BMP (*.bmp)", "GIF (*.gif)", "ICO (*.ico)", "JPEG (*.jpg)", "PNG (*.png)" });
+ String filename = fileChooser.open();
+ lastPath = fileChooser.getFilterPath();
+ if (filename == null)
+ return;
+
+ // Figure out what file type the user wants saved.
+ // We need to rely on the file extension because FileDialog
+ // does not have API for asking what filter type was selected.
+ int filetype = determineFileType(filename);
+ if (filetype == SWT.IMAGE_UNDEFINED) {
+ MessageBox box = new MessageBox(shell, SWT.ICON_ERROR);
+ box.setMessage(createMsg(bundle.getString("Unknown_extension"),
+ filename.substring(filename.lastIndexOf('.') + 1)));
+ box.open();
+ return;
+ }
+
+ if (new java.io.File(filename).exists()) {
+ MessageBox box = new MessageBox(shell, SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
+ box.setMessage(createMsg(bundle.getString("Overwrite"), filename));
+ if (box.open() == SWT.CANCEL)
+ return;
+ }
+
+ Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
+ shell.setCursor(waitCursor);
+ try {
+ // Save the current image to the specified file.
+ loader.data = new ImageData[] {imageData};
+ loader.save(filename, filetype);
+
+ // Update the shell title and file type label,
+ // and use the new file.
+ fileName = filename;
+ shell.setText(createMsg(bundle.getString("Analyzer_on"), filename));
+ typeLabel.setText(createMsg(bundle.getString("Type_string"), fileTypeString(filetype)));
+
+ } catch (SWTException e) {
+ showErrorDialog(bundle.getString("Saving_lc"), filename, e);
+ } finally {
+ shell.setCursor(null);
+ waitCursor.dispose();
+ }
+ }
+
+ void menuSaveMaskAs() {
+ if (image == null || !showMask) return;
+ if (imageData.getTransparencyType() == SWT.TRANSPARENCY_NONE) return;
+ animate = false; // stop any animation in progress
+
+ // Get the user to choose a file name and type to save.
+ FileDialog fileChooser = new FileDialog(shell, SWT.SAVE);
+ fileChooser.setFilterPath(lastPath);
+ fileChooser.setFileName(fileName);
+ fileChooser.setFilterExtensions(new String[] { "*.bmp", "*.gif", "*.ico", "*.jpg", "*.png" });
+ fileChooser.setFilterNames(new String[] { "BMP (*.bmp)", "GIF (*.gif)", "ICO (*.ico)", "JPEG (*.jpg)", "PNG (*.png)" });
+ String filename = fileChooser.open();
+ lastPath = fileChooser.getFilterPath();
+ if (filename == null)
+ return;
+
+ // Figure out what file type the user wants saved.
+ // We need to rely on the file extension because FileDialog
+ // does not have API for asking what filter type was selected.
+ int filetype = determineFileType(filename);
+ if (filetype == SWT.IMAGE_UNDEFINED) {
+ MessageBox box = new MessageBox(shell, SWT.ICON_ERROR);
+ box.setMessage(createMsg(bundle.getString("Unknown_extension"),
+ filename.substring(filename.lastIndexOf('.') + 1)));
+ box.open();
+ return;
+ }
+
+ if (new java.io.File(filename).exists()) {
+ MessageBox box = new MessageBox(shell, SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
+ box.setMessage(createMsg(bundle.getString("Overwrite"), filename));
+ if (box.open() == SWT.CANCEL)
+ return;
+ }
+
+ Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
+ shell.setCursor(waitCursor);
+ try {
+ // Save the mask of the current image to the specified file.
+ ImageData maskImageData = imageData.getTransparencyMask();
+ loader.data = new ImageData[] {maskImageData};
+ loader.save(filename, filetype);
+
+ } catch (SWTException e) {
+ showErrorDialog(bundle.getString("Saving_lc"), filename, e);
+ } finally {
+ shell.setCursor(null);
+ waitCursor.dispose();
+ }
+ }
+
+ void menuReopen() {
+ if (fileName == null) return;
+ animate = false; // stop any animation in progress
+ resetScrollBars();
+ resetScaleCombos();
+
+ Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
+ shell.setCursor(waitCursor);
+ try {
+ loader = new ImageLoader();
+ ImageData[] newImageData = loader.load(fileName);
+ imageDataIndex = 0;
+ displayImage(newImageData[imageDataIndex]);
+
+ } catch (SWTException e) {
+ showErrorDialog(bundle.getString("Reloading_lc"), fileName, e);
+ } finally {
+ shell.setCursor(null);
+ waitCursor.dispose();
+ }
+ }
+
+ void changeBackground() {
+ String background = backgroundCombo.getText();
+ if (background.equals(bundle.getString("White"))) {
+ imageCanvas.setBackground(whiteColor);
+ } else if (background.equals(bundle.getString("Black"))) {
+ imageCanvas.setBackground(blackColor);
+ } else if (background.equals(bundle.getString("Red"))) {
+ imageCanvas.setBackground(redColor);
+ } else if (background.equals(bundle.getString("Green"))) {
+ imageCanvas.setBackground(greenColor);
+ } else if (background.equals(bundle.getString("Blue"))) {
+ imageCanvas.setBackground(blueColor);
+ } else {
+ imageCanvas.setBackground(null);
+ }
+ // Fill the image canvas with the background color.
+ Rectangle clientArea = imageCanvas.getClientArea();
+ imageCanvasGC.fillRectangle(
+ clientArea.x,
+ clientArea.y,
+ clientArea.width,
+ clientArea.height);
+ if (image != null) {
+ imageCanvas.redraw();
+ }
+ }
+
+ /*
+ * Called when the ScaleX combo selection changes.
+ */
+ void scaleX() {
+ try {
+ xscale = Float.parseFloat(scaleXCombo.getText());
+ } catch (NumberFormatException e) {
+ xscale = 1;
+ scaleXCombo.select(scaleXCombo.indexOf("1"));
+ }
+ if (image != null) {
+ resizeScrollBars();
+ imageCanvas.redraw();
+ }
+ }
+
+ /*
+ * Called when the ScaleY combo selection changes.
+ */
+ void scaleY() {
+ try {
+ yscale = Float.parseFloat(scaleYCombo.getText());
+ } catch (NumberFormatException e) {
+ yscale = 1;
+ scaleYCombo.select(scaleYCombo.indexOf("1"));
+ }
+ if (image != null) {
+ resizeScrollBars();
+ imageCanvas.redraw();
+ }
+ }
+
+ /*
+ * Called when the Alpha combo selection changes.
+ */
+ void alpha() {
+ try {
+ alpha = Integer.parseInt(alphaCombo.getText());
+ } catch (NumberFormatException e) {
+ alphaCombo.select(alphaCombo.indexOf("255"));
+ alpha = 255;
+ }
+ }
+
+ /*
+ * Called when the mouse moves in the image canvas.
+ * Show the color of the image at the point under the mouse.
+ */
+ void showColorAt(int mx, int my) {
+ int x = mx - imageData.x - ix;
+ int y = my - imageData.y - iy;
+ showColorForPixel(x, y);
+ }
+
+ /*
+ * Called when a mouse down or key press is detected
+ * in the data text. Show the color of the pixel at
+ * the caret position in the data text.
+ */
+ void showColorForData() {
+ int delimiterLength = dataText.getLineDelimiter().length();
+ int charactersPerLine = 6 + 3 * imageData.bytesPerLine + delimiterLength;
+ int position = dataText.getCaretPosition();
+ int y = position / charactersPerLine;
+ if ((position - y * charactersPerLine) < 6 || ((y + 1) * charactersPerLine - position) <= delimiterLength) {
+ statusLabel.setText("");
+ return;
+ }
+ int dataPosition = position - 6 * (y + 1) - delimiterLength * y;
+ int byteNumber = dataPosition / 3;
+ int where = dataPosition - byteNumber * 3;
+ int xByte = byteNumber % imageData.bytesPerLine;
+ int x = -1;
+ int depth = imageData.depth;
+ if (depth == 1) { // 8 pixels per byte (can only show 3 of 8)
+ if (where == 0) x = xByte * 8;
+ if (where == 1) x = xByte * 8 + 3;
+ if (where == 2) x = xByte * 8 + 7;
+ }
+ if (depth == 2) { // 4 pixels per byte (can only show 3 of 4)
+ if (where == 0) x = xByte * 4;
+ if (where == 1) x = xByte * 4 + 1;
+ if (where == 2) x = xByte * 4 + 3;
+ }
+ if (depth == 4) { // 2 pixels per byte
+ if (where == 0) x = xByte * 2;
+ if (where == 1) x = xByte * 2;
+ if (where == 2) x = xByte * 2 + 1;
+ }
+ if (depth == 8) { // 1 byte per pixel
+ x = xByte;
+ }
+ if (depth == 16) { // 2 bytes per pixel
+ x = xByte / 2;
+ }
+ if (depth == 24) { // 3 bytes per pixel
+ x = xByte / 3;
+ }
+ if (depth == 32) { // 4 bytes per pixel
+ x = xByte / 4;
+ }
+ if (x != -1) {
+ showColorForPixel(x, y);
+ } else {
+ statusLabel.setText("");
+ }
+ }
+
+ /*
+ * Set the status label to show color information
+ * for the specified pixel in the image.
+ */
+ void showColorForPixel(int x, int y) {
+ if (x >= 0 && x < imageData.width && y >= 0 && y < imageData.height) {
+ int pixel = imageData.getPixel(x, y);
+ RGB rgb = imageData.palette.getRGB(pixel);
+
+ Object[] args = {new Integer(x),
+ new Integer(y),
+ new Integer(pixel),
+ Integer.toHexString(pixel),
+ rgb};
+ if(pixel == imageData.transparentPixel){
+ statusLabel.setText(createMsg(bundle.getString("Color_at_trans"), args));
+ } else {
+ statusLabel.setText(createMsg(bundle.getString("Color_at"), args));
+ }
+ } else {
+ statusLabel.setText("");
+ }
+ }
+
+ /*
+ * Called when the Animate button is pressed.
+ */
+ void animate() {
+ animate = !animate;
+ if (animate && image != null && imageDataArray.length > 1) {
+ animateThread = new Thread(bundle.getString("Animation")) {
+ public void run() {
+ // Pre-animation widget setup.
+ preAnimation();
+
+ // Animate.
+ try {
+ animateLoop();
+ } catch (final SWTException e) {
+ display.syncExec(new Runnable() {
+ public void run() {
+ showErrorDialog(createMsg(bundle.getString("Creating_image"),
+ new Integer(imageDataIndex+1)),
+ fileName, e);
+ }
+ });
+ }
+
+ // Post animation widget reset.
+ postAnimation();
+ }
+ };
+ animateThread.start();
+ }
+ }
+
+ /*
+ * Loop through all of the images in a multi-image file
+ * and display them one after another.
+ */
+ void animateLoop() {
+ // Create an off-screen image to draw on, and a GC to draw with.
+ // Both are disposed after the animation.
+ Image offScreenImage = new Image(null, loader.logicalScreenWidth, loader.logicalScreenHeight);
+ GC offScreenImageGC = new GC(offScreenImage);
+
+ try {
+ // Use syncExec to get the background color of the imageCanvas.
+ display.syncExec(new Runnable() {
+ public void run() {
+ canvasBackground = imageCanvas.getBackground();
+ }
+ });
+
+ // Fill the off-screen image with the background color of the canvas.
+ offScreenImageGC.setBackground(canvasBackground);
+ offScreenImageGC.fillRectangle(
+ 0,
+ 0,
+ loader.logicalScreenWidth,
+ loader.logicalScreenHeight);
+
+ // Draw the current image onto the off-screen image.
+ offScreenImageGC.drawImage(
+ image,
+ 0,
+ 0,
+ imageData.width,
+ imageData.height,
+ imageData.x,
+ imageData.y,
+ imageData.width,
+ imageData.height);
+
+ int repeatCount = loader.repeatCount;
+ while (animate && (loader.repeatCount == 0 || repeatCount > 0)) {
+ if (imageData.disposalMethod == SWT.DM_FILL_BACKGROUND) {
+ // Fill with the background color before drawing.
+ Color bgColor = null;
+ int backgroundPixel = loader.backgroundPixel;
+ if (showBackground && backgroundPixel != -1) {
+ // Fill with the background color.
+ RGB backgroundRGB = imageData.palette.getRGB(backgroundPixel);
+ bgColor = new Color(null, backgroundRGB);
+ }
+ try {
+ offScreenImageGC.setBackground(bgColor != null ? bgColor : canvasBackground);
+ offScreenImageGC.fillRectangle(
+ imageData.x,
+ imageData.y,
+ imageData.width,
+ imageData.height);
+ } finally {
+ if (bgColor != null) bgColor.dispose();
+ }
+ } else if (imageData.disposalMethod == SWT.DM_FILL_PREVIOUS) {
+ // Restore the previous image before drawing.
+ offScreenImageGC.drawImage(
+ image,
+ 0,
+ 0,
+ imageData.width,
+ imageData.height,
+ imageData.x,
+ imageData.y,
+ imageData.width,
+ imageData.height);
+ }
+
+ // Get the next image data.
+ imageDataIndex = (imageDataIndex + 1) % imageDataArray.length;
+ imageData = imageDataArray[imageDataIndex];
+ image.dispose();
+ image = new Image(null, imageData);
+
+ // Draw the new image data.
+ offScreenImageGC.drawImage(
+ image,
+ 0,
+ 0,
+ imageData.width,
+ imageData.height,
+ imageData.x,
+ imageData.y,
+ imageData.width,
+ imageData.height);
+
+ // Draw the off-screen image to the screen.
+ imageCanvasGC.drawImage(offScreenImage, 0, 0);
+
+ // Sleep for the specified delay time before drawing again.
+ try {
+ Thread.sleep(visibleDelay(imageData.delayTime * 10));
+ } catch (InterruptedException e) {
+ }
+
+ // If we have just drawn the last image in the set,
+ // then decrement the repeat count.
+ if (imageDataIndex == imageDataArray.length - 1) repeatCount--;
+ }
+ } finally {
+ offScreenImage.dispose();
+ offScreenImageGC.dispose();
+ }
+ }
+
+ /*
+ * Pre animation setup.
+ */
+ void preAnimation() {
+ display.syncExec(new Runnable() {
+ public void run() {
+ // Change the label of the Animate button to 'Stop'.
+ animateButton.setText(bundle.getString("Stop"));
+
+ // Disable anything we don't want the user
+ // to select during the animation.
+ previousButton.setEnabled(false);
+ nextButton.setEnabled(false);
+ backgroundCombo.setEnabled(false);
+ scaleXCombo.setEnabled(false);
+ scaleYCombo.setEnabled(false);
+ alphaCombo.setEnabled(false);
+ incrementalCheck.setEnabled(false);
+ transparentCheck.setEnabled(false);
+ maskCheck.setEnabled(false);
+ // leave backgroundCheck enabled
+
+ // Reset the scale combos and scrollbars.
+ resetScaleCombos();
+ resetScrollBars();
+ }
+ });
+ }
+
+ /*
+ * Post animation reset.
+ */
+ void postAnimation() {
+ display.syncExec(new Runnable() {
+ public void run() {
+ // Enable anything we disabled before the animation.
+ previousButton.setEnabled(true);
+ nextButton.setEnabled(true);
+ backgroundCombo.setEnabled(true);
+ scaleXCombo.setEnabled(true);
+ scaleYCombo.setEnabled(true);
+ alphaCombo.setEnabled(true);
+ incrementalCheck.setEnabled(true);
+ transparentCheck.setEnabled(true);
+ maskCheck.setEnabled(true);
+
+ // Reset the label of the Animate button.
+ animateButton.setText(bundle.getString("Animate"));
+
+ if (animate) {
+ // If animate is still true, we finished the
+ // full number of repeats. Leave the image as-is.
+ animate = false;
+ } else {
+ // Redisplay the current image and its palette.
+ displayImage(imageDataArray[imageDataIndex]);
+ }
+ }
+ });
+ }
+
+ /*
+ * Called when the Previous button is pressed.
+ * Display the previous image in a multi-image file.
+ */
+ void previous() {
+ if (image != null && imageDataArray.length > 1) {
+ if (imageDataIndex == 0) {
+ imageDataIndex = imageDataArray.length;
+ }
+ imageDataIndex = imageDataIndex - 1;
+ displayImage(imageDataArray[imageDataIndex]);
+ }
+ }
+
+ /*
+ * Called when the Next button is pressed.
+ * Display the next image in a multi-image file.
+ */
+ void next() {
+ if (image != null && imageDataArray.length > 1) {
+ imageDataIndex = (imageDataIndex + 1) % imageDataArray.length;
+ displayImage(imageDataArray[imageDataIndex]);
+ }
+ }
+
+ void displayImage(ImageData newImageData) {
+ if (incremental) {
+ // Wait until all incremental threads have finished drawing
+ while (drawIncrement < finalIncrement) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ }
+
+ // Dispose of the old image, if there was one.
+ if (image != null) image.dispose();
+
+ try {
+ // Cache the new image and imageData.
+ image = new Image(null, newImageData);
+ imageData = newImageData;
+
+ } catch (SWTException e) {
+ showErrorDialog(bundle.getString("Creating_from") + " ", fileName, e);
+ image = null;
+ return;
+ }
+
+ // Update the widgets with the new image info.
+ String string = createMsg(bundle.getString("Analyzer_on"), fileName);
+ shell.setText(string);
+
+ if(imageDataArray.length > 1){
+ string = createMsg(bundle.getString("Type_index"),
+ new Object[] {fileTypeString(imageData.type),
+ new Integer(imageDataIndex + 1),
+ new Integer(imageDataArray.length)});
+ } else {
+ string = createMsg(bundle.getString("Type_string"), fileTypeString(imageData.type));
+ }
+ typeLabel.setText(string);
+
+ string = createMsg(bundle.getString("Size_value"),
+ new Object[] {new Integer(imageData.width),
+ new Integer(imageData.height)});
+ sizeLabel.setText(string);
+
+ string = createMsg(bundle.getString("Depth_value"), new Integer(imageData.depth));
+ depthLabel.setText(string);
+
+ string = createMsg(bundle.getString("Transparent_pixel_value"), pixelInfo(imageData.transparentPixel));
+ transparentPixelLabel.setText(string);
+
+ string = createMsg(bundle.getString("Animation_size_value"),
+ new Object[] {new Integer(loader.logicalScreenWidth),
+ new Integer(loader.logicalScreenHeight)});
+ screenSizeLabel.setText(string);
+
+ string = createMsg(bundle.getString("Background_pixel_value"), pixelInfo(loader.backgroundPixel));
+ backgroundPixelLabel.setText(string);
+
+ string = createMsg(bundle.getString("Image_location_value"),
+ new Object[] {new Integer(imageData.x), new Integer(imageData.y)});
+ locationLabel.setText(string);
+
+ string = createMsg(bundle.getString("Disposal_value"),
+ new Object[] {new Integer(imageData.disposalMethod),
+ disposalString(imageData.disposalMethod)});
+ disposalMethodLabel.setText(string);
+
+ int delay = imageData.delayTime * 10;
+ int delayUsed = visibleDelay(delay);
+ if(delay != delayUsed){
+ string = createMsg(bundle.getString("Delay_value"),
+ new Object[] {new Integer(delay), new Integer(delayUsed)});
+ } else {
+ string = createMsg(bundle.getString("Delay_used"), new Integer(delay));
+ }
+ delayTimeLabel.setText(string);
+
+ if(loader.repeatCount == 0){
+ string = createMsg( bundle.getString("Repeats_forever"), new Integer(loader.repeatCount));
+ } else {
+ string = createMsg(bundle.getString("Repeats_value"), new Integer(loader.repeatCount));
+ }
+ repeatCountLabel.setText(string);
+
+ if(imageData.palette.isDirect){
+ string = bundle.getString("Palette_direct");
+ } else {
+ string = createMsg(bundle.getString("Palette_value"), new Integer(imageData.palette.getRGBs().length));
+ }
+ paletteLabel.setText(string);
+
+ string = createMsg(bundle.getString("Pixel_data_value"),
+ new Object[] {new Integer(imageData.bytesPerLine),
+ new Integer(imageData.scanlinePad),
+ depthInfo(imageData.depth)});
+ dataLabel.setText(string);
+
+ dataText.setText(dataHexDump(dataText.getLineDelimiter()));
+ statusLabel.setText("");
+
+ // Redraw both canvases.
+ paletteCanvas.redraw();
+ imageCanvas.redraw();
+ }
+
+ void paintImage(PaintEvent event) {
+ Image paintImage = image;
+ int transparentPixel = imageData.transparentPixel;
+ if (transparentPixel != -1 && !transparent) {
+ imageData.transparentPixel = -1;
+ paintImage = new Image(display, imageData);
+ }
+ int w = Math.round(imageData.width * xscale);
+ int h = Math.round(imageData.height * yscale);
+ event.gc.drawImage(
+ paintImage,
+ 0,
+ 0,
+ imageData.width,
+ imageData.height,
+ ix + imageData.x,
+ iy + imageData.y,
+ w,
+ h);
+ if (showMask && (imageData.getTransparencyType() != SWT.TRANSPARENCY_NONE)) {
+ ImageData maskImageData = imageData.getTransparencyMask();
+ Image maskImage = new Image(display, maskImageData);
+ event.gc.drawImage(
+ maskImage,
+ 0,
+ 0,
+ imageData.width,
+ imageData.height,
+ w + 10 + ix + imageData.x,
+ iy + imageData.y,
+ w,
+ h);
+ maskImage.dispose();
+ }
+ if (transparentPixel != -1 && !transparent) {
+ imageData.transparentPixel = transparentPixel;
+ paintImage.dispose();
+ }
+ }
+
+ void paintPalette(PaintEvent event) {
+ GC gc = event.gc;
+ gc.fillRectangle(paletteCanvas.getClientArea());
+ if (imageData.palette.isDirect) {
+ // For a direct palette, display the masks.
+ int y = py + 10;
+ int xTab = 50;
+ gc.drawString("rMsk", 10, y, true);
+ gc.drawString(toHex4ByteString(imageData.palette.redMask), xTab, y, true);
+ gc.drawString("gMsk", 10, y+=12, true);
+ gc.drawString(toHex4ByteString(imageData.palette.greenMask), xTab, y, true);
+ gc.drawString("bMsk", 10, y+=12, true);
+ gc.drawString(toHex4ByteString(imageData.palette.blueMask), xTab, y, true);
+ gc.drawString("rShf", 10, y+=12, true);
+ gc.drawString(Integer.toString(imageData.palette.redShift), xTab, y, true);
+ gc.drawString("gShf", 10, y+=12, true);
+ gc.drawString(Integer.toString(imageData.palette.greenShift), xTab, y, true);
+ gc.drawString("bShf", 10, y+=12, true);
+ gc.drawString(Integer.toString(imageData.palette.blueShift), xTab, y, true);
+ } else {
+ // For an indexed palette, display the palette colors and indices.
+ RGB[] rgbs = imageData.palette.getRGBs();
+ if (rgbs != null) {
+ int xTab1 = 40, xTab2 = 100;
+ for (int i = 0; i < rgbs.length; i++) {
+ int y = (i+1) * 10 + py;
+ gc.drawString(String.valueOf(i), 10, y, true);
+ gc.drawString(toHexByteString(rgbs[i].red) + toHexByteString(rgbs[i].green) + toHexByteString(rgbs[i].blue), xTab1, y, true);
+ Color color = new Color(display, rgbs[i]);
+ gc.setBackground(color);
+ gc.fillRectangle(xTab2, y+2, 10, 10);
+ color.dispose();
+ }
+ }
+ }
+ }
+
+ void resizeShell(ControlEvent event) {
+ if (image == null || shell.isDisposed())
+ return;
+ resizeScrollBars();
+ }
+
+ // Reset the scale combos to 1.
+ void resetScaleCombos() {
+ xscale = 1; yscale = 1;
+ scaleXCombo.select(scaleXCombo.indexOf("1"));
+ scaleYCombo.select(scaleYCombo.indexOf("1"));
+ }
+
+ // Reset the scroll bars to 0.
+ void resetScrollBars() {
+ if (image == null) return;
+ ix = 0; iy = 0; py = 0;
+ resizeScrollBars();
+ imageCanvas.getHorizontalBar().setSelection(0);
+ imageCanvas.getVerticalBar().setSelection(0);
+ paletteCanvas.getVerticalBar().setSelection(0);
+ }
+
+ void resizeScrollBars() {
+ // Set the max and thumb for the image canvas scroll bars.
+ ScrollBar horizontal = imageCanvas.getHorizontalBar();
+ ScrollBar vertical = imageCanvas.getVerticalBar();
+ Rectangle canvasBounds = imageCanvas.getClientArea();
+ int width = Math.round(imageData.width * xscale);
+ if (width > canvasBounds.width) {
+ // The image is wider than the canvas.
+ horizontal.setEnabled(true);
+ horizontal.setMaximum(width);
+ horizontal.setThumb(canvasBounds.width);
+ horizontal.setPageIncrement(canvasBounds.width);
+ } else {
+ // The canvas is wider than the image.
+ horizontal.setEnabled(false);
+ if (ix != 0) {
+ // Make sure the image is completely visible.
+ ix = 0;
+ imageCanvas.redraw();
+ }
+ }
+ int height = Math.round(imageData.height * yscale);
+ if (height > canvasBounds.height) {
+ // The image is taller than the canvas.
+ vertical.setEnabled(true);
+ vertical.setMaximum(height);
+ vertical.setThumb(canvasBounds.height);
+ vertical.setPageIncrement(canvasBounds.height);
+ } else {
+ // The canvas is taller than the image.
+ vertical.setEnabled(false);
+ if (iy != 0) {
+ // Make sure the image is completely visible.
+ iy = 0;
+ imageCanvas.redraw();
+ }
+ }
+
+ // Set the max and thumb for the palette canvas scroll bar.
+ vertical = paletteCanvas.getVerticalBar();
+ if (imageData.palette.isDirect) {
+ vertical.setEnabled(false);
+ } else { // indexed palette
+ canvasBounds = paletteCanvas.getClientArea();
+ int paletteHeight = imageData.palette.getRGBs().length * 10 + 20; // 10 pixels each index + 20 for margins.
+ vertical.setEnabled(true);
+ vertical.setMaximum(paletteHeight);
+ vertical.setThumb(canvasBounds.height);
+ vertical.setPageIncrement(canvasBounds.height);
+ }
+ }
+
+ /*
+ * Called when the image canvas' horizontal scrollbar is selected.
+ */
+ void scrollHorizontally(ScrollBar scrollBar) {
+ if (image == null) return;
+ Rectangle canvasBounds = imageCanvas.getClientArea();
+ int width = Math.round(imageData.width * xscale);
+ int height = Math.round(imageData.height * yscale);
+ if (width > canvasBounds.width) {
+ // Only scroll if the image is bigger than the canvas.
+ int x = -scrollBar.getSelection();
+ if (x + width < canvasBounds.width) {
+ // Don't scroll past the end of the image.
+ x = canvasBounds.width - width;
+ }
+ imageCanvas.scroll(x, iy, ix, iy, width, height, false);
+ ix = x;
+ }
+ }
+
+ /*
+ * Called when the image canvas' vertical scrollbar is selected.
+ */
+ void scrollVertically(ScrollBar scrollBar) {
+ if (image == null) return;
+ Rectangle canvasBounds = imageCanvas.getClientArea();
+ int width = Math.round(imageData.width * xscale);
+ int height = Math.round(imageData.height * yscale);
+ if (height > canvasBounds.height) {
+ // Only scroll if the image is bigger than the canvas.
+ int y = -scrollBar.getSelection();
+ if (y + height < canvasBounds.height) {
+ // Don't scroll past the end of the image.
+ y = canvasBounds.height - height;
+ }
+ imageCanvas.scroll(ix, y, ix, iy, width, height, false);
+ iy = y;
+ }
+ }
+
+ /*
+ * Called when the palette canvas' vertical scrollbar is selected.
+ */
+ void scrollPalette(ScrollBar scrollBar) {
+ if (image == null) return;
+ Rectangle canvasBounds = paletteCanvas.getClientArea();
+ int paletteHeight = imageData.palette.getRGBs().length * 10 + 20;
+ if (paletteHeight > canvasBounds.height) {
+ // Only scroll if the palette is bigger than the canvas.
+ int y = -scrollBar.getSelection();
+ if (y + paletteHeight < canvasBounds.height) {
+ // Don't scroll past the end of the palette.
+ y = canvasBounds.height - paletteHeight;
+ }
+ paletteCanvas.scroll(0, y, 0, py, paletteWidth, paletteHeight, false);
+ py = y;
+ }
+ }
+
+ /*
+ * Return a String containing a line-by-line dump of
+ * the data in the current imageData. The lineDelimiter
+ * parameter must be a string of length 1 or 2.
+ */
+ String dataHexDump(String lineDelimiter) {
+ if (image == null) return "";
+ char[] dump = new char[imageData.height * (6 + 3 * imageData.bytesPerLine + lineDelimiter.length())];
+ int index = 0;
+ for (int i = 0; i < imageData.data.length; i++) {
+ if (i % imageData.bytesPerLine == 0) {
+ int line = i / imageData.bytesPerLine;
+ dump[index++] = Character.forDigit(line / 1000 % 10, 10);
+ dump[index++] = Character.forDigit(line / 100 % 10, 10);
+ dump[index++] = Character.forDigit(line / 10 % 10, 10);
+ dump[index++] = Character.forDigit(line % 10, 10);
+ dump[index++] = ':';
+ dump[index++] = ' ';
+ }
+ byte b = imageData.data[i];
+ dump[index++] = Character.forDigit((b & 0xF0) >> 4, 16);
+ dump[index++] = Character.forDigit(b & 0x0F, 16);
+ dump[index++] = ' ';
+ if ((i + 1) % imageData.bytesPerLine == 0) {
+ dump[index++] = lineDelimiter.charAt(0);
+ if (lineDelimiter.length() > 1)
+ dump[index++] = lineDelimiter.charAt(1);
+ }
+ }
+ return new String(dump);
+ }
+
+ /*
+ * Open an error dialog displaying the specified information.
+ */
+ void showErrorDialog(String operation, String filename, SWTException e) {
+ MessageBox box = new MessageBox(shell, SWT.ICON_ERROR);
+ String message = createMsg(bundle.getString("Error"), new String[] {operation, filename});
+
+ String errorMessage = e.getMessage();
+ if (e.throwable != null) {
+ errorMessage += ":\n" + e.throwable.toString();
+ }
+ box.setMessage(message + errorMessage);
+ box.open();
+ }
+
+ /*
+ * Return a String describing how to analyze the bytes
+ * in the hex dump.
+ */
+ static String depthInfo(int depth) {
+ Object[] args = {new Integer(depth), ""};
+
+ switch(depth){
+ case 1:
+ args[1] = createMsg(bundle.getString("Multi_pixels"),
+ new Object[] {new Integer(8), " [01234567]"});
+ break;
+ case 2:
+ args[1] = createMsg(bundle.getString("Multi_pixels"),
+ new Object[] {new Integer(4), "[00112233]"});
+ break;
+ case 4:
+ args[1] = createMsg(bundle.getString("Multi_pixels"),
+ new Object[] {new Integer(2), "[00001111]"});
+ break;
+ case 8:
+ args[1] = bundle.getString("One_byte");
+ break;
+ case 16:
+ args[1] = createMsg(bundle.getString("Multi_bytes"), new Integer(2));
+ break;
+ case 24:
+ args[1] = createMsg(bundle.getString("Multi_bytes"), new Integer(3));
+ break;
+ case 32:
+ args[1] = createMsg(bundle.getString("Multi_bytes"), new Integer(4));
+ break;
+ default:
+ args[1] = bundle.getString("Unsupported_lc");
+ }
+ return createMsg(bundle.getString("Depth_info"), args);
+ }
+
+ /*
+ * Return the specified number of milliseconds.
+ * If the specified number of milliseconds is too small
+ * to see a visual change, then return a higher number.
+ */
+ static int visibleDelay(int ms) {
+ if (ms < 20) return ms + 30;
+ if (ms < 30) return ms + 10;
+ return ms;
+ }
+
+
+ /*
+ * Return the specified byte value as a hex string,
+ * preserving leading 0's.
+ */
+ static String toHexByteString(int i) {
+ if (i <= 0x0f)
+ return "0" + Integer.toHexString(i);
+ return Integer.toHexString(i & 0xff);
+ }
+
+ /*
+ * Return the specified 4-byte value as a hex string,
+ * preserving leading 0's.
+ * (a bit 'brute force'... should probably use a loop...)
+ */
+ static String toHex4ByteString(int i) {
+ String hex = Integer.toHexString(i);
+ if (hex.length() == 1)
+ return "0000000" + hex;
+ if (hex.length() == 2)
+ return "000000" + hex;
+ if (hex.length() == 3)
+ return "00000" + hex;
+ if (hex.length() == 4)
+ return "0000" + hex;
+ if (hex.length() == 5)
+ return "000" + hex;
+ if (hex.length() == 6)
+ return "00" + hex;
+ if (hex.length() == 7)
+ return "0" + hex;
+ return hex;
+ }
+
+ /*
+ * Return a String describing the specified
+ * transparent or background pixel.
+ */
+ static String pixelInfo(int pixel) {
+ if (pixel == -1)
+ return pixel + " (" + bundle.getString("None_lc") + ")";
+ else
+ return pixel + " (0x" + Integer.toHexString(pixel) + ")";
+ }
+
+ /*
+ * Return a String describing the specified disposal method.
+ */
+ static String disposalString(int disposalMethod) {
+ switch (disposalMethod) {
+ case SWT.DM_FILL_NONE: return bundle.getString("None_lc");
+ case SWT.DM_FILL_BACKGROUND: return bundle.getString("Background_lc");
+ case SWT.DM_FILL_PREVIOUS: return bundle.getString("Previous_lc");
+ }
+ return bundle.getString("Unspecified_lc");
+ }
+
+ /*
+ * Return a String describing the specified image file type.
+ */
+ static String fileTypeString(int filetype) {
+ if (filetype == SWT.IMAGE_BMP)
+ return "BMP";
+ if (filetype == SWT.IMAGE_GIF)
+ return "GIF";
+ if (filetype == SWT.IMAGE_ICO)
+ return "ICO";
+ if (filetype == SWT.IMAGE_JPEG)
+ return "JPEG";
+ if (filetype == SWT.IMAGE_PNG)
+ return "PNG";
+ return bundle.getString("Unknown_ac");
+ }
+
+ /*
+ * Return the specified file's image type, based on its extension.
+ * Note that this is not a very robust way to determine image type,
+ * and it is only to be used in the absence of any better method.
+ */
+ static int determineFileType(String filename) {
+ String ext = filename.substring(filename.lastIndexOf('.') + 1);
+ if (ext.equalsIgnoreCase("bmp"))
+ return SWT.IMAGE_BMP;
+ if (ext.equalsIgnoreCase("gif"))
+ return SWT.IMAGE_GIF;
+ if (ext.equalsIgnoreCase("ico"))
+ return SWT.IMAGE_ICO;
+ if (ext.equalsIgnoreCase("jpg") || ext.equalsIgnoreCase("jpeg"))
+ return SWT.IMAGE_JPEG;
+ if (ext.equalsIgnoreCase("png"))
+ return SWT.IMAGE_PNG;
+ return SWT.IMAGE_UNDEFINED;
+ }
+
+ static String createMsg(String msg, Object[] args){
+ MessageFormat formatter = new MessageFormat(msg);
+ return formatter.format(args);
+ }
+ static String createMsg(String msg, Object arg){
+ MessageFormat formatter = new MessageFormat(msg);
+ return formatter.format(new Object[]{arg});
+ }
+
+}
+
+
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/javaviewer/JavaLineStyler.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/javaviewer/JavaLineStyler.java
new file mode 100755
index 0000000000..62d384981d
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/javaviewer/JavaLineStyler.java
@@ -0,0 +1,357 @@
+package org.eclipse.swt.examples.javaviewer;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.custom.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import java.util.*;
+import java.io.*;
+
+class JavaLineStyler implements LineStyleListener {
+ JavaScanner scanner = new JavaScanner();
+ int[] tokenColors;
+ Color[] colors;
+ Vector blockComments = new Vector();
+
+ public static final int EOF= -1;
+ public static final int EOL= 10;
+
+ public static final int WORD= 0;
+ public static final int WHITE= 1;
+ public static final int KEY= 2;
+ public static final int COMMENT= 3; // single line comment: //
+ public static final int STRING= 5;
+ public static final int OTHER= 6;
+ public static final int NUMBER= 7;
+
+ public static final int MAXIMUM_TOKEN= 8;
+
+public JavaLineStyler() {
+ initializeColors();
+ scanner = new JavaScanner();
+}
+
+Color getColor(int type) {
+ if (type < 0 || type >= tokenColors.length) {
+ return null;
+ }
+ return colors[tokenColors[type]];
+}
+
+boolean inBlockComment(int start, int end) {
+ for (int i=0; i<blockComments.size(); i++) {
+ int[] offsets = (int[])blockComments.elementAt(i);
+ // start of comment in the line
+ if ((offsets[0] >= start) && (offsets[0] <= end)) return true;
+ // end of comment in the line
+ if ((offsets[1] >= start) && (offsets[1] <= end)) return true;
+ if ((offsets[0] <= start) && (offsets[1] >= end)) return true;
+ }
+ return false;
+}
+
+void initializeColors() {
+ Display display = Display.getDefault();
+ colors= new Color[] {
+ new Color(display, new RGB(0, 0, 0)), // black
+ new Color(display, new RGB(255, 0, 0)), // red
+ new Color(display, new RGB(0, 255, 0)), // green
+ new Color(display, new RGB(0, 0, 255)) // blue
+ };
+ tokenColors= new int[MAXIMUM_TOKEN];
+ tokenColors[WORD]= 0;
+ tokenColors[WHITE]= 0;
+ tokenColors[KEY]= 3;
+ tokenColors[COMMENT]= 1;
+ tokenColors[STRING]= 2;
+ tokenColors[OTHER]= 0;
+ tokenColors[NUMBER]= 0;
+}
+
+void disposeColors() {
+ for (int i=0;i<colors.length;i++) {
+ colors[i].dispose();
+ }
+}
+
+/**
+ * Event.detail line start offset (input)
+ * Event.text line text (input)
+ * LineStyleEvent.styles Enumeration of StyleRanges, need to be in order. (output)
+ * LineStyleEvent.background line background color (output)
+ */
+public void lineGetStyle(LineStyleEvent event) {
+ Vector styles = new Vector();
+ int token;
+ StyleRange lastStyle;
+ if (inBlockComment(event.lineOffset, event.lineOffset + event.lineText.length())) {
+ styles.addElement(new StyleRange(event.lineOffset, event.lineText.length(), colors[1], null));
+ event.styles = new StyleRange[styles.size()];
+ styles.copyInto(event.styles);
+ return;
+ }
+ scanner.setRange(event.lineText);
+ token = scanner.nextToken();
+ while (token != EOF) {
+ if (token == OTHER) {
+ // do nothing
+ } else if ((token == WHITE) && (!styles.isEmpty())) {
+ int start = scanner.getStartOffset() + event.lineOffset;
+ lastStyle = (StyleRange)styles.lastElement();
+ if (lastStyle.fontStyle != SWT.NORMAL) {
+ if (lastStyle.start + lastStyle.length == start) {
+ // have the white space take on the style before it to minimize font style
+ // changes
+ lastStyle.length += scanner.getLength();
+ }
+ }
+ } else {
+ Color color = getColor(token);
+ if (color != colors[0]) { // hardcoded default foreground color, black
+ StyleRange style = new StyleRange(scanner.getStartOffset() + event.lineOffset, scanner.getLength(), color, null);
+ if (token == KEY) {
+ style.fontStyle = SWT.BOLD;
+ }
+ if (styles.isEmpty()) {
+ styles.addElement(style);
+ } else {
+ lastStyle = (StyleRange)styles.lastElement();
+ if (lastStyle.similarTo(style) && (lastStyle.start + lastStyle.length == style.start)) {
+ lastStyle.length += style.length;
+ } else {
+ styles.addElement(style);
+ }
+ }
+ }
+ }
+ token= scanner.nextToken();
+ }
+ event.styles = new StyleRange[styles.size()];
+ styles.copyInto(event.styles);
+}
+
+public void parseBlockComments(String text) {
+ blockComments = new Vector();
+ StringBufferInputStream buffer = new StringBufferInputStream(text);
+ int ch;
+ boolean blkComment = false;
+ int cnt = 0;
+ int[] offsets = new int[2];
+ boolean done = false;
+ while (!done) {
+ switch (ch = buffer.read()) {
+ case -1 : {
+ if (blkComment) {
+ offsets[1] = cnt;
+ blockComments.addElement(offsets);
+ }
+ done = true;
+ break;
+ }
+ case '/' : {
+ ch = buffer.read();
+ if ((ch == '*') && (!blkComment)) {
+ offsets = new int[2];
+ offsets[0] = cnt;
+ blkComment = true;
+ cnt++;
+ } else {
+ cnt++;
+ }
+ cnt++;
+ break;
+ }
+ case '*' : {
+ if (blkComment) {
+ ch = buffer.read();
+ cnt++;
+ if (ch == '/') {
+ blkComment = false;
+ offsets[1] = cnt;
+ blockComments.addElement(offsets);
+ }
+ }
+ cnt++;
+ break;
+ }
+ default : {
+ cnt++;
+ break;
+ }
+ }
+ }
+}
+
+/**
+ * A simple fuzzy scanner for Java
+ */
+public class JavaScanner {
+
+ protected Hashtable fgKeys= null;
+ protected StringBuffer fBuffer= new StringBuffer();
+ protected String fDoc;
+ protected int fPos;
+ protected int fEnd;
+ protected int fStartToken;
+ protected boolean fEofSeen= false;
+
+ private String[] fgKeywords= {
+ "abstract",
+ "boolean", "break", "byte",
+ "case", "catch", "char", "class", "continue",
+ "default", "do", "double",
+ "else", "extends",
+ "false", "final", "finally", "float", "for",
+ "if", "implements", "import", "instanceof", "int", "interface",
+ "long",
+ "native", "new", "null",
+ "package", "private", "protected", "public",
+ "return",
+ "short", "static", "super", "switch", "synchronized",
+ "this", "throw", "throws", "transient", "true", "try",
+ "void", "volatile",
+ "while"
+ };
+
+ public JavaScanner() {
+ initialize();
+ }
+
+ /**
+ * Returns the ending location of the current token in the document.
+ */
+ public final int getLength() {
+ return fPos - fStartToken;
+ }
+
+ /**
+ * Initialize the lookup table.
+ */
+ void initialize() {
+ fgKeys= new Hashtable();
+ Integer k= new Integer(KEY);
+ for (int i= 0; i < fgKeywords.length; i++)
+ fgKeys.put(fgKeywords[i], k);
+ }
+
+ /**
+ * Returns the starting location of the current token in the document.
+ */
+ public final int getStartOffset() {
+ return fStartToken;
+ }
+
+ /**
+ * Returns the next lexical token in the document.
+ */
+ public int nextToken() {
+ int c;
+ fStartToken= fPos;
+ while (true) {
+ switch (c= read()) {
+ case EOF:
+ return EOF;
+ case '/': // comment
+ c= read();
+ if (c == '/') {
+ while (true) {
+ c= read();
+ if ((c == EOF) || (c == EOL)) {
+ unread(c);
+ return COMMENT;
+ }
+ }
+ } else {
+ unread(c);
+ }
+ return OTHER;
+ case '\'': // char const
+ character: for(;;) {
+ c= read();
+ switch (c) {
+ case '\'':
+ return STRING;
+ case EOF:
+ unread(c);
+ return STRING;
+ case '\\':
+ c= read();
+ break;
+ }
+ }
+
+ case '"': // string
+ string: for (;;) {
+ c= read();
+ switch (c) {
+ case '"':
+ return STRING;
+ case EOF:
+ unread(c);
+ return STRING;
+ case '\\':
+ c= read();
+ break;
+ }
+ }
+
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ do {
+ c= read();
+ } while(Character.isDigit((char)c));
+ unread(c);
+ return NUMBER;
+ default:
+ if (Character.isWhitespace((char)c)) {
+ do {
+ c= read();
+ } while(Character.isWhitespace((char)c));
+ unread(c);
+ return WHITE;
+ }
+ if (Character.isJavaIdentifierStart((char)c)) {
+ fBuffer.setLength(0);
+ do {
+ fBuffer.append((char)c);
+ c= read();
+ } while(Character.isJavaIdentifierPart((char)c));
+ unread(c);
+ Integer i= (Integer) fgKeys.get(fBuffer.toString());
+ if (i != null)
+ return i.intValue();
+ return WORD;
+ }
+ return OTHER;
+ }
+ }
+ }
+
+ /**
+ * Returns next character.
+ */
+ protected int read() {
+ if (fPos <= fEnd) {
+ return fDoc.charAt(fPos++);
+ }
+ return EOF;
+ }
+
+ public void setRange(String text) {
+ fDoc= text;
+ fPos= 0;
+ fEnd= fDoc.length() -1;
+ }
+
+ protected void unread(int c) {
+ if (c != EOF)
+ fPos--;
+ }
+}
+
+
+
+
+
+} \ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/javaviewer/JavaViewer.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/javaviewer/JavaViewer.java
new file mode 100755
index 0000000000..b2f40875e4
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/javaviewer/JavaViewer.java
@@ -0,0 +1,185 @@
+package org.eclipse.swt.examples.javaviewer;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/* Imports */
+import org.eclipse.swt.*;
+import org.eclipse.swt.custom.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+import java.util.*;
+import java.io.*;
+import java.text.*;
+
+/**
+*/
+public class JavaViewer implements DisposeListener {
+ Shell shell;
+ StyledText text;
+ JavaLineStyler lineStyler = new JavaLineStyler();
+ static ResourceBundle resources = ResourceBundle.getBundle("examples_javaviewer");
+
+public void close () {
+ if (shell != null && !shell.isDisposed ())
+ shell.dispose ();
+ lineStyler.disposeColors();
+}
+public void widgetDisposed (DisposeEvent event) {
+ text.removeLineStyleListener(lineStyler);
+ text.removeDisposeListener(this);
+}
+
+Menu createFileMenu() {
+ Menu bar = shell.getMenuBar ();
+ Menu menu = new Menu (bar);
+ MenuItem item;
+
+ // Open
+ item = new MenuItem (menu, SWT.CASCADE);
+ item.setText (resources.getString("Open_menuitem"));
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ openFile();
+ }
+ });
+
+ // Close
+ item = new MenuItem (menu, SWT.PUSH);
+ item.setText (resources.getString("Close_menuitem"));
+ item.addSelectionListener (new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent e) {
+ menuFileExit ();
+ }
+ });
+ return menu;
+}
+
+void createMenuBar () {
+ Menu bar = new Menu (shell, SWT.BAR);
+ shell.setMenuBar (bar);
+
+ MenuItem fileItem = new MenuItem (bar, SWT.CASCADE);
+ fileItem.setText (resources.getString("File_menuitem"));
+ fileItem.setMenu (createFileMenu ());
+
+}
+
+void createShell () {
+ shell = new Shell ();
+ shell.setText (resources.getString("Window_title"));
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ shell.setSize(500, 400);
+ shell.setLayout(layout);
+}
+void createStyledText() {
+ text = new StyledText (shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
+ GridData spec = new GridData();
+ spec.horizontalAlignment = spec.FILL;
+ spec.grabExcessHorizontalSpace = true;
+ spec.verticalAlignment = spec.FILL;
+ spec.grabExcessVerticalSpace = true;
+ text.setLayoutData(spec);
+ text.addLineStyleListener(lineStyler);
+ text.addDisposeListener(this);
+ text.setEditable(false);
+ Color bg = Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
+ text.setBackground(bg);
+}
+
+void displayError(String msg) {
+ MessageBox box = new MessageBox(shell, SWT.ICON_ERROR);
+ box.setMessage(msg);
+ box.open();
+}
+
+public static void main (String [] args) {
+ JavaViewer example = new JavaViewer ();
+ example.open ();
+ example.run ();
+ example.close ();
+}
+
+void openFile() {
+ final String textString;
+ FileDialog fileDialog = new FileDialog(shell, SWT.OPEN);
+
+ fileDialog.setFilterExtensions(new String[] {"*.java", "*.*"});
+ fileDialog.open();
+ String name = fileDialog.getFileName();
+
+ if ((name == null) || (name.length() == 0)) return;
+
+ File file = new File(fileDialog.getFilterPath(), name);
+ if (!file.exists()) {
+ String message = MessageFormat.format(resources.getString("Err_file_no_exist"), new String[] {file.getName()});
+ displayError(message);
+ return;
+ }
+
+ try {
+ FileInputStream stream= new FileInputStream(file.getPath());
+ try {
+ Reader in = new BufferedReader(new InputStreamReader(stream));
+ char[] readBuffer= new char[2048];
+ StringBuffer buffer= new StringBuffer((int) file.length());
+ int n;
+ while ((n = in.read(readBuffer)) > 0) {
+ buffer.append(readBuffer, 0, n);
+ }
+ textString = buffer.toString();
+ stream.close();
+ }
+ catch (IOException e) {
+ // Err_file_io
+ String message = MessageFormat.format(resources.getString("Err_file_io"), new String[] {file.getName()});
+ displayError(message);
+ return;
+ }
+ }
+ catch (FileNotFoundException e) {
+ String message = MessageFormat.format(resources.getString("Err_not_found"), new String[] {file.getName()});
+ displayError(message);
+ return;
+ }
+ // Workaround for superfluous mouse move event that is being sent
+ // by the WIN platform when a file is selected via a double click in
+ // in the file dialog (PR 1G80JJV). If the extra move event was not
+ // being generated, the asyncExec would not be necessary.
+ Display display = text.getDisplay();
+ display.asyncExec(new Runnable() {
+ public void run() {
+ text.setText(textString);
+ }
+ });
+
+ // parse the block comments up front since block comments can go across
+ // lines - inefficient way of doing this
+ lineStyler.parseBlockComments(textString);
+}
+
+void menuFileExit () {
+ shell.close ();
+}
+
+public void open () {
+ createShell ();
+ createMenuBar ();
+ createStyledText ();
+ shell.open ();
+}
+
+public void run () {
+ Display display = shell.getDisplay ();
+ while (!shell.isDisposed ())
+ if (!display.readAndDispatch ()) display.sleep ();
+}
+
+
+}
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/ColorTextEditor.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/ColorTextEditor.java
new file mode 100755
index 0000000000..54f487085f
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/ColorTextEditor.java
@@ -0,0 +1,357 @@
+package org.eclipse.swt.examples.texteditor;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/* Imports */
+import org.eclipse.swt.*;
+import org.eclipse.swt.custom.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+import java.util.*;
+import java.io.*;
+
+/**
+*/
+public class ColorTextEditor {
+ Shell shell;
+ ToolBar toolBar;
+ StyledText text;
+
+ Vector cachedStyles = new Vector();
+ Color RED = null;
+ Color BLUE = null;
+ Color GREEN = null;
+ Font font = null;
+
+ boolean isBold = false;
+
+ ExtendedModifyListener extendedModifyListener;
+ VerifyKeyListener verifyKeyListener;
+ static ResourceBundle resources = ResourceBundle.getBundle("examples_texteditor");
+
+/*
+ * Free the allocated resources.
+ */
+public void close () {
+ if (shell != null && !shell.isDisposed ())
+ shell.dispose ();
+ if (font != null) font.dispose();
+ Images.freeAll ();
+ RED.dispose();
+ GREEN.dispose();
+ BLUE.dispose();
+}
+
+Menu createEditMenu() {
+ Menu bar = shell.getMenuBar ();
+ Menu menu = new Menu (bar);
+
+ MenuItem item = new MenuItem (menu, SWT.PUSH);
+ item.setText (resources.getString("Cut_menuitem"));
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ text.cut();
+ }
+ });
+
+ item = new MenuItem (menu, SWT.PUSH);
+ item.setText (resources.getString("Copy_menuitem"));
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ text.copy();
+ }
+ });
+
+ item = new MenuItem (menu, SWT.PUSH);
+ item.setText (resources.getString("Paste_menuitem"));
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ text.paste();
+ }
+ });
+
+ new MenuItem (menu, SWT.SEPARATOR);
+
+ item = new MenuItem (menu, SWT.PUSH);
+ item.setText (resources.getString("Font_menuitem"));
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ setFont();
+ }
+ });
+ return menu;
+}
+
+
+/*
+ * Set the text state to bold.
+ */
+void bold(boolean bold) {
+ isBold = bold;
+}
+/*
+ * Clear all style data for the selected text.
+ */
+void clear() {
+ Point sel = text.getSelectionRange();
+ if ((sel != null) && (sel.y != 0)) {
+ StyleRange style;
+ style = new StyleRange(sel.x, sel.y, null, null, SWT.NORMAL);
+ text.setStyleRange(style);
+ }
+ text.setSelectionRange(sel.x + sel.y, 0);
+}
+/*
+ * Set the foreground color for the selected text.
+ */
+void fgColor(int color) {
+ Point sel = text.getSelectionRange();
+ if ((sel == null) || (sel.y == 0)) return;
+ Color fg;
+ if (color == SWT.COLOR_RED) {
+ fg = RED;
+ } else if (color == SWT.COLOR_GREEN) {
+ fg = GREEN;
+ } else if (color == SWT.COLOR_BLUE) {
+ fg = BLUE;
+ } else {
+ fg = null;
+ }
+ StyleRange style;
+ for (int i = sel.x; i<sel.x+sel.y; i++) {
+ StyleRange range = text.getStyleRangeAtOffset(i);
+ if (range == null) {style = new StyleRange(i, 1, fg, null, SWT.NORMAL);}
+ else {style = new StyleRange(i, 1, fg, null, range.fontStyle);};
+ text.setStyleRange(style);
+ }
+ text.setSelectionRange(sel.x + sel.y, 0);
+}
+void createMenuBar () {
+ Menu bar = new Menu (shell, SWT.BAR);
+ shell.setMenuBar (bar);
+
+ MenuItem editItem = new MenuItem (bar, SWT.CASCADE);
+ editItem.setText (resources.getString("Edit_menuitem"));
+ editItem.setMenu (createEditMenu ());
+}
+
+void createShell () {
+ shell = new Shell ();
+ shell.setText (resources.getString("Window_title"));
+ Images.loadAll (shell.getDisplay ());
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ shell.setSize(500, 300);
+ shell.setLayout(layout);
+}
+void createStyledText() {
+ initializeColors();
+ text = new StyledText (shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
+ GridData spec = new GridData();
+ spec.horizontalAlignment = spec.FILL;
+ spec.grabExcessHorizontalSpace = true;
+ spec.verticalAlignment = spec.FILL;
+ spec.grabExcessVerticalSpace = true;
+ text.setLayoutData(spec);
+ extendedModifyListener = new ExtendedModifyListener() {
+ public void modifyText(ExtendedModifyEvent e) {
+ handleExtendedModify(e);
+ }
+ };
+ text.addExtendedModifyListener(extendedModifyListener);
+ verifyKeyListener = new VerifyKeyListener() {
+ public void verifyKey(VerifyEvent e) {
+ handleVerifyKey(e);
+ }
+ };
+ text.addVerifyKeyListener(verifyKeyListener);
+}
+
+void createToolBar() {
+ toolBar = new ToolBar(shell, SWT.NULL);
+
+ ToolItem item = new ToolItem(toolBar, SWT.CHECK);
+ item.setImage(Images.Bold);
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ bold(((ToolItem)event.widget).getSelection());
+ }
+ });
+
+ item = new ToolItem(toolBar, SWT.SEPARATOR);
+
+ item = new ToolItem(toolBar, SWT.PUSH);
+ item.setImage(Images.Red);
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ fgColor(SWT.COLOR_RED);
+ }
+ });
+ item = new ToolItem(toolBar, SWT.PUSH);
+ item.setImage(Images.Green);
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ fgColor(SWT.COLOR_GREEN);
+ }
+ });
+ item = new ToolItem(toolBar, SWT.PUSH);
+ item.setImage(Images.Blue);
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ fgColor(SWT.COLOR_BLUE);
+ }
+ });
+
+ item = new ToolItem(toolBar, SWT.SEPARATOR);
+
+ item = new ToolItem(toolBar, SWT.PUSH);
+ item.setImage(Images.Erase);
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ clear();
+ }
+ });
+}
+void displayError(String msg) {
+ MessageBox box = new MessageBox(shell, SWT.ICON_ERROR);
+ box.setMessage(msg);
+ box.open();
+}
+/*
+ * Cache the style information for text that has been cut or copied.
+ */
+void handleCutCopy() {
+ // Save the cut/copied style info so that during paste we will maintain
+ // the style information. Cut/copied text is put in the clipboard in
+ // RTF format, but is not pasted in RTF format. The other way to
+ // handle the pasting of styles would be to access the Clipboard directly and
+ // parse the RTF text.
+ cachedStyles = new Vector();
+ Point sel = text.getSelectionRange();
+ int startX = sel.x;
+ for (int i=sel.x; i<=sel.x+sel.y-1; i++) {
+ StyleRange style = text.getStyleRangeAtOffset(i);
+ if (style != null) {
+ style.start = style.start - startX;
+ if (!cachedStyles.isEmpty()) {
+ StyleRange lastStyle = (StyleRange)cachedStyles.lastElement();
+ if (lastStyle.similarTo(style)) {
+ lastStyle.length++;
+ } else {
+ cachedStyles.addElement(style);
+ }
+ } else {
+ cachedStyles.addElement(style);
+ }
+ }
+ }
+}
+void handleExtendedModify(ExtendedModifyEvent event) {
+ if (event.length == 0) return;
+ StyleRange style;
+ if (event.length == 1 || text.getTextRange(event.start, event.length).equals(text.getLineDelimiter())) {
+ // Have the new text take on the style of the text to its right (during
+ // typing) if no style information is active.
+ int caretOffset = text.getCaretOffset();
+ style = null;
+ if (caretOffset <= text.getCharCount()) style = text.getStyleRangeAtOffset(caretOffset);
+ if (style != null) {
+ style.start = event.start;
+ style.length = event.length;
+ int fontStyle = SWT.NORMAL;
+ if (isBold) fontStyle = SWT.BOLD;
+ style.fontStyle = fontStyle;
+ text.setStyleRange(style);
+ } else if (isBold) {
+ StyleRange newStyle = new StyleRange(event.start, event.length, null, null, SWT.BOLD);
+ text.setStyleRange(newStyle);
+ }
+ } else {
+ // paste occurring
+ for (int i=0; i<cachedStyles.size(); i++) {
+ style = (StyleRange)cachedStyles.elementAt(i);
+ StyleRange newStyle = (StyleRange)style.clone();
+ newStyle.start = style.start + event.start;
+ text.setStyleRange(newStyle);
+ }
+ }
+}
+/*
+ * Intercept the cut and copy keys so that during paste we can maintain
+ * style information.
+ */
+void handleVerifyKey(VerifyEvent event) {
+ int input;
+ if (event.keyCode != 0) input = event.keyCode | event.stateMask;
+ else input = event.character | event.stateMask;
+ if (isCut(input) || isCopy(input)) {
+ handleCutCopy();
+ }
+}
+
+public static void main (String [] args) {
+ ColorTextEditor example = new ColorTextEditor ();
+ example.open ();
+ example.run ();
+ example.close ();
+}
+
+void open () {
+ createShell ();
+ createMenuBar ();
+ createToolBar ();
+ createStyledText ();
+ shell.open ();
+}
+
+void run () {
+ Display display = shell.getDisplay ();
+ while (!shell.isDisposed ())
+ if (!display.readAndDispatch ()) display.sleep ();
+}
+
+void setFont() {
+ FontDialog fontDialog = new FontDialog(shell);
+ fontDialog.setFontData((text.getFont()).getFontData()[0]);
+ FontData fontData = fontDialog.open();
+ if(fontData != null) {
+ if(font != null)
+ font.dispose();
+ font = new Font(shell.getDisplay(), fontData);
+ text.setFont(font);
+ }
+}
+
+void initializeColors() {
+ Display display = Display.getDefault();
+ RED = new Color (display, new RGB(255,0,0));
+ BLUE = new Color (display, new RGB(0,0,255));
+ GREEN = new Color (display, new RGB(0,255,0));
+}
+boolean isCopy(int input) {
+
+ if (input == (SWT.INSERT | SWT.CTRL)) return true;
+
+ if (input == ('\u0003' | SWT.CTRL)) return true;
+
+ return false;
+
+}
+boolean isCut(int input) {
+
+ if (input == (SWT.DEL | SWT.SHIFT)) return true;
+
+ if (input == ('\u0018' | SWT.CTRL)) return true;
+
+ return false;
+
+}
+
+
+}
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/Images.java b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/Images.java
new file mode 100755
index 0000000000..6077c0d482
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/Images.java
@@ -0,0 +1,47 @@
+package org.eclipse.swt.examples.texteditor;
+
+import java.io.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+public class Images {
+
+ // Bitmap Images
+ public static Image Bold;
+ public static Image Red;
+ public static Image Green;
+ public static Image Blue;
+ public static Image Erase;
+
+ static Image [] AllBitmaps;
+
+public static void freeAll () {
+ for (int i=0; i<AllBitmaps.length; i++) AllBitmaps [i].dispose ();
+ AllBitmaps = null;
+}
+
+static Image createBitmapImage(Display display, String fileName) {
+ ImageData source = new ImageData(Images.class.getResourceAsStream(fileName+".bmp"));
+ ImageData mask = new ImageData(Images.class.getResourceAsStream(fileName+"_mask"+".bmp"));
+ return new Image (display, source, mask);
+}
+public static void loadAll (Display display) {
+
+ // Bitmap Images
+ Bold = createBitmapImage (display, "bold");
+ Red = createBitmapImage (display, "red");
+ Green = createBitmapImage (display, "green");
+ Blue = createBitmapImage (display, "blue");
+ Erase = createBitmapImage (display, "erase");
+
+ AllBitmaps = new Image [] {
+ Bold,
+ Red,
+ Green,
+ Blue,
+ Erase,
+ };
+
+}
+}
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/blue.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/blue.bmp
new file mode 100755
index 0000000000..84c7ac9a46
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/blue.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/blue_mask.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/blue_mask.bmp
new file mode 100755
index 0000000000..6ce92645e5
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/blue_mask.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/bold.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/bold.bmp
new file mode 100755
index 0000000000..a3184bb26c
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/bold.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/bold_mask.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/bold_mask.bmp
new file mode 100755
index 0000000000..382751efa3
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/bold_mask.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/erase.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/erase.bmp
new file mode 100755
index 0000000000..1d2ace7ee3
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/erase.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/erase_mask.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/erase_mask.bmp
new file mode 100755
index 0000000000..f6ab21e471
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/erase_mask.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/green.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/green.bmp
new file mode 100755
index 0000000000..cca023fd57
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/green.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/green_mask.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/green_mask.bmp
new file mode 100755
index 0000000000..6ce92645e5
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/green_mask.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/red.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/red.bmp
new file mode 100755
index 0000000000..88c63be336
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/red.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/red_mask.bmp b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/red_mask.bmp
new file mode 100755
index 0000000000..6ce92645e5
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/Eclipse SWT Examples/common/org/eclipse/swt/examples/texteditor/red_mask.bmp
Binary files differ

Back to the top