Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Brown2001-05-31 10:31:15 -0400
committerJeff Brown2001-05-31 10:31:15 -0400
commita69b71b480495a134732d5bf957cfb436d9f13d0 (patch)
tree5cbeba2e8fc9f5a43170619cf4f389bafdaac3ce
parent6f8ff4998ed324027331ad3cfda5134080a6096d (diff)
downloadeclipse.platform.swt-a69b71b480495a134732d5bf957cfb436d9f13d0.tar.gz
eclipse.platform.swt-a69b71b480495a134732d5bf957cfb436d9f13d0.tar.xz
eclipse.platform.swt-a69b71b480495a134732d5bf957cfb436d9f13d0.zip
freeze
-rwxr-xr-xexamples/org.eclipse.swt.examples.controls/.classpath13
-rwxr-xr-xexamples/org.eclipse.swt.examples.controls/.cvsignore1
-rwxr-xr-xexamples/org.eclipse.swt.examples.controls/.vcm_meta12
-rwxr-xr-xexamples/org.eclipse.swt.examples.controls/plugin.jars3
-rwxr-xr-xexamples/org.eclipse.swt.examples.controls/plugin.properties179
-rwxr-xr-xexamples/org.eclipse.swt.examples.controls/plugin.xml56
-rwxr-xr-xexamples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/AlignableTab.java76
-rwxr-xr-xexamples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/ButtonTab.java181
-rwxr-xr-xexamples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/ComboTab.java107
-rwxr-xr-xexamples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/DialogTab.java424
-rwxr-xr-xexamples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/LabelTab.java158
-rwxr-xr-xexamples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/ListTab.java74
-rwxr-xr-xexamples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/ProgressBarTab.java107
-rwxr-xr-xexamples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/RangeTab.java161
-rwxr-xr-xexamples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/SashTab.java158
-rwxr-xr-xexamples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/ScrollableTab.java48
-rwxr-xr-xexamples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/ShellTab.java217
-rwxr-xr-xexamples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/SliderTab.java226
-rwxr-xr-xexamples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/Tab.java364
-rwxr-xr-xexamples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/TableTab.java172
-rwxr-xr-xexamples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/TextTab.java100
-rwxr-xr-xexamples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/ToolBarTab.java268
-rwxr-xr-xexamples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/TreeTab.java113
-rwxr-xr-xexamples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/closedFolder.gifbin0 -> 906 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/openFolder.gifbin0 -> 184 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/target.gifbin0 -> 917 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples.launcher/.classpath15
-rwxr-xr-xexamples/org.eclipse.swt.examples.launcher/.cvsignore1
-rwxr-xr-xexamples/org.eclipse.swt.examples.launcher/.vcm_meta11
-rwxr-xr-xexamples/org.eclipse.swt.examples.launcher/doc/org.eclipse.swt.examples.launcher.launchItems.html48
-rwxr-xr-xexamples/org.eclipse.swt.examples.launcher/plugin.jars1
-rwxr-xr-xexamples/org.eclipse.swt.examples.launcher/plugin.properties42
-rwxr-xr-xexamples/org.eclipse.swt.examples.launcher/plugin.xml58
-rwxr-xr-xexamples/org.eclipse.swt.examples.launcher/schema/org.eclipse.swt.examples.launcher.launchItems.xsd181
-rwxr-xr-xexamples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LaunchDelegate.java9
-rwxr-xr-xexamples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/ProgramLaunchDelegate.java89
-rwxr-xr-xexamples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/URLAsFileInputAdapter.java42
-rwxr-xr-xexamples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/ViewLaunchDelegate.java23
-rwxr-xr-xexamples/org.eclipse.swt.examples.ole.win32/.classpath13
-rwxr-xr-xexamples/org.eclipse.swt.examples.ole.win32/.cvsignore1
-rwxr-xr-xexamples/org.eclipse.swt.examples.ole.win32/.vcm_meta12
-rwxr-xr-xexamples/org.eclipse.swt.examples.ole.win32/plugin.jars1
-rwxr-xr-xexamples/org.eclipse.swt.examples.ole.win32/plugin.properties39
-rwxr-xr-xexamples/org.eclipse.swt.examples.ole.win32/plugin.xml58
-rwxr-xr-xexamples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/backward_nav.gifbin0 -> 881 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/forward_nav.gifbin0 -> 883 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/home_nav.gifbin0 -> 928 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/refresh_nav.gifbin0 -> 160 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/search_nav.gifbin0 -> 245 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/stop_nav.gifbin0 -> 174 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples.paint/.classpath14
-rwxr-xr-xexamples/org.eclipse.swt.examples.paint/.cvsignore1
-rwxr-xr-xexamples/org.eclipse.swt.examples.paint/.vcm_meta12
-rwxr-xr-xexamples/org.eclipse.swt.examples.paint/icons/airbrush_tool.gifbin0 -> 890 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples.paint/icons/ellipse_tool.gifbin0 -> 872 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples.paint/icons/filledrectangle_tool.gifbin0 -> 872 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples.paint/icons/line_tool.gifbin0 -> 860 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples.paint/icons/pencil_tool.gifbin0 -> 874 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples.paint/icons/polyline_tool.gifbin0 -> 879 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples.paint/icons/rectangle_tool.gifbin0 -> 865 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples.paint/paintsrc.zipbin0 -> 28703 bytes
-rwxr-xr-xexamples/org.eclipse.swt.examples.paint/plugin.jars1
-rwxr-xr-xexamples/org.eclipse.swt.examples.paint/plugin.properties50
-rwxr-xr-xexamples/org.eclipse.swt.examples.paint/plugin.xml148
-rwxr-xr-xexamples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/Assert.java42
-rwxr-xr-xexamples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/DragInteractivePaintSession.java170
-rwxr-xr-xexamples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/FilledRectangleTool.java86
-rwxr-xr-xexamples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintRenderer.java19
-rwxr-xr-xexamples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintStatus.java99
-rwxr-xr-xexamples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintViewAction.java78
-rwxr-xr-xexamples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/SegmentedInteractivePaintSession.java192
-rwxr-xr-xexamples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/SimplePaintSession.java87
72 files changed, 4861 insertions, 0 deletions
diff --git a/examples/org.eclipse.swt.examples.controls/.classpath b/examples/org.eclipse.swt.examples.controls/.classpath
new file mode 100755
index 0000000000..2057dc6610
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.controls/.classpath
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="/org.eclipse.swt"/>
+ <classpathentry kind="var" path="JRE_LIB"/>
+ <classpathentry kind="var"
+ path="PDE_ECLIPSE_HOME/plugins/org.eclipse.core.resources/resources.jar" sourcepath="PDE_ECLIPSE_HOME/plugins/org.eclipse.core.resources/resourcessrc.zip"/>
+ <classpathentry kind="var"
+ path="PDE_ECLIPSE_HOME/plugins/org.eclipse.core.runtime/runtime.jar" sourcepath="PDE_ECLIPSE_HOME/plugins/org.eclipse.core.runtime/runtimesrc.zip"/>
+ <classpathentry kind="var"
+ path="PDE_ECLIPSE_HOME/plugins/org.eclipse.ui/workbench.jar" sourcepath="PDE_ECLIPSE_HOME/plugins/org.eclipse.ui/workbenchsrc.zip"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/examples/org.eclipse.swt.examples.controls/.cvsignore b/examples/org.eclipse.swt.examples.controls/.cvsignore
new file mode 100755
index 0000000000..c5e82d7458
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.controls/.cvsignore
@@ -0,0 +1 @@
+bin \ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples.controls/.vcm_meta b/examples/org.eclipse.swt.examples.controls/.vcm_meta
new file mode 100755
index 0000000000..e9dbb98bc0
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.controls/.vcm_meta
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-description>
+ <nature id="org.eclipse.jdt.core.javanature"/>
+ <nature id="org.eclipse.pde.PluginNature"/>
+ <reference project-name="org.eclipse.swt"/>
+ <builder name="org.eclipse.jdt.core.javabuilder">
+ </builder>
+ <builder name="org.eclipse.pde.ManifestBuilder">
+ </builder>
+ <builder name="org.eclipse.pde.SchemaBuilder">
+ </builder>
+</project-description>
diff --git a/examples/org.eclipse.swt.examples.controls/plugin.jars b/examples/org.eclipse.swt.examples.controls/plugin.jars
new file mode 100755
index 0000000000..493bce128f
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.controls/plugin.jars
@@ -0,0 +1,3 @@
+controls.jar =\
+ src, \
+ icons
diff --git a/examples/org.eclipse.swt.examples.controls/plugin.properties b/examples/org.eclipse.swt.examples.controls/plugin.properties
new file mode 100755
index 0000000000..287b5c13bc
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.controls/plugin.properties
@@ -0,0 +1,179 @@
+plugin.SWTControlsExample.name = SWT Controls Example Plugin
+category.SWTExamples.name = SWT Examples
+view.ControlsExample.name = Controls
+
+launchcategory.SWTExamples.name = SWT Examples
+launchitem.ControlsExample.name = Controls
+launchitem.ControlsExample.description = This example is a simple demonstration of common Standard Widget Toolkip (SWT) UI controls. It consists of a shell and tab folder where each tab in the folder allows the user to interact with a control.
+
+error.CouldNotLoadResources = Unable to load resources : {0}
+
+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.controls/plugin.xml b/examples/org.eclipse.swt.examples.controls/plugin.xml
new file mode 100755
index 0000000000..79a4749e1d
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.controls/plugin.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- File written by PDE 1.0 -->
+<plugin
+ id="org.eclipse.swt.examples.controls"
+ name="%plugin.SWTControlsExample.name"
+ version="1.0.0"
+ provider-name="IBM"
+ class="org.eclipse.swt.examples.controls.ControlPlugin">
+
+<!-- Required plugins -->
+
+<requires>
+ <import plugin="org.eclipse.core.runtime"/>
+ <import plugin="org.eclipse.core.resources"/>
+ <import plugin="org.eclipse.ui"/>
+ <import plugin="org.eclipse.swt"/>
+</requires>
+
+<!-- Runtime -->
+
+<runtime>
+ <library name="controls.jar"/>
+</runtime>
+
+<!-- Extension points -->
+
+
+<!-- Extensions -->
+<extension
+ point="org.eclipse.ui.views">
+ <category
+ name="%category.SWTExamples.name"
+ id="org.eclipse.swt.examples.category">
+ </category>
+ <view
+ name="%view.ControlsExample.name"
+ category="org.eclipse.swt.examples.category"
+ class="org.eclipse.swt.examples.controls.ControlView"
+ id="org.eclipse.swt.examples.controls.view">
+ </view>
+</extension>
+
+<extension
+ point="org.eclipse.swt.examples.launcher.launchItems">
+ <category
+ name="%launchcategory.SWTExamples.name"
+ id="org.eclipse.swt.examples.launchcategory">
+ </category>
+ <viewItem
+ name="%launchitem.ControlsExample.name"
+ id="org.eclipse.swt.examples.controls.launcher"
+ viewId="org.eclipse.swt.examples.controls.view"
+ description="%launchitem.ControlsExample.description"
+ category="org.eclipse.swt.examples.launchcategory"/>
+</extension>
+</plugin>
diff --git a/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/AlignableTab.java b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/AlignableTab.java
new file mode 100755
index 0000000000..82f7df5948
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/AlignableTab.java
@@ -0,0 +1,76 @@
+package org.eclipse.swt.examples.controls;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+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.
+ */
+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 (ControlPlugin.getResourceString("Alignment"));
+
+ /* Create the controls */
+ leftButton = new Button (allignmentGroup, SWT.RADIO);
+ leftButton.setText (ControlPlugin.getResourceString("Left"));
+ centerButton = new Button (allignmentGroup, SWT.RADIO);
+ centerButton.setText(ControlPlugin.getResourceString("Center"));
+ rightButton = new Button (allignmentGroup, SWT.RADIO);
+ rightButton.setText (ControlPlugin.getResourceString("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.controls/src/org/eclipse/swt/examples/controls/ButtonTab.java b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/ButtonTab.java
new file mode 100755
index 0000000000..036842b1b3
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/ButtonTab.java
@@ -0,0 +1,181 @@
+package org.eclipse.swt.examples.controls;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+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 (ControlPlugin.getResourceString("Up"));
+ downButton = new Button (allignmentGroup, SWT.RADIO);
+ downButton.setText (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("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(ControlPlugin.getResourceString("One"));
+ button2 = new Button(textButtonGroup, style);
+ button2.setText(ControlPlugin.getResourceString("Two"));
+ button3 = new Button(textButtonGroup, style);
+ button3.setText(ControlPlugin.getResourceString("Three"));
+ button4 = new Button(imageButtonGroup, style);
+ button4.setImage(ControlPlugin.images[ControlPlugin.ciClosedFolder]);
+ button5 = new Button(imageButtonGroup, style);
+ button5.setImage(ControlPlugin.images[ControlPlugin.ciOpenFolder]);
+ button6 = new Button(imageButtonGroup, style);
+ button6.setImage(ControlPlugin.images[ControlPlugin.ciTarget]);
+ }
+
+ /**
+ * Creates the "Style" group.
+ */
+ void createStyleGroup() {
+ super.createStyleGroup ();
+
+ /* Create the extra widgets */
+ pushButton = new Button (styleGroup, SWT.RADIO);
+ pushButton.setText(ControlPlugin.getResourceString("SWT_PUSH"));
+ checkButton = new Button (styleGroup, SWT.RADIO);
+ checkButton.setText (ControlPlugin.getResourceString("SWT_CHECK"));
+ radioButton = new Button (styleGroup, SWT.RADIO);
+ radioButton.setText (ControlPlugin.getResourceString("SWT_RADIO"));
+ toggleButton = new Button (styleGroup, SWT.RADIO);
+ toggleButton.setText (ControlPlugin.getResourceString("SWT_TOGGLE"));
+ arrowButton = new Button (styleGroup, SWT.RADIO);
+ arrowButton.setText (ControlPlugin.getResourceString("SWT_ARROW"));
+ borderButton = new Button (styleGroup, SWT.CHECK);
+ borderButton.setText (ControlPlugin.getResourceString("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 ControlPlugin.getResourceString("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.controls/src/org/eclipse/swt/examples/controls/ComboTab.java b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/ComboTab.java
new file mode 100755
index 0000000000..37ef288ece
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/ComboTab.java
@@ -0,0 +1,107 @@
+package org.eclipse.swt.examples.controls;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+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 = {ControlPlugin.getResourceString("ListData0_0"),
+ ControlPlugin.getResourceString("ListData0_1"),
+ ControlPlugin.getResourceString("ListData0_2"),
+ ControlPlugin.getResourceString("ListData0_3"),
+ ControlPlugin.getResourceString("ListData0_4"),
+ ControlPlugin.getResourceString("ListData0_5"),
+ ControlPlugin.getResourceString("ListData0_6"),
+ ControlPlugin.getResourceString("ListData0_7"),
+ ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("SWT_DROP_DOWN"));
+ simpleButton = new Button (styleGroup, SWT.RADIO);
+ simpleButton.setText(ControlPlugin.getResourceString("SWT_SIMPLE"));
+ readOnlyButton = new Button (styleGroup, SWT.CHECK);
+ readOnlyButton.setText (ControlPlugin.getResourceString("SWT_READ_ONLY"));
+ borderButton = new Button (styleGroup, SWT.CHECK);
+ borderButton.setText (ControlPlugin.getResourceString("SWT_BORDER"));
+ }
+
+ /**
+ * Gets the "Example" widget children.
+ */
+ Control [] getExampleWidgets () {
+ return new Control [] {combo1};
+ }
+
+ /**
+ * Gets the text for the tab folder item.
+ */
+ String getTabText () {
+ return ControlPlugin.getResourceString("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.controls/src/org/eclipse/swt/examples/controls/DialogTab.java b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/DialogTab.java
new file mode 100755
index 0000000000..14a9f7e301
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/DialogTab.java
@@ -0,0 +1,424 @@
+package org.eclipse.swt.examples.controls;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+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 = {ControlPlugin.getResourceString("FilterName_0"),
+ ControlPlugin.getResourceString("FilterName_1"),
+ ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("ColorDialog"))) {
+ ColorDialog dialog = new ColorDialog (shell ,style);
+ dialog.setRGB (new RGB (100, 100, 100));
+ dialog.setText (ControlPlugin.getResourceString("Title"));
+ RGB result = dialog.open ();
+ textWidget.append (ControlPlugin.getResourceString("ColorDialog") + Text.DELIMITER);
+ textWidget.append (ControlPlugin.getResourceString("Result") + " " + result + Text.DELIMITER + Text.DELIMITER);
+ return;
+ }
+
+ if (name.equals (ControlPlugin.getResourceString("DirectoryDialog"))) {
+ DirectoryDialog dialog = new DirectoryDialog (shell, style);
+ dialog.setMessage (ControlPlugin.getResourceString("Example_string"));
+ dialog.setText (ControlPlugin.getResourceString("Title"));
+ String result = dialog.open ();
+ textWidget.append (ControlPlugin.getResourceString("DirectoryDialog") + Text.DELIMITER);
+ textWidget.append (ControlPlugin.getResourceString("Result") + " " + result + Text.DELIMITER + Text.DELIMITER);
+ return;
+ }
+
+ if (name.equals (ControlPlugin.getResourceString("FileDialog"))) {
+ FileDialog dialog = new FileDialog (shell, style);
+ dialog.setFileName (ControlPlugin.getResourceString("readme_txt"));
+ dialog.setFilterNames (FilterNames);
+ dialog.setFilterExtensions (FilterExtensions);
+ dialog.setText (ControlPlugin.getResourceString("Title"));
+ String result = dialog.open();
+ textWidget.append (ControlPlugin.getResourceString("FileDialog") + Text.DELIMITER);
+ textWidget.append (ControlPlugin.getResourceString("Result") + " " + result + Text.DELIMITER + Text.DELIMITER);
+ return;
+ }
+
+ if (name.equals (ControlPlugin.getResourceString("FontDialog"))) {
+ FontDialog dialog = new FontDialog (shell, style);
+ dialog.setText (ControlPlugin.getResourceString("Title"));
+ FontData result = dialog.open ();
+ textWidget.append (ControlPlugin.getResourceString("FontDialog") + Text.DELIMITER);
+ textWidget.append (ControlPlugin.getResourceString("Result") + " " + result + Text.DELIMITER + Text.DELIMITER);
+ return;
+ }
+
+ if (name.equals(ControlPlugin.getResourceString("MessageBox"))) {
+ MessageBox dialog = new MessageBox (shell, style);
+ dialog.setMessage (ControlPlugin.getResourceString("Example_string"));
+ dialog.setText (ControlPlugin.getResourceString("Title"));
+ int result = dialog.open ();
+ textWidget.append (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("Result") + ControlPlugin.getResourceString("SWT_OK"));
+ break;
+ case SWT.YES:
+ textWidget.append (ControlPlugin.getResourceString("Result") + ControlPlugin.getResourceString("SWT_YES"));
+ break;
+ case SWT.NO:
+ textWidget.append (ControlPlugin.getResourceString("Result") + ControlPlugin.getResourceString("SWT_NO"));
+ break;
+ case SWT.CANCEL:
+ textWidget.append (ControlPlugin.getResourceString("Result") + ControlPlugin.getResourceString("SWT_CANCEL"));
+ break;
+ case SWT.ABORT:
+ textWidget.append (ControlPlugin.getResourceString("Result") + ControlPlugin.getResourceString("SWT_ABORT"));
+ break;
+ case SWT.RETRY:
+ textWidget.append (ControlPlugin.getResourceString("Result") + ControlPlugin.getResourceString("SWT_RETRY"));
+ break;
+ case SWT.IGNORE:
+ textWidget.append (ControlPlugin.getResourceString("Result") + ControlPlugin.getResourceString("SWT_IGNORE"));
+ break;
+ default:
+ textWidget.append(ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("Dialog_Type"));
+ }
+
+ /**
+ * Creates the "Control" widget children.
+ */
+ void createControlWidgets () {
+
+ /* Create the combo */
+ String [] strings = {
+ ControlPlugin.getResourceString("ColorDialog"),
+ ControlPlugin.getResourceString("DirectoryDialog"),
+ ControlPlugin.getResourceString("FileDialog"),
+ ControlPlugin.getResourceString("FontDialog"),
+ ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("Button_Styles"));
+
+ /* Create the button style buttons */
+ okButton = new Button (buttonStyleGroup, SWT.CHECK);
+ okButton.setText (ControlPlugin.getResourceString("SWT_OK"));
+ cancelButton = new Button (buttonStyleGroup, SWT.CHECK);
+ cancelButton.setText (ControlPlugin.getResourceString("SWT_CANCEL"));
+ yesButton = new Button (buttonStyleGroup, SWT.CHECK);
+ yesButton.setText (ControlPlugin.getResourceString("SWT_YES"));
+ noButton = new Button (buttonStyleGroup, SWT.CHECK);
+ noButton.setText (ControlPlugin.getResourceString("SWT_NO"));
+ retryButton = new Button (buttonStyleGroup, SWT.CHECK);
+ retryButton.setText (ControlPlugin.getResourceString("SWT_RETRY"));
+ abortButton = new Button (buttonStyleGroup, SWT.CHECK);
+ abortButton.setText (ControlPlugin.getResourceString("SWT_ABORT"));
+ ignoreButton = new Button (buttonStyleGroup, SWT.CHECK);
+ ignoreButton.setText (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("Icon_Styles"));
+
+ /* Create the icon style buttons */
+ iconErrorButton = new Button (iconStyleGroup, SWT.RADIO);
+ iconErrorButton.setText (ControlPlugin.getResourceString("SWT_ICON_ERROR"));
+ iconInformationButton = new Button (iconStyleGroup, SWT.RADIO);
+ iconInformationButton.setText (ControlPlugin.getResourceString("SWT_ICON_INFORMATION"));
+ iconQuestionButton = new Button (iconStyleGroup, SWT.RADIO);
+ iconQuestionButton.setText (ControlPlugin.getResourceString("SWT_ICON_QUESTION"));
+ iconWarningButton = new Button (iconStyleGroup, SWT.RADIO);
+ iconWarningButton.setText (ControlPlugin.getResourceString("SWT_ICON_WARNING"));
+ iconWorkingButton = new Button (iconStyleGroup, SWT.RADIO);
+ iconWorkingButton.setText (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("Modal_Styles"));
+
+ /* Create the modal style buttons */
+ modelessButton = new Button (modalStyleGroup, SWT.RADIO);
+ modelessButton.setText (ControlPlugin.getResourceString("SWT_MODELESS"));
+ primaryModalButton = new Button (modalStyleGroup, SWT.RADIO);
+ primaryModalButton.setText (ControlPlugin.getResourceString("SWT_PRIMARY_MODAL"));
+ applicationModalButton = new Button (modalStyleGroup, SWT.RADIO);
+ applicationModalButton.setText (ControlPlugin.getResourceString("SWT_APPLICATION_MODAL"));
+ systemModalButton = new Button (modalStyleGroup, SWT.RADIO);
+ systemModalButton.setText (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("File_Dialog_Styles"));
+
+ /* Create the file dialog style buttons */
+ saveButton = new Button (fileDialogStyleGroup, SWT.RADIO);
+ saveButton.setText (ControlPlugin.getResourceString("SWT_SAVE"));
+ openButton = new Button(fileDialogStyleGroup, SWT.RADIO);
+ openButton.setText(ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("MessageBox"));
+ boolean isFileDialog = name.equals (ControlPlugin.getResourceString("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 ControlPlugin.getResourceString("Dialog");
+ }
+}
diff --git a/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/LabelTab.java b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/LabelTab.java
new file mode 100755
index 0000000000..3df4a386dd
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/LabelTab.java
@@ -0,0 +1,158 @@
+package org.eclipse.swt.examples.controls;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+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 (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("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(ControlPlugin.getResourceString("One"));
+ label2 = new Label (textLabelGroup, style);
+ label2.setText(ControlPlugin.getResourceString("Two"));
+ label3 = new Label (textLabelGroup, style);
+ label3.setText (ControlPlugin.getResourceString("Three"));
+ label4 = new Label (imageLabelGroup, style);
+ label4.setImage (ControlPlugin.images[ControlPlugin.ciClosedFolder]);
+ label5 = new Label (imageLabelGroup, style);
+ label5.setImage (ControlPlugin.images[ControlPlugin.ciOpenFolder]);
+ label6 = new Label(imageLabelGroup, style);
+ label6.setImage (ControlPlugin.images[ControlPlugin.ciTarget]);
+ }
+
+ /**
+ * Creates the "Style" group.
+ */
+ void createStyleGroup() {
+ super.createStyleGroup ();
+
+ /* Create the extra widgets */
+ separatorButton = new Button (styleGroup, SWT.CHECK);
+ separatorButton.setText (ControlPlugin.getResourceString("SWT_SEPARATOR"));
+ horizontalButton = new Button (styleGroup, SWT.RADIO);
+ horizontalButton.setText (ControlPlugin.getResourceString("SWT_HORIZONTAL"));
+ verticalButton = new Button (styleGroup, SWT.RADIO);
+ verticalButton.setText (ControlPlugin.getResourceString("SWT_VERTICAL"));
+ Group styleSubGroup = new Group (styleGroup, SWT.NULL);
+ styleSubGroup.setLayout (new GridLayout ());
+ shadowInButton = new Button (styleSubGroup, SWT.RADIO);
+ shadowInButton.setText (ControlPlugin.getResourceString("SWT_SHADOW_IN"));
+ shadowOutButton = new Button (styleSubGroup, SWT.RADIO);
+ shadowOutButton.setText (ControlPlugin.getResourceString("SWT_SHADOW_OUT"));
+ borderButton = new Button(styleGroup, SWT.CHECK);
+ borderButton.setText(ControlPlugin.getResourceString("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 ControlPlugin.getResourceString("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.controls/src/org/eclipse/swt/examples/controls/ListTab.java b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/ListTab.java
new file mode 100755
index 0000000000..d55f05b839
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/ListTab.java
@@ -0,0 +1,74 @@
+package org.eclipse.swt.examples.controls;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+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 = {ControlPlugin.getResourceString("ListData1_0"),
+ ControlPlugin.getResourceString("ListData1_1"),
+ ControlPlugin.getResourceString("ListData1_2"),
+ ControlPlugin.getResourceString("ListData1_3"),
+ ControlPlugin.getResourceString("ListData1_4"),
+ ControlPlugin.getResourceString("ListData1_5"),
+ ControlPlugin.getResourceString("ListData1_6"),
+ ControlPlugin.getResourceString("ListData1_7"),
+ ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("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 ControlPlugin.getResourceString("List");
+ }
+}
diff --git a/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/ProgressBarTab.java b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/ProgressBarTab.java
new file mode 100755
index 0000000000..6c98778d26
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/ProgressBarTab.java
@@ -0,0 +1,107 @@
+package org.eclipse.swt.examples.controls;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+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 (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("SWT_SMOOTH"));
+ }
+
+ /**
+ * Gets the "Example" widget children.
+ */
+ Control [] getExampleWidgets () {
+ return new Control [] {progressBar1};
+ }
+
+ /**
+ * Gets the text for the tab folder item.
+ */
+ String getTabText () {
+ return ControlPlugin.getResourceString("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.controls/src/org/eclipse/swt/examples/controls/RangeTab.java b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/RangeTab.java
new file mode 100755
index 0000000000..3e39268a0b
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/RangeTab.java
@@ -0,0 +1,161 @@
+package org.eclipse.swt.examples.controls;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+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 (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("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(ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("SWT_HORIZONTAL"));
+ verticalButton = new Button (styleGroup, SWT.RADIO);
+ verticalButton.setText (ControlPlugin.getResourceString("SWT_VERTICAL"));
+ borderButton = new Button (styleGroup, SWT.CHECK);
+ borderButton.setText (ControlPlugin.getResourceString("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.controls/src/org/eclipse/swt/examples/controls/SashTab.java b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/SashTab.java
new file mode 100755
index 0000000000..013cf3487f
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/SashTab.java
@@ -0,0 +1,158 @@
+package org.eclipse.swt.examples.controls;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+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 = {ControlPlugin.getResourceString("ListData0_0"),
+ ControlPlugin.getResourceString("ListData0_1"),
+ ControlPlugin.getResourceString("ListData0_2"),
+ ControlPlugin.getResourceString("ListData0_3"),
+ ControlPlugin.getResourceString("ListData0_4"),
+ ControlPlugin.getResourceString("ListData0_5"),
+ ControlPlugin.getResourceString("ListData0_6"),
+ ControlPlugin.getResourceString("ListData0_7"),
+ ControlPlugin.getResourceString("ListData0_8")};
+
+ static String [] ListData1 = {ControlPlugin.getResourceString("ListData1_0"),
+ ControlPlugin.getResourceString("ListData1_1"),
+ ControlPlugin.getResourceString("ListData1_2"),
+ ControlPlugin.getResourceString("ListData1_3"),
+ ControlPlugin.getResourceString("ListData1_4"),
+ ControlPlugin.getResourceString("ListData1_5"),
+ ControlPlugin.getResourceString("ListData1_6"),
+ ControlPlugin.getResourceString("ListData1_7"),
+ ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("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 ControlPlugin.getResourceString("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.controls/src/org/eclipse/swt/examples/controls/ScrollableTab.java b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/ScrollableTab.java
new file mode 100755
index 0000000000..8695173478
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/ScrollableTab.java
@@ -0,0 +1,48 @@
+package org.eclipse.swt.examples.controls;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+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 (ControlPlugin.getResourceString("SWT_SINGLE"));
+ multiButton = new Button (styleGroup, SWT.RADIO);
+ multiButton.setText (ControlPlugin.getResourceString("SWT_MULTI"));
+ horizontalButton = new Button (styleGroup, SWT.CHECK);
+ horizontalButton.setText (ControlPlugin.getResourceString("SWT_H_SCROLL"));
+ verticalButton = new Button (styleGroup, SWT.CHECK);
+ verticalButton.setText (ControlPlugin.getResourceString("SWT_V_SCROLL"));
+ borderButton = new Button (styleGroup, SWT.CHECK);
+ borderButton.setText (ControlPlugin.getResourceString("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.controls/src/org/eclipse/swt/examples/controls/ShellTab.java b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/ShellTab.java
new file mode 100755
index 0000000000..1eede5da1f
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/ShellTab.java
@@ -0,0 +1,217 @@
+package org.eclipse.swt.examples.controls;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+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 (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("Parent"));
+ }
+
+ /**
+ * Creates the "Control" widget children.
+ */
+ void createControlWidgets () {
+
+ /* Create the parent style buttons */
+ noParentButton = new Button (parentStyleGroup, SWT.RADIO);
+ noParentButton.setText (ControlPlugin.getResourceString("No_Parent"));
+ parentButton = new Button (parentStyleGroup, SWT.RADIO);
+ parentButton.setText (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("Decoration_Styles"));
+
+ /* Create the decoration style buttons */
+ noTrimButton = new Button (decorationStyleGroup, SWT.CHECK);
+ noTrimButton.setText (ControlPlugin.getResourceString("SWT_NO_TRIM"));
+ closeButton = new Button (decorationStyleGroup, SWT.CHECK);
+ closeButton.setText (ControlPlugin.getResourceString("SWT_CLOSE"));
+ titleButton = new Button (decorationStyleGroup, SWT.CHECK);
+ titleButton.setText (ControlPlugin.getResourceString("SWT_TITLE"));
+ minButton = new Button (decorationStyleGroup, SWT.CHECK);
+ minButton.setText (ControlPlugin.getResourceString("SWT_MIN"));
+ maxButton = new Button (decorationStyleGroup, SWT.CHECK);
+ maxButton.setText (ControlPlugin.getResourceString("SWT_MAX"));
+ borderButton = new Button (decorationStyleGroup, SWT.CHECK);
+ borderButton.setText (ControlPlugin.getResourceString("SWT_BORDER"));
+ resizeButton = new Button (decorationStyleGroup, SWT.CHECK);
+ resizeButton.setText (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("Create_Shell"));
+ closeAllButton = new Button (styleGroup, SWT.NULL);
+ closeAllButton.setText (ControlPlugin.getResourceString("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 ControlPlugin.getResourceString("Shell");
+ }
+}
diff --git a/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/SliderTab.java b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/SliderTab.java
new file mode 100755
index 0000000000..3058d09ca5
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/SliderTab.java
@@ -0,0 +1,226 @@
+package org.eclipse.swt.examples.controls;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+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 (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("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 ControlPlugin.getResourceString("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.controls/src/org/eclipse/swt/examples/controls/Tab.java b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/Tab.java
new file mode 100755
index 0000000000..a28d88aae0
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/Tab.java
@@ -0,0 +1,364 @@
+package org.eclipse.swt.examples.controls;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+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.
+ */
+abstract class Tab {
+ /* 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 (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("State"));
+
+ /* Create the controls */
+ enabledButton = new Button(displayGroup, SWT.CHECK);
+ enabledButton.setText(ControlPlugin.getResourceString("Enabled"));
+ visibleButton = new Button(displayGroup, SWT.CHECK);
+ visibleButton.setText(ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("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.controls/src/org/eclipse/swt/examples/controls/TableTab.java b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/TableTab.java
new file mode 100755
index 0000000000..92a68da784
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/TableTab.java
@@ -0,0 +1,172 @@
+package org.eclipse.swt.examples.controls;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+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 = {ControlPlugin.getResourceString("TableTitle_0"),
+ ControlPlugin.getResourceString("TableTitle_1"),
+ ControlPlugin.getResourceString("TableTitle_2"),
+ ControlPlugin.getResourceString("TableTitle_3")};
+
+ static String [] stringLine0 = {ControlPlugin.getResourceString("TableLine0_0"),
+ ControlPlugin.getResourceString("TableLine0_1"),
+ ControlPlugin.getResourceString("TableLine0_2"),
+ ControlPlugin.getResourceString("TableLine0_3")};
+
+ static String [] stringLine1 = {ControlPlugin.getResourceString("TableLine1_0"),
+ ControlPlugin.getResourceString("TableLine1_1"),
+ ControlPlugin.getResourceString("TableLine1_2"),
+ ControlPlugin.getResourceString("TableLine1_3")};
+
+ static String [] stringLine2 = {ControlPlugin.getResourceString("TableLine2_0"),
+ ControlPlugin.getResourceString("TableLine2_1"),
+ ControlPlugin.getResourceString("TableLine2_2"),
+ ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("Header_Visible"));
+ linesVisibleButton = new Button (displayGroup, SWT.CHECK);
+ linesVisibleButton.setText (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("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 */
+ 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 (ControlPlugin.images [i % 3]);
+ switch (i % 3) {
+ case 0:
+ stringLine0 [0] = ControlPlugin.getResourceString("Index") + i;
+ item.setText(stringLine0);
+ break;
+ case 1:
+ stringLine1 [0] = ControlPlugin.getResourceString("Index") + i;
+ item.setText(stringLine1);
+ break;
+ case 2:
+ stringLine2 [0] = ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("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 ControlPlugin.getResourceString("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.controls/src/org/eclipse/swt/examples/controls/TextTab.java b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/TextTab.java
new file mode 100755
index 0000000000..58956dde74
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/TextTab.java
@@ -0,0 +1,100 @@
+package org.eclipse.swt.examples.controls;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+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 (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("Example_string"));
+ text.append (text.DELIMITER);
+ text.append (ControlPlugin.getResourceString("One_Two_Three"));
+ richText = new StyledText (richTextGroup, style);
+ richText.setText (ControlPlugin.getResourceString("Example_string"));
+ richText.append ("\n");
+ richText.append (ControlPlugin.getResourceString("One_Two_Three"));
+ }
+
+ /**
+ * Creates the "Style" group.
+ */
+ void createStyleGroup() {
+ super.createStyleGroup();
+
+ /* Create the extra widgets */
+ readOnlyButton = new Button (styleGroup, SWT.CHECK);
+ readOnlyButton.setText (ControlPlugin.getResourceString("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 ControlPlugin.getResourceString("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.controls/src/org/eclipse/swt/examples/controls/ToolBarTab.java b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/ToolBarTab.java
new file mode 100755
index 0000000000..eb4fb8e297
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/ToolBarTab.java
@@ -0,0 +1,268 @@
+package org.eclipse.swt.examples.controls;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+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 = {ControlPlugin.getResourceString("ListData0_0"),
+ ControlPlugin.getResourceString("ListData0_1"),
+ ControlPlugin.getResourceString("ListData0_2"),
+ ControlPlugin.getResourceString("ListData0_3"),
+ ControlPlugin.getResourceString("ListData0_4"),
+ ControlPlugin.getResourceString("ListData0_5"),
+ ControlPlugin.getResourceString("ListData0_6"),
+ ControlPlugin.getResourceString("ListData0_7"),
+ ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("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 (ControlPlugin.images[ControlPlugin.ciClosedFolder]);
+ item.setToolTipText(ControlPlugin.getResourceString("SWT_PUSH"));
+ item = new ToolItem (imageToolBar, SWT.PUSH);
+ item.setImage (ControlPlugin.images[ControlPlugin.ciClosedFolder]);
+ item.setToolTipText (ControlPlugin.getResourceString("SWT_PUSH"));
+ item = new ToolItem (imageToolBar, SWT.RADIO);
+ item.setImage (ControlPlugin.images[ControlPlugin.ciOpenFolder]);
+ item.setToolTipText (ControlPlugin.getResourceString("SWT_RADIO"));
+ item = new ToolItem (imageToolBar, SWT.RADIO);
+ item.setImage (ControlPlugin.images[ControlPlugin.ciOpenFolder]);
+ item.setToolTipText (ControlPlugin.getResourceString("SWT_RADIO"));
+ item = new ToolItem (imageToolBar, SWT.CHECK);
+ item.setImage (ControlPlugin.images[ControlPlugin.ciTarget]);
+ item.setToolTipText (ControlPlugin.getResourceString("SWT_CHECK"));
+ item = new ToolItem (imageToolBar, SWT.RADIO);
+ item.setImage (ControlPlugin.images[ControlPlugin.ciClosedFolder]);
+ item.setToolTipText (ControlPlugin.getResourceString("SWT_RADIO"));
+ item = new ToolItem (imageToolBar, SWT.RADIO);
+ item.setImage (ControlPlugin.images[ControlPlugin.ciClosedFolder]);
+ item.setToolTipText (ControlPlugin.getResourceString("SWT_RADIO"));
+ item = new ToolItem (imageToolBar, SWT.SEPARATOR);
+ item.setToolTipText(ControlPlugin.getResourceString("SWT_SEPARATOR"));
+ item = new ToolItem (imageToolBar, SWT.DROP_DOWN);
+ item.setImage (ControlPlugin.images[ControlPlugin.ciTarget]);
+ item.setToolTipText (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("Push"));
+ item.setToolTipText(ControlPlugin.getResourceString("SWT_PUSH"));
+ item = new ToolItem (textToolBar, SWT.PUSH);
+ item.setText (ControlPlugin.getResourceString("Push"));
+ item.setToolTipText(ControlPlugin.getResourceString("SWT_PUSH"));
+ item = new ToolItem (textToolBar, SWT.RADIO);
+ item.setText (ControlPlugin.getResourceString("Radio"));
+ item.setToolTipText(ControlPlugin.getResourceString("SWT_RADIO"));
+ item = new ToolItem (textToolBar, SWT.RADIO);
+ item.setText (ControlPlugin.getResourceString("Radio"));
+ item.setToolTipText(ControlPlugin.getResourceString("SWT_RADIO"));
+ item = new ToolItem (textToolBar, SWT.CHECK);
+ item.setText (ControlPlugin.getResourceString("Check"));
+ item.setToolTipText(ControlPlugin.getResourceString("SWT_CHECK"));
+ item = new ToolItem (textToolBar, SWT.RADIO);
+ item.setText (ControlPlugin.getResourceString("Radio"));
+ item.setToolTipText(ControlPlugin.getResourceString("SWT_RADIO"));
+ item = new ToolItem (textToolBar, SWT.RADIO);
+ item.setText (ControlPlugin.getResourceString("Radio"));
+ item.setToolTipText(ControlPlugin.getResourceString("SWT_RADIO"));
+ item = new ToolItem (textToolBar, SWT.SEPARATOR);
+ item.setToolTipText(ControlPlugin.getResourceString("SWT_SEPARATOR"));
+ item = new ToolItem (textToolBar, SWT.DROP_DOWN);
+ item.setText (ControlPlugin.getResourceString("Drop_Down"));
+ item.setToolTipText(ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("SWT_FLAT"));
+ wrapButton = new Button (styleGroup, SWT.CHECK);
+ wrapButton.setText (ControlPlugin.getResourceString("SWT_WRAP"));
+ borderButton = new Button (styleGroup, SWT.CHECK);
+ borderButton.setText (ControlPlugin.getResourceString("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 ControlPlugin.getResourceString("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.controls/src/org/eclipse/swt/examples/controls/TreeTab.java b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/TreeTab.java
new file mode 100755
index 0000000000..0270245c6d
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/TreeTab.java
@@ -0,0 +1,113 @@
+package org.eclipse.swt.examples.controls;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+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 (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("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 (ControlPlugin.getResourceString("Node_1"));
+ TreeItem node2 = new TreeItem (tree1, SWT.NULL);
+ node2.setText (ControlPlugin.getResourceString("Node_2"));
+ TreeItem node3 = new TreeItem (tree1, SWT.NULL);
+ node3.setText (ControlPlugin.getResourceString("Node_3"));
+ TreeItem node4 = new TreeItem (tree1, SWT.NULL);
+ node4.setText (ControlPlugin.getResourceString("Node_4"));
+ TreeItem node1_1 = new TreeItem (node1, SWT.NULL);
+ node1_1.setText (ControlPlugin.getResourceString("Node_1_1"));
+ TreeItem node2_1 = new TreeItem (node2, SWT.NULL);
+ node2_1.setText (ControlPlugin.getResourceString("Node_2_1"));
+ TreeItem node3_1 = new TreeItem (node3, SWT.NULL);
+ node3_1.setText (ControlPlugin.getResourceString("Node_3_1"));
+ TreeItem node2_2 = new TreeItem (node2, SWT.NULL);
+ node2_2.setText (ControlPlugin.getResourceString("Node_2_2"));
+ TreeItem node2_2_1 = new TreeItem (node2_2, SWT.NULL);
+ node2_2_1.setText (ControlPlugin.getResourceString("Node_2_2_1"));
+
+ /* Create the image tree */
+ tree2 = new Tree (imageTreeGroup, style);
+ node1 = new TreeItem (tree2, SWT.NULL);
+ node1.setText (ControlPlugin.getResourceString("Node_1"));
+ node1.setImage (ControlPlugin.images[ControlPlugin.ciClosedFolder]);
+ node2 = new TreeItem (tree2, SWT.NULL);
+ node2.setText (ControlPlugin.getResourceString("Node_2"));
+ node2.setImage (ControlPlugin.images[ControlPlugin.ciClosedFolder]);
+ node3 = new TreeItem (tree2, SWT.NULL);
+ node3.setText (ControlPlugin.getResourceString("Node_3"));
+ node3.setImage (ControlPlugin.images[ControlPlugin.ciClosedFolder]);
+ node4 = new TreeItem (tree2, SWT.NULL);
+ node4.setText (ControlPlugin.getResourceString("Node_4"));
+ node4.setImage (ControlPlugin.images[ControlPlugin.ciClosedFolder]);
+ node1_1 = new TreeItem (node1, SWT.NULL);
+ node1_1.setText (ControlPlugin.getResourceString("Node_1_1"));
+ node1_1.setImage (ControlPlugin.images[ControlPlugin.ciClosedFolder]);
+ node2_1 = new TreeItem (node2, SWT.NULL);
+ node2_1.setText (ControlPlugin.getResourceString("Node_2_1"));
+ node2_1.setImage (ControlPlugin.images[ControlPlugin.ciClosedFolder]);
+ node3_1 = new TreeItem (node3, SWT.NULL);
+ node3_1.setText (ControlPlugin.getResourceString("Node_3_1"));
+ node3_1.setImage (ControlPlugin.images[ControlPlugin.ciClosedFolder]);
+ node2_2 = new TreeItem(node2, SWT.NULL);
+ node2_2.setText (ControlPlugin.getResourceString("Node_2_2"));
+ node2_2.setImage (ControlPlugin.images[ControlPlugin.ciClosedFolder]);
+ node2_2_1 = new TreeItem (node2_2, SWT.NULL);
+ node2_2_1.setText (ControlPlugin.getResourceString("Node_2_2_1"));
+ node2_2_1.setImage (ControlPlugin.images[ControlPlugin.ciClosedFolder]);
+ }
+
+ /**
+ * Gets the "Example" widget children.
+ */
+ Control [] getExampleWidgets () {
+ return new Control [] {tree1, tree2};
+ }
+
+ /**
+ * Gets the text for the tab folder item.
+ */
+ String getTabText () {
+ return ControlPlugin.getResourceString("Tree");
+ }
+}
diff --git a/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/closedFolder.gif b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/closedFolder.gif
new file mode 100755
index 0000000000..6660d0b11a
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/closedFolder.gif
Binary files differ
diff --git a/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/openFolder.gif b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/openFolder.gif
new file mode 100755
index 0000000000..fc9943f111
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/openFolder.gif
Binary files differ
diff --git a/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/target.gif b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/target.gif
new file mode 100755
index 0000000000..9807ae648d
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/target.gif
Binary files differ
diff --git a/examples/org.eclipse.swt.examples.launcher/.classpath b/examples/org.eclipse.swt.examples.launcher/.classpath
new file mode 100755
index 0000000000..b7f3bd4086
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.launcher/.classpath
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="schema"/>
+ <classpathentry kind="src" path="doc"/>
+ <classpathentry kind="src" path="/org.eclipse.swt"/>
+ <classpathentry kind="var" path="JRE_LIB"/>
+ <classpathentry kind="var"
+ path="PDE_ECLIPSE_HOME/plugins/org.eclipse.core.resources/resources.jar" sourcepath="PDE_ECLIPSE_HOME/plugins/org.eclipse.core.resources/resourcessrc.zip"/>
+ <classpathentry kind="var"
+ path="PDE_ECLIPSE_HOME/plugins/org.eclipse.core.runtime/runtime.jar" sourcepath="PDE_ECLIPSE_HOME/plugins/org.eclipse.core.runtime/runtimesrc.zip"/>
+ <classpathentry kind="var"
+ path="PDE_ECLIPSE_HOME/plugins/org.eclipse.ui/workbench.jar" sourcepath="PDE_ECLIPSE_HOME/plugins/org.eclipse.ui/workbenchsrc.zip"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/examples/org.eclipse.swt.examples.launcher/.cvsignore b/examples/org.eclipse.swt.examples.launcher/.cvsignore
new file mode 100755
index 0000000000..c5e82d7458
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.launcher/.cvsignore
@@ -0,0 +1 @@
+bin \ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples.launcher/.vcm_meta b/examples/org.eclipse.swt.examples.launcher/.vcm_meta
new file mode 100755
index 0000000000..0c9e8d8b7a
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.launcher/.vcm_meta
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-description>
+ <nature id="org.eclipse.jdt.core.javanature"/>
+ <nature id="org.eclipse.pde.PluginNature"/>
+ <builder name="org.eclipse.jdt.core.javabuilder">
+ </builder>
+ <builder name="org.eclipse.pde.ManifestBuilder">
+ </builder>
+ <builder name="org.eclipse.pde.SchemaBuilder">
+ </builder>
+</project-description>
diff --git a/examples/org.eclipse.swt.examples.launcher/doc/org.eclipse.swt.examples.launcher.launchItems.html b/examples/org.eclipse.swt.examples.launcher/doc/org.eclipse.swt.examples.launcher.launchItems.html
new file mode 100755
index 0000000000..3d7c46e9e8
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.launcher/doc/org.eclipse.swt.examples.launcher.launchItems.html
@@ -0,0 +1,48 @@
+<HTML>
+<BODY>
+<H1><CENTER>%extension-point.launchItems.name</CENTER></H1>
+<H2>Identifier</H2>
+org.eclipse.swt.examples.launcher.org.eclipse.swt.examples.launcher.launchItems<H2>Description</H2>
+[Enter description of this extension point]<H2>Markup</H2>
+<p><samp>&nbsp;&nbsp; &lt;!ELEMENT extension (EMPTY)&gt;</samp>
+<br><samp>&nbsp;&nbsp; &lt;!ATTLIST extension</samp>
+<br><samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;point&nbsp;CDATA #REQUIRED</samp>
+<br><samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;id&nbsp;&nbsp;&nbsp;&nbsp;CDATA #IMPLIED</samp>
+<br><samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name&nbsp;&nbsp;CDATA #IMPLIED</samp>
+<br><samp>&nbsp;&nbsp; &gt;</samp>
+<ul>
+<li><b>point</b> - </li><li><b>id</b> - </li><li><b>name</b> - </li></ul>
+<p><samp>&nbsp;&nbsp; &lt;!ELEMENT programItem (EMPTY)&gt;</samp>
+<br><samp>&nbsp;&nbsp; &lt;!ATTLIST programItem</samp>
+<br><samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CDATA #REQUIRED</samp>
+<br><samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CDATA #IMPLIED</samp>
+<br><samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mainClass&nbsp;CDATA #REQUIRED</samp>
+<br><samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pluginId&nbsp;&nbsp;CDATA #REQUIRED</samp>
+<br><samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;category&nbsp;&nbsp;CDATA #IMPLIED</samp>
+<br><samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;source&nbsp;&nbsp;&nbsp;&nbsp;CDATA #IMPLIED</samp>
+<br><samp>&nbsp;&nbsp; &gt;</samp>
+<ul>
+<li><b>name</b> - </li><li><b>id</b> - </li><li><b>mainClass</b> - </li><li><b>pluginId</b> - </li><li><b>category</b> - </li><li><b>source</b> - </li></ul>
+<p><samp>&nbsp;&nbsp; &lt;!ELEMENT viewItem (EMPTY)&gt;</samp>
+<br><samp>&nbsp;&nbsp; &lt;!ATTLIST viewItem</samp>
+<br><samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CDATA #REQUIRED</samp>
+<br><samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CDATA #IMPLIED</samp>
+<br><samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;viewId&nbsp;&nbsp;&nbsp;CDATA #REQUIRED</samp>
+<br><samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;category&nbsp;CDATA #IMPLIED</samp>
+<br><samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;source&nbsp;&nbsp;&nbsp;CDATA #IMPLIED</samp>
+<br><samp>&nbsp;&nbsp; &gt;</samp>
+<ul>
+<li><b>name</b> - </li><li><b>id</b> - </li><li><b>viewId</b> - </li><li><b>category</b> - </li><li><b>source</b> - </li></ul>
+<p><samp>&nbsp;&nbsp; &lt;!ELEMENT category (EMPTY)&gt;</samp>
+<br><samp>&nbsp;&nbsp; &lt;!ATTLIST category</samp>
+<br><samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CDATA #REQUIRED</samp>
+<br><samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CDATA #REQUIRED</samp>
+<br><samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;category&nbsp;CDATA #IMPLIED</samp>
+<br><samp>&nbsp;&nbsp; &gt;</samp>
+<ul>
+<li><b>name</b> - </li><li><b>id</b> - </li><li><b>category</b> - </li></ul>
+<H2>Example</H2>
+[Enter extension point usage example here.]<H2>API Information</H2>
+[Enter API information here.]<H2>Supplied Implementation</H2>
+[Enter information about supplied implementation of this extension point.]</BODY>
+</HTML>
diff --git a/examples/org.eclipse.swt.examples.launcher/plugin.jars b/examples/org.eclipse.swt.examples.launcher/plugin.jars
new file mode 100755
index 0000000000..c523749f98
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.launcher/plugin.jars
@@ -0,0 +1 @@
+launcher.jar = \ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples.launcher/plugin.properties b/examples/org.eclipse.swt.examples.launcher/plugin.properties
new file mode 100755
index 0000000000..e92d2cbbe5
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.launcher/plugin.properties
@@ -0,0 +1,42 @@
+plugin.SWTLauncherExample.name = SWT Launcher Example Plugin
+category.SWTExamples.name = SWT Examples
+view.LauncherExample.name = Launcher
+
+launchcategory.SWTExamples.name = SWT Examples
+launchcategory.SWTExamples.description = A collection of Standard Widget Toolkit examples.
+launchitem.LauncherExample.name = Launcher
+launchitem.LauncherExample.description = This example demontrates a mechanism for creating views and launching applications from within Eclipse. It also serves as a launchpad for accessing other examples in the system.
+
+extension-point.launchItems.name = Launch Items List
+
+error.CouldNotLoadResources = Unable to load resources : {0}
+error.IncompleteProgramLaunchItem = Incomplete XML ProgramLaunchItem definition
+error.IncompleteViewLaunchItem = Incomplete XML ViewLaunchItem definition
+
+dialog.RunProgramProblems.title = Run Program Problems
+dialog.ProgramErrorCheckLog.message = Error while running program "{0}", check log for details.
+
+dialog.ImportProgramProblems.title = Add to Workbench Problems
+dialog.InvalidTargetProjectPath.message = "{0}" is not a valid project name.
+dialog.ErrorAccessingZipFile.message = Error accessing Zip/Jar file "{0}" for import. {1}
+
+dialog.ImportProgramOverwrite.title = Question
+dialog.FileAlreadyExists.message = {0} already exists. Would you like to overwrite it?
+
+launchitem.Null.description = <<no item selected>>
+
+launchitem.Missing.name = <<unnamed>>
+launchitem.Missing.description = <<no description available>>
+
+view.launchGroup.text = Examples
+view.launchButton.text = Run
+view.importButton.text = Add to Workspace
+view.descriptionGroup.text = Description
+
+run.InvocationSummaryHeader = *** Program execution summary ***
+run.InvocationSummaryFooter = *** end ***
+run.InvokingView = Creating Eclipse view: view id = {0}
+run.InvokingProgram = Launching standalone program: plugin id = {0}, class = {1}
+run.error.Invocation = A fatal error occurred while launching the program:
+run.error.Execution = An uncaught exception occured while running the program:
+run.error.CouldNotFindPlugin = Could not find plugin: {0}
diff --git a/examples/org.eclipse.swt.examples.launcher/plugin.xml b/examples/org.eclipse.swt.examples.launcher/plugin.xml
new file mode 100755
index 0000000000..ed8b5d96be
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.launcher/plugin.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- File written by PDE 1.0 -->
+<plugin
+ id="org.eclipse.swt.examples.launcher"
+ name="%plugin.SWTLauncherExample.name"
+ version="1.0.0"
+ provider-name="IBM"
+ class="org.eclipse.swt.examples.launcher.LauncherPlugin">
+
+<!-- Required plugins -->
+
+<requires>
+ <import plugin="org.eclipse.core.runtime"/>
+ <import plugin="org.eclipse.core.resources"/>
+ <import plugin="org.eclipse.ui"/>
+ <import plugin="org.eclipse.swt"/>
+</requires>
+
+<!-- Runtime -->
+
+<runtime>
+ <library name="launcher.jar"/>
+</runtime>
+
+<!-- Extension points -->
+
+<extension-point id="launchItems" name="%extension-point.launchItems.name" schema="schema/org.eclipse.swt.examples.launcher.launchItems.xsd"/>
+
+<!-- Extensions -->
+<extension
+ point="org.eclipse.ui.views">
+ <category
+ name="%category.SWTExamples.name"
+ id="org.eclipse.swt.examples.category">
+ </category>
+ <view
+ name="%view.LauncherExample.name"
+ category="org.eclipse.swt.examples.category"
+ class="org.eclipse.swt.examples.launcher.LauncherView"
+ id="org.eclipse.swt.examples.launcher.view">
+ </view>
+</extension>
+<extension
+ point="org.eclipse.swt.examples.launcher.launchItems">
+ <category
+ name="%launchcategory.SWTExamples.name"
+ description="%launchcategory.SWTExamples.description"
+ id="org.eclipse.swt.examples.launchcategory">
+ </category>
+ <viewItem
+ viewId="org.eclipse.swt.examples.launcher.view"
+ name="%launchitem.LauncherExample.name"
+ category="org.eclipse.swt.examples.launchcategory"
+ description="%launchitem.LauncherExample.description"
+ id="org.eclipse.swt.examples.launcher.launcher">
+ </viewItem>
+</extension>
+</plugin>
diff --git a/examples/org.eclipse.swt.examples.launcher/schema/org.eclipse.swt.examples.launcher.launchItems.xsd b/examples/org.eclipse.swt.examples.launcher/schema/org.eclipse.swt.examples.launcher.launchItems.xsd
new file mode 100755
index 0000000000..45fc79ef42
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.launcher/schema/org.eclipse.swt.examples.launcher.launchItems.xsd
@@ -0,0 +1,181 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.swt.examples.launcher.org.eclipse.swt.examples.launcher">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.swt.examples.launcher.org.eclipse.swt.examples.launcher" id="launchItems" name="%extension-point.launchItems.name"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point]
+ </documentation>
+</annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="programItem">
+ <complexType>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="mainClass" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="pluginId" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="category" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="source" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="viewItem">
+ <complexType>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="viewId" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="category" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="source" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="category">
+ <complexType>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="category" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LaunchDelegate.java b/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LaunchDelegate.java
new file mode 100755
index 0000000000..eab77ca81c
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LaunchDelegate.java
@@ -0,0 +1,9 @@
+package org.eclipse.swt.examples.launcher;
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+ import org.eclipse.ui.IViewPart; import java.io.PrintWriter; /** * LaunchDelegate provide a means of encapsulating a method for launching a * variety of programs of different types along with information about these * programs. */
+public interface LaunchDelegate { /** * Launch the program described by this object. * * @param hostView the IViewPart for the launcher program. Use this to ensure that * child programs are visible on the same display / Eclipse perspective as * the launcher application * @param logWriter a PrintWriter to which run-log information will be written, must NOT be null * * @return true iff the launch was (probably) successful */
+ public boolean launch(IViewPart hostView, PrintWriter logWriter);
+}
diff --git a/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/ProgramLaunchDelegate.java b/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/ProgramLaunchDelegate.java
new file mode 100755
index 0000000000..97c2d85522
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/ProgramLaunchDelegate.java
@@ -0,0 +1,89 @@
+package org.eclipse.swt.examples.launcher;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.core.runtime.IPluginDescriptor; import org.eclipse.core.runtime.IPluginRegistry; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.PluginVersionIdentifier; import org.eclipse.ui.IViewPart; import java.io.PrintWriter; import java.io.StringWriter; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Arrays; import java.util.Comparator;
+
+/**
+ * A launch delegate for running a standalone program embedded inside a plugin package
+ */
+public class ProgramLaunchDelegate implements LaunchDelegate {
+ private String mainClassName;
+ private String pluginId;
+
+ public ProgramLaunchDelegate(String pluginId, String mainClassName) {
+ this.pluginId = pluginId;
+ this.mainClassName = mainClassName;
+ }
+
+ public boolean launch(IViewPart hostView, PrintWriter logWriter) {
+ logWriter.println(LauncherPlugin.getResourceString("run.InvocationSummaryHeader"));
+ logWriter.println(LauncherPlugin.getResourceString("run.InvokingProgram",
+ new Object[] { pluginId, mainClassName }));
+
+ boolean result = launchHelper(hostView, logWriter);
+ logWriter.println(LauncherPlugin.getResourceString("run.InvocationSummaryFooter"));
+ return result;
+ }
+
+ public boolean launchHelper(IViewPart hostView, PrintWriter logWriter) {
+ // get the platform's public plugin registry
+ IPluginRegistry pluginRegistry = Platform.getPluginRegistry();
+ // retrieve plugin descriptors for all plugins matching pluginId
+ // [array may contain multiple versions of a given plugin]
+ IPluginDescriptor[] pluginDescriptors = pluginRegistry.getPluginDescriptors(pluginId);
+
+ if (pluginDescriptors == null || pluginDescriptors.length == 0) {
+ logWriter.println(LauncherPlugin.getResourceString("run.error.CouldNotFindPlugin",
+ new Object[] { pluginId }));
+ return false;
+ }
+
+ // sort list of plugins in decreasing order by version number
+ Arrays.sort(pluginDescriptors, new Comparator() {
+ public int compare(Object a, Object b) {
+ final PluginVersionIdentifier versionA = ((IPluginDescriptor) a).getVersionIdentifier();
+ final PluginVersionIdentifier versionB = ((IPluginDescriptor) b).getVersionIdentifier();
+ return versionA.isGreaterThan(versionB) ? -1 :
+ (versionA.equals(versionB) ? 0 : 1);
+ }
+ });
+
+ // attempt to load and run a program in decreasing order by version until we find one
+ // that works or we run out of them
+ Throwable exception = null;
+ for (int i = 0; i < pluginDescriptors.length; ++i) {
+ final IPluginDescriptor pd = pluginDescriptors[i];
+ final ClassLoader loader = pd.getPluginClassLoader();
+
+ try {
+ Class programMainClass = Class.forName(mainClassName, true, loader);
+
+ final Class[] parameterList = { String[].class };
+ Method programMainMethod = programMainClass.getMethod("main", parameterList);
+
+ final Object[] parameters = { new String[0] };
+ programMainMethod.invoke(null, parameters);
+ break;
+ } catch (InvocationTargetException e) {
+ logWriter.println(LauncherPlugin.getResourceString("run.error.Execution"));
+ exception = e;
+ break;
+ } catch (Throwable e) {
+ logWriter.println(LauncherPlugin.getResourceString("run.error.Invocation"));
+ exception = e;
+ }
+ }
+ // log exceptions
+ if (exception != null) {
+ logWriter.println(exception.toString());
+ exception.printStackTrace(logWriter);
+ return false;
+ }
+ return true;
+ }
+}
+
diff --git a/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/URLAsFileInputAdapter.java b/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/URLAsFileInputAdapter.java
new file mode 100755
index 0000000000..ed9eab4b61
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/URLAsFileInputAdapter.java
@@ -0,0 +1,42 @@
+package org.eclipse.swt.examples.launcher; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.net.URL;
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+ /** * Grants access to a URL as if it were a file. * * There _must_ be a better way of doing this! */
+public class URLAsFileInputAdapter {
+ URL url;
+ File file;
+ /** * Create an adapter control object * * @param url the URL to be accessed */ public URLAsFileInputAdapter(URL url) {
+ this.url = url;
+ } /** * Dispose of any allocated resources, call when finished with the file. */
+ public void dispose() {
+ file.delete();
+ file = null;
+ } /** * Get a File object corresponding to the URL specified in the constructor * * @return a read-only File object corresponding to the URL */
+ public File getFile() throws IOException {
+ if (file != null) return file;
+ BufferedInputStream is = null;
+ BufferedOutputStream os = null;
+ try {
+ is = new BufferedInputStream(url.openConnection().getInputStream());
+
+ file = File.createTempFile("urlcache", "tmp");
+ file.deleteOnExit();
+
+ os = new BufferedOutputStream(new FileOutputStream(file));
+ byte[] buffer = new byte[4096];
+ for (;;) {
+ int count = is.read(buffer, 0, buffer.length);
+ if (count < 0) break;
+ os.write(buffer, 0, count);
+ }
+ file.setReadOnly();
+ return file;
+ } finally {
+ if (is != null) is.close();
+ if (os != null) os.close();
+ }
+ }
+
+}
diff --git a/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/ViewLaunchDelegate.java b/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/ViewLaunchDelegate.java
new file mode 100755
index 0000000000..31dd15e300
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/ViewLaunchDelegate.java
@@ -0,0 +1,23 @@
+package org.eclipse.swt.examples.launcher;
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+ import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPartSite; import java.io.PrintWriter; import java.io.StringWriter;
+ /** * A launch delegate for starting an Eclipse view */
+public class ViewLaunchDelegate implements LaunchDelegate {
+ private String pluginViewId;
+
+ public ViewLaunchDelegate(String pluginViewId) {
+ this.pluginViewId = pluginViewId;
+ }
+ public boolean launch(IViewPart hostView, PrintWriter logWriter) { logWriter.println(LauncherPlugin.getResourceString("run.InvocationSummaryHeader")); logWriter.println(LauncherPlugin.getResourceString("run.InvokingView", new Object[] { pluginViewId })); boolean result = launchHelper(hostView, logWriter); logWriter.println(LauncherPlugin.getResourceString("run.InvocationSummaryFooter")); return result; }
+ public boolean launchHelper(IViewPart hostView, PrintWriter logWriter) {
+ final IWorkbenchPart workbenchPart = hostView;
+ final IWorkbenchPartSite workbenchPartSite = workbenchPart.getSite();
+ final IWorkbenchPage workbenchPage = workbenchPartSite.getPage();
+
+ try {
+ workbenchPage.showView(pluginViewId);
+ } catch (Throwable exception) { logWriter.println(LauncherPlugin.getResourceString("run.error.Invocation")); logWriter.println(exception.toString()); exception.printStackTrace(logWriter); return false; } return true; }
+}
diff --git a/examples/org.eclipse.swt.examples.ole.win32/.classpath b/examples/org.eclipse.swt.examples.ole.win32/.classpath
new file mode 100755
index 0000000000..2057dc6610
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.ole.win32/.classpath
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="/org.eclipse.swt"/>
+ <classpathentry kind="var" path="JRE_LIB"/>
+ <classpathentry kind="var"
+ path="PDE_ECLIPSE_HOME/plugins/org.eclipse.core.resources/resources.jar" sourcepath="PDE_ECLIPSE_HOME/plugins/org.eclipse.core.resources/resourcessrc.zip"/>
+ <classpathentry kind="var"
+ path="PDE_ECLIPSE_HOME/plugins/org.eclipse.core.runtime/runtime.jar" sourcepath="PDE_ECLIPSE_HOME/plugins/org.eclipse.core.runtime/runtimesrc.zip"/>
+ <classpathentry kind="var"
+ path="PDE_ECLIPSE_HOME/plugins/org.eclipse.ui/workbench.jar" sourcepath="PDE_ECLIPSE_HOME/plugins/org.eclipse.ui/workbenchsrc.zip"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/examples/org.eclipse.swt.examples.ole.win32/.cvsignore b/examples/org.eclipse.swt.examples.ole.win32/.cvsignore
new file mode 100755
index 0000000000..c5e82d7458
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.ole.win32/.cvsignore
@@ -0,0 +1 @@
+bin \ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples.ole.win32/.vcm_meta b/examples/org.eclipse.swt.examples.ole.win32/.vcm_meta
new file mode 100755
index 0000000000..e9dbb98bc0
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.ole.win32/.vcm_meta
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-description>
+ <nature id="org.eclipse.jdt.core.javanature"/>
+ <nature id="org.eclipse.pde.PluginNature"/>
+ <reference project-name="org.eclipse.swt"/>
+ <builder name="org.eclipse.jdt.core.javabuilder">
+ </builder>
+ <builder name="org.eclipse.pde.ManifestBuilder">
+ </builder>
+ <builder name="org.eclipse.pde.SchemaBuilder">
+ </builder>
+</project-description>
diff --git a/examples/org.eclipse.swt.examples.ole.win32/plugin.jars b/examples/org.eclipse.swt.examples.ole.win32/plugin.jars
new file mode 100755
index 0000000000..60dff10867
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.ole.win32/plugin.jars
@@ -0,0 +1 @@
+olewin32.jar = \ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples.ole.win32/plugin.properties b/examples/org.eclipse.swt.examples.ole.win32/plugin.properties
new file mode 100755
index 0000000000..47dba6e946
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.ole.win32/plugin.properties
@@ -0,0 +1,39 @@
+plugin.SWTOLEExample.name = SWT OLE Example Plugin (Win32)
+category.SWTExamples.name = SWT Examples
+view.OLEWebBrowserExample.name = OLE Web Browser (Win32)
+
+launchcategory.SWTExamples.name = SWT Examples
+launchcategory.SWTExamples.description = A collection of Standard Widget Toolkit examples.
+launchitem.OLEWebBrowserExample.name = OLE Web Browser (Win32)
+launchitem.OLEWebBrowserExample.description = This example demonstrates how to embed Active X / OLE controls into an SWT application or an Eclipse view. When the view is activated, it will create an instance of a Windows "Shell.Explorer" control and provide a GUI interface to it via OLE Automation. To run this example, Internet Explorer must be installed.
+
+browser.Back.text = Backward
+browser.Back.tooltip = Surf to previously viewed Web site
+
+browser.Forward.text = Forward
+browser.Forward.tooltip = Surf to next viewed Web site
+
+browser.Home.text = Home
+browser.Home.tooltip = Surf to home Web site
+
+browser.Stop.text = Stop
+browser.Stop.tooltip = Stop loading current Web site
+
+browser.Refresh.text = Refresh
+browser.Refresh.tooltip = Refresh current Web site
+
+browser.Search.text = Search
+browser.Search.tooltip = Search the Web
+
+browser.Address.label = Address :
+
+browser.Go.text = Go
+
+browser.State.Uninitialized.text = Not ready.
+browser.State.Loading.text = Loading Web site...
+browser.State.Loaded.text = Ready.
+browser.State.Interactive.text = Loading Web site...
+browser.State.Complete.text = Done.
+
+error.CouldNotLoadResources = Unable to load resources : {0}
+error.CouldNotCreateBrowserControl = Unable to create <<Browser Control>> : {0}
diff --git a/examples/org.eclipse.swt.examples.ole.win32/plugin.xml b/examples/org.eclipse.swt.examples.ole.win32/plugin.xml
new file mode 100755
index 0000000000..6adab5b802
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.ole.win32/plugin.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- File written by PDE 1.0 -->
+<plugin
+ id="org.eclipse.swt.examples.ole.win32"
+ name="%plugin.SWTOLEExample.name"
+ version="1.0.0"
+ provider-name="IBM"
+ class="org.eclipse.swt.examples.ole.win32.OlePlugin">
+
+<!-- Required plugins -->
+
+<requires>
+ <import plugin="org.eclipse.core.runtime"/>
+ <import plugin="org.eclipse.core.resources"/>
+ <import plugin="org.eclipse.ui"/>
+ <import plugin="org.eclipse.swt"/>
+</requires>
+
+<!-- Runtime -->
+
+<runtime>
+ <library name="olewin32.jar"/>
+</runtime>
+
+<!-- Extension points -->
+
+
+<!-- Extensions -->
+<extension
+ point="org.eclipse.ui.views">
+ <category
+ name="%category.SWTExamples.name"
+ id="org.eclipse.swt.examples.category">
+ </category>
+ <view
+ name="%view.OLEWebBrowserExample.name"
+ category="org.eclipse.swt.examples.category"
+ class="org.eclipse.swt.examples.ole.win32.OleBrowserView"
+ id="org.eclipse.swt.examples.ole.win32.browserView">
+ </view>
+</extension>
+
+<extension
+ point="org.eclipse.swt.examples.launcher.launchItems">
+ <category
+ name="%launchcategory.SWTExamples.name"
+ description="%launchcategory.SWTExamples.description"
+ id="org.eclipse.swt.examples.launchcategory">
+ </category>
+ <viewItem
+ name="%launchitem.OLEWebBrowserExample.name"
+ id="org.eclipse.swt.examples.ole.win32.launcher"
+ viewId="org.eclipse.swt.examples.ole.win32.browserView"
+ description="%launchitem.OLEWebBrowserExample.description"
+ category="org.eclipse.swt.examples.launchcategory"/>
+</extension>
+
+</plugin>
diff --git a/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/backward_nav.gif b/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/backward_nav.gif
new file mode 100755
index 0000000000..5fcf41b783
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/backward_nav.gif
Binary files differ
diff --git a/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/forward_nav.gif b/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/forward_nav.gif
new file mode 100755
index 0000000000..3b9b6af9b1
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/forward_nav.gif
Binary files differ
diff --git a/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/home_nav.gif b/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/home_nav.gif
new file mode 100755
index 0000000000..77a2306ed2
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/home_nav.gif
Binary files differ
diff --git a/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/refresh_nav.gif b/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/refresh_nav.gif
new file mode 100755
index 0000000000..e270e18bde
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/refresh_nav.gif
Binary files differ
diff --git a/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/search_nav.gif b/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/search_nav.gif
new file mode 100755
index 0000000000..73ac91bddb
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/search_nav.gif
Binary files differ
diff --git a/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/stop_nav.gif b/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/stop_nav.gif
new file mode 100755
index 0000000000..653d347b57
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/stop_nav.gif
Binary files differ
diff --git a/examples/org.eclipse.swt.examples.paint/.classpath b/examples/org.eclipse.swt.examples.paint/.classpath
new file mode 100755
index 0000000000..2576509d69
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.paint/.classpath
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="icons"/>
+ <classpathentry kind="src" path="/org.eclipse.swt"/>
+ <classpathentry kind="var" path="JRE_LIB"/>
+ <classpathentry kind="var"
+ path="PDE_ECLIPSE_HOME/plugins/org.eclipse.core.resources/resources.jar" sourcepath="PDE_ECLIPSE_HOME/plugins/org.eclipse.core.resources/resourcessrc.zip"/>
+ <classpathentry kind="var"
+ path="PDE_ECLIPSE_HOME/plugins/org.eclipse.core.runtime/runtime.jar" sourcepath="PDE_ECLIPSE_HOME/plugins/org.eclipse.core.runtime/runtimesrc.zip"/>
+ <classpathentry kind="var"
+ path="PDE_ECLIPSE_HOME/plugins/org.eclipse.ui/workbench.jar" sourcepath="PDE_ECLIPSE_HOME/plugins/org.eclipse.ui/workbenchsrc.zip"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/examples/org.eclipse.swt.examples.paint/.cvsignore b/examples/org.eclipse.swt.examples.paint/.cvsignore
new file mode 100755
index 0000000000..c5e82d7458
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.paint/.cvsignore
@@ -0,0 +1 @@
+bin \ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples.paint/.vcm_meta b/examples/org.eclipse.swt.examples.paint/.vcm_meta
new file mode 100755
index 0000000000..e9dbb98bc0
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.paint/.vcm_meta
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-description>
+ <nature id="org.eclipse.jdt.core.javanature"/>
+ <nature id="org.eclipse.pde.PluginNature"/>
+ <reference project-name="org.eclipse.swt"/>
+ <builder name="org.eclipse.jdt.core.javabuilder">
+ </builder>
+ <builder name="org.eclipse.pde.ManifestBuilder">
+ </builder>
+ <builder name="org.eclipse.pde.SchemaBuilder">
+ </builder>
+</project-description>
diff --git a/examples/org.eclipse.swt.examples.paint/icons/airbrush_tool.gif b/examples/org.eclipse.swt.examples.paint/icons/airbrush_tool.gif
new file mode 100755
index 0000000000..a310edddb2
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.paint/icons/airbrush_tool.gif
Binary files differ
diff --git a/examples/org.eclipse.swt.examples.paint/icons/ellipse_tool.gif b/examples/org.eclipse.swt.examples.paint/icons/ellipse_tool.gif
new file mode 100755
index 0000000000..dc2142f8e2
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.paint/icons/ellipse_tool.gif
Binary files differ
diff --git a/examples/org.eclipse.swt.examples.paint/icons/filledrectangle_tool.gif b/examples/org.eclipse.swt.examples.paint/icons/filledrectangle_tool.gif
new file mode 100755
index 0000000000..bec81b91e9
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.paint/icons/filledrectangle_tool.gif
Binary files differ
diff --git a/examples/org.eclipse.swt.examples.paint/icons/line_tool.gif b/examples/org.eclipse.swt.examples.paint/icons/line_tool.gif
new file mode 100755
index 0000000000..2ff819f129
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.paint/icons/line_tool.gif
Binary files differ
diff --git a/examples/org.eclipse.swt.examples.paint/icons/pencil_tool.gif b/examples/org.eclipse.swt.examples.paint/icons/pencil_tool.gif
new file mode 100755
index 0000000000..f16a234c13
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.paint/icons/pencil_tool.gif
Binary files differ
diff --git a/examples/org.eclipse.swt.examples.paint/icons/polyline_tool.gif b/examples/org.eclipse.swt.examples.paint/icons/polyline_tool.gif
new file mode 100755
index 0000000000..aa384e9b30
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.paint/icons/polyline_tool.gif
Binary files differ
diff --git a/examples/org.eclipse.swt.examples.paint/icons/rectangle_tool.gif b/examples/org.eclipse.swt.examples.paint/icons/rectangle_tool.gif
new file mode 100755
index 0000000000..d26dd584e7
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.paint/icons/rectangle_tool.gif
Binary files differ
diff --git a/examples/org.eclipse.swt.examples.paint/paintsrc.zip b/examples/org.eclipse.swt.examples.paint/paintsrc.zip
new file mode 100755
index 0000000000..c2dc9fa7c9
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.paint/paintsrc.zip
Binary files differ
diff --git a/examples/org.eclipse.swt.examples.paint/plugin.jars b/examples/org.eclipse.swt.examples.paint/plugin.jars
new file mode 100755
index 0000000000..69c397a10a
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.paint/plugin.jars
@@ -0,0 +1 @@
+paint.jar = bin, src, icons
diff --git a/examples/org.eclipse.swt.examples.paint/plugin.properties b/examples/org.eclipse.swt.examples.paint/plugin.properties
new file mode 100755
index 0000000000..52bfbcecac
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.paint/plugin.properties
@@ -0,0 +1,50 @@
+plugin.SWTPaintExample.name = SWT Paint Example Plugin
+category.SWTExamples.name = SWT Examples
+view.PaintExample.name = Paint
+
+launchcategory.SWTExamples.name = SWT Examples
+launchcategory.SWTExamples.description = A collection of Standard Widget Toolkit examples.
+launchitem.PaintExample.name = Paint
+launchitem.PaintExample.description = This example demonstrates the use of SWT graphics operations in the form of a rudimentary bitmap painting program.
+
+menu.Tools.label = Tools
+
+tool.Pencil.label = &Pencil
+tool.Pencil.tooltip = Pencil
+tool.Pencil.displayname = Pencil
+
+tool.Airbrush.label = &Airbrush
+tool.Airbrush.tooltip = Airbrush
+tool.Airbrush.displayname = Airbrush
+
+tool.Line.label = &Line
+tool.Line.tooltip = Line
+tool.Line.displayname = Line
+
+tool.PolyLine.label = &Polygon
+tool.PolyLine.tooltip = Polygon
+tool.PolyLine.displayname = Polygon
+
+tool.Rectangle.label = &Rectangle
+tool.Rectangle.tooltip = Rectangle
+tool.Rectangle.displayname = Rectangle
+
+tool.FilledRectangle.label = &Filled Rectangle
+tool.FilledRectangle.tooltip = Filled Rectangle
+tool.FilledRectangle.displayname = Filled Rectangle
+
+tool.Ellipse.label = &Ellipse
+tool.Ellipse.tooltip = Ellipse
+tool.Ellipse.displayname = Ellipse
+
+tool.Null.displayname = <none>
+
+session.Null.message = Select a tool...
+session.ContinuousPaint.message = Click and drag to draw...
+session.DragInteractivePaint.message = Click and drag to preview, release to draw, right-click to abort...
+session.SegmentedInteractivePaint.message.anchorMode = Click to set anchor...
+session.SegmentedInteractivePaint.message.interactiveMode = Click to draw, double-click to close figure, right-click to abort...
+
+status.Coord.format = ({0}, {1})
+status.CoordRange.format = ({0}, {1}) - ({2}, {3})
+status.Bar.format = {0} : {1} {2}
diff --git a/examples/org.eclipse.swt.examples.paint/plugin.xml b/examples/org.eclipse.swt.examples.paint/plugin.xml
new file mode 100755
index 0000000000..28aa6d4d38
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.paint/plugin.xml
@@ -0,0 +1,148 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- File written by PDE 1.0 -->
+<plugin
+ id="org.eclipse.swt.examples.paint"
+ name="%plugin.SWTPaintExample.name"
+ version="1.0.0"
+ provider-name="IBM"
+ class="org.eclipse.swt.examples.paint.PaintPlugin">
+
+<!-- Required plugins -->
+
+<requires>
+ <import plugin="org.eclipse.core.runtime"/>
+ <import plugin="org.eclipse.core.resources"/>
+ <import plugin="org.eclipse.ui"/>
+ <import plugin="org.eclipse.swt"/>
+</requires>
+
+<!-- Runtime -->
+
+<runtime>
+ <library name="paint.jar"/>
+</runtime>
+
+<!-- Extension points -->
+
+
+<!-- Extensions -->
+<extension
+ point="org.eclipse.ui.views">
+ <category
+ name="%category.SWTExamples.name"
+ id="org.eclipse.swt.examples.category">
+ </category>
+ <view
+ name="%view.PaintExample.name"
+ category="org.eclipse.swt.examples.category"
+ class="org.eclipse.swt.examples.paint.PaintView"
+ id="org.eclipse.swt.examples.paint.view">
+ </view>
+</extension>
+
+<extension
+ point="org.eclipse.ui.viewActions">
+ <viewContribution
+ targetID="org.eclipse.swt.examples.paint.view"
+ id="org.eclipse.swt.examples.paint.viewContribution">
+ <menu
+ id="org.eclipse.swt.examples.paint.menuTools"
+ label="%menu.Tools.label">
+ </menu>
+ <action
+ id="org.eclipse.swt.examples.paint.toolPencil"
+ toolbarPath="Normal/Pencil"
+ menubarPath="org.eclipse.swt.examples.paint.menuTools/Pencil"
+ class="org.eclipse.swt.examples.paint.PaintViewAction"
+ state="false"
+ enablesFor="*"
+ icon="icons/pencil_tool.gif"
+ label="%tool.Pencil.label"
+ tooltip="%tool.Pencil.tooltip">
+ </action>
+ <action
+ id="org.eclipse.swt.examples.paint.toolAirbrush"
+ toolbarPath="Normal/Airbrush"
+ menubarPath="org.eclipse.swt.examples.paint.menuTools/Airbrush"
+ class="org.eclipse.swt.examples.paint.PaintViewAction"
+ state="false"
+ enablesFor="*"
+ icon="icons/airbrush_tool.gif"
+ label="%tool.Airbrush.label"
+ tooltip="%tool.Airbrush.tooltip">
+ </action>
+ <action
+ id="org.eclipse.swt.examples.paint.toolLine"
+ toolbarPath="Normal/Line"
+ menubarPath="org.eclipse.swt.examples.paint.menuTools/Line"
+ class="org.eclipse.swt.examples.paint.PaintViewAction"
+ state="false"
+ enablesFor="*"
+ icon="icons/line_tool.gif"
+ label="%tool.Line.label"
+ tooltip="%tool.Line.tooltip">
+ </action>
+ <action
+ id="org.eclipse.swt.examples.paint.toolPolyLine"
+ toolbarPath="Normal/Polygon"
+ menubarPath="org.eclipse.swt.examples.paint.menuTools/PolyLine"
+ class="org.eclipse.swt.examples.paint.PaintViewAction"
+ state="false"
+ enablesFor="*"
+ icon="icons/polyline_tool.gif"
+ label="%tool.PolyLine.label"
+ tooltip="%tool.PolyLine.tooltip">
+ </action>
+ <action
+ id="org.eclipse.swt.examples.paint.toolEllipse"
+ toolbarPath="Normal/Ellipse"
+ menubarPath="org.eclipse.swt.examples.paint.menuTools/Ellipse"
+ class="org.eclipse.swt.examples.paint.PaintViewAction"
+ state="false"
+ enablesFor="*"
+ icon="icons/ellipse_tool.gif"
+ label="%tool.Ellipse.label"
+ tooltip="%tool.Ellipse.tooltip">
+ </action>
+ <action
+ id="org.eclipse.swt.examples.paint.toolRectangle"
+ toolbarPath="Normal/Rectangle"
+ menubarPath="org.eclipse.swt.examples.paint.menuTools/Rectangle"
+ class="org.eclipse.swt.examples.paint.PaintViewAction"
+ state="false"
+ enablesFor="*"
+ icon="icons/rectangle_tool.gif"
+ label="%tool.Rectangle.label"
+ tooltip="%tool.Rectangle.tooltip">
+ </action>
+ <action
+ id="org.eclipse.swt.examples.paint.toolFilledRectangle"
+ toolbarPath="Normal/FilledRectangle"
+ menubarPath="org.eclipse.swt.examples.paint.menuTools/FilledRectangle"
+ class="org.eclipse.swt.examples.paint.PaintViewAction"
+ state="false"
+ enablesFor="*"
+ icon="icons/filledrectangle_tool.gif"
+ label="%tool.FilledRectangle.label"
+ tooltip="%tool.FilledRectangle.tooltip">
+ </action>
+ </viewContribution>
+</extension>
+
+<extension
+ point="org.eclipse.swt.examples.launcher.launchItems">
+ <category
+ name="%launchcategory.SWTExamples.name"
+ description="%launchcategory.SWTExamples.description"
+ id="org.eclipse.swt.examples.launchcategory">
+ </category>
+ <viewItem
+ name="%launchitem.PaintExample.name"
+ id="org.eclipse.swt.examples.paint.launcher"
+ viewId="org.eclipse.swt.examples.paint.view"
+ description="%launchitem.PaintExample.description"
+ source="paintsrc.zip"
+ category="org.eclipse.swt.examples.launchcategory"/>
+</extension>
+
+</plugin>
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/Assert.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/Assert.java
new file mode 100755
index 0000000000..86603be439
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/Assert.java
@@ -0,0 +1,42 @@
+package org.eclipse.swt.examples.paint;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+/**
+ * Provides a means of verifying that assertions are met
+ */
+public class Assert extends Error {
+ /**
+ * Construct an Assert exception
+ */
+ private Assert() {
+ super("Assertion failed: <no reason given>");
+ }
+ private Assert(String message) {
+ super("Assertion failed: " + message);
+ }
+
+ /**
+ * Raise an error
+ */
+ public static final void raise() {
+ throw new Assert();
+ }
+ public static final void raise(String message) {
+ if (message == null) raise();
+ throw new Assert(message);
+ }
+
+ /**
+ * Test an assertion
+ */
+ public static final void assert(boolean condition) {
+ if (! condition) raise();
+ }
+ public static final void assert(boolean condition, String message) {
+ if (! condition) raise(message);
+ }
+}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/DragInteractivePaintSession.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/DragInteractivePaintSession.java
new file mode 100755
index 0000000000..3ac17f5315
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/DragInteractivePaintSession.java
@@ -0,0 +1,170 @@
+package org.eclipse.swt.examples.paint;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Point;
+
+/**
+ * The superclass for paint tools that use click-drag-release motions to
+ * draw objects
+ */
+public abstract class DragInteractivePaintSession extends BasicPaintSession
+ implements PaintRenderer {
+ /**
+ * True iff a click-drag is in progress
+ */
+ private boolean dragInProgress;
+
+ /**
+ * The position of the first click in a click-drag
+ */
+ private Point anchorPosition = new Point(-1, -1);
+
+ /**
+ * The position of the last drawn temporary point in a click-drag
+ */
+ private Point tempPosition = new Point(-1, -1);
+
+ /**
+ * Create a DragInteractivePaintSession
+ *
+ * @param getPaintSurface() the drawing surface to use
+ */
+ protected DragInteractivePaintSession(PaintSurface paintSurface) {
+ super(paintSurface);
+ }
+
+ /**
+ * Activate the tool.
+ */
+ public void beginSession() {
+ getPaintSurface().getPaintStatus().
+ setMessage(PaintPlugin.getResourceString("session.DragInteractivePaint.message"));
+
+ anchorPosition.x = -1;
+ tempPosition.x = -1;
+ dragInProgress = false;
+ }
+
+ /**
+ * Deactivate the tool.
+ */
+ public void endSession() {
+ }
+
+ /**
+ * Reset the tool.
+ * Aborts any operation in progress.
+ */
+ public void resetSession() {
+ if (tempPosition.x != -1) { // restore old image
+ final GC gc = getPaintSurface().getGC();
+ eraseTemporary(gc, anchorPosition, tempPosition);
+ }
+ anchorPosition.x = -1;
+ tempPosition.x = -1;
+ dragInProgress = false;
+ }
+
+ /**
+ * Handle a mouseDown event
+ *
+ * @param event the mouse event detail information
+ */
+ public void mouseDown(MouseEvent event) {
+ if (event.button != 1) return;
+ if (dragInProgress) return; // spurious event
+ dragInProgress = true;
+
+ anchorPosition.x = event.x;
+ anchorPosition.y = event.y;
+ tempPosition.x = -1;
+ }
+
+ /**
+ * Handle a mouseDoubleClick event
+ *
+ * @param event the mouse event detail information
+ */
+ public void mouseDoubleClick(MouseEvent event) {
+ }
+
+ /**
+ * Handle a mouseUp event
+ *
+ * @param event the mouse event detail information
+ */
+ public void mouseUp(MouseEvent event) {
+ if (event.button != 1) {
+ resetSession(); // abort if right or middle mouse button pressed
+ return;
+ }
+ if (! dragInProgress) return; // spurious event
+ dragInProgress = false;
+ if (anchorPosition.x == -1) return; // spurious event
+
+ final GC gc = getPaintSurface().getGC();
+ if (tempPosition.x != -1) { // restore old image
+ eraseTemporary(gc, anchorPosition, tempPosition);
+ }
+
+ // draw permanent entiry
+ tempPosition.x = event.x;
+ tempPosition.y = event.y;
+ drawPermanent(gc, anchorPosition, tempPosition);
+ tempPosition.x = -1;
+ }
+
+ /**
+ * Handle a mouseMove event
+ *
+ * @param event the mouse event detail information
+ */
+ public void mouseMove(MouseEvent event) {
+ if (! dragInProgress) {
+ getPaintSurface().showCurrentPositionStatus();
+ return;
+ }
+ getPaintSurface().showCurrentRangeStatus(anchorPosition);
+
+ final GC gc = getPaintSurface().getGC();
+
+ if (tempPosition.x != -1) { // restore old image
+ eraseTemporary(gc, anchorPosition, tempPosition);
+ }
+ // draw temporary entity
+ tempPosition.x = event.x;
+ tempPosition.y = event.y;
+ drawTemporary(gc, anchorPosition, tempPosition);
+ }
+
+ /**
+ * Draw a permanent entity given 2 points
+ *
+ * @param points[0] and points[1] are two points
+ * @param numPoints the number of valid points in the array (must be 2)
+ */
+ public void render(final Point[] points, int numPoints) {
+ Assert.assert(numPoints == 2);
+ final GC gc = getPaintSurface().getGC();
+ drawPermanent(gc, points[0], points[1]);
+ }
+
+ /**
+ * Draw a permanent entity
+ */
+ protected abstract void drawPermanent(GC gc, Point a, Point b);
+
+ /**
+ * Draw a temporary entity
+ */
+ protected abstract void drawTemporary(GC gc, Point a, Point b);
+
+ /**
+ * Erase a temporary entity
+ */
+ protected abstract void eraseTemporary(GC gc, Point a, Point b);
+}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/FilledRectangleTool.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/FilledRectangleTool.java
new file mode 100755
index 0000000000..1e8cb7c4eb
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/FilledRectangleTool.java
@@ -0,0 +1,86 @@
+package org.eclipse.swt.examples.paint;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.graphics.*;
+
+/**
+ * A rectangle drawing tool
+ */
+public class FilledRectangleTool extends DragInteractivePaintSession implements PaintTool {
+ private Color temporaryFGColor;
+ private Color temporaryBGColor;
+ private Color drawFGColor;
+ private Color drawBGColor;
+
+ /**
+ * Create a RectangleTool.
+ *
+ * @param toolSettings the new tool settings
+ * @param paintSurface the PaintSurface we will render on.
+ */
+ public FilledRectangleTool(ToolSettings toolSettings, PaintSurface paintSurface) {
+ super(paintSurface);
+ set(toolSettings);
+ temporaryFGColor = new Color(null, 255, 255, 255);
+ temporaryBGColor = new Color(null, 127, 127, 127);
+ }
+
+ /**
+ * Set the tool's settings
+ *
+ * @param toolSettings the new tool settings
+ */
+ public void set(ToolSettings toolSettings) {
+ drawFGColor = toolSettings.commonForegroundColor;
+ drawBGColor = toolSettings.commonBackgroundColor;
+ }
+
+ /**
+ * Get name associated with this tool
+ *
+ * @return the localized name of this tool
+ */
+ public String getDisplayName() {
+ return PaintPlugin.getResourceString("tool.FilledRectangle.displayname");
+ }
+
+ /*
+ * Template methods for drawing
+ */
+ protected void drawPermanent(GC gc, Point a, Point b) {
+ gc.setForeground(drawFGColor);
+ gc.setBackground(drawBGColor);
+ fillRectangle(gc, a, b);
+ }
+
+ protected void drawTemporary(GC gc, Point a, Point b) {
+ gc.setForeground(temporaryFGColor);
+ gc.setBackground(temporaryBGColor);
+ gc.setXORMode(true);
+ fillRectangle(gc, a, b);
+ gc.setXORMode(false);
+ }
+
+ protected void eraseTemporary(GC gc, Point a, Point b) {
+ drawTemporary(gc, a, b);
+ }
+
+ /**
+ * Draw a filled rectangle
+ */
+ protected void fillRectangle(GC gc, Point a, Point b) {
+ final int left = Math.min(a.x, b.x);
+ final int top = Math.min(a.y, b.y);
+ final int width = Math.abs(a.x - b.x) + 1;
+ final int height = Math.abs(a.y - b.y) + 1;
+
+ gc.drawRectangle(left, top, width, height);
+ if ((width > 2) && (height > 2))
+ gc.fillRectangle(left + 1, top + 1,
+ width - 1/*- 2*/, height - 1/*- 2*/); // BUG in GC
+ }
+}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintRenderer.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintRenderer.java
new file mode 100755
index 0000000000..72e359519a
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintRenderer.java
@@ -0,0 +1,19 @@
+package org.eclipse.swt.examples.paint;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+
+public interface PaintRenderer {
+ /**
+ * Render an object on a given point/region
+ *
+ * @param points the array of points
+ * @param numPoints the number of valid points in the array
+ */
+ public void render(Point[] points, int numPoints);
+}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintStatus.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintStatus.java
new file mode 100755
index 0000000000..ee12b6a90b
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintStatus.java
@@ -0,0 +1,99 @@
+package org.eclipse.swt.examples.paint; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Text;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+public class PaintStatus {
+ private Text statusText;
+ private String actionInfo, messageInfo, coordInfo;
+
+ /**
+ * Create a PaintStatus
+ *
+ * @param statusText the handle of status bar text widget to use
+ */
+ public PaintStatus(Text statusText) {
+ this.statusText = statusText;
+ clear();
+ }
+
+ /**
+ * Clear the status bar
+ */
+ public void clear() {
+ clearAction();
+ clearMessage();
+ clearCoord();
+ }
+
+ /**
+ * Set the status bar action text
+ *
+ * @param action the action in progress
+ */
+ public void setAction(String action) {
+ actionInfo = action;
+ update();
+ }
+
+ /**
+ * Clear the status bar action text
+ */
+ public void clearAction() {
+ actionInfo = "";
+ update();
+ }
+
+ /**
+ * Set the status bar message text
+ *
+ * @param message the message to display
+ */
+ public void setMessage(String message) {
+ messageInfo = message;
+ update();
+ }
+
+ /**
+ * Clear the status bar message text
+ */
+ public void clearMessage() {
+ messageInfo = "";
+ update();
+ }
+
+ /**
+ * Set the coordinates in the status bar
+ *
+ * @param coord the coordinates to display
+ */
+ public void setCoord(Point coord) {
+ coordInfo = PaintPlugin.getResourceString("status.Coord.format", new Object[] { new Integer(coord.x), new Integer(coord.y)}); update();
+ }
+
+ /**
+ * Set the coordinate range in the status bar
+ *
+ * @param a the "from" coordinate
+ * @param b the "to" coordinate
+ */
+ public void setCoordRange(Point a, Point b) {
+ coordInfo = PaintPlugin.getResourceString("status.CoordRange.format", new Object[] { new Integer(a.x), new Integer(a.y), new Integer(b.x), new Integer(b.y)}); update();
+ }
+
+ /**
+ * Clear the coordinates in the status bar
+ */
+ public void clearCoord() {
+ coordInfo = "";
+ update();
+ }
+
+ /**
+ * Update the display
+ */
+ private void update() {
+ statusText.setText( PaintPlugin.getResourceString("status.Bar.format", new Object[] { actionInfo, messageInfo, coordInfo })); }
+}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintViewAction.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintViewAction.java
new file mode 100755
index 0000000000..115c2fa503
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintViewAction.java
@@ -0,0 +1,78 @@
+package org.eclipse.swt.examples.paint;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExecutableExtension; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IViewActionDelegate; import org.eclipse.ui.IViewPart;
+
+/**
+ *
+ * @see IViewActionDelegate
+ */
+public class PaintViewAction implements IViewActionDelegate, IExecutableExtension {
+ private PaintView paintView;
+ private String id;
+
+ /**
+ * Initializes this action delegate with the view it will work in.
+ *
+ * @param view the view that provides the context for this delegate
+ */
+ public void init(IViewPart view) {
+ if (view != null && view instanceof PaintView) {
+ paintView = (PaintView) view;
+ } else throw new IllegalArgumentException("Expected an instance of PaintView");
+ }
+
+ /**
+ * Performs this action.
+ * <p>
+ * This method is called when the delegating action has been triggered.
+ * Implement this method to do the actual work.
+ * </p>
+ *
+ * @param action the action proxy that handles the presentation portion of the
+ * action
+ */
+ public void run(IAction action) {
+ final Display display = paintView.getDisplay();
+ action.setId(id); // temporary workaround since ID field not set by default
+ display.syncExec(new ActionRunnable(action));
+ }
+ private class ActionRunnable implements Runnable {
+ IAction action;
+ public ActionRunnable(IAction action) {
+ this.action = action;
+ }
+ public void run() {
+ paintView.setPaintToolByAction(action);
+ }
+ }
+
+
+ /**
+ * Notifies this action delegate that the selection in the workbench has changed.
+ * <p>
+ * Implementers can use this opportunity to change the availability of the
+ * action or to modify other presentation properties.
+ * </p>
+ *
+ * @param action the action proxy that handles presentation portion of the action
+ * @param selection the current selection in the workbench
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ // We don't care about the selection for now
+ }
+
+ /**
+ * Implementation of <code>IExecutableExtension</code> allows us to get access to the
+ * configuration data (i.e. plugin.xml attributes) that were specified in order to create
+ * the IAction we received
+ */
+ public void setInitializationData(IConfigurationElement cfig, String propertyName, Object data) {
+ // Get the identifier
+ id = cfig.getAttribute("id");
+ }
+}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/SegmentedInteractivePaintSession.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/SegmentedInteractivePaintSession.java
new file mode 100755
index 0000000000..bc58be27bd
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/SegmentedInteractivePaintSession.java
@@ -0,0 +1,192 @@
+package org.eclipse.swt.examples.paint;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Point;
+
+/**
+ * The superclass for paint tools that contruct objects from individually
+ * picked segments
+ */
+public abstract class SegmentedInteractivePaintSession extends BasicPaintSession
+ implements PaintRenderer {
+ /**
+ * The position of the first click in a segmented selection
+ */
+ private Point anchorPosition = new Point(-1, -1);
+
+ /**
+ * The position of the last drawn temporary point in a segmented selection
+ */
+ private Point tempPosition = new Point(-1, -1);
+
+ /**
+ * The position of the first anchor in a segmented selection sequence
+ */
+ protected Point firstAnchorPosition = new Point(-1, 0);
+
+ /**
+ * Create an SegmentedInteractivePaintSession
+ *
+ * @param paintSurface the drawing surface to use
+ */
+ protected SegmentedInteractivePaintSession(PaintSurface paintSurface) {
+ super(paintSurface);
+ }
+
+ /**
+ * Activate the tool.
+ */
+ public void beginSession() {
+ getPaintSurface().getPaintStatus().setMessage(PaintPlugin.getResourceString(
+ "session.SegmentedInteractivePaint.message.anchorMode"));
+
+ anchorPosition.x = -1;
+ tempPosition.x = -1;
+ firstAnchorPosition.x = -1;
+ }
+
+ /**
+ * Deactivate the tool.
+ */
+ public void endSession() {
+ }
+
+ /**
+ * Reset the tool.
+ * Aborts any operation in progress.
+ */
+ public void resetSession() {
+ getPaintSurface().getPaintStatus().setMessage(PaintPlugin.getResourceString(
+ "session.SegmentedInteractivePaint.message.anchorMode"));
+
+ if (anchorPosition.x == -1) return; // spurious event
+
+ if (tempPosition.x != -1) { // restore old image
+ final GC gc = getPaintSurface().getGC();
+ eraseTemporary(gc, anchorPosition, tempPosition);
+ }
+ anchorPosition.x = -1;
+ tempPosition.x = -1;
+ firstAnchorPosition.x = -1;
+ }
+
+ /**
+ * Handle a mouseDown event
+ *
+ * @param event the mouse event detail information
+ */
+ public void mouseDown(MouseEvent event) {
+ if (event.button != 1) return;
+
+ if (tempPosition.x != -1) { // restore old image
+ final GC gc = getPaintSurface().getGC();
+ Assert.assert(anchorPosition.x != -1);
+ eraseTemporary(gc, anchorPosition, tempPosition);
+ tempPosition.x = event.x;
+ tempPosition.y = event.y;
+ drawPermanent(gc, anchorPosition, tempPosition);
+ tempPosition.x = -1;
+ }
+ anchorPosition.x = event.x;
+ anchorPosition.y = event.y;
+ if (firstAnchorPosition.x == -1) {
+ firstAnchorPosition.x = anchorPosition.x;
+ firstAnchorPosition.y = anchorPosition.y;
+ }
+ getPaintSurface().getPaintStatus().setMessage(PaintPlugin.getResourceString(
+ "session.SegmentedInteractivePaint.message.interactiveMode"));
+ }
+
+ /**
+ * Handle a mouseDoubleClick event
+ *
+ * @param event the mouse event detail information
+ */
+ public void mouseDoubleClick(MouseEvent event) {
+ if (event.button != 1) return;
+ if (firstAnchorPosition.x == -1) return; // spurious event
+ Assert.assert(anchorPosition.x != -1);
+
+ final GC gc = getPaintSurface().getGC();
+ if (tempPosition.x != -1) { // restore old image
+ eraseTemporary(gc, anchorPosition, tempPosition);
+ tempPosition.x = -1;
+ }
+ drawPermanent(gc, anchorPosition, firstAnchorPosition);
+ anchorPosition.x = -1;
+ firstAnchorPosition.x = -1;
+
+ getPaintSurface().getPaintStatus().setMessage(PaintPlugin.getResourceString(
+ "session.SegmentedInteractivePaint.message.anchorMode"));
+ }
+
+ /**
+ * Handle a mouseUp event
+ *
+ * @param event the mouse event detail information
+ */
+ public void mouseUp(MouseEvent event) {
+ if (event.button != 1) {
+ resetSession(); // abort if right or middle mouse button pressed
+ return;
+ }
+ }
+
+ /**
+ * Handle a mouseMove event
+ *
+ * @param event the mouse event detail information
+ */
+ public void mouseMove(MouseEvent event) {
+ if (anchorPosition.x == -1) {
+ getPaintSurface().showCurrentPositionStatus();
+ return; // spurious event
+ } else {
+ getPaintSurface().showCurrentRangeStatus(anchorPosition);
+ }
+
+ final GC gc = getPaintSurface().getGC();
+ if (tempPosition.x != -1) { // restore old image
+ eraseTemporary(gc, anchorPosition, tempPosition);
+ }
+ // draw temporary entity
+ tempPosition.x = event.x;
+ tempPosition.y = event.y;
+ drawTemporary(gc, anchorPosition, tempPosition);
+ }
+
+ /**
+ * Draw a permanent entity given 2...n points
+ *
+ * @param points[0] and points[1] are two points
+ * @param numPoints the number of valid points in the array (n >= 2)
+ */
+ public void render(final Point[] points, int numPoints) {
+ Assert.assert(numPoints >= 2);
+
+ final GC gc = getPaintSurface().getGC();
+ for (int i = 1; i < numPoints; ++i) {
+ drawPermanent(gc, points[i - 1], points[i]);
+ }
+ drawPermanent(gc, points[numPoints - 1], points[0]);
+ }
+
+ /**
+ * Draw a permanent segment
+ */
+ protected abstract void drawPermanent(GC gc, Point a, Point b);
+
+ /**
+ * Draw a temporary segment
+ */
+ protected abstract void drawTemporary(GC gc, Point a, Point b);
+
+ /**
+ * Erase a temporary segment
+ */
+ protected abstract void eraseTemporary(GC gc, Point a, Point b);
+}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/SimplePaintSession.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/SimplePaintSession.java
new file mode 100755
index 0000000000..eec18edf04
--- /dev/null
+++ b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/SimplePaintSession.java
@@ -0,0 +1,87 @@
+package org.eclipse.swt.examples.paint;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.graphics.Point;
+
+/**
+ * The superclass for single-click paint tools
+ */
+public abstract class SimplePaintSession extends BasicPaintSession implements PaintRenderer {
+ /**
+ * A cached Point array
+ */
+ protected Point[] cachedPointArray = new Point[] { new Point(-1, -1) };
+
+ /**
+ * Create a SimplePaintSession
+ *
+ * @param paintSurface the drawing surface to use
+ */
+ protected SimplePaintSession(PaintSurface paintSurface) {
+ super(paintSurface);
+ }
+
+ /**
+ * Activate the tool
+ */
+ public void beginSession() {
+ getPaintSurface().getPaintStatus().setMessage(PaintPlugin.getResourceString(
+ "session.SimplePaint.message"));
+ }
+
+ /**
+ * Deactivate the tool
+ */
+ public void endSession() {
+ }
+
+ /**
+ * Abort the current operation
+ */
+ public void resetSession() {
+ }
+
+ /**
+ * Handle a mouseDown event
+ *
+ * @param event the mouse event detail information
+ */
+ public void mouseDown(MouseEvent event) {
+ if (event.button != 1) return; // catch only left mouse actions
+
+ cachedPointArray[0].x = event.x;
+ cachedPointArray[0].y = event.y;
+ render(cachedPointArray, 1);
+ }
+
+ /**
+ * Handle a mouseDoubleClick event
+ *
+ * @param event the mouse event detail information
+ */
+ public void mouseDoubleClick(MouseEvent event) {
+ mouseDown(event);
+ }
+
+ /**
+ * Handle a mouseUp event
+ *
+ * @param event the mouse event detail information
+ */
+ public void mouseUp(MouseEvent event) {
+ }
+
+ /**
+ * Handle a mouseMove event
+ *
+ * @param event the mouse event detail information
+ */
+ public void mouseMove(MouseEvent event) {
+ getPaintSurface().showCurrentPositionStatus();
+ }
+}

Back to the top